directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1605999 - /directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RecordManager.java
Date Fri, 27 Jun 2014 09:33:49 GMT
Author: elecharny
Date: Fri Jun 27 09:33:48 2014
New Revision: 1605999

URL: http://svn.apache.org/r1605999
Log:
o Added a constant for ROLLBACKs
o Added a check after the RM initialization
o Removed a check that is done too early
o Fixed a BufferUnderflow error : we were trying to read too much data in a pageIO while logging
the content of a page

Modified:
    directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RecordManager.java

Modified: directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RecordManager.java
URL: http://svn.apache.org/viewvc/directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RecordManager.java?rev=1605999&r1=1605998&r2=1605999&view=diff
==============================================================================
--- directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RecordManager.java
(original)
+++ directory/mavibot/trunk/mavibot/src/main/java/org/apache/directory/mavibot/btree/RecordManager.java
Fri Jun 27 09:33:48 2014
@@ -138,7 +138,7 @@ public class RecordManager extends Abstr
     private byte[] RECORD_MANAGER_HEADER_BYTES;
 
     /** The length of an Offset, as a negative value */
-    private static byte[] LONG_LENGTH = new byte[]
+    private  byte[] LONG_LENGTH = new byte[]
         { ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xF8 };
 
     /** The RecordManager underlying page size. */
@@ -204,6 +204,9 @@ public class RecordManager extends Abstr
     /** A lock to protect the BtreeHeader maps */
     private ReadWriteLock btreeHeadersLock = new ReentrantReadWriteLock();
     
+    /** A value stored into the transaction context for rollbacked transactions */
+    private static final int ROLLBACKED_TXN = 0;
+    
     /**
      * Create a Record manager which will either create the underlying file
      * or load an existing one. If a folder is provided, then we will create
@@ -382,7 +385,12 @@ public class RecordManager extends Abstr
             // Can't happen here.
         }
 
-        // We are all set !
+        // We are all set ! Verify the file
+        if ( LOG_CHECK.isDebugEnabled() )
+        {
+            MavibotInspector.check( this );
+        }
+
     }
 
 
@@ -586,7 +594,7 @@ public class RecordManager extends Abstr
         
         switch ( nbTxnStarted )
         {
-            case 0 :
+            case ROLLBACKED_TXN :
                 // The transaction was rollbacked, quit immediatelly
                 transactionLock.unlock();
                 
@@ -720,7 +728,7 @@ public class RecordManager extends Abstr
     public void rollback()
     {
         // Reset the counter
-        context.set( 0 );
+        context.set( ROLLBACKED_TXN );
 
         // We can now free allocated pages, this is the end of the transaction
         for ( PageIO pageIo : allocatedPages )
@@ -1473,11 +1481,6 @@ public class RecordManager extends Abstr
             // Inject it into the B-tree of B-tree
             btreeOfBtrees.insert( nameRevision, btreeHeaderOffset );
         }
-
-        if ( LOG_CHECK.isDebugEnabled() )
-        {
-            MavibotInspector.check( this );
-        }
     }
 
 
@@ -2774,11 +2777,6 @@ public class RecordManager extends Abstr
         PersistedPageHolder<K, V> pageHolder = new PersistedPageHolder<K, V>(
btree, newPage, offset,
             lastOffset );
 
-        if ( LOG_CHECK.isDebugEnabled() )
-        {
-            MavibotInspector.check( this );
-        }
-
         return pageHolder;
     }
 
@@ -2798,7 +2796,14 @@ public class RecordManager extends Abstr
             ByteBuffer data = pageIo.getData();
 
             int position = data.position();
-            byte[] bytes = new byte[(int)pageIo.getSize() + 12];
+            int dataLength = (int)pageIo.getSize() + 12;
+            
+            if ( dataLength > data.limit() )
+            {
+                dataLength = data.limit();
+            }
+            
+            byte[] bytes = new byte[dataLength];
 
             data.get( bytes );
             data.position( position );



Mime
View raw message