directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1235334 [3/6] - in /directory/apacheds/trunk: ldap-client-test/src/test/java/org/apache/directory/shared/client/api/ ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ ldap-client-test/src/test/java/org/apach...
Date Tue, 24 Jan 2012 16:27:22 GMT
Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java?rev=1235334&r1=1235333&r2=1235334&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java Tue Jan 24 16:27:18 2012
@@ -98,17 +98,18 @@ import org.slf4j.LoggerFactory;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public abstract class AbstractBTreePartition<ID extends Comparable<ID>> extends AbstractPartition implements Store<Entry, ID>
+public abstract class AbstractBTreePartition<ID extends Comparable<ID>> extends AbstractPartition implements
+    Store<Entry, ID>
 {
     /** static logger */
     private static final Logger LOG = LoggerFactory.getLogger( AbstractBTreePartition.class );
 
     /** the search engine used to search the database */
     protected SearchEngine<Entry, ID> searchEngine;
-    
+
     /** The optimizer to use during search operation */
     protected Optimizer optimizer;
-    
+
     /** Tells if the Optimizer is enabled */
     protected boolean optimizerEnabled = true;
 
@@ -168,13 +169,14 @@ public abstract class AbstractBTreeParti
 
     /** the one level scope alias index */
     protected Index<ID, Entry, ID> oneAliasIdx;
-    
+
     /** Cached attributes types to avoid lookup all over the code */
     protected AttributeType OBJECT_CLASS_AT;
     protected AttributeType ENTRY_CSN_AT;
     protected AttributeType ENTRY_UUID_AT;
     protected AttributeType ALIASED_OBJECT_NAME_AT;
 
+
     // ------------------------------------------------------------------------
     // C O N S T R U C T O R S
     // ------------------------------------------------------------------------
@@ -208,8 +210,8 @@ public abstract class AbstractBTreeParti
     {
         return cacheSize;
     }
-    
-    
+
+
     /**
      * Used to specify the entry cache size for a Partition.  Various Partition
      * implementations may interpret this value in different ways: i.e. total cache
@@ -242,7 +244,7 @@ public abstract class AbstractBTreeParti
         this.optimizerEnabled = optimizerEnabled;
     }
 
-    
+
     /**
      * Sets the path in which this Partition stores data. This may be an URL to
      * a file or directory, or an JDBC URL.
@@ -264,6 +266,7 @@ public abstract class AbstractBTreeParti
         return isSyncOnWrite.get();
     }
 
+
     /**
      * {@inheritDoc}
      */
@@ -283,7 +286,8 @@ public abstract class AbstractBTreeParti
         // add missing system indices
         if ( getPresenceIndex() == null )
         {
-            Index<String, Entry, ID> index = new GenericIndex<String, Entry, ID>( ApacheSchemaConstants.APACHE_PRESENCE_AT_OID ) ;
+            Index<String, Entry, ID> index = new GenericIndex<String, Entry, ID>(
+                ApacheSchemaConstants.APACHE_PRESENCE_AT_OID );
             index.setWkDirPath( partitionPath );
             addIndex( index );
         }
@@ -304,14 +308,16 @@ public abstract class AbstractBTreeParti
 
         if ( getRdnIndex() == null )
         {
-            Index<ParentIdAndRdn<ID>, Entry, ID> index = new GenericIndex<ParentIdAndRdn<ID>, Entry, ID>( ApacheSchemaConstants.APACHE_RDN_AT_OID );
+            Index<ParentIdAndRdn<ID>, Entry, ID> index = new GenericIndex<ParentIdAndRdn<ID>, Entry, ID>(
+                ApacheSchemaConstants.APACHE_RDN_AT_OID );
             index.setWkDirPath( partitionPath );
             addIndex( index );
         }
 
         if ( getAliasIndex() == null )
         {
-            Index<String, Entry, ID> index = new GenericIndex<String, Entry, ID>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID );
+            Index<String, Entry, ID> index = new GenericIndex<String, Entry, ID>(
+                ApacheSchemaConstants.APACHE_ALIAS_AT_OID );
             index.setWkDirPath( partitionPath );
             addIndex( index );
         }
@@ -401,7 +407,7 @@ public abstract class AbstractBTreeParti
 
         userIndices = tmp;
     }
-    
+
 
     /**
      * Gets the DefaultSearchEngine used by this ContextPartition to search the
@@ -428,8 +434,8 @@ public abstract class AbstractBTreeParti
      * {@inheritDoc}
      */
     public abstract ID getRootId();
-    
-    
+
+
     /**
      * Convert and initialize an index for a specific store implementation.
      *
@@ -516,7 +522,7 @@ public abstract class AbstractBTreeParti
         }
     }
 
-    
+
     /**
      * {@inheritDoc}
      */
@@ -526,6 +532,7 @@ public abstract class AbstractBTreeParti
         setupUserIndices();
     }
 
+
     //---------------------------------------------------------------------------------------------
     // The Add operation
     //---------------------------------------------------------------------------------------------
@@ -538,7 +545,7 @@ public abstract class AbstractBTreeParti
         {
             Entry entry = ( ( ClonedServerEntry ) addContext.getEntry() ).getClonedEntry();
             Dn entryDn = entry.getDn();
-    
+
             // check if the entry already exists
             if ( getEntryId( entryDn ) != null )
             {
@@ -546,9 +553,9 @@ public abstract class AbstractBTreeParti
                     I18n.err( I18n.ERR_250_ENTRY_ALREADY_EXISTS, entryDn.getName() ) );
                 throw ne;
             }
-    
+
             ID parentId = null;
-    
+
             //
             // Suffix entry cannot have a parent since it is the root so it is
             // capped off using the zero value which no entry can have since
@@ -556,7 +563,7 @@ public abstract class AbstractBTreeParti
             //
             Dn parentDn = null;
             ParentIdAndRdn<ID> key = null;
-    
+
             if ( entryDn.equals( suffixDn ) )
             {
                 parentId = getRootId();
@@ -566,25 +573,25 @@ public abstract class AbstractBTreeParti
             {
                 parentDn = entryDn.getParent();
                 parentId = getEntryId( parentDn );
-                
+
                 key = new ParentIdAndRdn<ID>( parentId, entryDn.getRdn() );
             }
-    
+
             // don't keep going if we cannot find the parent Id
             if ( parentId == null )
             {
                 throw new LdapNoSuchObjectException( I18n.err( I18n.ERR_216_ID_FOR_PARENT_NOT_FOUND, parentDn ) );
             }
-            
+
             // Get a new ID for the added entry
             ID id = master.getNextId( entry );
-    
+
             // Update the RDN index
             rdnIdx.add( key, id );
-    
+
             // Update the ObjectClass index
             Attribute objectClass = entry.get( OBJECT_CLASS_AT );
-            
+
             if ( objectClass == null )
             {
                 String msg = I18n.err( I18n.ERR_217, entryDn.getName(), entry );
@@ -593,84 +600,84 @@ public abstract class AbstractBTreeParti
                 //e.setResolvedName( entryDn );
                 throw e;
             }
-    
+
             for ( Value<?> value : objectClass )
             {
                 objectClassIdx.add( value.getString(), id );
             }
-    
+
             if ( objectClass.contains( SchemaConstants.ALIAS_OC ) )
             {
                 Attribute aliasAttr = entry.get( ALIASED_OBJECT_NAME_AT );
                 addAliasIndices( id, entryDn, aliasAttr.getString() );
             }
-    
+
             // Update the OneLevel index
             oneLevelIdx.add( parentId, id );
-    
+
             // Update the SubLevel index
             ID tempId = parentId;
-    
+
             while ( ( tempId != null ) && ( !tempId.equals( getRootId() ) ) && ( !tempId.equals( getSuffixId() ) ) )
             {
                 subLevelIdx.add( tempId, id );
                 tempId = getParentId( tempId );
             }
-    
+
             // making entry an ancestor/descendent of itself in sublevel index
             subLevelIdx.add( id, id );
-    
+
             // Update the EntryCsn index
             Attribute entryCsn = entry.get( ENTRY_CSN_AT );
-    
+
             if ( entryCsn == null )
             {
                 String msg = I18n.err( I18n.ERR_219, entryDn.getName(), entry );
                 throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION, msg );
             }
-    
+
             entryCsnIdx.add( entryCsn.getString(), id );
-    
+
             // Update the EntryUuid index
             Attribute entryUuid = entry.get( ENTRY_UUID_AT );
-    
+
             if ( entryUuid == null )
             {
                 String msg = I18n.err( I18n.ERR_220, entryDn.getName(), entry );
                 throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION, msg );
             }
-    
+
             entryUuidIdx.add( entryUuid.getString(), id );
-    
+
             // Now work on the user defined userIndices
             for ( Attribute attribute : entry )
             {
                 AttributeType attributeType = attribute.getAttributeType();
                 String attributeOid = attributeType.getOid();
-    
+
                 if ( hasUserIndexOn( attributeType ) )
                 {
                     Index<Object, Entry, ID> idx = ( Index<Object, Entry, ID> ) getUserIndex( attributeType );
-    
+
                     // here lookup by attributeId is OK since we got attributeId from
                     // the entry via the enumeration - it's in there as is for sure
-    
+
                     for ( Value<?> value : attribute )
                     {
                         idx.add( value.getValue(), id );
                     }
-    
+
                     // Adds only those attributes that are indexed
                     presenceIdx.add( attributeOid, id );
                 }
             }
