directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1540963 - in /directory/apacheds/trunk: core-annotations/src/main/java/org/apache/directory/server/core/factory/ jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ mavibot-partition/src/main/java/org/a...
Date Tue, 12 Nov 2013 07:50:27 GMT
Author: elecharny
Date: Tue Nov 12 07:50:27 2013
New Revision: 1540963

URL: http://svn.apache.org/r1540963
Log:
o Injected the CacheService into the partitions created by annotation
o Injected the real cache size set by annotation into mavibot partitions (the default value
of 500 was used instead)
o Added an Alias cache in all partitions
o Used this alias cache in SubtreeScopeEvaluator and DefaultSearchEngine

Modified:
    directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
    directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/MavibotPartitionFactory.java
    directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
    directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotPartition.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/main/java/org/apache/directory/server/xdbm/Store.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/SubtreeScopeEvaluator.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java

Modified: directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java?rev=1540963&r1=1540962&r2=1540963&view=diff
==============================================================================
--- directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
(original)
+++ directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
Tue Nov 12 07:50:27 2013
@@ -211,6 +211,8 @@ public class DSAnnotationProcessor
                     createPartition.suffix(),
                     createPartition.cacheSize(),
                     new File( service.getInstanceLayout().getPartitionsDirectory(), createPartition.name()
) );
+                
+                partition.setCacheService( service.getCacheService() );
 
                 CreateIndex[] indexes = createPartition.indexes();
 

Modified: directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/MavibotPartitionFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/MavibotPartitionFactory.java?rev=1540963&r1=1540962&r2=1540963&view=diff
==============================================================================
--- directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/MavibotPartitionFactory.java
(original)
+++ directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/MavibotPartitionFactory.java
Tue Nov 12 07:50:27 2013
@@ -51,7 +51,7 @@ public class MavibotPartitionFactory imp
         MavibotPartition partition = new MavibotPartition( schemaManager, dnFactory );
         partition.setId( id );
         partition.setSuffixDn( new Dn( suffix ) );
-        partition.setCacheSize( 500 );
+        partition.setCacheSize( cacheSize );
         partition.setPartitionPath( workingDirectory.toURI() );
 
         return partition;

Modified: directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java?rev=1540963&r1=1540962&r2=1540963&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
(original)
+++ directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
Tue Nov 12 07:50:27 2013
@@ -268,6 +268,7 @@ public class JdbmPartition extends Abstr
             if ( cacheService != null )
             {
                 entryCache = cacheService.getCache( getId() );
+                aliasCache = cacheService.getCache( "alias" );
             }
 
             // We are done !

Modified: directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotPartition.java?rev=1540963&r1=1540962&r2=1540963&view=diff
==============================================================================
--- directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotPartition.java
(original)
+++ directory/apacheds/trunk/mavibot-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotPartition.java
Tue Nov 12 07:50:27 2013
@@ -209,6 +209,7 @@ public class MavibotPartition extends Ab
             if ( cacheService != null )
             {
                 entryCache = cacheService.getCache( getId() );
+                aliasCache = cacheService.getCache( "alias" );
             }
 
             // We are done !

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=1540963&r1=1540962&r2=1540963&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
Tue Nov 12 07:50:27 2013
@@ -33,6 +33,9 @@ import java.util.concurrent.atomic.Atomi
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
+import net.sf.ehcache.Cache;
+import net.sf.ehcache.Element;
+
 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;
@@ -117,6 +120,9 @@ public abstract class AbstractBTreeParti
     /** The Entry cache size for this partition */
     protected int cacheSize = -1;
 
+    /** The alias cache */
+    protected Cache aliasCache;
+
     /** true if we sync disks on every write operation */
     protected AtomicBoolean isSyncOnWrite = new AtomicBoolean( true );
 
@@ -179,7 +185,6 @@ public abstract class AbstractBTreeParti
     /** A lock to protect the backend from concurrent reads/writes */
     private ReadWriteLock rwLock;
 
-
     // ------------------------------------------------------------------------
     // C O N S T R U C T O R S
     // ------------------------------------------------------------------------
