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 2010/06/05 14:46:33 UTC

svn commit: r951702 - in /directory/apacheds/trunk: core-integ/src/test/java/org/apache/directory/server/core/operations/getRootDse/ core-integ/src/test/java/org/apache/directory/server/core/operations/hasEntry/ core/src/main/java/org/apache/directory/...

Author: elecharny
Date: Sat Jun  5 12:46:32 2010
New Revision: 951702

URL: http://svn.apache.org/viewvc?rev=951702&view=rev
Log:
o Added a perf test for the hasEntry method
o Added a isRootDSE() method in the DN class
o Minor cleanup 

Added:
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/hasEntry/
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/hasEntry/hasEntryPerfIT.java
Modified:
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/getRootDse/GetRootDsePerfIT.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/getRootDse/GetRootDsePerfIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/getRootDse/GetRootDsePerfIT.java?rev=951702&r1=951701&r2=951702&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/getRootDse/GetRootDsePerfIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/getRootDse/GetRootDsePerfIT.java Sat Jun  5 12:46:32 2010
@@ -21,10 +21,8 @@ package org.apache.directory.server.core
 
 import static org.junit.Assert.assertNotNull;
 
-import org.apache.directory.ldap.client.api.LdapConnection;
 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.server.core.interceptor.context.GetRootDSEOperationContext;
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.junit.Test;
@@ -46,8 +44,6 @@ public class GetRootDsePerfIT extends Ab
     @Test
     public void testPerfGetRootDSE() throws Exception
     {
-        LdapConnection connection = IntegrationUtils.getAdminConnection( service );
-
         GetRootDSEOperationContext opContext = new GetRootDSEOperationContext( service.getAdminSession() );
         Entry rootDSE = service.getOperationManager().getRootDSE( opContext );
 
@@ -68,6 +64,5 @@ public class GetRootDsePerfIT extends Ab
         long t1 = System.currentTimeMillis();
         
         System.out.println( "Delta : " + ( t1 - t0 ) );
-        connection.close();
     }
 }

Added: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/hasEntry/hasEntryPerfIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/hasEntry/hasEntryPerfIT.java?rev=951702&view=auto
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/hasEntry/hasEntryPerfIT.java (added)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/hasEntry/hasEntryPerfIT.java Sat Jun  5 12:46:32 2010
@@ -0,0 +1,69 @@
+/*
+ *  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 org.apache.directory.server.core.operations.hasEntry;
+
+import static org.junit.Assert.assertTrue;
+
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.server.core.interceptor.context.EntryOperationContext;
+import org.apache.directory.shared.ldap.name.DN;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Test the hasEntry operation
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+@RunWith ( FrameworkRunner.class )
+public class hasEntryPerfIT extends AbstractLdapTestUnit
+{
+    /**
+     * A hasEntry performance test
+     */
+    @Test
+    public void testPerfHasEntry() throws Exception
+    {
+        DN adminDn = new DN( "uid=admin, ou=system" );
+        EntryOperationContext opContext = new EntryOperationContext( service.getAdminSession(), adminDn );
+        boolean hasEntry = service.getOperationManager().hasEntry( opContext );
+
+        assertTrue( hasEntry );
+        
+        long t0 = System.currentTimeMillis();
+        
+        for ( int i = 0; i < 100; i++ )
+        {
+            for ( int j = 0; j < 5000; j++ )
+            {
+                hasEntry = service.getOperationManager().hasEntry( opContext );
+            }
+            
+            System.out.print( "." );
+        }
+        
+        long t1 = System.currentTimeMillis();
+        
+        System.out.println( "Delta : " + ( t1 - t0 ) );
+    }
+}

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java?rev=951702&r1=951701&r2=951702&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java Sat Jun  5 12:46:32 2010
@@ -663,17 +663,17 @@ public class AciAuthorizationInterceptor
 
     public boolean hasEntry( NextInterceptor next, EntryOperationContext entryContext ) throws LdapException
     {
-        DN name = entryContext.getDn();
+        DN dn = entryContext.getDn();
 
         if ( !entryContext.getSession().getDirectoryService().isAccessControlEnabled() )
         {
-            return name.size() == 0 || next.hasEntry( entryContext );
+            return ( dn.isRootDSE() || next.hasEntry( entryContext ) );
         }
 
         boolean answer = next.hasEntry( entryContext );
 
         // no checks on the RootDSE
-        if ( name.size() == 0 )
+        if ( dn.isRootDSE() )
         {
             // No need to go down to the stack, if the dn is empty 
             // It's the rootDSE, and it exists ! 
@@ -683,21 +683,22 @@ public class AciAuthorizationInterceptor
         // TODO - eventually replace this with a check on session.isAnAdministrator()
         LdapPrincipal principal = entryContext.getSession().getEffectivePrincipal();
         DN principalDn = principal.getDN();
+        
         if ( isPrincipalAnAdministrator( principalDn ) )
         {
             return answer;
         }
 
-        Entry entry = entryContext.lookup( name, ByPassConstants.HAS_ENTRY_BYPASS );
+        Entry entry = entryContext.lookup( dn, ByPassConstants.HAS_ENTRY_BYPASS );
         Set<DN> userGroups = groupCache.getGroups( principalDn.getNormName() );
         Collection<ACITuple> tuples = new HashSet<ACITuple>();
-        addPerscriptiveAciTuples( entryContext, tuples, name, ( ( ClonedServerEntry ) entry ).getOriginalEntry() );
+        addPerscriptiveAciTuples( entryContext, tuples, dn, ( ( ClonedServerEntry ) entry ).getOriginalEntry() );
         addEntryAciTuples( tuples, ( ( ClonedServerEntry ) entry ).getOriginalEntry() );
-        addSubentryAciTuples( entryContext, tuples, name, ( ( ClonedServerEntry ) entry ).getOriginalEntry() );
+        addSubentryAciTuples( entryContext, tuples, dn, ( ( ClonedServerEntry ) entry ).getOriginalEntry() );
 
         // check that we have browse access to the entry
         engine.checkPermission( schemaManager, entryContext, userGroups, principalDn, principal
-            .getAuthenticationLevel(), name, null, null, BROWSE_PERMS, tuples, ( ( ClonedServerEntry ) entry )
+            .getAuthenticationLevel(), dn, null, null, BROWSE_PERMS, tuples, ( ( ClonedServerEntry ) entry )
             .getOriginalEntry(), null );
 
         return next.hasEntry( entryContext );

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java?rev=951702&r1=951701&r2=951702&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java Sat Jun  5 12:46:32 2010
@@ -625,7 +625,7 @@ public class DefaultPartitionNexus exten
             LOG.debug( "Check if DN '" + dn + "' exists." );
         }
 
-        if ( dn.size() == 0 )
+        if ( dn.isRootDSE() )
         {
             return true;
         }