-    
+
             // Add the parentId in the entry
             entry.put( SchemaConstants.ENTRY_PARENT_ID_AT, parentId.toString() );
-            
+
             // And finally add the entry into the master table
             master.put( id, entry );
-    
+
             if ( isSyncOnWrite.get() )
             {
                 sync();
@@ -728,7 +735,7 @@ public abstract class AbstractBTreeParti
         {
             // First get the entry
             Entry entry = master.get( id );
-            
+
             if ( entry == null )
             {
                 // Not allowed
@@ -777,7 +784,7 @@ public abstract class AbstractBTreeParti
             }
 
             master.remove( id );
-            
+
             // if this is a context entry reset the master table counter
             if ( id.equals( getDefaultId() ) )
             {
@@ -795,7 +802,7 @@ public abstract class AbstractBTreeParti
         }
     }
 
-    
+
     //---------------------------------------------------------------------------------------------
     // The List operation
     //---------------------------------------------------------------------------------------------
@@ -809,7 +816,7 @@ public abstract class AbstractBTreeParti
                 list( getEntryId( listContext.getDn() ) ) ), listContext );
     }
 
-    
+
     /**
      * {@inheritDoc}
      */
@@ -821,9 +828,9 @@ public abstract class AbstractBTreeParti
             // and below
             IndexCursor<ID, Entry, ID> cursor = oneLevelIdx.forwardCursor( id );
             cursor.beforeValue( id, null );
-            
+
             return cursor;
-         }
+        }
         catch ( Exception e )
         {
             throw new LdapOperationErrorException( e.getMessage(), e );
@@ -831,7 +838,6 @@ public abstract class AbstractBTreeParti
     }
 
 
-
     //---------------------------------------------------------------------------------------------
     // The Search operation
     //---------------------------------------------------------------------------------------------
@@ -882,7 +888,8 @@ public abstract class AbstractBTreeParti
         Entry entry = lookup( id );
 
         // Remove all the attributes if the NO_ATTRIBUTE flag is set and there is no requested attribute
