activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1375852 - in /activemq/trunk: activemq-core/src/main/java/org/apache/activemq/store/kahadb/plist/PList.java kahadb/src/main/java/org/apache/kahadb/page/PageFile.java
Date Tue, 21 Aug 2012 23:28:51 GMT
Author: tabish
Date: Tue Aug 21 23:28:50 2012
New Revision: 1375852

URL: http://svn.apache.org/viewvc?rev=1375852&view=rev
Log:
updated fix: https://issues.apache.org/jira/browse/AMQ-3982

Instead of locking on the PList iterator which forces a lock on every access to hasNext we
should lock down at the PageFile level in readPage making the seek and read an atomic operation.
 Since many reads on a single already loaded page don't need to be synchronized we pay a higher
price for locking in the specific PList case than we do buy creating this atomic read operation
in PageFile. 

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/plist/PList.java
    activemq/trunk/kahadb/src/main/java/org/apache/kahadb/page/PageFile.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/plist/PList.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/plist/PList.java?rev=1375852&r1=1375851&r2=1375852&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/plist/PList.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/kahadb/plist/PList.java
Tue Aug 21 23:28:50 2012
@@ -202,9 +202,7 @@ public class PList extends ListIndex<Str
 
         @Override
         public boolean hasNext() {
-            synchronized (indexLock) {
-                return iterator.hasNext();
-            }
+            return iterator.hasNext();
         }
 
         @Override

Modified: activemq/trunk/kahadb/src/main/java/org/apache/kahadb/page/PageFile.java
URL: http://svn.apache.org/viewvc/activemq/trunk/kahadb/src/main/java/org/apache/kahadb/page/PageFile.java?rev=1375852&r1=1375851&r2=1375852&view=diff
==============================================================================
--- activemq/trunk/kahadb/src/main/java/org/apache/kahadb/page/PageFile.java (original)
+++ activemq/trunk/kahadb/src/main/java/org/apache/kahadb/page/PageFile.java Tue Aug 21 23:28:50
2012
@@ -16,7 +16,16 @@
  */
 package org.apache.kahadb.page;
 
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InterruptedIOException;
+import java.io.RandomAccessFile;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -862,7 +871,7 @@ public class PageFile {
         return nextTxid.incrementAndGet();
     }
 
-    void readPage(long pageId, byte[] data) throws IOException {
+    synchronized void readPage(long pageId, byte[] data) throws IOException {
         readFile.seek(toOffset(pageId));
         readFile.readFully(data);
     }



Mime
View raw message