You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2012/01/24 17:15:29 UTC

svn commit: r1235326 [5/28] - in /directory/apacheds/trunk: jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ jdbm-partition...

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ActionVersioning.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ActionVersioning.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ActionVersioning.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ActionVersioning.java Tue Jan 24 16:15:05 2012
@@ -19,6 +19,7 @@
  */
 package jdbm.helper;
 
+
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.concurrent.locks.Lock;
@@ -39,28 +40,28 @@ public class ActionVersioning
 {
     /** Current write version */
     private Version nextVersion;
-    
+
     /** Current read version reference */
     private AtomicReference<Version> readReference;
-    
+
     /** List to put versions on */
     private ExplicitList<Version> versions = new ExplicitList<Version>();
-    
+
     /** Lock to protect the list */
     private Lock listLock = new ReentrantLock();
-    
-    
+
+
     public ActionVersioning()
     {
         Version readVersion = new Version( 0 );
-        nextVersion = new Version( 1 ); 
+        nextVersion = new Version( 1 );
         readReference = new AtomicReference<Version>( readVersion );
 
         versions.addFirst( nextVersion.getVersionsLink() );
         versions.addFirst( readVersion.getVersionsLink() );
     }
-    
-    
+
+
     /**
      * Returns back the new version to be used with the read/write action.
      * Assume one read/write action at a time.
@@ -71,8 +72,8 @@ public class ActionVersioning
     {
         return nextVersion;
     }
-    
-    
+
+
     /**
      * Called when the read/write action completes. Advances the version of action subsystem 
      * and publishes a new version for the readers. Assume one read/write action at a time.
@@ -82,32 +83,32 @@ public class ActionVersioning
     public Version endWriteAction()
     {
         Version minVersion;
-        
+
         // Allocate the new nextVersion
         Version newNextVersion = new Version( nextVersion.getVersion() + 1 );
-        
+
         // Post the commited version as the new read version
         Version oldReadVersion = readReference.getAndSet( nextVersion );
-        
+
         // add the newnextversion to the versions list
         listLock.lock();
         versions.addLast( newNextVersion.getVersionsLink() );
-        
-        if ( ( oldReadVersion.getNumActions().get() == 0 ) && 
+
+        if ( ( oldReadVersion.getNumActions().get() == 0 ) &&
             oldReadVersion.getVersionsLink().isLinked() )
         {
             versions.remove( oldReadVersion.getVersionsLink() );
             oldReadVersion.getVersionsLink().uninit();
         }
-        
+
         minVersion = versions.begin().getElement();
         listLock.unlock();
-        
+
         nextVersion = newNextVersion;
         return minVersion;
     }
-    
-    
+
+
     /**
      * Returns a version that can be used by the read only action
      *
@@ -116,9 +117,9 @@ public class ActionVersioning
     public Version beginReadAction()
     {
         Version readVersion = readReference.get();
-        
+
         readVersion.getNumActions().incrementAndGet();
-        
+
         /*
          * If the write txn just finished and published
          * a new version to read, check if we can still
@@ -127,20 +128,20 @@ public class ActionVersioning
         if ( readVersion != readReference.get() )
         {
             listLock.lock();
-            
+
             if ( readVersion.getVersionsLink().isUnLinked() )
             {
                 readVersion = readReference.get();
                 readVersion.getNumActions().incrementAndGet();
             }
-            
+
             listLock.unlock();
         }
-        
+
         return readVersion;
     }
-    
-    
+
+
     /**
      * Called when the read action with the given action is ended.
      * Checks whether the minimum read version advanced
@@ -152,84 +153,83 @@ public class ActionVersioning
     public Version endReadAction( Version version )
     {
         long numActions = version.getNumActions().decrementAndGet();
-        
+
         if ( numActions < 0 )
         {
             throw new IllegalStateException( "NumActions zero when read action is ended : " + version );
         }
 
-        
         if ( ( numActions > 0 ) || ( version == readReference.get() ) )
         {
             // minimum read version did not change for sure
             return null;
         }
-        
+
         Version minVersion = null;
         listLock.lock();
-        
-        if ( ( version.getNumActions().get() == 0 ) && 
+
+        if ( ( version.getNumActions().get() == 0 ) &&
             version.getVersionsLink().isLinked() )
         {
             version.getVersionsLink().remove();
             version.getVersionsLink().uninit();
         }
-        
+
         minVersion = versions.begin().getElement();
         listLock.unlock();
-        
+
         return minVersion;
     }
-    
-    
+
     public static class Version
     {
         /** Represented version */
         private long version;
-        
+
         /** Used to put on versions chain */
         private ExplicitList.Link<Version> versionsLink;
-        
+
         /** Number of txns running with this version */
-        private  AtomicInteger numActions;
-        
-        
-        public Version ( long version )
+        private AtomicInteger numActions;
+
+
+        public Version( long version )
         {
             this.version = version;
-            
+
             versionsLink = new ExplicitList.Link<ActionVersioning.Version>( this );
-            
+
             numActions = new AtomicInteger( 0 );
         }
-        
-        
+
+
         private ExplicitList.Link<Version> getVersionsLink()
         {
             return versionsLink;
         }
-        
-        
+
+
         private AtomicInteger getNumActions()
         {
             return numActions;
         }
-        
-        
+
+
         public long getVersion()
         {
             return version;
         }
-        
+
+
         @Override
         public String toString()
         {
             StringBuilder sb = new StringBuilder();
-            sb.append( "Version: ");
+            sb.append( "Version: " );
             sb.append( "(vesion: " ).append( version );
             sb.append( ", numActions: " ).append( numActions );
             sb.append( ")\n" );
-            
+
             return sb.toString();
         }
     }

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ByteArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ByteArrayComparator.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ByteArrayComparator.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ByteArrayComparator.java Tue Jan 24 16:15:05 2012
@@ -46,11 +46,13 @@
 
 package jdbm.helper;
 
+
 import java.util.Comparator;
 import java.io.Serializable;
 
 import org.apache.directory.server.i18n.I18n;
 
+
 /**
  * Comparator for byte arrays.
  *
@@ -74,18 +76,20 @@ public final class ByteArrayComparator
      * @return a positive integer if obj1 > obj2, 0 if obj1 == obj2,
      *         and a negative integer if obj1 < obj2
      */
-     public int compare( byte[] obj1, byte[] obj2 )
-     {
-        if ( obj1 == null ) {
+    public int compare( byte[] obj1, byte[] 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 ) );
         }
 
         return compareByteArray( obj1, obj2 );
-     }
+    }
 
 
     /**
@@ -96,37 +100,55 @@ public final class ByteArrayComparator
         int len = Math.min( thisKey.length, otherKey.length );
 
         // compare the byte arrays
-        for ( int i=0; i<len; i++ ) {
-            if ( thisKey[i] >= 0 ) {
-                if ( otherKey[i] >= 0 ) {
+        for ( int i = 0; i < len; i++ )
+        {
+            if ( thisKey[i] >= 0 )
+            {
+                if ( otherKey[i] >= 0 )
+                {
                     // both positive
-                    if ( thisKey[i] < otherKey[i] ) {
+                    if ( thisKey[i] < otherKey[i] )
+                    {
                         return -1;
-                    } else if ( thisKey[i] > otherKey[i] ) {
+                    }
+                    else if ( thisKey[i] > otherKey[i] )
+                    {
                         return 1;
                     }
-                } else {
+                }
+                else
+                {
                     // otherKey is negative => greater (because MSB is 1)
                     return -1;
                 }
-            } else {
-                if ( otherKey[i] >= 0 ) {
+            }
+            else
+            {
+                if ( otherKey[i] >= 0 )
+                {
                     // thisKey is negative => greater (because MSB is 1)
                     return 1;
-                } else {
+                }
+                else
+                {
                     // both negative
-                    if ( thisKey[i] < otherKey[i] ) {
+                    if ( thisKey[i] < otherKey[i] )
+                    {
                         return -1;
-                    } else if ( thisKey[i] > otherKey[i] ) {
+                    }
+                    else if ( thisKey[i] > otherKey[i] )
+                    {
                         return 1;
                     }
                 }
             }
         }
-        if ( thisKey.length == otherKey.length) {
+        if ( thisKey.length == otherKey.length )
+        {
             return 0;
         }
-        if ( thisKey.length < otherKey.length ) {
+        if ( thisKey.length < otherKey.length )
+        {
             return -1;
         }
         return 1;

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ByteArraySerializer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ByteArraySerializer.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ByteArraySerializer.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ByteArraySerializer.java Tue Jan 24 16:15:05 2012
@@ -46,6 +46,7 @@
 
 package jdbm.helper;
 
+
 import java.io.IOException;
 
 
@@ -64,13 +65,12 @@ public final class ByteArraySerializer
      */
     final static long serialVersionUID = 1L;
 
-
     /**
      * Static instance.
      */
     public static final ByteArraySerializer INSTANCE = new ByteArraySerializer();