-        if ( lookupContext.hasNoAttribute() && ( ( lookupContext.getAttrsId() == null ) || lookupContext.getAttrsId().size() == 0 ) )
+        if ( lookupContext.hasNoAttribute()
+            && ( ( lookupContext.getAttrsId() == null ) || lookupContext.getAttrsId().size() == 0 ) )
         {
             entry.clear();
 
@@ -897,7 +904,7 @@ public abstract class AbstractBTreeParti
             }
             else
             {
-                for ( Attribute attribute : ( ((ClonedServerEntry)entry).getOriginalEntry() ).getAttributes() )
+                for ( Attribute attribute : ( ( ( ClonedServerEntry ) entry ).getOriginalEntry() ).getAttributes() )
                 {
                     AttributeType attributeType = attribute.getAttributeType();
                     String oid = attributeType.getOid();
@@ -916,7 +923,7 @@ public abstract class AbstractBTreeParti
         {
             if ( lookupContext.hasAllOperational() )
             {
-                for ( Attribute attribute : ( ((ClonedServerEntry)entry).getOriginalEntry() ).getAttributes() )
+                for ( Attribute attribute : ( ( ( ClonedServerEntry ) entry ).getOriginalEntry() ).getAttributes() )
                 {
                     AttributeType attributeType = attribute.getAttributeType();
 
@@ -930,7 +937,7 @@ public abstract class AbstractBTreeParti
             {
                 if ( lookupContext.getAttrsId().size() == 0 )
                 {
-                    for ( Attribute attribute : ( ((ClonedServerEntry)entry).getOriginalEntry() ).getAttributes() )
+                    for ( Attribute attribute : ( ( ( ClonedServerEntry ) entry ).getOriginalEntry() ).getAttributes() )
                     {
                         AttributeType attributeType = attribute.getAttributeType();
 
@@ -942,11 +949,11 @@ public abstract class AbstractBTreeParti
                 }
                 else
                 {
-                    for ( Attribute attribute : ( ((ClonedServerEntry)entry).getOriginalEntry() ).getAttributes() )
+                    for ( Attribute attribute : ( ( ( ClonedServerEntry ) entry ).getOriginalEntry() ).getAttributes() )
                     {
                         AttributeType attributeType = attribute.getAttributeType();
                         String oid = attributeType.getOid();
-                        
+
                         if ( !lookupContext.getAttrsId().contains( oid ) )
                         {
                             entry.removeAttributes( attributeType );
@@ -972,16 +979,16 @@ public abstract class AbstractBTreeParti
         try
         {
             Entry entry = master.get( id );
-    
+
             if ( entry != null )
             {
                 // We have to store the DN in this entry
                 Dn dn = buildEntryDn( id );
                 entry.setDn( dn );
-                
+
                 return new ClonedServerEntry( entry );
             }
-    
+
             return null;
         }
         catch ( Exception e )
@@ -1001,7 +1008,9 @@ public abstract class AbstractBTreeParti
     {
         try
         {
-            Entry modifiedEntry = modify( modifyContext.getDn(), modifyContext.getModItems().toArray( new Modification[]{}) );
+            Entry modifiedEntry = modify( modifyContext.getDn(),
+                modifyContext.getModItems().toArray( new Modification[]
+                    {} ) );
             modifyContext.setAlteredEntry( modifiedEntry );
         }
         catch ( Exception e )
@@ -1009,8 +1018,8 @@ public abstract class AbstractBTreeParti
             throw new LdapOperationErrorException( e.getMessage(), e );
         }
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
@@ -1018,7 +1027,7 @@ public abstract class AbstractBTreeParti
     {
         ID id = getEntryId( dn );
         Entry entry = master.get( id );
-        
+
         for ( Modification mod : mods )
         {
             Attribute attrMods = mod.getAttribute();
@@ -1052,8 +1061,8 @@ public abstract class AbstractBTreeParti
 
         return entry;
     }
-    
-    
+
+
     /**
      * Adds a set of attribute values while affecting the appropriate userIndices.
      * The entry is not persisted: it is only changed in anticipation for a put
@@ -1336,7 +1345,7 @@ public abstract class AbstractBTreeParti
             Dn newSuperior = moveContext.getNewSuperior();
             Dn newDn = moveContext.getNewDn();
             Entry modifiedEntry = moveContext.getModifiedEntry();
-            
+
             move( oldDn, newSuperior, newDn, modifiedEntry );
         }
         catch ( Exception e )
@@ -1402,7 +1411,6 @@ public abstract class AbstractBTreeParti
         ParentIdAndRdn<ID> key = new ParentIdAndRdn<ID>( newParentId, oldDn.getRdn() );
         rdnIdx.add( key, entryId );
 
-
         /*
          * Read Alias Index Tuples
          *
@@ -1427,7 +1435,7 @@ public abstract class AbstractBTreeParti
         {
             modifiedEntry = lookup( entryId );
         }
-        
+
         // Update the master table with the modified entry
         modifiedEntry.put( SchemaConstants.ENTRY_PARENT_ID_AT, newParentId.toString() );
         master.put( entryId, modifiedEntry );
@@ -1460,7 +1468,7 @@ public abstract class AbstractBTreeParti
             Rdn newRdn = moveAndRenameContext.getNewRdn();
             boolean deleteOldRdn = moveAndRenameContext.getDeleteOldRdn();
             Entry modifiedEntry = moveAndRenameContext.getModifiedEntry();
-            
+
             moveAndRename( oldDn, newSuperiorDn, newRdn, modifiedEntry, deleteOldRdn );
         }
         catch ( LdapException le )
@@ -1479,7 +1487,8 @@ public abstract class AbstractBTreeParti
     /**
      * {@inheritDoc}
      */
-    public synchronized final void moveAndRename( Dn oldDn, Dn newSuperiorDn, Rdn newRdn, Entry modifiedEntry, boolean deleteOldRdn ) throws Exception
+    public synchronized final void moveAndRename( Dn oldDn, Dn newSuperiorDn, Rdn newRdn, Entry modifiedEntry,
+        boolean deleteOldRdn ) throws Exception
     {
         // Check that the old entry exists
         ID oldId = getEntryId( oldDn );
@@ -1542,7 +1551,8 @@ public abstract class AbstractBTreeParti
      * @param modifiedEntry the modified entry
      * @throws Exception if something goes wrong
      */
-    private void moveAndRename( Dn oldDn, ID childId, Dn newSuperior, Rdn newRdn, Entry modifiedEntry ) throws Exception
+    private void moveAndRename( Dn oldDn, ID childId, Dn newSuperior, Rdn newRdn, Entry modifiedEntry )
+        throws Exception
     {
         // Get the child and the new parent to be entries and Ids
         ID newParentId = getEntryId( newSuperior );
@@ -1647,7 +1657,7 @@ public abstract class AbstractBTreeParti
         {
             entry = master.get( id );
         }
-        
+
         Dn updn = entry.getDn();
 
         newRdn.apply( schemaManager );
@@ -1744,7 +1754,6 @@ public abstract class AbstractBTreeParti
             }
         }
 
-
         /*
          * H A N D L E   D N   C H A N G E
          * ====================================================================
@@ -1790,7 +1799,7 @@ public abstract class AbstractBTreeParti
             ID id = getEntryId( entryContext.getDn() );
 
             Entry entry = lookup( id );
-            
+
             return entry != null;
         }
         catch ( LdapException e )
@@ -1849,7 +1858,7 @@ public abstract class AbstractBTreeParti
         }
 
         cursor.close();
-        
+
         // detach the childId and all its children from oldParentId and all it parents excluding the root
         for ( ID pid : parentIds )
         {
@@ -1863,7 +1872,7 @@ public abstract class AbstractBTreeParti
         tempId = newParentId;
 
         // find all the parents of the newParentId
-        while ( ( tempId != null)  && !tempId.equals( getRootId() ) && !tempId.equals( getSuffixId() ) )
+        while ( ( tempId != null ) && !tempId.equals( getRootId() ) && !tempId.equals( getSuffixId() ) )
         {
             parentIds.add( tempId );
             tempId = getParentId( tempId );
@@ -1913,7 +1922,7 @@ public abstract class AbstractBTreeParti
                 {
                     upName.append( ',' );
                 }
-                
+
                 upName.append( rdn.getName() );
             }
 
@@ -1959,8 +1968,8 @@ public abstract class AbstractBTreeParti
     {
         return buildEntryDn( id );
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
@@ -2023,7 +2032,7 @@ public abstract class AbstractBTreeParti
         if ( suffixId == null )
         {
             ParentIdAndRdn<ID> key = new ParentIdAndRdn<ID>( getRootId(), suffixDn.getRdns() );
-            
+
             suffixId = rdnIdx.forwardLookup( key );
         }
 
@@ -2080,7 +2089,7 @@ public abstract class AbstractBTreeParti
         }
     }
 
-    
+
     /**
      * Set the list of indexes for this partition
      * @param indexedAttributes The list of indexes
@@ -2099,6 +2108,7 @@ public abstract class AbstractBTreeParti
         return indexedAttributes;
     }
 
+
     /**
      * {@inheritDoc}
      */
@@ -2149,7 +2159,7 @@ public abstract class AbstractBTreeParti
         }
 
         String oid = attributeType.getOid();
-        
+
         if ( userIndices.containsKey( oid ) )
         {
             return userIndices.get( oid );
@@ -2170,7 +2180,7 @@ public abstract class AbstractBTreeParti
         }
 
         String oid = attributeType.getOid();
-        
+
         if ( systemIndices.containsKey( oid ) )
         {
             return systemIndices.get( oid );
@@ -2305,8 +2315,8 @@ public abstract class AbstractBTreeParti
     {
         return hasUserIndexOn( attributeType ) || hasSystemIndexOn( attributeType );
     }
-    
-    
+
+
     //---------------------------------------------------------------------------------------------
     // Alias index manipulation
     //---------------------------------------------------------------------------------------------
@@ -2425,8 +2435,8 @@ public abstract class AbstractBTreeParti
             ancestorId = getEntryId( ancestorDn );
         }
     }
-    
-    
+
+
     /**
      * Removes the index entries for an alias before the entry is deleted from
      * the master table.
@@ -2548,7 +2558,7 @@ public abstract class AbstractBTreeParti
         }
     }
 
-    
+
     //---------------------------------------------------------------------------------------------
     // Debug methods
     //---------------------------------------------------------------------------------------------
@@ -2557,11 +2567,11 @@ public abstract class AbstractBTreeParti
         try
         {
             IndexCursor<?, Entry, ID> cursor = index.forwardCursor();
-            
+
             while ( cursor.next() )
             {
                 IndexEntry<?, ID> entry = cursor.get();
-                
+
                 System.out.println( entry );
             }
         }
@@ -2570,8 +2580,8 @@ public abstract class AbstractBTreeParti
             // TODO : fixme
         }
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
@@ -2580,15 +2590,15 @@ public abstract class AbstractBTreeParti
         try
         {
             AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( name );
-            
+
             if ( attributeType == null )
             {
                 stream.write( Strings.getBytesUtf8( "Cannot find an index for AttributeType names " + name ) );
-                
+
                 return;
             }
-            
-            if ( attributeType.getOid().equals( ApacheSchemaConstants.APACHE_RDN_AT_OID  ))
+
+            if ( attributeType.getOid().equals( ApacheSchemaConstants.APACHE_RDN_AT_OID ) )
             {
                 dumpIndex( stream, rdnIdx );
             }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/IndexCursorAdaptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/IndexCursorAdaptor.java?rev=1235334&r1=1235333&r2=1235334&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/IndexCursorAdaptor.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/IndexCursorAdaptor.java Tue Jan 24 16:27:18 2012
@@ -60,7 +60,7 @@ public class IndexCursorAdaptor<K, O, ID
     public IndexCursorAdaptor( Cursor<Tuple> wrappedCursor, boolean forwardIndex )
     {
         this.wrappedCursor = wrappedCursor;
-        
+
         if ( forwardIndex )
         {
             forwardEntry = new ForwardIndexEntry<K, ID>();
@@ -95,7 +95,7 @@ public class IndexCursorAdaptor<K, O, ID
     {
         if ( wrappedCursor instanceof TupleCursor )
         {
-            ( (TupleCursor) wrappedCursor ).afterValue( key, id );
+            ( ( TupleCursor ) wrappedCursor ).afterValue( key, id );
         }
     }
 

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/LongComparator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/LongComparator.java?rev=1235334&r1=1235333&r2=1235334&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/LongComparator.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/LongComparator.java Tue Jan 24 16:27:18 2012
@@ -34,6 +34,7 @@ public class LongComparator extends Seri
     /** The serial version UID */
     private static final long serialVersionUID = 2L;
 
+
     public LongComparator()
     {
         super( "1.3.6.1.4.1.18060.0.4.1.1.2" );

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/InvalidLogException.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/InvalidLogException.java?rev=1235334&r1=1235333&r2=1235334&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/InvalidLogException.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/InvalidLogException.java Tue Jan 24 16:27:18 2012
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.server.log;
 
+
 /** 
  * An exception used when the log content could be invalid.
  *
@@ -26,21 +27,26 @@ package org.apache.directory.server.log;
  */
 public class InvalidLogException extends Exception
 {
-    public InvalidLogException() {}
+    public InvalidLogException()
+    {
+    }
 
-    public InvalidLogException(String s) 
+
+    public InvalidLogException( String s )
     {
-        super(s);
+        super( s );
     }
 
-    public InvalidLogException(Throwable cause) 
+
+    public InvalidLogException( Throwable cause )
     {
-        super(cause);
+        super( cause );
     }
 
-    public InvalidLogException(String s, Throwable cause) 
+
+    public InvalidLogException( String s, Throwable cause )
     {
-        super(s, cause);
+        super( s, cause );
     }
 
 }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/Log.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/Log.java?rev=1235334&r1=1235333&r2=1235334&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/Log.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/Log.java Tue Jan 24 16:27:18 2012
@@ -19,11 +19,13 @@
  */
 package org.apache.directory.server.log;
 
+
 import java.io.IOException;
 
+
 public interface Log
 {
-    
+
     /**
      * Initializes the logging subsystem
      *
@@ -32,8 +34,9 @@ public interface Log
      * @param logBufferSize size of buffer that will hold unflushed log changes. Specifigy zero if no buffering is desired
      * @param logFileSize A soft limit on the log file size
      */
-   public void init( String logFilepath, String suffix, int logBufferSize, long logFileSize );
-    
+    public void init( String logFilepath, String suffix, int logBufferSize, long logFileSize );
+
+
     /**
      * Logs the given user record to the log. Position in the log files where the record is logged is returned as part of
      * userRecord.
@@ -44,8 +47,8 @@ public interface Log
      * @throws InvalidLogException
      */
     public void log( UserLogRecord userRecord, boolean sync ) throws IOException, InvalidLogException;
-    
-    
+
+
     /**
      * Starts a san in the logs starting from the given log position
      *
@@ -54,5 +57,4 @@ public interface Log
      */
     public LogScanner beginScan( LogAnchor startPoint );
 
-    
 }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/LogAnchor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/LogAnchor.java?rev=1235334&r1=1235333&r2=1235334&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/LogAnchor.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/LogAnchor.java Tue Jan 24 16:27:18 2012
@@ -19,8 +19,10 @@
  */
 package org.apache.directory.server.log;
 
+
 import org.apache.directory.server.i18n.I18n;
 
+
 /**
  * Implements a pointer in to the log files
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -30,72 +32,73 @@ public class LogAnchor
     // TODO move this to logger 
     /** Invalid/unknown lsn. Log LSN starts at UNKNOWN_LSN + 1 and is ever increasing */
     public final static long UNKNOWN_LSN = Long.MIN_VALUE;
-    
+
     /** Min log file number */
     public final static long MIN_LOG_NUMBER = 0;
-    
+
     /** Min log file offset */
     public final static long MIN_LOG_OFFSET = 0;
-    
-    
+
     /** log file identifier of the anchor */
-    private long logFileNumber = 0 ;
-    
+    private long logFileNumber = 0;
+
     /** Offset into the log file identified by logfilenumber */
     private long logFileOffset = 0;
-    
+
     /** LSN corresponding to the logFileNumber and fileOffset */
-    private long logLSN = UNKNOWN_LSN; 
-    
+    private long logLSN = UNKNOWN_LSN;
+
+
     public LogAnchor()
     {
-        
+
     }
-    
+
+
     public LogAnchor( long logFileNumber, long logFileOffset, long logLSN )
     {
         this.resetLogAnchor( logFileNumber, logFileOffset, logLSN );
     }
-    
-    
+
+
     public void resetLogAnchor( long logFileNumber, long logFileOffset, long logLSN )
     {
         if ( logFileNumber < 0 )
         {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_746, logFileNumber ) );
         }
-        
+
         if ( logFileOffset < 0 )
         {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_747, logFileOffset ) );
         }
-        
-        
+
         this.logFileNumber = logFileNumber;
         this.logFileOffset = logFileOffset;
         this.logLSN = logLSN;
     }
-    
+
+
     public void resetLogAnchor( LogAnchor logAnchor )
     {
         this.resetLogAnchor( logAnchor.getLogFileNumber(), logAnchor.getLogFileOffset(), logAnchor.getLogLSN() );
     }
-    
-     
+
+
     public long getLogFileNumber()
     {
         return this.logFileNumber;
     }
-    
-    
+
+
     public long getLogFileOffset()
     {
         return this.logFileOffset;
     }
-    
-    
+
+
     public long getLogLSN()
     {
         return this.logLSN;
-    }  
+    }
 }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/LogAnchorComparator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/LogAnchorComparator.java?rev=1235334&r1=1235333&r2=1235334&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/LogAnchorComparator.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/LogAnchorComparator.java Tue Jan 24 16:27:18 2012
@@ -19,10 +19,12 @@
  */
 package org.apache.directory.server.log;
 
+
 import java.util.Comparator;
 
 import org.apache.directory.server.i18n.I18n;
 
+
 public class LogAnchorComparator implements Comparator<LogAnchor>
 {
     /**
@@ -33,13 +35,15 @@ public class LogAnchorComparator impleme
      * @return a positive integer if obj1 > obj2, 0 if obj1 == obj2,
      *         and a negative integer if obj1 < obj2
      */
-     public int compare( LogAnchor obj1, LogAnchor obj2 )
-     {
-        if ( obj1 == null ) {
+    public int compare( LogAnchor obj1, LogAnchor obj2 )
+    {
+        if ( obj1 == null )
+        {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_525 ) );
         }
 
-        if ( obj2 == null ) {
+        if ( obj2 == null )
+        {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_526 ) );
         }
 
@@ -47,7 +51,7 @@ public class LogAnchorComparator impleme
         long logFileOffset1 = obj1.getLogFileOffset();
         long logFileNumber2 = obj2.getLogFileNumber();
         long logFileOffset2 = obj2.getLogFileOffset();
-        
+
         if ( logFileNumber1 > logFileNumber2 )
         {
             return 1;
@@ -70,6 +74,6 @@ public class LogAnchorComparator impleme
         else
         {
             return -1;
-        }     
-     }
+        }
+    }
 }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/LogScanner.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/LogScanner.java?rev=1235334&r1=1235333&r2=1235334&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/LogScanner.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/LogScanner.java Tue Jan 24 16:27:18 2012
@@ -22,6 +22,7 @@ package org.apache.directory.server.log;
 
 import java.io.IOException;
 
+
 public interface LogScanner
 {
     /**
@@ -34,23 +35,25 @@ public interface LogScanner
      * throws IOException
      * throws InvalidLogException thrown if the log content is invalid 
      */
-    public boolean getNextRecord(UserLogRecord logRecord) throws IOException, InvalidLogException;
-    
-    
+    public boolean getNextRecord( UserLogRecord logRecord ) throws IOException, InvalidLogException;
+
+
     /**
      * Returns the last successfully read log file number
      *
      * @return last successfully read log file number
      */
     public long getLastGoodFileNumber();
-    
+
+
     /**
      * Returns the last successfully read log file number
      *
      * @return last successfully read log file number
      */
     public long getLastGoodOffset();
-    
+
+
     /**
      * Closes the scanner and releases any
      * resources. 

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/UserLogRecord.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/UserLogRecord.java?rev=1235334&r1=1235333&r2=1235334&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/UserLogRecord.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/UserLogRecord.java Tue Jan 24 16:27:18 2012
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.server.log;
 
+
 /** 
  * A user log record that can be used to pass user record between the clients and the logger
  *
@@ -26,40 +27,42 @@ package org.apache.directory.server.log;
  */
 public class UserLogRecord
 {
-    private final static int INITIAL_SIZE =  1024;
-    
+    private final static int INITIAL_SIZE = 1024;
+
     /** array used to hold user log records */
     private byte[] recordHolder;
-    
+
     /** offset int the  byte array where user record starts */
     int offset;
-    
+
     /** length of the user record in the byte array */
     int length;
-    
+
     /** Position of the log record in the log */
     private LogAnchor logAnchor = new LogAnchor();
-    
+
+
     public void setData( byte[] data, int length )
     {
         this.recordHolder = recordHolder;
     }
-    
+
+
     public byte[] getDataBuffer()
     {
         return recordHolder;
     }
-    
-   
+
+
     public int getDataLength()
     {
         return length;
     }
-    
-    
+
+
     public LogAnchor getLogAnchor()
     {
         return logAnchor;
     }
-    
+
 }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/impl/DefaultLogFileManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/impl/DefaultLogFileManager.java?rev=1235334&r1=1235333&r2=1235334&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/impl/DefaultLogFileManager.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/impl/DefaultLogFileManager.java Tue Jan 24 16:27:18 2012
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.server.log.impl;
 
+
 import java.io.EOFException;
 import java.io.File;
 import java.io.IOException;
@@ -30,11 +31,13 @@ import org.apache.directory.server.i18n.
 import org.apache.directory.server.log.impl.LogFileManager.LogFileReader;
 import org.apache.directory.server.log.impl.LogFileManager.LogFileWriter;
 
-class DefaultLogFileManager implements LogFileManager 
+
+class DefaultLogFileManager implements LogFileManager
 {
     private String logFilePath;
     private String suffix;
-    
+
+
     /**
      * Inits the log file manager to use the given logfile path and the suffix. Each log file
      * has name logFileName_<logFileNumber>.suffix 
@@ -47,48 +50,49 @@ class DefaultLogFileManager implements L
         this.logFilePath = logFilePath;
         this.suffix = suffix;
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
     public LogFileReader getReaderForLogFile( long logFileNumber ) throws IOException, FileNotFoundException
-    {      
+    {
         File logFile = this.makeLogFileName( logFileNumber );
-        
+
         // This will throw a file not found exception if file does not exist
         RandomAccessFile raf = new RandomAccessFile( logFile, "r" );
-        
+
         return new LogFileReader( raf, logFileNumber );
     }
-    
+
+
     /**
      * {@inheritDoc}
      */
     public LogFileWriter getWriterForLogFile( long logFileNumber ) throws IOException, FileNotFoundException
     {
         File logFile = this.makeLogFileName( logFileNumber );
-        
+
         // This will throw a file not found exception if file does not exist
         RandomAccessFile raf = new RandomAccessFile( logFile, "rw" );
-        
+
         return new LogFileWriter( raf, logFileNumber );
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
     public boolean createLogFile( long logFileNumber ) throws IOException
     {
         File logFile = this.makeLogFileName( logFileNumber );
-        
+
         boolean fileAlreadyExists = !logFile.createNewFile();
-        
+
         return fileAlreadyExists;
     }
-    
-       
+
+
     /**
      * {@inheritDoc}
      */
@@ -96,65 +100,67 @@ class DefaultLogFileManager implements L
     {
         if ( size < 0 )
         {
-            throw new IllegalArgumentException( "Invalid file size is specified for the log file: " + logFileNumber + " " + size );
+            throw new IllegalArgumentException( "Invalid file size is specified for the log file: " + logFileNumber
+                + " " + size );
         }
-        
+
         File logFile = this.makeLogFileName( logFileNumber );
-        
+
         // This will throw a file not found exception if file does not exist
         RandomAccessFile raf = new RandomAccessFile( logFile, "rw" );
-        
+
         raf.setLength( size );
         raf.getFD().sync();
     }
-    
-   
+
+
     /**
      * {@inheritDoc}
      */
     public void deleteLogFile( long logFileNumber ) throws IOException
     {
         File logFile = this.makeLogFileName( logFileNumber );
-        
+
         if ( !logFile.delete() )
         {
-            throw new IOException(I18n.err( I18n.ERR_113_COULD_NOT_DELETE_FILE_OR_DIRECTORY, logFile ));
+            throw new IOException( I18n.err( I18n.ERR_113_COULD_NOT_DELETE_FILE_OR_DIRECTORY, logFile ) );
         }
     }
-    
-   
+
+
     /**
      * {@inheritDoc}
      */
-    public boolean rename(long originalLogFileNumber, long newLongFileNumber)
+    public boolean rename( long originalLogFileNumber, long newLongFileNumber )
     {
-        File oldLogFile = this.makeLogFileName( originalLogFileNumber );  
+        File oldLogFile = this.makeLogFileName( originalLogFileNumber );
         boolean result = oldLogFile.renameTo( this.makeLogFileName( newLongFileNumber ) );
         return result;
     }
-    
-    
+
+
     private File makeLogFileName( long logFileNumber )
     {
-        
+
         return new File( logFilePath + "/" + LogFileManager.LOG_NAME_PREFIX + logFileNumber + "." + suffix );
     }
-    
+
     static class LogFileReader implements LogFileManager.LogFileReader
     {
         /** Underlying log file */
         RandomAccessFile raf;
-        
+
         /** Log file identifier */
         long logFileNumber;
-        
-  
+
+
         public LogFileReader( RandomAccessFile raf, long logFileNumber )
         {
             this.raf = raf;
             this.logFileNumber = logFileNumber;
         }
-        
+
+
         /**
          * {@inheritDoc}
          */
@@ -163,7 +169,8 @@ class DefaultLogFileManager implements L
             raf.readFully( buffer, offset, length );
             return length;
         }
-        
+
+
         /**
          * {@inheritDoc}
          */
@@ -171,7 +178,8 @@ class DefaultLogFileManager implements L
         {
             raf.seek( position );
         }
-        
+
+
         /**
          * {@inheritDoc}
          */
@@ -179,8 +187,8 @@ class DefaultLogFileManager implements L
         {
             raf.close();
         }
-        
-        
+
+
         /**
          * {@inheritDoc}
          */
@@ -188,7 +196,8 @@ class DefaultLogFileManager implements L
         {
             return logFileNumber;
         }
-        
+
+
         /**
          * {@inheritDoc}
          */
@@ -196,7 +205,8 @@ class DefaultLogFileManager implements L
         {
             return raf.length();
         }
-        
+
+
         /**
          * {@inheritDoc}
          */
@@ -205,22 +215,23 @@ class DefaultLogFileManager implements L
             return raf.getFilePointer();
         }
     }
-    
-    
+
     static class LogFileWriter implements LogFileManager.LogFileWriter
     {
         /** Underlying log file */
         RandomAccessFile raf;
-        
+
         /** Log file identifier */
         long logFileNumber;
-        
-  
+
+
         public LogFileWriter( RandomAccessFile raf, long logFileNumber )
         {
             this.raf = raf;
             this.logFileNumber = logFileNumber;
         }
+
+
         /**
          * {@inheritDoc}
          */
@@ -228,15 +239,17 @@ class DefaultLogFileManager implements L
         {
             raf.write( buffer, offset, length );
         }
-        
+
+
         /**
          * {@inheritDoc}
          */
         public void sync() throws IOException
         {
-             raf.getFD().sync();
+            raf.getFD().sync();
         }
-        
+
+
         /**
          * {@inheritDoc}
          */
@@ -244,15 +257,17 @@ class DefaultLogFileManager implements L
         {
             raf.close();
         }
-        
-         /**
-          * {@inheritDoc}
-          */
+
+
+        /**
+         * {@inheritDoc}
+         */
         public long logFileNumber()
         {
             return logFileNumber;
         }
-        
+
+
         /**
          * {@inheritDoc}
          */

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/impl/DefaultLogScanner.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/impl/DefaultLogScanner.java?rev=1235334&r1=1235333&r2=1235334&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/impl/DefaultLogScanner.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/impl/DefaultLogScanner.java Tue Jan 24 16:27:18 2012
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.server.log.impl;
 
+
 import java.io.IOException;
 import java.io.EOFException;
 import java.io.FileNotFoundException;
@@ -30,80 +31,82 @@ import org.apache.directory.server.log.L
 import org.apache.directory.server.log.LogScanner;
 import org.apache.directory.server.log.UserLogRecord;
 
+
 public class DefaultLogScanner implements LogScanner
 {
     /** LSN of the last successfully read log record */
     private long prevLSN = LogAnchor.UNKNOWN_LSN;
-    
+
     /** File number of the last successfully read position's file number */
     private long prevLogFileNumber = -1;
-    
+
     /** File number of the last known good offset */
     private long prevLogFileOffset = -1;
-    
+
     /** Position to read the next record from */
     private LogAnchor startingLogAnchor = new LogAnchor();
-    
+
     /** Last Read Lsn */
     private long lastReadLSN = LogAnchor.UNKNOWN_LSN;
-    
+
     /** Current log file pointer to read from */
     LogFileManager.LogFileReader currentLogFile;
-    
+
     /** True if scanner is closed */
     boolean closed = false;
-    
+
     /** True if scanner hit invalid content. No more reads will be done after invalid log content is hit */
     boolean invalidLog = false;
-    
+
     /** log file manager used to open files for reading */
     LogFileManager logFileManager;
-    
+
     /** Buffer used to read log file markers */
     byte markerBuffer[] = new byte[LogFileRecords.MAX_MARKER_SIZE];
-    
+
     /** ByteBuffer wrapper for the marker buffer */
     ByteBuffer markerHead = ByteBuffer.wrap( markerBuffer );
-    
+
+
     public DefaultLogScanner( LogAnchor startingLogAnchor, LogFileManager logFileManger )
     {
         startingLogAnchor.resetLogAnchor( startingLogAnchor );
         this.logFileManager = logFileManager;
     }
-    
+
+
     /**
      * {@inheritDoc}
      */
-    public boolean getNextRecord(UserLogRecord logRecord) throws IOException, InvalidLogException
+    public boolean getNextRecord( UserLogRecord logRecord ) throws IOException, InvalidLogException
     {
         boolean startingRead = false;
-        
+
         checkIfClosed();
-        
+
         if ( invalidLog )
         {
             throw new InvalidLogException( I18n.err( I18n.ERR_750 ) );
         }
-        
+
         long fileLength;
         long fileOffset;
-        
-        
+
         try
         {
             if ( currentLogFile == null )
             {
-                
+
                 long startingOffset = startingLogAnchor.getLogFileOffset();
-                
+
                 // Read and verify header
                 currentLogFile = this.readFileHeader( startingLogAnchor.getLogFileNumber() );
-                
+
                 if ( currentLogFile == null )
                 {
                     return false; // Nothing to read
                 }
-    
+
                 if ( startingOffset > 0 )
                 {
                     if ( startingOffset < LogFileRecords.LOG_FILE_HEADER_SIZE )
@@ -111,18 +114,18 @@ public class DefaultLogScanner implement
                         // Offset should be at log file marker boundary
                         this.markScanInvalid();
                     }
-                    
+
                     prevLogFileOffset = Math.max( startingOffset, currentLogFile.getLength() );
                     currentLogFile.seek( startingOffset );
                 }
                 startingRead = true;
-            }     
-            
+            }
+
             while ( true )
             {
                 fileLength = currentLogFile.getLength();
-                fileOffset = currentLogFile.getOffset(); 
-                
+                fileOffset = currentLogFile.getOffset();
+
                 if ( fileOffset > fileLength )
                 {
                     this.markScanInvalid();
@@ -133,63 +136,62 @@ public class DefaultLogScanner implement
                     long nextLogFileNumber = currentLogFile.logFileNumber() + 1;
                     currentLogFile.close();
                     currentLogFile = this.readFileHeader( nextLogFileNumber );
-                    
+
                     if ( currentLogFile == null )
                         return false; // Done.. End of log stream
-                    
-                   
+
                 }
                 else
                 {
-                    break;  // break to read the user record
+                    break; // break to read the user record
                 }
             }
-            
+
             // Read and verify record header
             int recordLength = this.readRecordHeader();
-            
+
             // If starting read, then check if we have the expected lsn in case
             // expected lsn is known
             if ( startingRead )
             {
                 long startingLSN = startingLogAnchor.getLogLSN();
-                
+
                 if ( ( startingLSN != LogAnchor.UNKNOWN_LSN ) && ( startingLSN != lastReadLSN ) )
                 {
                     this.markScanInvalid();
                 }
             }
-            
+
             // Read and verify user block
             this.readLogRecord( logRecord, recordLength );
-            
+
             // Read and verify footer
             this.readRecordFooter();
-            
-            
+
             // If we are here, then we successfully read the log record. 
             // Set the read record's position, uptate last read good location
             // and then return
             fileOffset = currentLogFile.getOffset();
-            
+
             LogAnchor userLogAnchor = logRecord.getLogAnchor();
             userLogAnchor.resetLogAnchor( currentLogFile.logFileNumber(), fileOffset - recordLength, lastReadLSN );
-            
+
             prevLogFileOffset = fileOffset;
             prevLogFileNumber = currentLogFile.logFileNumber();
             prevLSN = lastReadLSN;
         }
-        catch( EOFException e)
+        catch ( EOFException e )
         {
             // This means either the log record or the log file header was
             // partially written. Treat this as invalid log content
             this.markScanInvalid();
         }
-        
+
         return true;
-        
+
     }
-    
+
+
     /**
      * {@inheritDoc}
      */
@@ -197,8 +199,8 @@ public class DefaultLogScanner implement
     {
         return this.prevLogFileNumber;
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
@@ -207,8 +209,7 @@ public class DefaultLogScanner implement
         return this.prevLogFileOffset;
     }
 
-    
-    
+
     /**
      * {@inheritDoc}
      */
@@ -217,106 +218,109 @@ public class DefaultLogScanner implement
         if ( closed == false )
         {
             closed = true;
-            if (currentLogFile != null)
+            if ( currentLogFile != null )
             {
                 try
                 {
                     currentLogFile.close();
                     currentLogFile = null;
                 }
-                catch( IOException e )
+                catch ( IOException e )
                 {
                     // Ignore
                 }
             }
         }
-        
+
     }
-    
-    
+
+
     private int readRecordHeader() throws IOException, InvalidLogException, EOFException
     {
-        boolean invalid = false; 
-        
+        boolean invalid = false;
+
         markerHead.rewind();
         currentLogFile.read( markerBuffer, 0, LogFileRecords.RECORD_HEADER_SIZE );
         int magicNumber = markerHead.getInt();
         int length = markerHead.getInt();
         long lsn = markerHead.getLong();
         long checksum = markerHead.getLong();
-        
+
         if ( magicNumber != LogFileRecords.RECORD_HEADER_MAGIC_NUMBER )
         {
             invalid = true;
         }
-        
+
         if ( length <= ( LogFileRecords.RECORD_HEADER_SIZE + LogFileRecords.RECORD_FOOTER_SIZE ) )
         {
             invalid = true;
         }
-        
+
         if ( lsn < prevLSN )
         {
             invalid = true;
         }
-        
+
         if ( checksum != ( lsn ^ length ) )
         {
             invalid = true;
         }
-        
+
         if ( invalid == true )
         {
             this.markScanInvalid();
         }
-        
+
         // Everything went fine
         lastReadLSN = lsn;
         return length;
     }
-    
-    
-    private void readRecordFooter() throws IOException, InvalidLogException, EOFException 
+
+
+    private void readRecordFooter() throws IOException, InvalidLogException, EOFException
     {
-        boolean invalid = false; 
-        
+        boolean invalid = false;
+
         markerHead.rewind();
         currentLogFile.read( markerBuffer, 0, LogFileRecords.RECORD_FOOTER_SIZE );
         int checksum = markerHead.getInt();
         int magicNumber = markerHead.getInt();
-      
+
         if ( magicNumber != LogFileRecords.RECORD_FOOTER_MAGIC_NUMBER )
         {
             invalid = true;
         }
-        
+
         // TODO compute checksum
-        
+
         if ( invalid == true )
         {
             this.markScanInvalid();
         }
     }
-    
+
+
     private void readLogRecord( UserLogRecord userRecord, int length ) throws IOException, EOFException
     {
         byte dataBuffer[] = userRecord.getDataBuffer();
-        
+
         if ( dataBuffer == null || dataBuffer.length < length )
         {
             // Allocate a larger buffer
             dataBuffer = new byte[length];
         }
-        
+
         currentLogFile.read( dataBuffer, 0, length );
         userRecord.setData( dataBuffer, length );
     }
-    
-    private LogFileManager.LogFileReader readFileHeader( long logFileNumber ) throws IOException, InvalidLogException, EOFException
+
+
+    private LogFileManager.LogFileReader readFileHeader( long logFileNumber ) throws IOException, InvalidLogException,
+        EOFException
     {
         boolean invalid = false;
-        LogFileManager.LogFileReader logFile;      
-          
+        LogFileManager.LogFileReader logFile;
+
         try
         {
             logFile = logFileManager.getReaderForLogFile( logFileNumber );
@@ -325,37 +329,37 @@ public class DefaultLogScanner implement
         {
             return null; // end of log scan
         }
-        
+
         // File exists
         this.prevLogFileNumber = logFileNumber;
         this.prevLogFileOffset = 0;
-        
+
         markerHead.rewind();
         currentLogFile.read( markerBuffer, 0, LogFileRecords.LOG_FILE_HEADER_SIZE );
         long persistedLogFileNumber = markerHead.getLong();
         int magicNumber = markerHead.getInt();
-      
+
         if ( persistedLogFileNumber != logFileNumber )
         {
             invalid = true;
         }
-        
+
         if ( magicNumber != LogFileRecords.LOG_FILE_HEADER_MAGIC_NUMBER )
         {
             invalid = true;
         }
-       
-        
+
         if ( invalid == true )
         {
             this.markScanInvalid();
         }
-        
+
         // Everything is fine, advance good file offset and return
         this.prevLogFileOffset = LogFileRecords.LOG_FILE_HEADER_SIZE;
         return logFile;
     }
-    
+
+
     private void checkIfClosed()
     {
         if ( closed == true )
@@ -363,7 +367,8 @@ public class DefaultLogScanner implement
             throw new IllegalStateException( I18n.err( I18n.ERR_749 ) );
         }
     }
-    
+
+
     private void markScanInvalid() throws InvalidLogException
     {
         invalidLog = true;

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/impl/LogFileManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/impl/LogFileManager.java?rev=1235334&r1=1235333&r2=1235334&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/impl/LogFileManager.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/impl/LogFileManager.java Tue Jan 24 16:27:18 2012
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.server.log.impl;
 
+
 import java.io.IOException;
 import java.io.EOFException;
 import java.io.FileNotFoundException;
@@ -31,8 +32,9 @@ import java.io.FileNotFoundException;
  */
 interface LogFileManager
 {
-    final static String LOG_NAME_PREFIX = "log_"; 
-  
+    final static String LOG_NAME_PREFIX = "log_";
+
+
     /**
      * Inits the log file manager to use the given logfile path and the suffix. Each log file
      * has name logFileName_<logFileNumber>.suffix 
@@ -41,8 +43,8 @@ interface LogFileManager
      * @param suffix suffix for log file.
      */
     public void init( String logFilepath, String suffix );
-    
-    
+
+
     /**
      * Returns a reader for the given log file number
      *
@@ -52,8 +54,8 @@ interface LogFileManager
      * @throws FileNotFoundException
      */
     public LogFileReader getReaderForLogFile( long logFileNumber ) throws IOException, FileNotFoundException;
-    
-  
+
+
     /**
      * Returns a writer for the given log file number
      *
@@ -63,8 +65,8 @@ interface LogFileManager
      * @throws FileNotFoundException
      */
     public LogFileWriter getWriterForLogFile( long logFileNumber ) throws IOException, FileNotFoundException;
-    
-    
+
+
     /**
      * Create a log file with the given identifier
      * 
@@ -73,8 +75,8 @@ interface LogFileManager
      * @throws IOException
      */
     public boolean createLogFile( long logFileNumber ) throws IOException;
-    
-       
+
+
     /**
      * Truncates the file to the given size. Mostly used for throwing away
      * junk at the end of log file after a log replay after a crash.
@@ -84,16 +86,17 @@ interface LogFileManager
      * @throws IOException
      */
     public void truncateLogFile( long logFileNumber, long size ) throws IOException;
-    
+
+
     /**
      * Deletes the underlying log file.
      *
      * @param logFileNumber identifier of the log file
      * @throws IOException If the log file could not be deleted
      */
-    public void deleteLogFile( long logFileNumber ) throws IOException; 
-    
-    
+    public void deleteLogFile( long logFileNumber ) throws IOException;
+
+
     /**
      * Moves the old log file to a new name
      *
@@ -101,9 +104,8 @@ interface LogFileManager
      * @param newLongFileNumber identifier of the new file
      * @return true if the rename succeeded
      */
-    public boolean rename(long orignalLogFileNumber, long newLongFileNumber);
-    
-    
+    public boolean rename( long orignalLogFileNumber, long newLongFileNumber );
+
     interface LogFileReader
     {
         /**
@@ -117,7 +119,7 @@ interface LogFileManager
          * @throws IOException
          */
         public int read( byte[] buffer, int offset, int length ) throws IOException, EOFException;
-        
+
 
         /**
          * Repositions the reader at the given offset
@@ -125,14 +127,15 @@ interface LogFileManager
          * @param position
          */
         public void seek( long position ) throws IOException;
-        
+
+
         /**
          * Close the log file reader and releases the resources 
          *
          */
         public void close() throws IOException;
-        
-        
+
+
         /**
          * Each log file is assigned a sequence number. This method
          * returns that number
@@ -140,18 +143,20 @@ interface LogFileManager
          * @return number assigned to this log file
          */
         public long logFileNumber();
-        
+
+
         /**
          * returns the length of the file
          */
         public long getLength() throws IOException;
-        
+
+
         /**
          * returns the offset of the next read
          */
         public long getOffset() throws IOException;
     }
-    
+
     interface LogFileWriter
     {
         /**
@@ -162,21 +167,22 @@ interface LogFileManager
          * @param length number of bytes to be appended
          */
         public void append( byte[] buffer, int offset, int length ) throws IOException;
-        
-        
-        
+
+
         /**
          * Sync the file contents to media  
          *
          */
         public void sync() throws IOException;
-        
+
+
         /**
          * Close the log file reader and releases the resources 
          *
          */
         public void close() throws IOException;
-        
+
+
         /**
          * Each log file is assigned a sequence number. This method
          * returns that number
@@ -184,12 +190,13 @@ interface LogFileManager
          * @return number assigned to this log file
          */
         public long logFileNumber();
-        
+
+
         /**
          * returns the length of the file
          */
         public long getLength() throws IOException;
 
     }
-    
+
 }
\ No newline at end of file

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/impl/LogFileRecords.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/impl/LogFileRecords.java?rev=1235334&r1=1235333&r2=1235334&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/impl/LogFileRecords.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/impl/LogFileRecords.java Tue Jan 24 16:27:18 2012
@@ -28,8 +28,8 @@ public class LogFileRecords
      * into the log. Header and footer information makes
      * it easier to scan the log, detect the end of 
      * log during log scan and verify the integrity of log.  
-     */  
-    
+     */
+
     /**
      * Record Header marker
      * int RECORD_HEADER_MAGIC_NUMBER
@@ -37,44 +37,44 @@ public class LogFileRecords
      * long recordLSN     lsn of the log record   
      * long headerChecksum checksum to verify header
      */
-    
+
     /** Header magic number */
     final static int RECORD_HEADER_MAGIC_NUMBER = 0x010F010F;
-     
+
     /** Total header size */
     final static int RECORD_HEADER_SIZE = 24;
-    
+
     /**
      * Record Footer marker 
      * int checksum 
      * int RECORD_FOOTER_MAGIC_NUMBER
      */
-    
+
     /** Footer magic number */
     final static int RECORD_FOOTER_MAGIC_NUMBER = 0x0F010F01;
-   
+
     /** Total header size */
     final static int RECORD_FOOTER_SIZE = 8;
-    
+
     /**
      * LogFileHeader marker
      * long log file number
      * int LOG_FILE_HEADER_MAGIC_NUMBER 0xFF00FF00
      */
-    
+
     /** Log file header marker size */
     final static int LOG_FILE_HEADER_SIZE = 12;
-    
+
     /** Log file header magic number */
     final static int LOG_FILE_HEADER_MAGIC_NUMBER = 0xFF00FF00;
-    
+
     /** Maximum marker size */
     final static int MAX_MARKER_SIZE;
-    
+
     static
     {
         int markerSize = Math.max( RECORD_HEADER_SIZE, RECORD_FOOTER_SIZE );
         MAX_MARKER_SIZE = Math.max( markerSize, LOG_FILE_HEADER_SIZE );
     }
-    
+
 }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/impl/LogFlushManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/impl/LogFlushManager.java?rev=1235334&r1=1235333&r2=1235334&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/impl/LogFlushManager.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/log/impl/LogFlushManager.java Tue Jan 24 16:27:18 2012
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.server.log.impl;
 
+
 import java.nio.ByteBuffer;
 
 import java.util.concurrent.locks.Lock;
@@ -26,7 +27,6 @@ import java.util.concurrent.locks.Reentr
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.atomic.AtomicInteger;
 
-
 import java.io.IOException;
 
 import org.apache.directory.server.i18n.I18n;
@@ -34,6 +34,7 @@ import org.apache.directory.server.log.I
 import org.apache.directory.server.log.LogAnchor;
 import org.apache.directory.server.log.UserLogRecord;
 
+
 /**
  * Manages the flushing of log to media and scanning of logs. All appends to the log file go through this class.
  *
@@ -45,28 +46,28 @@ import org.apache.directory.server.log.U
  */
 class LogFlushManager
 {
-    
+
     /** Ever increasing logical log sequence number assigned to user log records. Bumped up under append lock */
     private long logLSN = Long.MIN_VALUE + 1;
-       
+
     /** Memory buffer size in bytes */
     private final int logBufferSize;
-        
+
     /** Synchronizes appends */
     private final Lock appendLock = new ReentrantLock();
-    
+
     /** Synchronizes flushes to media */
     private final Lock flushLock = new ReentrantLock();
-    
+
     /** Used to wait on ongoing flush */
     private final Condition flushCondition = flushLock.newCondition();
-     
+
     /** In memory LogBuffer */
     private LogBuffer logBuffer;
-    
+
     /** Flush status */
     private FlushStatus flushStatus = new FlushStatus();
-       
+
     /** Current LogFile appends go to */
     private LogFileManager.LogFileWriter currentLogFile;
 
@@ -75,25 +76,27 @@ class LogFlushManager
 
     /** Size of data appended to the currentLogFile so far */
     long appendedSize;
-    
+
     /** Sof limit on the log file size */
     long targetLogFileSize;
-    
-    public LogFlushManager(LogManager logManager, int logMemoryBufferSize, long logFileSize )
+
+
+    public LogFlushManager( LogManager logManager, int logMemoryBufferSize, long logFileSize )
     {
         if ( ( logMemoryBufferSize < 0 ) || ( logFileSize < 0 ) )
         {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_748, logMemoryBufferSize, logFileSize ) );
         }
-        
+
         logBufferSize = logMemoryBufferSize;
         targetLogFileSize = logFileSize;
         this.logManager = logManager;
-        
+
         logBuffer = new LogBuffer( logBufferSize, currentLogFile );
-        
+
     }
-    
+
+
     /**
      * Appends the given user record to the log. Position where the record is appended is returned as part of
      * userRecord.
@@ -103,50 +106,50 @@ class LogFlushManager
      * @throws IOException
      * @throws InvalidLogException
      */
-    public void append(UserLogRecord userRecord, boolean sync ) throws IOException, InvalidLogException
+    public void append( UserLogRecord userRecord, boolean sync ) throws IOException, InvalidLogException
     {
         long lsn;
         boolean appendedRecord = false;
         byte[] userBuffer = userRecord.getDataBuffer();
-        int length  = userRecord.getDataLength();
+        int length = userRecord.getDataLength();
         LogAnchor userLogAnchor = userRecord.getLogAnchor();
-        
+
         int recordSize = LogFileRecords.RECORD_HEADER_SIZE + LogFileRecords.RECORD_FOOTER_SIZE + length;
-        
+
         appendLock.lock();
         try
         {
             lsn = logLSN++;
-            
+
             if ( currentLogFile == null )
             {
                 // We are just starting, get the current log file
                 currentLogFile = logManager.switchToNextLogFile( null );
                 appendedSize = currentLogFile.getLength();
             }
-            
+
             if ( appendedSize > this.targetLogFileSize )
             {
                 // Make sure everything outstanding goes to the current log file
-                this.flush( lsn, null, 0, 0, true);
-                
+                this.flush( lsn, null, 0, 0, true );
+
                 currentLogFile = logManager.switchToNextLogFile( currentLogFile );
                 appendedSize = currentLogFile.getLength();
             }
-            
+
             if ( recordSize <= logBufferSize )
             {
                 ByteBuffer writeHead = logBuffer.writeHead;
-                
+
                 while ( !appendedRecord )
                 {
                     // First get the rewind count then the position to which the readhead advanced
                     int readHeadRewindCount = logBuffer.readHeadRewindCount.get();
                     int readHeadPosition = logBuffer.readHeadPosition;
-                    
+
                     if ( ( logBuffer.writeHeadRewindCount == readHeadRewindCount ) ||
                         ( ( logBuffer.writeHeadRewindCount == readHeadRewindCount + 1 ) &&
-                            ( readHeadPosition < writeHead.position() ) ) )
+                        ( readHeadPosition < writeHead.position() ) ) )
                     {
                         if ( writeHead.remaining() >= recordSize )
                         {
@@ -155,14 +158,15 @@ class LogFlushManager
                             this.writeFooter( writeHead, 0 );
                             appendedRecord = true;
                         }
-                        else // ( writeHead.remaining() < recordSize )
+                        else
+                        // ( writeHead.remaining() < recordSize )
                         {
                             if ( writeHead.remaining() >= LogFileRecords.RECORD_HEADER_SIZE )
                             {
                                 // Write a skip record
                                 this.writeHeader( writeHead, -1, -1 );
                             }
-                            
+
                             // rewind buffer now
                             writeHead.rewind();
                             logBuffer.writeHeadRewindCount++;
@@ -170,10 +174,10 @@ class LogFlushManager
                     }
                     else
                     {
-                        assert( logBuffer.writeHeadRewindCount == ( readHeadRewindCount + 1 ) ) :
-                                "Unexpected sequence number for read/write heads:" + logBuffer.writeHeadRewindCount +
-                                " " + readHeadRewindCount;
-                        
+                        assert ( logBuffer.writeHeadRewindCount == ( readHeadRewindCount + 1 ) ) : "Unexpected sequence number for read/write heads:"
+                            + logBuffer.writeHeadRewindCount +
+                            " " + readHeadRewindCount;
+
                         if ( ( readHeadPosition - writeHead.position() ) > recordSize )
                         {
                             this.writeHeader( writeHead, length, lsn );
@@ -183,19 +187,17 @@ class LogFlushManager
                         }
                         else
                         {
-                            this.flush( lsn, null, 0, 0, true);
+                            this.flush( lsn, null, 0, 0, true );
                         }
                     }
                 }
-                
+
             }
             else
             {
                 this.flush( lsn, userBuffer, 0, length, true );
             }
-            
-            
-            
+
             userLogAnchor.resetLogAnchor( currentLogFile.logFileNumber(), appendedSize, lsn );
             this.appendedSize += recordSize;
         }
@@ -203,12 +205,13 @@ class LogFlushManager
         {
             appendLock.unlock();
         }
-        
+
         if ( sync )
             this.flush( lsn, null, 0, 0, false );
 
     }
