directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r996504 - in /directory/apacheds/trunk: core-api/src/main/java/org/apache/directory/server/core/ core-api/src/test/java/org/apache/directory/server/core/ core/src/main/java/org/apache/directory/server/core/ server-integ/src/test/java/org/ap...
Date Mon, 13 Sep 2010 11:39:45 GMT
Author: elecharny
Date: Mon Sep 13 11:39:45 2010
New Revision: 996504

URL: http://svn.apache.org/viewvc?rev=996504&view=rev
Log:
o Moved the AdminPoint cache up to the DirectoryService class
o Added some tests to check that the cache is correctly created when the server is started
after having been stopped (ie the AP are reloaded into the cache)

Modified:
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/DirectoryService.java
    directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/MockDirectoryService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointPersistentIT.java

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/DirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/DirectoryService.java?rev=996504&r1=996503&r2=996504&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/DirectoryService.java
(original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/DirectoryService.java
Mon Sep 13 11:39:45 2010
@@ -24,6 +24,7 @@ import java.io.File;
 import java.util.List;
 import java.util.Set;
 
+import org.apache.directory.server.core.administrative.AdministrativePoint;
 import org.apache.directory.server.core.changelog.ChangeLog;
 import org.apache.directory.server.core.entry.ServerEntryFactory;
 import org.apache.directory.server.core.event.EventService;
@@ -40,6 +41,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.util.tree.DnNode;
 
 
 /**
@@ -522,4 +524,10 @@ public interface DirectoryService extend
      * @return the cache service
      */
     CacheService getCacheService();
+    
+
+    /**
+     * @return The AdministrativePoint cache
+     */
+    DnNode<List<AdministrativePoint>> getAdministrativePoints();
 }

Modified: directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/MockDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/MockDirectoryService.java?rev=996504&r1=996503&r2=996504&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/MockDirectoryService.java
(original)
+++ directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/MockDirectoryService.java
Mon Sep 13 11:39:45 2010
@@ -27,6 +27,7 @@ import java.util.Set;
 
 import javax.naming.ldap.LdapContext;
 
+import org.apache.directory.server.core.administrative.AdministrativePoint;
 import org.apache.directory.server.core.changelog.ChangeLog;
 import org.apache.directory.server.core.event.EventService;
 import org.apache.directory.server.core.interceptor.Interceptor;
@@ -42,6 +43,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.util.tree.DnNode;
 
 
 public class MockDirectoryService implements DirectoryService
@@ -442,54 +444,51 @@ public class MockDirectoryService implem
     
     public void setReplicaId( int replicaId )
     {
-        
     }
 
     public void setJournal( Journal journal )
     {
-        
     }
 
     public void setReplicationConfiguration( ReplicationConfiguration replicationConfig )
     {
-        // TODO Auto-generated method stub
-        
     }
 
     public ReplicationConfiguration getReplicationConfiguration()
     {
-        // TODO Auto-generated method stub
         return null;
     }
 
     public String getContextCsn()
     {
-        // TODO Auto-generated method stub
         return null;
     }
 
     public long getSyncPeriodMillis()
     {
-        // TODO Auto-generated method stub
         return 0;
     }
 
     public void setContextCsn( String lastCommittedCsnVal )
     {
-        // TODO Auto-generated method stub
-        
     }
 
     public void setSyncPeriodMillis( long syncPeriodMillis )
     {
-        // TODO Auto-generated method stub
-        
     }
 
 
     public CacheService getCacheService()
     {
-        // TODO Auto-generated method stub
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public DnNode<List<AdministrativePoint>> getAdministrativePoints()
+    {
         return null;
     }
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=996504&r1=996503&r2=996504&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
Mon Sep 13 11:39:45 2010
@@ -39,6 +39,7 @@ import javax.naming.directory.Attributes
 
 import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.admin.AdministrativePointInterceptor;
+import org.apache.directory.server.core.administrative.AdministrativePoint;
 import org.apache.directory.server.core.authn.AuthenticationInterceptor;
 import org.apache.directory.server.core.authz.AciAuthorizationInterceptor;
 import org.apache.directory.server.core.authz.DefaultAuthorizationInterceptor;
@@ -98,6 +99,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.schema.SchemaManager;
 import org.apache.directory.shared.ldap.util.DateUtils;
 import org.apache.directory.shared.ldap.util.StringTools;
+import org.apache.directory.shared.ldap.util.tree.DnNode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -243,6 +245,9 @@ public class DefaultDirectoryService imp
     /** the ehcache based cache service */
     private CacheService cacheService;
 
+    /** The AdministrativePoint cache */
+    private DnNode<List<AdministrativePoint>> adminPointCache;
+
     /**
      * The synchronizer thread. It flush data on disk periodically.
      */
@@ -1423,6 +1428,9 @@ public class DefaultDirectoryService imp
         cacheService = new CacheService();
         cacheService.initialize( this );
 
+        // Initialize the AP cache
+        adminPointCache = new DnNode<List<AdministrativePoint>>();
+
         DNFactory.initialize( this );
 
         // triggers partition to load schema fully from schema partition
@@ -1783,4 +1791,12 @@ public class DefaultDirectoryService imp
         return cacheService;
     }
 