-    
-    
+
+
     /** 
      * Serialize the content of an object into a byte array.
      *
@@ -78,13 +78,13 @@ public final class ByteArraySerializer
      * @return a byte array representing the object's state
      *
      */
-    public byte[] serialize( Object obj ) 
+    public byte[] serialize( Object obj )
         throws IOException
     {
-        return (byte[]) obj;
+        return ( byte[] ) obj;
     }
 
-    
+
     /**
      * Deserialize the content of an object from a byte array.
      *
@@ -92,10 +92,10 @@ public final class ByteArraySerializer
      * @return deserialized object
      *
      */
-    public Object deserialize( byte[] serialized ) 
+    public Object deserialize( byte[] serialized )
         throws IOException
     {
         return serialized;
-    }    
+    }
 
 }

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/CacheEvictionException.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/CacheEvictionException.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/CacheEvictionException.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/CacheEvictionException.java Tue Jan 24 16:15:05 2012
@@ -47,6 +47,7 @@
 
 package jdbm.helper;
 
+
 /**
  *  Exception that occurs during eviction of an object in the cache.
  *
@@ -67,6 +68,7 @@ public class CacheEvictionException
         _nested = nested;
     }
 
+
     public Exception getNestedException()
     {
         return _nested;

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/CachePolicy.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/CachePolicy.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/CachePolicy.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/CachePolicy.java Tue Jan 24 16:15:05 2012
@@ -57,7 +57,7 @@ import java.util.Enumeration;
  * @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
  * @author <a href="mailto:dranatunga@users.sourceforge.net">Dilum Ranatunga</a>
  */
-public interface CachePolicy<K,V>
+public interface CachePolicy<K, V>
 {
     /**
      * Place an object in the cache. If the cache does not currently contain
@@ -128,7 +128,7 @@ public interface CachePolicy<K,V>
      */
     public void addListener( CachePolicyListener<V> listener ) throws IllegalArgumentException;
 
-    
+
     /**
      * Remove a listener from this cache policy. The listener is found
      * using object equality, not identity.

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/CachePolicyListener.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/CachePolicyListener.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/CachePolicyListener.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/CachePolicyListener.java Tue Jan 24 16:15:05 2012
@@ -47,6 +47,7 @@
 
 package jdbm.helper;
 
+
 /**
  * Callback interface between {@link CachePolicy} and a Cache implementation
  * to notify about cached object eviction.
@@ -59,7 +60,7 @@ package jdbm.helper;
  *
  * @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
  */
-public interface CachePolicyListener<T> 
+public interface CachePolicyListener<T>
 {
     /**
      * Notification that the cache this listener is attached to is evicting

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/DefaultSerializer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/DefaultSerializer.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/DefaultSerializer.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/DefaultSerializer.java Tue Jan 24 16:15:05 2012
@@ -59,8 +59,8 @@ public class DefaultSerializer implement
     private static final long serialVersionUID = -3818545055661017388L;
 
     public static final DefaultSerializer INSTANCE = new DefaultSerializer();
-    
-    
+
+
     /**
      * Construct a DefaultSerializer.
      */
@@ -69,34 +69,34 @@ public class DefaultSerializer implement
         // no op
     }
 
-    
+
     /**
      * Serialize the content of an object into a byte array.
      *
      * @param obj Object to serialize
      * @return a byte array representing the object's state
      */
-     public byte[] serialize( Object obj ) throws IOException
-     {
-         return Serialization.serialize( obj );
-     }
-        
-        
+    public byte[] serialize( Object obj ) throws IOException
+    {
+        return Serialization.serialize( obj );
+    }
+
+
     /**
      * De-serialize the content of an object from a byte array.
      *
      * @param serialized Byte array representation of the object
      * @return de-serialized object
      */
-     public Object deserialize( byte[] serialized ) throws IOException
-     {
-         try 
-         {
+    public Object deserialize( byte[] serialized ) throws IOException
+    {
+        try
+        {
             return Serialization.deserialize( serialized );
-         } 
-         catch ( ClassNotFoundException except ) 
-         {
+        }
+        catch ( ClassNotFoundException except )
+        {
             throw new WrappedRuntimeException( except );
-         }
-     }
+        }
+    }
 }

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/EntryIO.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/EntryIO.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/EntryIO.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/EntryIO.java Tue Jan 24 16:15:05 2012
@@ -19,8 +19,10 @@
  */
 package jdbm.helper;
 
+
 import java.io.IOException;
 
+
 /**
  * 
  * TODO EntryIO.
@@ -29,6 +31,8 @@ import java.io.IOException;
  */
 public interface EntryIO<K, V>
 {
-    public V read( K key, Serializer serializer) throws IOException;
+    public V read( K key, Serializer serializer ) throws IOException;
+
+
     public void write( K key, V value, Serializer serializer ) throws IOException;
 }
\ No newline at end of file

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ExplicitList.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ExplicitList.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ExplicitList.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ExplicitList.java Tue Jan 24 16:15:05 2012
@@ -34,7 +34,7 @@ public class ExplicitList<T>
     private Link<T> head = new Link<T>( null );
 
     private int listSize = 0;
-    
+
     public static class Link<V>
     {
         private V element;
@@ -79,7 +79,7 @@ public class ExplicitList<T>
             {
                 throw new IllegalStateException( "Trying to remove from list an unlinked link" );
             }
- 
+
             this.getPrev().setNext( this.getNext() );
             this.getNext().setPrev( this.getPrev() );
             this.reset();
@@ -92,7 +92,7 @@ public class ExplicitList<T>
             {
                 throw new IllegalStateException( "Trying to add to list already linked link: " + this );
             }
-            
+
             after.getNext().setPrev( this );
             this.setNext( after.getNext() );
             after.setNext( this );
@@ -106,7 +106,7 @@ public class ExplicitList<T>
             {
                 throw new IllegalStateException( "Trying to add to list already linked link: " + this );
             }
-  
+
             before.getPrev().setNext( this );
             this.setPrev( before.getPrev() );
             before.setPrev( this );
@@ -154,7 +154,7 @@ public class ExplicitList<T>
             {
                 throw new IllegalStateException( " Unitializing a still linked entry" + this );
             }
-   
+
             element = null;
         }
 
@@ -163,16 +163,17 @@ public class ExplicitList<T>
         {
             return this.element;
         }
-        
+
+
         @Override
         public String toString()
         {
             StringBuilder sb = new StringBuilder();
             sb.append( "Link: " ).append( this ).append( " " );
             sb.append( "(next: " ).append( next );
-            sb.append( ",prev: " ).append( prev ).append(")");            
+            sb.append( ",prev: " ).append( prev ).append( ")" );
             sb.append( "\n" );
-            
+
             return sb.toString();
         }
     }
@@ -214,12 +215,14 @@ public class ExplicitList<T>
     {
         return head;
     }
-    
+
+
     public int size()
     {
         return listSize;
     }
-    
+
+
     @Override
     public String toString()
     {
@@ -227,7 +230,7 @@ public class ExplicitList<T>
         sb.append( "List: " );
         sb.append( "(size: " ).append( listSize ).append( ")" );
         sb.append( "\n" );
-        
+
         return sb.toString();
     }
 

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/IntegerComparator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/IntegerComparator.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/IntegerComparator.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/IntegerComparator.java Tue Jan 24 16:15:05 2012
@@ -46,11 +46,13 @@
 
 package jdbm.helper;
 
+
 import java.io.Serializable;
 import java.util.Comparator;
 
 import org.apache.directory.server.i18n.I18n;
 
+
 /**
  * Comparator for Integer objects.
  *
@@ -76,15 +78,18 @@ public final class IntegerComparator
      */
     public int compare( Integer obj1, Integer obj2 )
     {
-        if ( obj1 == obj2 ) {
+        if ( obj1 == obj2 )
+        {
             return 0;
         }
 
-        if ( obj1 == null ) {
+        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 ) );
         }
 
@@ -92,14 +97,18 @@ public final class IntegerComparator
         // method is Java 1.2 only!
         int int1 = obj1.intValue();
         int int2 = obj2.intValue();
-        if ( int1 == int2 ) {
+        if ( int1 == int2 )
+        {
             return 0;
         }
 
-        if ( int1 < int2 ) {
-          return -1;
-        } else {
-          return 1;
+        if ( int1 < int2 )
+        {
+            return -1;
+        }
+        else
+        {
+            return 1;
         }
     }
 

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/IntegerSerializer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/IntegerSerializer.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/IntegerSerializer.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/IntegerSerializer.java Tue Jan 24 16:15:05 2012
@@ -46,8 +46,10 @@
 
 package jdbm.helper;
 
+
 import java.io.IOException;
 
+
 /**
  * Optimized serializer for integers.
  *
@@ -57,10 +59,9 @@ public class IntegerSerializer
     implements Serializer
 {
 
-    
     public static final IntegerSerializer INSTANCE = new IntegerSerializer();
-    
-    
+
+
     /**
      * Construct an IntegerSerializer.
      */
@@ -69,32 +70,32 @@ public class IntegerSerializer
         // no op
     }
 