-    
+
+
     /**
      * Flushes the changes in the log buffer upto the given point. The given point is determined as follows:
      * appendLock is held: flushLSN is the highest lsn generated by the logging system and no more appends can
@@ -236,28 +239,28 @@ class LogFlushManager
      * @throws IOException
      */
     private void flush( long flushLSN, byte[] userBuffer, int offset, int length,
-                        boolean appendLockHeld ) throws IOException
+        boolean appendLockHeld ) throws IOException
     {
         long uptoLSN = flushLSN;
-       
+
         if ( appendLockHeld == true )
         {
             uptoLSN--;
         }
-        
+
         flushLock.lock();
-        
+
         // Update max requested lsn if necessary
         if ( uptoLSN > flushStatus.uptoLSN )
         {
             flushStatus.uptoLSN = uptoLSN;
         }
-        
+
         /*
          * Check if we need to do flush and wait for ongoing flush if
          * necessary
          */
-        
+
         while ( true )
         {
             if ( ( flushStatus.flushedLSN >= uptoLSN ) && ( appendLockHeld == false ) )
@@ -265,20 +268,20 @@ class LogFlushManager
                 flushLock.unlock();
                 return;
             }
-            
+
             if ( flushStatus.flushInProgress == false )
             {
                 break;
             }
-            
+
             flushStatus.numWaiters++;
             flushCondition.awaitUninterruptibly();
             flushStatus.numWaiters--;
         }
