directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1555870 - in /directory/apacheds/trunk: jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/ xdbm-partition/...
Date Mon, 06 Jan 2014 15:44:17 GMT
Author: kayyagari
Date: Mon Jan  6 15:44:16 2014
New Revision: 1555870

URL: http://svn.apache.org/r1555870
Log:
o added a cache for holding <entryUUID, Dn> pairs
o fixed an issue with the wrong ancestor Dn calculation, updated tests

Modified:
    directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
    directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
    directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java

Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=1555870&r1=1555869&r2=1555870&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
(original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
Mon Jan  6 15:44:16 2014
@@ -668,9 +668,9 @@ public class JdbmStoreTest
 
         Dn newDn = parentDn.add( childDn.getRdn() );
 
-        store.move( childDn, parentDn, newDn, childEntry );
+        store.move( childDn, parentDn, newDn, null );
 
-        assertEquals( 4, store.getSubAliasIndex().count() );
+        assertEquals( 3, store.getSubAliasIndex().count() );
     }
 
 

Modified: directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java?rev=1555870&r1=1555869&r2=1555870&view=diff
==============================================================================
--- directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java
(original)
+++ directory/apacheds/trunk/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java
Mon Jan  6 15:44:16 2014
@@ -678,9 +678,9 @@ public class MavibotStoreTest
 
         Dn newDn = parentDn.add( childDn.getRdn() );
 
-        store.move( childDn, parentDn, newDn, childEntry );
+        store.move( childDn, parentDn, newDn, null );
 
-        assertEquals( 4, store.getSubAliasIndex().count() );
+        assertEquals( 3, store.getSubAliasIndex().count() );
     }
 
 

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=1555870&r1=1555869&r2=1555870&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
Mon Jan  6 15:44:16 2014
@@ -36,6 +36,7 @@ import java.util.concurrent.locks.Reentr
 import net.sf.ehcache.Cache;
 import net.sf.ehcache.Element;
 
+import org.apache.commons.collections.map.LRUMap;
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.cursor.Cursor;
 import org.apache.directory.api.ldap.model.entry.Attribute;
@@ -188,6 +189,9 @@ public abstract class AbstractBTreeParti
     /** A lock to protect the backend from concurrent reads/writes */
     private ReadWriteLock rwLock;
 
+    /** a cache to hold <entryUUID, Dn> pairs, this is used for speeding up the buildEntryDn()
method */
+    private LRUMap entryDnCache = new LRUMap( 10000 );
+    
     // ------------------------------------------------------------------------
     // C O N S T R U C T O R S
     // ------------------------------------------------------------------------
@@ -489,6 +493,8 @@ public abstract class AbstractBTreeParti
         // don't reset initialized flag
         initialized = false;
 
+        entryDnCache.clear();
+        
         MultiException errors = new MultiException( I18n.err( I18n.ERR_577 ) );
 
         for ( Index<?, String> index : userIndices.values() )
@@ -1058,6 +1064,8 @@ public abstract class AbstractBTreeParti
 
                 dumpRdnIdx();
 
+                entryDnCache.remove( id );
+                
                 master.remove( id );
             }
             finally
@@ -1827,6 +1835,8 @@ public abstract class AbstractBTreeParti
         // Remove the EntryDN
         modifiedEntry.removeAttributes( ENTRY_DN_AT );
 
+        entryDnCache.clear();
+        
         master.put( entryId, modifiedEntry );
 
         if ( isSyncOnWrite.get() )
@@ -1928,6 +1938,8 @@ public abstract class AbstractBTreeParti
         rename( oldId, newRdn, deleteOldRdn, modifiedEntry );
         moveAndRename( oldDn, oldId, newSuperiorDn, newRdn, modifiedEntry );
 
+        entryDnCache.clear();
+        
         if ( isSyncOnWrite.get() )
         {
             sync();
@@ -2182,6 +2194,8 @@ public abstract class AbstractBTreeParti
 
         rdnIdx.add( parentIdAndRdn, oldId );
 
+        entryDnCache.clear();
+        
         if ( isSyncOnWrite.get() )
         {
             sync();
@@ -2262,10 +2276,19 @@ public abstract class AbstractBTreeParti
         Rdn[] rdnArray = new Rdn[10];
         int pos = 0;
 
+        Dn dn = null;
+        
         try
         {
             rwLock.readLock().lock();
 
+            dn = ( Dn ) entryDnCache.get( id );
+            
+            if ( dn != null )
+            {
+                return dn;
+            }
+            
             do
             {
                 ParentIdAndRdn cur = null;
@@ -2318,15 +2341,16 @@ public abstract class AbstractBTreeParti
                 parentId = cur.getParentId();
             }
             while ( !parentId.equals( rootId ) );
+            
+            dn = new Dn( schemaManager, Arrays.copyOf( rdnArray, pos ) );
+            
+            entryDnCache.put( id, dn );
+            return dn;
         }
         finally
         {
             rwLock.readLock().unlock();
         }
-
-        Dn dn = new Dn( schemaManager, Arrays.copyOf( rdnArray, pos ) );
-
-        return dn;
     }
 
 
@@ -2928,7 +2952,7 @@ public abstract class AbstractBTreeParti
              * Start droping index tuples with the first ancestor right above the
              * moved base.  This is the first ancestor effected by the move.
              */
-            Dn ancestorDn = new Dn( schemaManager, movedBase.getRdn( movedBase.size() - 1
) );
+            Dn ancestorDn = movedBase.getParent();
             String ancestorId = getEntryId( ancestorDn );
 
             /*
@@ -2952,7 +2976,7 @@ public abstract class AbstractBTreeParti
 
             while ( !ancestorDn.equals( suffixDn ) )
             {
-                ancestorDn = new Dn( schemaManager, ancestorDn.getRdn( ancestorDn.size()
- 1 ) );
+                ancestorDn = ancestorDn.getParent();
                 ancestorId = getEntryId( ancestorDn );
 
                 subAliasIdx.drop( ancestorId, targetId );

Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java?rev=1555870&r1=1555869&r2=1555870&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java
Mon Jan  6 15:44:16 2014
@@ -501,9 +501,9 @@ public class AvlPartitionTest
         assertEquals( 3, partition.getSubAliasIndex().count() );
 
         Dn newDn = parentDn.add( childDn.getRdn() );
-        partition.move( childDn, parentDn, newDn, childEntry );
+        partition.move( childDn, parentDn, newDn, null );
 
-        assertEquals( 4, partition.getSubAliasIndex().count() );
+        assertEquals( 3, partition.getSubAliasIndex().count() );
     }
 
 



Mime
View raw message