-    
+
     /**
      * Serialize the content of an object into a byte array.
      *
      * @param obj Object to serialize
      * @return a byte array representing the object's state
      */
-     public byte[] serialize( Object obj )
+    public byte[] serialize( Object obj )
         throws IOException
-     {
-         Integer number = (Integer) obj;
-         return Conversion.convertToByteArray( number.intValue() );
-     }
-        
-        
+    {
+        Integer number = ( Integer ) obj;
+        return Conversion.convertToByteArray( number.intValue() );
+    }
+
+
     /**
      * Deserialize the content of an object from a byte array.
      *
      * @param serialized Byte array representation of the object
      * @return deserialized object
      */
-     public Object deserialize( byte[] serialized )
+    public Object deserialize( byte[] serialized )
         throws IOException
-     {
-         int number = Conversion.convertToInt( serialized );
-         return Integer.valueOf( number );
-     }
+    {
+        int number = Conversion.convertToInt( serialized );
+        return Integer.valueOf( number );
+    }
 
 }

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/IterationException.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/IterationException.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/IterationException.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/IterationException.java Tue Jan 24 16:15:05 2012
@@ -92,5 +92,3 @@ public class IterationException
     }
 
 }
-
-

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LRUCache.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LRUCache.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LRUCache.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LRUCache.java Tue Jan 24 16:15:05 2012
@@ -1,22 +1,22 @@
-    /*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *  
- *    http://www.apache.org/licenses/LICENSE-2.0
- *  
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License. 
- *  
- */
+/*
+*  Licensed to the Apache Software Foundation (ASF) under one
+*  or more contributor license agreements.  See the NOTICE file
+*  distributed with this work for additional information
+*  regarding copyright ownership.  The ASF licenses this file
+*  to you under the Apache License, Version 2.0 (the
+*  "License"); you may not use this file except in compliance
+*  with the License.  You may obtain a copy of the License at
+*  
+*    http://www.apache.org/licenses/LICENSE-2.0
+*  
+*  Unless required by applicable law or agreed to in writing,
+*  software distributed under the License is distributed on an
+*  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+*  KIND, either express or implied.  See the License for the
+*  specific language governing permissions and limitations
+*  under the License. 
+*  
+*/
 package jdbm.helper;
 
 