-        
+
         // Mark flush in progress and do the flush
         flushStatus.flushInProgress = true;
-        
+
         // If not appendlock held, adjust uptoLSN with the max one requested by any thread
         if ( appendLockHeld == false )
         {
@@ -288,57 +291,58 @@ class LogFlushManager
         {
             uptoLSN = flushLSN;
         }
-        
+
         flushLock.unlock();
-        
+
         long flushedLSN = this.doFlush( uptoLSN, appendLockHeld );
-        
+
         // Now if there is a user buffer, flush from that
         if ( userBuffer != null )
         {
             ByteBuffer headerFooterHead = logBuffer.headerFooterHead;
-            
+
             headerFooterHead.rewind();
             this.writeHeader( headerFooterHead, length, flushLSN );
             currentLogFile.append( logBuffer.headerFooterBuffer, 0, LogFileRecords.RECORD_HEADER_MAGIC_NUMBER );
-            
+
             currentLogFile.append( userBuffer, offset, length );
-            
+
             headerFooterHead.rewind();
             this.writeFooter( headerFooterHead, 0 );
             currentLogFile.append( logBuffer.headerFooterBuffer, 0, LogFileRecords.RECORD_FOOTER_SIZE );
 
             flushedLSN = flushLSN;
         }
-        
+
         currentLogFile.sync();
-        
+
         flushLock.lock();
-        
+
         if ( flushedLSN != LogAnchor.UNKNOWN_LSN )
         {
             flushStatus.flushedLSN = flushedLSN;
-            
+
             if ( flushStatus.flushedLSN > flushStatus.uptoLSN )
             {
                 // This should only happen with append lock held
-                assert( appendLockHeld == true ) : "FlushedLSN went ahead of uptoLSN while appendlock is not held: " + flushStatus.flushedLSN + "  " + flushStatus.uptoLSN;
-                
+                assert ( appendLockHeld == true ) : "FlushedLSN went ahead of uptoLSN while appendlock is not held: "
+                    + flushStatus.flushedLSN + "  " + flushStatus.uptoLSN;
+
                 flushStatus.uptoLSN = flushStatus.flushedLSN;
             }
         }
-        
+
         flushStatus.flushInProgress = false;
-        
+
         if ( flushStatus.numWaiters != 0 )
         {
             flushCondition.signalAll();
         }
-        
+
         flushLock.unlock();
     }