@@ -2696,6 +2701,11 @@ public abstract class AbstractBTreeParti
 
         // Add the alias to the simple alias index
         aliasIdx.add( aliasTarget, aliasId );
+        
+        if ( aliasCache != null )
+        {
+            aliasCache.put( new Element( aliasId, aliasTarget ) );
+        } 
 
         /*
          * Handle One Level Scope Alias Index
@@ -2789,6 +2799,11 @@ public abstract class AbstractBTreeParti
 
         // Drops all alias tuples pointing to the id of the alias to be deleted
         aliasIdx.drop( aliasId );
+        
+        if ( aliasCache != null )
+        {
+            aliasCache.remove( aliasId );
+        }
     }
 
 
@@ -3057,4 +3072,13 @@ public abstract class AbstractBTreeParti
     {
         return rwLock;
     }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public Cache getAliasCache()
+    {
+        return aliasCache;
+    }
 }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java?rev=1540963&r1=1540962&r2=1540963&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
Tue Nov 12 07:50:27 2013
@@ -28,6 +28,8 @@ import java.util.Iterator;
 import java.util.Set;
 import java.util.concurrent.locks.ReadWriteLock;
 
+import net.sf.ehcache.Cache;
+
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.entry.Entry;
 import org.apache.directory.api.ldap.model.entry.Modification;
@@ -434,4 +436,11 @@ public interface Store
      * @return The ReadWrite lock used to protect the server against concurrent read and
writes
      */
     ReadWriteLock getReadWriteLock();
+    
+    
+    /**
+     * @return the Alias cache
+     * @return
+     */
+    Cache getAliasCache();
 }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/SubtreeScopeEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/SubtreeScopeEvaluator.java?rev=1540963&r1=1540962&r2=1540963&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/SubtreeScopeEvaluator.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/evaluator/SubtreeScopeEvaluator.java
Tue Nov 12 07:50:27 2013
@@ -201,7 +201,8 @@ public class SubtreeScopeEvaluator imple
          * candidate id is an alias, if so we reject it since aliases should
          * not be returned.
          */
-        if ( null != db.getAliasIndex().reverseLookup( id ) )
+//        if ( null != db.getAliasIndex().reverseLookup( id ) )
+        if ( ( ( db.getAliasCache() != null ) && ( db.getAliasCache().get( id ) !=
null ) ) || ( null != db.getAliasIndex().reverseLookup( id ) ) )
         {
             return false;
         }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java?rev=1540963&r1=1540962&r2=1540963&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
Tue Nov 12 07:50:27 2013
@@ -23,6 +23,8 @@ package org.apache.directory.server.xdbm
 import java.util.HashSet;
 import java.util.Set;
 
+import net.sf.ehcache.Element;
+
 import org.apache.directory.api.ldap.model.cursor.Cursor;
 import org.apache.directory.api.ldap.model.entry.Entry;
 import org.apache.directory.api.ldap.model.exception.LdapNoSuchObjectException;
@@ -144,7 +146,30 @@ public class DefaultSearchEngine impleme
         // --------------------------------------------------------------------
         // Determine the effective base with aliases
         // --------------------------------------------------------------------
-        Dn aliasedBase = db.getAliasIndex().reverseLookup( baseId );
+//        Dn aliasedBase = db.getAliasIndex().reverseLookup( baseId );
+        Element element = null;
+        
+        if ( db.getAliasCache() != null )
+        {
+            element = db.getAliasCache().get( baseId );
+        }
+        
+        Dn aliasedBase = null;
+        
+        if ( element != null )
+        {
+            aliasedBase = (Dn)element.getObjectValue();
+        }
+        else
+        {
+            aliasedBase = db.getAliasIndex().reverseLookup( baseId );
+            
+            if ( db.getAliasCache() != null )
+            {
+                db.getAliasCache().put( new Element( baseId, aliasedBase ) );
+            }
+        }
+        
         Dn effectiveBase = baseDn;
         String effectiveBaseId = baseId;
 



Mime
View raw message