@@ -54,113 +54,114 @@ public class LRUCache<K, V>
 {
     /** A logger for this class */
     private static final Logger LOG = LoggerFactory.getLogger( LRUCache.class.getSimpleName() );
-       
+
     /** Array of hash buckets */
     private List<CacheEntry> buckets[];
-    
+
     /** Array of latches protecting buckets */
     private Lock latches[];
 
     /** Power of two number of buckets */
     private final int numBuckets;
-    
+
     /** Log of number of hash buckets each latch protects */
     private final static int LOG_BUCKET_PER_LATCH = 0;
-    
+
     /** Number of lrus */
     private final static int NUM_LRUS = 16;
-    
+
     /** Min number of entries */
     private final static int MIN_ENTRIES = 1 << 10;
-    
+
     /** Max sleep time(in ms) for writes in case of cache eviction failure */
     private final static long MAX_WRITE_SLEEP_TIME = 600000;
-    
+
     /** lru list */
     LRU lrus[];
-    
+
     /** Random number generator used for randomizing access to LRUS */
     Random lruRandomizer = new Random();
-    
+
     /** current number of cache entries */
     private AtomicInteger numEntries;
-    
+
     /** maximum number of entries */
     private final int maxEntries;
 
     /** Callback used to initialize entries not in cache */
     private final EntryIO<K, V> entryIO;
-   
+
     /** minimum version cache has to satisfy during reads */
     private long minReadVersion;
-    
+
     /** Stats to keep track of cache gets */
     private long cacheGets;
-    
+
     /** Stats to keep track of cache hits for cache gets */
     private long cacheMisses;
-    
+
     /** Stats to keep track of cache puts */
     private long cachePuts;
-    
+
     /** Stats to keep track of # of times writes sleep for free cache entry */
     private long cachePutSleeps;
-    
-    @SuppressWarnings("unchecked") 
+
+
+    @SuppressWarnings("unchecked")
     public LRUCache( EntryIO<K, V> entryIO, int cacheSize )
     {
         int idx;
-        this.entryIO =entryIO;
-        
+        this.entryIO = entryIO;
+
         if ( cacheSize < MIN_ENTRIES )
         {
             cacheSize = MIN_ENTRIES;
         }
-        
+
         maxEntries = cacheSize;
-        
+
         int numHashBuckets = MIN_ENTRIES;
-        
+
         while ( numHashBuckets < maxEntries )
         {
-            numHashBuckets  = numHashBuckets << 1;
+            numHashBuckets = numHashBuckets << 1;
         }
-        
-        if ( numHashBuckets >  maxEntries)
+
+        if ( numHashBuckets > maxEntries )
         {
             numBuckets = numHashBuckets >> 1;
         }
         else
         {
-            numBuckets  = numHashBuckets;
+            numBuckets = numHashBuckets;
+        }
+
+        buckets = ( List<CacheEntry>[] ) new LinkedList[numBuckets];
+
+        for ( idx = 0; idx < numBuckets; idx++ )
+        {
+            buckets[idx] = new LinkedList<CacheEntry>();
+        }
+
+        int numLatches = numBuckets >> LOG_BUCKET_PER_LATCH;
+        latches = new Lock[numLatches];
+
+        for ( idx = 0; idx < numLatches; idx++ )
+        {
+            latches[idx] = new ReentrantLock();
         }
-        
-       buckets = ( List<CacheEntry>[] )new LinkedList[numBuckets];
-       
-       for ( idx = 0; idx < numBuckets; idx++ ) 
-       {
-           buckets[idx] = new LinkedList<CacheEntry>(); 
-       }
-        
-       int numLatches = numBuckets >> LOG_BUCKET_PER_LATCH;
-       latches = new Lock[numLatches];
-       
-       for ( idx = 0; idx < numLatches; idx++ )
-       {
-           latches[idx] = new ReentrantLock(); 
-       }
-       
-       lrus = ( LRUCache.LRU[] ) new LRUCache.LRU[NUM_LRUS];
-       
-       for ( idx = 0; idx < NUM_LRUS; idx++ )
-       {
-           lrus[idx] = new LRU(); 
-       }
-       
-       numEntries = new AtomicInteger( 0 );
+
+        lrus = ( LRUCache.LRU[] ) new LRUCache.LRU[NUM_LRUS];
+
+        for ( idx = 0; idx < NUM_LRUS; idx++ )
+        {
+            lrus[idx] = new LRU();
+        }
+
+        numEntries = new AtomicInteger( 0 );
     }
-    
-    
+
+
     /**
      * Called as the minimum version that readers will use advances. This lets
      * cache get rid of the older versions of entries.
@@ -171,8 +172,8 @@ public class LRUCache<K, V>
     {
         minReadVersion = minVersion;
     }
-    
-    
+
+
     /**
      * Updates the entry identified with the key with the new value.
      *   
@@ -183,15 +184,15 @@ public class LRUCache<K, V>
      * @param neverReplace true if caller wants to always keep the entry in cache 
      * @throws IOException, CacheEvictionException
      */
-    public void put( K key, V value, long newVersion , Serializer serializer, 
+    public void put( K key, V value, long newVersion, Serializer serializer,
         boolean neverReplace ) throws IOException, CacheEvictionException
     {
-        int hashValue = hash(key);
+        int hashValue = hash( key );
         int hashIndex = ( hashValue & ( numBuckets - 1 ) );
         int latchIndex = ( hashIndex >> LOG_BUCKET_PER_LATCH );
-        long sleepInterval = 100; 
+        long sleepInterval = 100;
         long totalSleepTime = 0;
-        
+
         /*
          * Lock the hash bucket and find the current version of the entry: 
          * 1) If entry exists
@@ -205,29 +206,29 @@ public class LRUCache<K, V>
          * 
          * While reading or waiting, latch is released.
          */
-        
+
         this.cachePuts++;
-        
+
         while ( true )
         {
             latches[latchIndex].lock();
             boolean entryExists = false;
             boolean sleepForFreeEntry = false;
-            
+
             Iterator<CacheEntry> it = buckets[hashIndex].listIterator();
             CacheEntry entry = null;
-            
-            while (it.hasNext() )
+
+            while ( it.hasNext() )
             {
                 entry = it.next();
-                
+
                 if ( entry.getKey().equals( key ) )
                 {
                     entryExists = true;
                     break;
                 }
             }
-    
+
             try
             {
                 if ( entryExists )
@@ -235,17 +236,18 @@ public class LRUCache<K, V>
                     switch ( entry.getState() )
                     {
                         case ENTRY_READY: // should be the common case
-                            
+
                             if ( !entry.isCurrentVersion() )
                             {
                                 if ( entry.isNeverReplace() == true )
                                 {
-                                    throw new IllegalStateException( " Non current entry should not have neverReplace set " + entry );
+                                    throw new IllegalStateException(
+                                        " Non current entry should not have neverReplace set " + entry );
                                 }
-                                                            
+
                                 entry.setNeverReplace();
                                 CacheEntry newEntry = null;
-                                
+
                                 try
                                 {
                                     newEntry = this.findNewEntry( key, hashIndex >> LOG_BUCKET_PER_LATCH );
@@ -254,7 +256,7 @@ public class LRUCache<K, V>
                                 {
                                     entry.clearNeverReplace();
                                 }
-                                
+
                                 /*
                                  * Remove existing entry, chain as a snapshot
                                  * entry to the new entry and add newentry to the
@@ -266,37 +268,37 @@ public class LRUCache<K, V>
                                 entry = newEntry;
                                 this.doRead( entry, latches[latchIndex], serializer );
                             }
-                            
-                            this.putNewVersion( entry, key, value, newVersion, hashIndex, 
-                                latches[latchIndex], serializer, neverReplace );                       
+
+                            this.putNewVersion( entry, key, value, newVersion, hashIndex,
+                                latches[latchIndex], serializer, neverReplace );
                             break;
-                            
+
                         case ENTRY_READING:
                             // Somebody is reading our entry, wait until the read is done and then retry
                             this.doWaitForStateChange( entry, latches[latchIndex] );
-                            
+
                             if ( entry.getState() == EntryState.ENTRY_READY )
                             {
-                                this.putNewVersion( entry, key, value, newVersion, hashIndex, latches[latchIndex], 
+                                this.putNewVersion( entry, key, value, newVersion, hashIndex, latches[latchIndex],
                                     serializer, neverReplace );
                                 break;
                             }
-                            
+
                             LOG.warn( "Entry with key {} is at intial state after waiting for IO", entry.getKey() );
                             // FALLTHROUGH
-                            
+
                         case ENTRY_INITIAL:
                             LOG.warn( "Entry with key {} is at intial while trying to read from it", entry.getKey() );
                             this.doRead( entry, latches[latchIndex], serializer );
-                            this.putNewVersion( entry, key, value, newVersion, hashIndex, latches[latchIndex], 
+                            this.putNewVersion( entry, key, value, newVersion, hashIndex, latches[latchIndex],
                                 serializer, neverReplace );
                             break;
-                            
+
                         case ENTRY_WRITING:
                             // FALLTHROUGH
-                            
+
                         default:
-                            throw new IllegalStateException( "Unknown cache entry state: " + entry ) ;
+                            throw new IllegalStateException( "Unknown cache entry state: " + entry );
                     }
                 }
                 else
@@ -304,17 +306,17 @@ public class LRUCache<K, V>
                     entry = this.findNewEntry( key, latchIndex );
                     buckets[hashIndex].add( entry );
                     this.doRead( entry, latches[latchIndex], serializer );
-                    this.putNewVersion( entry, key, value, newVersion, hashIndex, latches[latchIndex], 
+                    this.putNewVersion( entry, key, value, newVersion, hashIndex, latches[latchIndex],
                         serializer, neverReplace );
-                }            
+                }
             }
             catch ( CacheEvictionException e )
             {
                 sleepForFreeEntry = totalSleepTime < this.MAX_WRITE_SLEEP_TIME;
-                
+
                 if ( sleepForFreeEntry == false )
                 {
-                    System.out.println(" NO cache entry for write " + totalSleepTime );
+                    System.out.println( " NO cache entry for write " + totalSleepTime );
                     throw e;
                 }
             }
@@ -322,7 +324,7 @@ public class LRUCache<K, V>
             {
                 latches[latchIndex].unlock();
             }
-            
+
             if ( sleepForFreeEntry )
             {
                 try
@@ -334,7 +336,7 @@ public class LRUCache<K, V>
                     // Restore interrupted stat
                     Thread.currentThread().interrupt();
                 }
-                
+
                 totalSleepTime += sleepInterval;
             }
             else
@@ -342,14 +344,13 @@ public class LRUCache<K, V>
                 break;
             }
         }
-        
+
         if ( totalSleepTime != 0 )
-        {  
+        {
             this.cachePutSleeps++;
         }
     }
-    
-    
+
 
     /**
      * Finds and returns the entry corresponding to the given key and version.
@@ -362,11 +363,11 @@ public class LRUCache<K, V>
      */
     public V get( K key, long version, Serializer serializer ) throws IOException
     {
-        int hashValue = hash(key);
+        int hashValue = hash( key );
         int hashIndex = ( hashValue & ( numBuckets - 1 ) );
         int latchIndex = ( hashIndex >> LOG_BUCKET_PER_LATCH );
         V value = null;
-        
+
         /*
          * 1) If entry exists
          *   1.1) if the version chain contains the desired version, then return it, otherwise read
@@ -379,19 +380,19 @@ public class LRUCache<K, V>
          * 
          * While reading or waiting, latch is released.
          */
-        
+
         this.cacheGets++;
-        
+
         latches[latchIndex].lock();
         boolean chainExists = false;
-        
+
         Iterator<CacheEntry> it = buckets[hashIndex].listIterator();
         CacheEntry entry = null;
-        
+
         while ( it.hasNext() )
         {
             entry = it.next();
-            
+
             if ( entry.getKey().equals( key ) )
             {
                 chainExists = true;
@@ -409,22 +410,23 @@ public class LRUCache<K, V>
                         if ( !entry.isCurrentVersion() )
                         {
                             value = this.searchChainForVersion( entry, version );
-                            
+
                             if ( value != null )
                             {
                                 break;
                             }
-                            
+
                             this.cacheMisses++;
-                            
+
                             if ( entry.isNeverReplace() == true )
                             {
-                                throw new IllegalStateException( "Non Current Entry has neverReplace set to true:" + entry );
+                                throw new IllegalStateException( "Non Current Entry has neverReplace set to true:"
+                                    + entry );
                             }
-                            
+
                             entry.setNeverReplace();
                             CacheEntry newEntry = null;
-                            
+
                             try
                             {
                                 newEntry = this.findNewEntry( key, hashIndex >> LOG_BUCKET_PER_LATCH );
@@ -433,7 +435,7 @@ public class LRUCache<K, V>
                             {
                                 entry.clearNeverReplace();
                             }
-    
+
                             /*
                              * Remove existing entry, chain as a snapshot
                              * entry to the new entry and add newentry to the
@@ -445,16 +447,16 @@ public class LRUCache<K, V>
                             entry = newEntry;
                             this.doRead( entry, latches[latchIndex], serializer );
                         }
-                        
+
                         // FALLTHROUGH
-                    case ENTRY_WRITING:    // being written entry is always at current version                        
+                    case ENTRY_WRITING: // being written entry is always at current version                        
                         value = this.searchChainForVersion( entry, version );
                         break;
-                        
+
                     case ENTRY_READING:
                         // Somebody is reading our entry, wait until the read is done and then retry
                         this.doWaitForStateChange( entry, latches[latchIndex] );
-                        
+
                         if ( entry.getState() == EntryState.ENTRY_READY )
                         {
                             value = this.searchChainForVersion( entry, version );
@@ -462,9 +464,9 @@ public class LRUCache<K, V>
                         }
                         LOG.warn( "Entry with key {} is at intial state after waiting for IO", entry.getKey() );
                         // FALLTHROUGH
-                        
+
                     case ENTRY_INITIAL:
-                        
+
                         LOG.warn( "Entry with key {} is at intial while trying to read from it", entry.getKey() );
                         this.cacheMisses++;
                         this.doRead( entry, latches[latchIndex], serializer );
@@ -484,7 +486,7 @@ public class LRUCache<K, V>
                 value = this.searchChainForVersion( entry, version );
             }
         }
-        catch ( CacheEvictionException e)
+        catch ( CacheEvictionException e )
         {
             /*
              * In this case read while holding the hash bucket lock. Entry
@@ -497,10 +499,11 @@ public class LRUCache<K, V>
         {
             latches[latchIndex].unlock();
         }
-        
+
         return value;
     }
-    
+
+
     @Override
     public String toString()
     {
@@ -513,10 +516,11 @@ public class LRUCache<K, V>
         sb.append( ",cachePuts:" ).append( this.cachePuts );
         sb.append( ",cachePutSleeps:" ).append( this.cachePutSleeps );
         sb.append( ")\n" );
-        
+
         return sb.toString();
     }
-     
+
+
     /**
      * Creates a new version of the given entry with the given new version.
      *
@@ -530,23 +534,23 @@ public class LRUCache<K, V>
      * @param neverReplace true if most recent version of entry should be kept in memory all the time
      * @throws IOException
      */
-    private void putNewVersion( CacheEntry entry, K key, V value, long newVersion, int hashIndex, 
+    private void putNewVersion( CacheEntry entry, K key, V value, long newVersion, int hashIndex,
         Lock latch, Serializer serializer, boolean neverReplace ) throws IOException, CacheEvictionException
     {
-        
-        if ( entry.getStartVersion() != newVersion  )
+
+        if ( entry.getStartVersion() != newVersion )
         {
-            
+
             boolean resetNeverReplace = true;
-            
+
             if ( entry.isNeverReplace() )
-            {  
+            {
                 resetNeverReplace = false;
             }
-            
+
             entry.setNeverReplace();
             CacheEntry newEntry = null;
-            
+
             try
             {
                 newEntry = this.findNewEntry( key, hashIndex >> LOG_BUCKET_PER_LATCH );
@@ -558,7 +562,7 @@ public class LRUCache<K, V>
                     entry.clearNeverReplace();
                 }
             }
-            
+
             // Set to new version 
             newEntry.setAsCurrentVersion( value, newVersion );
 
@@ -569,45 +573,44 @@ public class LRUCache<K, V>
              */
             buckets[hashIndex].remove( entry );
             entry.setAsSnapshotVersion( newVersion );
-            newEntry.getVersionsLink().splice( entry.getVersionsLink() );  // splices entry and its chain after the newEntry
+            newEntry.getVersionsLink().splice( entry.getVersionsLink() ); // splices entry and its chain after the newEntry
             buckets[hashIndex].add( newEntry );
             entry = newEntry;
         }
         else
         {
-            if  ( entry.isCurrentVersion() == false )
+            if ( entry.isCurrentVersion() == false )
             {
                 throw new IllegalStateException( "Entry not at expected version: " + entry );
             }
-            
+
             // Entry already at current version. Just update the value
             entry.setAsCurrentVersion( value, newVersion );
         }
-        
+
         if ( neverReplace )
         {
             entry.setNeverReplace();
         }
-        
+
         entry.setState( EntryState.ENTRY_WRITING );
         latch.unlock();
-        
+
         try
         {
             entryIO.write( key, value, serializer );
         }
-        catch( IOException e )
+        catch ( IOException e )
         {
             /*
              * Not much we can do here, just leave the entry in an
              * inconsistent state.
              */
             latch.lock();
-            
-            
+
             entry.setState( EntryState.ENTRY_INITIAL );
             entry.clearNeverReplace();
-            
+
             if ( entry.anyWaiters() )
             {
                 entry.getStateCondition( latch ).notifyAll();
@@ -619,17 +622,17 @@ public class LRUCache<K, V>
                 lru.moveToTail( entry );
                 lru.getLock().unlock();
             }
-            
+
             latch.unlock();
-            
+
             throw e;
         }
-        
+
         latch.lock();
         entry.setState( EntryState.ENTRY_READY );
     }
-    
-    
+
+
     /**
      * Searches the given version for the entry that can satisfy the read with the 
      * given version and returns the value of that entry. Cache is responsible is for
@@ -645,43 +648,43 @@ public class LRUCache<K, V>
         CacheEntry curEntry;
         boolean mustFind = true;
         long curStartVersion = 0;
-        
+
         V value = null;
-        
-        if ( head.getState() !=  EntryState.ENTRY_READY || !head.isCurrentVersion() )
+
+        if ( head.getState() != EntryState.ENTRY_READY || !head.isCurrentVersion() )
         {
             mustFind = false;
         }
-        
+
         do
         {
             curEntry = curLink.getElement();
-            
+
             if ( curEntry.getState() != EntryState.ENTRY_READY )
             {
                 if ( curEntry != head )
                 {
                     throw new IllegalStateException( "Unexpected state for entry: " + curEntry );
                 }
-    
+
                 curLink = curLink.getNext();
                 continue;
             }
-        
+
             if ( curStartVersion != 0 && ( curEntry.getEndVersion() > curStartVersion ) )
             {
-                throw new IllegalStateException( "Unexpected version number for entry. curStartVersion: " 
-                        + curStartVersion + " entry: " + curEntry );
+                throw new IllegalStateException( "Unexpected version number for entry. curStartVersion: "
+                    + curStartVersion + " entry: " + curEntry );
             }
-            
+
             curStartVersion = curEntry.getStartVersion();
-            
+
             if ( !curEntry.canReadFrom( version ) )
             {
                 curLink = curLink.getNext();
                 continue;
             }
-            
+
             // found it
             if ( curEntry.isCurrentVersion() )
             {
@@ -691,21 +694,22 @@ public class LRUCache<K, V>
                 lru.touch( curEntry );
                 lru.getLock().unlock();
             }
-            
+
             value = curEntry.getValue();
             break;
-            
-        } while ( curLink != head.getVersionsLink() );
-        
+
+        }
+        while ( curLink != head.getVersionsLink() );
+
         if ( value == null && mustFind == true )
         {
             throw new IllegalStateException( "Traversed all versions and could not find cache entry" );
         }
-        
+
         return value;
     }
-    
-    
+
+
     /**
      * Wait for the state change to happen. Usually used to wait for another 
      * thread to complete the IO.Latch covering the entry is held at the entry.
@@ -718,42 +722,43 @@ public class LRUCache<K, V>
         EntryState curState = entry.getState();
         Condition cond = entry.getStateCondition( latch );
         entry.bumpWaiters();
-        
+
         do
         {
             cond.awaitUninterruptibly();
-            
-        } while ( curState == entry.getState() );
-        
+
+        }
+        while ( curState == entry.getState() );
+
         entry.decrementWaiters();
     }
-    
-    
-   /**
-    * Does read the value for the given entry. At entry, latch is held. It is
-    * dropped during the read and regotten after a successful read. 
-    *
-    * @param entry entry for which we will do the read
-    * @param latch latch protecting the entry to which the bucket belongs
-    * @param serializer used in case of IO
-    * @throws IOException
-    */
+
+
+    /**
+     * Does read the value for the given entry. At entry, latch is held. It is
+     * dropped during the read and regotten after a successful read. 
+     *
+     * @param entry entry for which we will do the read
+     * @param latch latch protecting the entry to which the bucket belongs
+     * @param serializer used in case of IO
+     * @throws IOException
+     */
     private void doRead( CacheEntry entry, Lock latch, Serializer serializer ) throws IOException
     {
         V value = null;
         entry.setState( EntryState.ENTRY_READING );
         latch.unlock();
-        
+
         try
         {
-           value = entryIO.read( entry.getKey(), serializer ); 
+            value = entryIO.read( entry.getKey(), serializer );
         }
         catch ( IOException e )
         {
             // do cleanup and rethrow
             latch.lock();
             entry.setState( EntryState.ENTRY_INITIAL );
-            
+
             if ( entry.anyWaiters() )
             {
                 entry.getStateCondition( latch ).notifyAll();
@@ -765,18 +770,18 @@ public class LRUCache<K, V>
                 lru.moveToTail( entry );
                 lru.getLock().unlock();
             }
-            
+
             latch.unlock();
-            
+
             throw e;
         }
-        
+
         latch.lock();
-        
+
         // set the version range
         ExplicitList.Link<CacheEntry> nextLink = entry.getVersionsLink().getNext();
         long startVersion;
-        
+
         if ( entry.getVersionsLink().isUnLinked() )
         {
             startVersion = 0;
@@ -785,15 +790,16 @@ public class LRUCache<K, V>
         {
             startVersion = nextLink.getElement().getEndVersion();
         }
-        
+
         entry.setAsCurrentVersion( value, startVersion );
-        
+
         if ( entry.anyWaiters() )
         {
             entry.getStateCondition( latch ).signalAll();
         }
     }
-    
+
+
     /**
      * Finds a victim entry to be replaced by the given key. 
      * 
@@ -809,21 +815,21 @@ public class LRUCache<K, V>
         int index = lruRandomizer.nextInt( NUM_LRUS );
         int id, curIndex;
         boolean lruLocked = false;
-        
+
         // if under max entries, allocate a new one and add it to the lru with the index.. numEntries check is dirty
         if ( numEntries.get() < maxEntries )
         {
             numEntries.incrementAndGet();
-            CacheEntry newEntry  = new CacheEntry( index );
+            CacheEntry newEntry = new CacheEntry( index );
             lru = lrus[index];
             newEntry.initialize( key );
             lru.getLock().lock();
             lru.addToLRU( newEntry );
             lru.getLock().unlock();
-            
+
             return newEntry;
         }
-        
+
         /*
          * We start with a lru determined by the lru randomizer and try to lock the lru without waiting. 
          * If this doesnt work, we wait on the first lru lock. 
@@ -831,47 +837,45 @@ public class LRUCache<K, V>
         CacheEntry victimEntry = null;
         lru = null;
         curIndex = 0;
-        
+
         for ( id = 0; id < NUM_LRUS; id++ )
         {
             curIndex = ( index + id ) % NUM_LRUS;
             lru = lrus[curIndex];
-            
+
             if ( lru.getLock().tryLock() == true )
             {
                 lruLocked = true;
                 break;
             }
         }
-        
+
         if ( !lruLocked )
         {
             curIndex = index;
             lru = lrus[curIndex];
             lru.getLock().lock();
         }
-        
+
         victimEntry = lru.findVictim( latchIndex );
-        
-        
+
         if ( victimEntry != null )
-        { 
+        {
             victimEntry.initialize( key );
             lru.getLock().unlock();
         }
         else
         {
             lru.getLock().unlock();
-            
+
             LOG.warn( "Cache eviction failure: " + this.minReadVersion );
             throw new CacheEvictionException( null );
         }
-        
-        
+
         return victimEntry;
     }
-    
-   
+
+
     private int hash( K key )
     {
         int h = key.hashCode();
@@ -879,11 +883,10 @@ public class LRUCache<K, V>
         h ^= ( h >>> 14 );
         h += ( h << 4 );
         h ^= ( h >>> 10 );
-        
+
         return h;
     }
-    
-    
+
     private enum EntryState
     {
         ENTRY_INITIAL,
@@ -905,7 +908,7 @@ public class LRUCache<K, V>
 
         /** End of valid range. endVersion == Long.MAX_VALUE iff entry current version */
         private long endVersion;
-        
+
         /** hash index of the key */
         private int hashIndex;
 
@@ -920,23 +923,25 @@ public class LRUCache<K, V>
 
         /** Used to build a sorted chain of versions with the most current entry at the head */
         private ExplicitList.Link<CacheEntry> versionsLink;
-                
+
         /** Used to put on lru list */
         private ExplicitList.Link<CacheEntry> lruLink;
-        
+
         /** id of lru this cache entry lives on */
         int lruid;
-        
+
         /** true if entry should not be replaced */
         boolean neverReplace;
-        
-        public CacheEntry(int lruid)
+
+
+        public CacheEntry( int lruid )
         {
             versionsLink = new ExplicitList.Link<CacheEntry>( this );
             lruLink = new ExplicitList.Link<CacheEntry>( this );
-            this.lruid = lruid;        
+            this.lruid = lruid;
         }
 
+
         /**
          *  inits the fields..used after a cache entry is replaced 
          *
@@ -950,44 +955,46 @@ public class LRUCache<K, V>
             endVersion = Long.MAX_VALUE;
 
             stateCondition = null;
-            
+
             if ( numWaiters != 0 )
             {
                 throw new IllegalStateException( "Numwaiters is not zero when entry is newly initialized: " + this );
             }
-   
+
             state = EntryState.ENTRY_INITIAL;
 
             if ( versionsLink.isUnLinked() == false )
             {
                 throw new IllegalStateException( "Versions link is still linked when entry is initialized" );
             }
-           
-            
+
             hashIndex = hash( key ) & ( numBuckets - 1 );
-            
+
             if ( neverReplace == true )
             {
                 throw new IllegalStateException( "Neverreplace is true when entry is newly intialized:" + this );
             }
         }
 
+
         public void setNeverReplace()
         {
             neverReplace = true;
         }
-        
+
+
         public void clearNeverReplace()
         {
             neverReplace = false;
         }
-        
+
+
         public boolean isNeverReplace()
         {
             return neverReplace;
         }
-        
-        
+
+
         public K getKey()
         {
             return key;
@@ -998,20 +1005,20 @@ public class LRUCache<K, V>
         {
             return value;
         }
-        
-        
+
+
         public int getHashIndex()
         {
             return hashIndex;
         }
-        
+
 
         public LRU getLru()
         {
             return lrus[lruid];
         }
 
-        
+
         public Condition getStateCondition( Lock lock )
         {
             if ( stateCondition == null )
@@ -1035,7 +1042,7 @@ public class LRUCache<K, V>
             {
                 throw new IllegalStateException( "Unexpected num waiters for entry:" + this );
             }
-            
+
             numWaiters--;
         }
 
@@ -1044,20 +1051,20 @@ public class LRUCache<K, V>
         {
             return numWaiters > 0;
         }
-        
+
 
         public long getEndVersion()
         {
             return endVersion;
         }
-        
-        
+
+
         public long getStartVersion()
         {
             return startVersion;
         }
-        
-        
+
+
         /**
          * Check if entry is the most recent version for its key
          * 
@@ -1092,20 +1099,20 @@ public class LRUCache<K, V>
         {
             this.state = newState;
         }
-        
+
 
         public ExplicitList.Link<CacheEntry> getVersionsLink()
         {
             return versionsLink;
         }
-        
-        
+
+
         public ExplicitList.Link<CacheEntry> getLruLink()
         {
             return lruLink;
         }
-        
-        
+
+
         public void setAsCurrentVersion( V newValue, long startVersion )
         {
             this.startVersion = startVersion;
@@ -1113,8 +1120,8 @@ public class LRUCache<K, V>
             this.value = newValue;
             this.state = EntryState.ENTRY_READY;
         }
-        
-        
+
+
         public void setAsSnapshotVersion( long newEndVersion )
         {
             this.clearNeverReplace();
@@ -1124,53 +1131,54 @@ public class LRUCache<K, V>
             lru.addToSnapshots( this );
             lru.getLock().unlock();
         }
-        
-        
+
+
         public boolean isEntryFreeable()
         {
-            return ( this.state != EntryState.ENTRY_READING && this.numWaiters == 0 && 
-                this.state != EntryState.ENTRY_WRITING && !neverReplace);
+            return ( this.state != EntryState.ENTRY_READING && this.numWaiters == 0 &&
+                this.state != EntryState.ENTRY_WRITING && !neverReplace );
         }
-        
+
+
         @Override
         public String toString()
         {
             StringBuilder sb = new StringBuilder();
             sb.append( "Entry: " );
-            sb.append("(state: ").append( this.state );
-            sb.append(",numWaiters:").append( this.numWaiters );
-            sb.append(",startVersion:").append( this.startVersion );
-            sb.append(",endVersion:").append( this.endVersion );
-            sb.append(",key:").append( this.key );
-            sb.append(",value:").append( this.value ).append( ")" );
+            sb.append( "(state: " ).append( this.state );
+            sb.append( ",numWaiters:" ).append( this.numWaiters );
+            sb.append( ",startVersion:" ).append( this.startVersion );
+            sb.append( ",endVersion:" ).append( this.endVersion );
+            sb.append( ",key:" ).append( this.key );
+            sb.append( ",value:" ).append( this.value ).append( ")" );
             sb.append( "\n" );
-            
+
             return sb.toString();
-            
+
         }
     }
-    
-        
+
     private class LRU
     {
         /** List of entries representing most recent versions */
         private ExplicitList<CacheEntry> mostRecentVersions = new ExplicitList<CacheEntry>();
-        
+
         /** List of snapshot entries */
-        private ExplicitList<CacheEntry> snapshotVersions = new ExplicitList<CacheEntry>(); 
-        
+        private ExplicitList<CacheEntry> snapshotVersions = new ExplicitList<CacheEntry>();
+
         /** Lock protecting the list */
         private Lock lock = new ReentrantLock();
-        
+
         /** Number of snaphot versions created */
         private int numSnapshotsCreated;
-        
+
+
         public Lock getLock()
         {
             return lock;
         }
-        
-        
+
+
         /**
          * add the new entry to the head of the lru
          *
@@ -1180,8 +1188,8 @@ public class LRUCache<K, V>
         {
             mostRecentVersions.addFirst( entry.getLruLink() );
         }
-        
-        
+
+
         /**
          * Removes the entry from the lru list and Adds the entry to the list of snapshot entries.
          * Entry should a most recent entry. 
@@ -1192,11 +1200,11 @@ public class LRUCache<K, V>
         {
             mostRecentVersions.remove( entry.getLruLink() );
             snapshotVersions.addLast( entry.getLruLink() );
-            
+
             numSnapshotsCreated++;
         }
-        
-        
+
+
         /**
          * Moves the entry to the cold end of the lru. Entry should be a most
          * recent entry
@@ -1208,8 +1216,8 @@ public class LRUCache<K, V>
             mostRecentVersions.remove( entry.getLruLink() );
             mostRecentVersions.addFirst( entry.getLruLink() );
         }
-        
-        
+
+
         /**
          * Increases the hotness of the given entry
          *
@@ -1221,8 +1229,8 @@ public class LRUCache<K, V>
             mostRecentVersions.remove( entry.getLruLink() );
             mostRecentVersions.addLast( entry.getLruLink() );
         }
-        
-        
+
+
         /**
          * Finds a freeable entry from the lru.  Lru lock is held at entry and exit.
          *
@@ -1234,61 +1242,61 @@ public class LRUCache<K, V>
             CacheEntry victimEntry = null;
             int victimBucketIndex;
             int victimLatchIndex;
-            
+
             /*
              * If expired snapshot entries exist, they are preferred, otherwise an entry is
              * gotten from the tail of the lru.
              */
-            
+
             ExplicitList.Link<CacheEntry> curLink;
-              
+
             curLink = snapshotVersions.begin();
-            
+
             while ( curLink != snapshotVersions.end() )
             {
                 victimEntry = curLink.getElement();
-                
+
                 if ( victimEntry.getEndVersion() > minReadVersion )
                 {
                     break;
                 }
-                      
+
                 if ( victimEntry.getKey() == null )
                 {
                     throw new IllegalStateException( "Snapshot victimEntry doesnt have key set:" + victimEntry );
                 }
-                
+
                 if ( victimEntry.isNeverReplace() )
                 {
-                    curLink = curLink.getNext();    
+                    curLink = curLink.getNext();
                     continue;
                 }
-                
+
                 victimBucketIndex = victimEntry.getHashIndex();
-                victimLatchIndex = (victimBucketIndex >> LOG_BUCKET_PER_LATCH );
-                
+                victimLatchIndex = ( victimBucketIndex >> LOG_BUCKET_PER_LATCH );
+
                 if ( ( latchIndex != victimLatchIndex ) && ( latches[victimLatchIndex].tryLock() == false ) )
                 {
-                    curLink = curLink.getNext();    
+                    curLink = curLink.getNext();
                     continue;
                 }
-                
+
                 if ( victimEntry.isEntryFreeable() == false )
                 {
                     throw new IllegalStateException( "Snapshot victimEntry is not freeable:" + victimEntry );
                 }
-                
+
                 int hashChainIndex = buckets[victimEntry.getHashIndex()].indexOf( victimEntry );
-                
+
                 if ( hashChainIndex != -1 )
                 {
                     buckets[victimEntry.getHashIndex()].remove( hashChainIndex );
-                    
+
                     if ( victimEntry.getVersionsLink().isLinked() )
                     {
                         ExplicitList.Link<CacheEntry> nextLink = victimEntry.getVersionsLink().getNext();
                         victimEntry.getVersionsLink().remove();
-                        
+
                         CacheEntry newEntry = nextLink.getElement();
                         buckets[newEntry.getHashIndex()].add( newEntry );
                     }
@@ -1297,72 +1305,71 @@ public class LRUCache<K, V>
                 {
                     victimEntry.getVersionsLink().remove();
                 }
-                
+
                 if ( latchIndex != victimLatchIndex )
                 {
                     latches[victimLatchIndex].unlock();
                 }
-                
+
                 this.snapshotVersions.remove( victimEntry.getLruLink() );
                 this.mostRecentVersions.addLast( victimEntry.getLruLink() );
-                
+
                 return victimEntry;
             }
-            
+
             curLink = mostRecentVersions.begin();
-            
+
             while ( curLink != mostRecentVersions.end() )
             {
                 victimEntry = curLink.getElement();
-                
+
                 // Dirty check
                 if ( victimEntry.isEntryFreeable() == false )
                 {
                     curLink = curLink.getNext();
                     continue;
                 }
-                    
-                
+
                 victimBucketIndex = victimEntry.getHashIndex();
-                victimLatchIndex = (victimBucketIndex >> LOG_BUCKET_PER_LATCH );
-                
+                victimLatchIndex = ( victimBucketIndex >> LOG_BUCKET_PER_LATCH );
+
                 if ( latchIndex != victimLatchIndex && latches[victimLatchIndex].tryLock() == false )
                 {
                     curLink = curLink.getNext();
                     continue;
                 }
-                
+
                 if ( victimEntry.isEntryFreeable() == false )
                 {
                     if ( latchIndex != victimLatchIndex )
                     {
                         latches[victimLatchIndex].unlock();
                     }
-                    
+
                     curLink = curLink.getNext();
                     continue;
                 }
-                
+
                 buckets[victimEntry.getHashIndex()].remove( victimEntry );
-                
+
                 if ( victimEntry.getVersionsLink().isLinked() )
                 {
                     ExplicitList.Link<CacheEntry> nextLink = victimEntry.getVersionsLink().getNext();
                     victimEntry.getVersionsLink().remove();
-                    
+
                     CacheEntry newEntry = nextLink.getElement();
                     buckets[newEntry.getHashIndex()].add( newEntry );
                 }
-                
+
                 if ( latchIndex != victimLatchIndex )
                 {
                     latches[victimLatchIndex].unlock();
                 }
-                
+
                 this.touch( victimEntry );
                 return victimEntry;
             }
-            
+
             return null;
         }
     }

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LongComparator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LongComparator.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LongComparator.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LongComparator.java Tue Jan 24 16:15:05 2012
@@ -46,11 +46,13 @@
 
 package jdbm.helper;
 
+
 import java.io.Serializable;
 import java.util.Comparator;
 
 import org.apache.directory.server.i18n.I18n;
 
+
 /**
  * Comparator for java.lang.Long objects.
  *
@@ -74,26 +76,33 @@ public final class LongComparator
      * @return a positive integer if obj1 > obj2, 0 if obj1 == obj2,
      *         and a negative integer if obj1 < obj2
      */
-     public int compare( Long obj1, Long obj2 )
-     {
-        if ( obj1 == null ) {
+    public int compare( Long obj1, Long 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 ) );
         }
 
         long l1 = obj1.longValue();
         long l2 = obj2.longValue();
 
-        if ( l1 > l2 ) {
+        if ( l1 > l2 )
+        {
             return 1;
-        } else if ( l1 == l2 ) {
+        }
+        else if ( l1 == l2 )
+        {
             return 0;
-        } else {
+        }
+        else
+        {
             return -1;
         }
-     }
+    }
 
 }

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LongSerializer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LongSerializer.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LongSerializer.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/LongSerializer.java Tue Jan 24 16:15:05 2012
@@ -46,21 +46,22 @@
 
 package jdbm.helper;
 
+
 import java.io.IOException;
 
+
 /**
  * Optimized serializer for long integers.
  *
  * @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
  */
-public class LongSerializer 
+public class LongSerializer
     implements Serializer
 {
 
-    
     public static final LongSerializer INSTANCE = new LongSerializer();
-    
-    
+
+
     /**
      * Construct a LongSerializer.
      */
@@ -69,32 +70,32 @@ public class LongSerializer 
         // no op
     }
 
-    
+
     /**
      * Serialize the content of an object into a byte array.
      *
      * @param obj Object to serialize
      * @return a byte array representing the object's state
      */
-     public byte[] serialize( Object obj )
+    public byte[] serialize( Object obj )
         throws IOException
-     {
-         Long number = (Long) obj;
-         return Conversion.convertToByteArray( number.longValue() );
-     }
-        
-        
+    {
+        Long number = ( Long ) obj;
+        return Conversion.convertToByteArray( number.longValue() );
+    }
+
+
     /**
      * Deserialize the content of an object from a byte array.
      *
      * @param serialized Byte array representation of the object
      * @return deserialized object
      */
-     public Object deserialize( byte[] serialized )
+    public Object deserialize( byte[] serialized )
         throws IOException
-     {
-         long number = Conversion.convertToLong( serialized );
-         return Long.valueOf( number );
-     }
+    {
+        long number = Conversion.convertToLong( serialized );
+        return Long.valueOf( number );
+    }
 
 }

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/MRU.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/MRU.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/MRU.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/MRU.java Tue Jan 24 16:15:05 2012
@@ -102,7 +102,7 @@ public class MRU<K, V> implements CacheP
         {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_528 ) );
         }
-        
+
         this.max = max;
     }
 
@@ -113,7 +113,7 @@ public class MRU<K, V> implements CacheP
     public void put( K key, V value ) throws CacheEvictionException
     {
         CacheEntry entry = map.get( key );
-        
+
         if ( entry != null )
         {
             entry.setValue( value );
@@ -133,7 +133,7 @@ public class MRU<K, V> implements CacheP
             {
                 entry = new CacheEntry( key, value );
             }
-            
+
             addEntry( entry );
             map.put( entry.getKey(), entry );
         }
@@ -146,11 +146,11 @@ public class MRU<K, V> implements CacheP
     public V get( K key )
     {
         CacheEntry entry = map.get( key );
-        
+
         if ( entry != null )
         {
             touchEntry( entry );
-            return (V)entry.getValue();
+            return ( V ) entry.getValue();
         }
         else
         {
@@ -165,7 +165,7 @@ public class MRU<K, V> implements CacheP
     public void remove( K key )
     {
         CacheEntry entry = map.get( key );
-        
+
         if ( entry != null )
         {
             removeEntry( entry );
@@ -205,7 +205,7 @@ public class MRU<K, V> implements CacheP
         {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_539_BAD_BLOCK_ID ) );
         }
-        
+
         if ( !listeners.contains( listener ) )
         {
             listeners.add( listener );
@@ -252,7 +252,7 @@ public class MRU<K, V> implements CacheP
         if ( entry == first )
         {
             first = entry.getNext();
-            
+
             if ( first != null )
             {
                 first.setPrevious( null );
@@ -261,7 +261,7 @@ public class MRU<K, V> implements CacheP
         else if ( last == entry )
         {
             last = entry.getPrevious();
-            
+
             if ( last != null )
             {
                 last.setNext( null );
@@ -284,7 +284,7 @@ public class MRU<K, V> implements CacheP
         {
             return;
         }
-        
+
         removeEntry( entry );
         addEntry( entry );
     }
@@ -303,7 +303,7 @@ public class MRU<K, V> implements CacheP
         // eviction exception, then the internal data structure
         // remains untouched.
         CachePolicyListener listener;
-        
+
         for ( int i = 0; i < listeners.size(); i++ )
         {
             listener = listeners.get( i );
@@ -313,7 +313,7 @@ public class MRU<K, V> implements CacheP
         removeEntry( entry );
         map.remove( entry.getKey() );
         entry.setValue( null );
-        
+
         return entry;
     }
 
@@ -386,7 +386,6 @@ class CacheEntry
     }
 }
 
-
 /**
  * Enumeration wrapper to return actual user objects instead of
  * CacheEntries.
@@ -411,7 +410,7 @@ class MRUEnumeration<V> implements Enume
     public V nextElement()
     {
         CacheEntry entry = elements.next();
-        
-        return (V)entry.getValue();
+
+        return ( V ) entry.getValue();
     }
 }

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ObjectBAComparator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ObjectBAComparator.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ObjectBAComparator.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/ObjectBAComparator.java Tue Jan 24 16:15:05 2012
@@ -46,12 +46,14 @@
 
 package jdbm.helper;
 
+
 import java.io.IOException;
 import java.io.Serializable;
 import java.util.Comparator;
 
 import org.apache.directory.server.i18n.I18n;
 
+
 /**
  * Comparator for objects which have been serialized into byte arrays.
  * In effect, it wraps another Comparator which compares object and provides
@@ -68,7 +70,6 @@ public final class ObjectBAComparator
      */
     final static long serialVersionUID = 1L;
 
-
     /**
      * Wrapped comparator.
      */
@@ -82,7 +83,8 @@ public final class ObjectBAComparator
      */
     public ObjectBAComparator( Comparator comparator )
     {
-        if ( comparator == null ) {
+        if ( comparator == null )
+        {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_518 ) );
         }
 
@@ -97,27 +99,34 @@ public final class ObjectBAComparator
      * @param obj2 Second object
      * @return 1 if obj1 > obj2, 0 if obj1 == obj2, -1 if obj1 < obj2
      */
-     public int compare( Object obj1, Object obj2 )
-     {
-        if ( obj1 == null ) {
+    public int compare( Object obj1, Object 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 ) );
         }
 
-        try {
-            obj1 = Serialization.deserialize( (byte[]) obj1 );
-            obj2 = Serialization.deserialize( (byte[]) obj2 );
+        try
+        {
+            obj1 = Serialization.deserialize( ( byte[] ) obj1 );
+            obj2 = Serialization.deserialize( ( byte[] ) obj2 );
 
             return _comparator.compare( obj1, obj2 );
-        } catch ( IOException except ) {
+        }
+        catch ( IOException except )
+        {
             throw new WrappedRuntimeException( except );
-        } catch ( ClassNotFoundException except ) {
+        }
+        catch ( ClassNotFoundException except )
+        {
             throw new WrappedRuntimeException( except );
         }
-     }
+    }
 
 
     /**
@@ -128,37 +137,55 @@ public final class ObjectBAComparator
         int len = Math.min( thisKey.length, otherKey.length );
 
         // compare the byte arrays
-        for ( int i=0; i<len; i++ ) {
-            if ( thisKey[i] >= 0 ) {
-                if ( otherKey[i] >= 0 ) {
+        for ( int i = 0; i < len; i++ )
+        {
+            if ( thisKey[i] >= 0 )
+            {
+                if ( otherKey[i] >= 0 )
+                {
                     // both positive
-                    if ( thisKey[i] < otherKey[i] ) {
+                    if ( thisKey[i] < otherKey[i] )
+                    {
                         return -1;
-                    } else if ( thisKey[i] > otherKey[i] ) {
+                    }
+                    else if ( thisKey[i] > otherKey[i] )
+                    {
                         return 1;
                     }
-                } else {
+                }
+                else
+                {
                     // otherKey is negative => greater (because MSB is 1)
                     return -1;
                 }
-            } else {
-                if ( otherKey[i] >= 0 ) {
+            }
+            else
+            {
+                if ( otherKey[i] >= 0 )
+                {
                     // thisKey is negative => greater (because MSB is 1)
                     return 1;
-                } else {
+                }
+                else
+                {
                     // both negative
-                    if ( thisKey[i] < otherKey[i] ) {
+                    if ( thisKey[i] < otherKey[i] )
+                    {
                         return -1;
-                    } else if ( thisKey[i] > otherKey[i] ) {
+                    }
+                    else if ( thisKey[i] > otherKey[i] )
+                    {
                         return 1;
                     }
                 }
             }
         }
-        if ( thisKey.length == otherKey.length) {
+        if ( thisKey.length == otherKey.length )
+        {
             return 0;
         }
-        if ( thisKey.length < otherKey.length ) {
+        if ( thisKey.length < otherKey.length )
+        {
             return -1;
         }
         return 1;

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/Serialization.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/Serialization.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/Serialization.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/Serialization.java Tue Jan 24 16:15:05 2012
@@ -46,12 +46,14 @@
 
 package jdbm.helper;
 
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
+
 /**
  * Serialization-related utility methods.
  *
@@ -66,8 +68,8 @@ public final class Serialization
     public static byte[] serialize( Object obj )
         throws IOException
     {
-        ByteArrayOutputStream  baos;
-        ObjectOutputStream     oos;
+        ByteArrayOutputStream baos;
+        ObjectOutputStream oos;
 
         baos = new ByteArrayOutputStream();
         oos = new ObjectOutputStream( baos );
@@ -75,7 +77,7 @@ public final class Serialization
         oos.close();
 
         byte[] res = baos.toByteArray();
-        
+
         return res;
     }
 
@@ -86,8 +88,8 @@ public final class Serialization
     public static Object deserialize( byte[] buf )
         throws ClassNotFoundException, IOException
     {
-        ByteArrayInputStream  bais;
-        ObjectInputStream     ois;
+        ByteArrayInputStream bais;
+        ObjectInputStream ois;
 
         bais = new ByteArrayInputStream( buf );
         ois = new ObjectInputStream( bais );

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/Serializer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/Serializer.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/Serializer.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/Serializer.java Tue Jan 24 16:15:05 2012
@@ -46,9 +46,11 @@
 
 package jdbm.helper;
 
+
 import java.io.IOException;
 import java.io.Serializable;
 
+
 /**
  * Interface used to provide a serialization mechanism other than a class' normal
  * serialization.
@@ -63,14 +65,14 @@ public interface Serializer extends Seri
      * @param obj Object to serialize
      * @return a byte array representing the object's state
      */
-     public byte[] serialize( Object obj ) throws IOException;
-        
-        
+    public byte[] serialize( Object obj ) throws IOException;
+
+
     /**
      * Deserialize the content of an object from a byte array.
      *
      * @param serialized Byte array representation of the object
      * @return deserialized object
      */
-     public Object deserialize( byte[] serialized ) throws IOException;
+    public Object deserialize( byte[] serialized ) throws IOException;
 }

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/SoftCache.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/SoftCache.java?rev=1235326&r1=1235325&r2=1235326&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/SoftCache.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/SoftCache.java Tue Jan 24 16:15:05 2012
@@ -137,7 +137,7 @@ public class SoftCache implements CacheP
         {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_531 ) );
         }
-        
+
         this.internal = internal;
         map = new HashMap( INITIAL_CAPACITY, loadFactor );
     }
@@ -162,7 +162,7 @@ public class SoftCache implements CacheP
         {
             throw new IllegalArgumentException( I18n.err( I18n.ERR_533 ) );
         }
-        
+
         internal.put( key, value );
         removeClearedEntries();
         map.put( key, new Entry( key, value, clearQueue ) );
@@ -193,28 +193,28 @@ public class SoftCache implements CacheP
     {
         // first try the internal cache.
         Object value = internal.get( key );
-        
+
         if ( value != null )
         {
             return value;
         }
-        
+
         // poll and remove cleared references.
         removeClearedEntries();
         Entry entry = ( Entry ) map.get( key );
-        
+
         if ( entry == null )
         { // object is not in cache.
             return null;
         }
-        
+
         value = entry.getValue();
-        
+
         if ( value == null )
         { // object was in cache, but it was cleared.
             return null;
         }
-        
+
         // we have the object. so we try to re-insert it into internal cache
         try
         {
@@ -226,7 +226,7 @@ public class SoftCache implements CacheP
             map.remove( key );
             return null;
         }
-        
+
         return value;
     }