-    
-    
+
+
     /**
      * Walks the log buffer and writes it to the underlying log file until the uptoLSN or current write head.
      *
@@ -347,20 +351,20 @@ class LogFlushManager
      * @return lsn upto which flush is done. UNKNOWN_LSN if no flushing is done.
      * @throws IOException
      */
-    private long doFlush( long uptoLSN, boolean appendLockHeld  ) throws IOException
+    private long doFlush( long uptoLSN, boolean appendLockHeld ) throws IOException
     {
         ByteBuffer readHead = logBuffer.readHead;
         ByteBuffer writeHead = logBuffer.writeHead;
         boolean done = false;
-        
+
         int magicNumber;
         int length;
         long lsn = LogAnchor.UNKNOWN_LSN;
-        
+
         while ( !done )
         {
             int totalLength = 0;
-            while( true )
+            while ( true )
             {
                 /*
                  * If append lock is held, we might hit write head. We can read
@@ -369,63 +373,62 @@ class LogFlushManager
                 if ( appendLockHeld )
                 {
                     if ( ( writeHead.position() == readHead.position() ) &&
-                            ( logBuffer.writeHeadRewindCount == logBuffer.readHeadRewindCount.get() ) )
+                        ( logBuffer.writeHeadRewindCount == logBuffer.readHeadRewindCount.get() ) )
                     {
                         done = true;
                         break;
                     }
                 }
-                
+
                 // If less than header length left to process, then break and flush whatever we got so far
                 if ( readHead.remaining() < LogFileRecords.RECORD_HEADER_SIZE )
                     break;
-                
+
                 magicNumber = readHead.getInt();
-                
-                assert( magicNumber == LogFileRecords.RECORD_HEADER_MAGIC_NUMBER ) : " Record header magic " +
-                        "number does not match " + magicNumber + " expected "+
-                        LogFileRecords.RECORD_HEADER_MAGIC_NUMBER;
-                
+
+                assert ( magicNumber == LogFileRecords.RECORD_HEADER_MAGIC_NUMBER ) : " Record header magic " +
+                    "number does not match " + magicNumber + " expected " +
+                    LogFileRecords.RECORD_HEADER_MAGIC_NUMBER;
+
                 length = readHead.getInt();
-                
+
                 // Did we hit a skip record at the end of the buffer?
                 if ( length == LogBuffer.SKIP_RECORD_LENGTH )
                     break;
-                
-                
+
                 // Sanitize length, it includes header and footer overhead
-                assert( length >  ( LogFileRecords.RECORD_HEADER_MAGIC_NUMBER + LogFileRecords.RECORD_FOOTER_MAGIC_NUMBER) ) :
-                    "Record length doesnt make sense:" + length + " expected:" +
-                    ( LogFileRecords.RECORD_HEADER_MAGIC_NUMBER + LogFileRecords.RECORD_FOOTER_MAGIC_NUMBER);
-                
+                assert ( length > ( LogFileRecords.RECORD_HEADER_MAGIC_NUMBER + LogFileRecords.RECORD_FOOTER_MAGIC_NUMBER ) ) : "Record length doesnt make sense:"
+                    + length + " expected:" +
+                    ( LogFileRecords.RECORD_HEADER_MAGIC_NUMBER + LogFileRecords.RECORD_FOOTER_MAGIC_NUMBER );
+
                 // Add to the total length
                 totalLength += length;
-                
+
                 lsn = readHead.getLong();
-                
+
                 // Move to the next record, we processed 16 bytes already
                 readHead.position( readHead.position() + length - 16 );
-                
+
                 if ( lsn >= uptoLSN )
                 {
                     done = true;
                     break;
                 }
-                    
+
             }
-            
+
             // If there is something to flush, then do it now
             if ( totalLength > 0 )
             {
                 int offset;
                 offset = logBuffer.readHeadPosition;
-                
+
                 currentLogFile.append( logBuffer.buffer, offset, totalLength );
-                       
+
                 //move the position to the next record
                 logBuffer.readHeadPosition = readHead.position();
             }
-            
+
             if ( !done )
             {
                 // this means we need to rewind and keep flushing
@@ -434,26 +437,27 @@ class LogFlushManager
                 logBuffer.readHeadRewindCount.incrementAndGet();
             }
         }
-        
+
         return lsn;
 
     }
-    
-    private void writeHeader ( ByteBuffer buffer, int length, long lsn )
+
+
+    private void writeHeader( ByteBuffer buffer, int length, long lsn )
     {
         buffer.putInt( LogFileRecords.RECORD_HEADER_MAGIC_NUMBER );
         buffer.putInt( length );
         buffer.putLong( lsn );
         buffer.putLong( length ^ lsn );
     }
-    
-    private void writeFooter ( ByteBuffer buffer, int checksum )
+
+
+    private void writeFooter( ByteBuffer buffer, int checksum )
     {
         buffer.putInt( checksum );
         buffer.putInt( LogFileRecords.RECORD_FOOTER_MAGIC_NUMBER );
     }
-    
-    
+
     /**
      * Used to group the memory buffer data together
      */
@@ -461,45 +465,46 @@ class LogFlushManager
     {
         /** In memory buffer */
         byte buffer[];
-                
+
         /** Used to scan the buffer while reading it to flush */
         ByteBuffer readHead;
-        
+
         /** Advanced as readHead flushes data */
         int readHeadPosition;
-        
+
         /** Rewind count of readHead..used to avoid overwriting nonflushed data */
         AtomicInteger readHeadRewindCount;
-        
+
         /** Used to scan the buffer while appending records into it */
         ByteBuffer writeHead;
-        
+
         /** Rewind count of writeHead..used to avoid overwriting nonflushed data */
         int writeHeadRewindCount;
-        
+
         /** Used to mark records that should be skipped at the end of the log buffer */
         final static int SKIP_RECORD_LENGTH = -1;
-        
+
         /** Header footer buffer used when writing user buffers directly */
         byte headerFooterBuffer[];
-        
+
         /** Used to format header footer buffer */
         ByteBuffer headerFooterHead;
-        
+
+
         public LogBuffer( int bufferSize, LogFileManager.LogFileWriter currentLogFile )
         {
             buffer = new byte[bufferSize];
             readHead = ByteBuffer.wrap( buffer );
-            
+
             readHeadRewindCount = new AtomicInteger( 0 );
-            
+
             writeHead = ByteBuffer.wrap( buffer );
-            
+
             headerFooterBuffer = new byte[LogFileRecords.MAX_MARKER_SIZE];
             headerFooterHead = ByteBuffer.wrap( headerFooterBuffer );
         }
     }
-    
+
     /**
      * Used to group the flush related data together
      */
@@ -507,15 +512,13 @@ class LogFlushManager
     {
         /** whether flush is going on */
         boolean flushInProgress;
-        
+
         /** Current flush request */
         long uptoLSN;
-        
-        
+
         /** Current flushed lsn */
         long flushedLSN;
-        
-        
+
         /** Keeps track of the number of waiters */
         int numWaiters;
     }



Mime
View raw message