-}
+
+    /**
+     * @return The AdministrativePoint cache
+     */
+    public DnNode<List<AdministrativePoint>> getAdministrativePoints()
+    {
+        return adminPointCache;
+    }
+}
\ No newline at end of file

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointPersistentIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointPersistentIT.java?rev=996504&r1=996503&r2=996504&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointPersistentIT.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/admin/AdministrativePointPersistentIT.java
Mon Sep 13 11:39:45 2010
@@ -25,15 +25,21 @@ import static org.junit.Assert.assertFal
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import java.util.List;
+
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.core.administrative.AdministrativePoint;
 import org.apache.directory.server.core.annotations.ApplyLdifs;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.server.core.integ.IntegrationUtils;
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.name.DN;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.util.tree.DnNode;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -122,10 +128,14 @@ public class AdministrativePointPersiste
     // The shared LDAP connection
     private static LdapConnection connection;
 
+    // A reference to the schema manager
+    private static SchemaManager schemaManager;
+
     @Before
     public void init() throws Exception
     {
         connection = IntegrationUtils.getAdminConnection( service );
+        schemaManager = ldapServer.getDirectoryService().getSchemaManager();
     }
 
 
@@ -150,11 +160,10 @@ public class AdministrativePointPersiste
     // Test the Add operation
     // -------------------------------------------------------------------
     /**
-     * Test the addition of an autonomous area
-     * @throws Exception
+     * Test the persistence of autonomous areas across a server stop and start
      */
     @Test
-    public void testAddAutonomousArea() throws Exception
+    public void testPersistAutonomousArea() throws Exception
     {
         assertTrue( ldapServer.isStarted() );
 
@@ -169,6 +178,8 @@ public class AdministrativePointPersiste
         // And restart
         ldapServer.getDirectoryService().startup();
         ldapServer.start();
+        schemaManager = ldapServer.getDirectoryService().getSchemaManager();
+
         assertTrue( service.isStarted() );
         assertTrue( ldapServer.getDirectoryService().isStarted() );
         
@@ -176,5 +187,18 @@ public class AdministrativePointPersiste
         assertEquals( "autonomousArea", getAdminRole( "ou=AAP1,ou=noAP1,ou=system" ).getString()
);
         assertEquals( "autonomousArea", getAdminRole( "ou=AAP2,ou=system" ).getString() );
         assertEquals( "autonomousArea", getAdminRole( "ou=subAAP1,ou=noAP3,ou=AAP2,ou=system"
).getString() );
+
+        // Check the cache
+        DnNode<List<AdministrativePoint>> cache = ldapServer.getDirectoryService().getAdministrativePoints();
+
+        List<AdministrativePoint> aap1 = cache.getElement( new DN( "ou=AAP1,ou=noAP1,ou=system",
schemaManager ) );
+        assertNotNull( aap1 );
+
+        List<AdministrativePoint> aap2 = cache.getElement( new DN( "ou=AAP2,ou=system",
schemaManager ) );
+        assertNotNull( aap2 );
+
+        List<AdministrativePoint> subAap1 = cache.getElement( new DN( "ou=subAAP1,ou=noAP3,ou=AAP2,ou=system",
+            schemaManager ) );
+        assertNotNull( subAap1 );
     }
 }



Mime
View raw message