Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 807B9C5CE for ; Mon, 30 Apr 2012 15:59:56 +0000 (UTC) Received: (qmail 3847 invoked by uid 500); 30 Apr 2012 15:59:56 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 3787 invoked by uid 500); 30 Apr 2012 15:59:56 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 3780 invoked by uid 99); 30 Apr 2012 15:59:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Apr 2012 15:59:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Apr 2012 15:59:51 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2773C23889FD for ; Mon, 30 Apr 2012 15:59:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1332268 [2/5] - in /directory/apacheds/trunk: ./ all/ core-annotations/ core-annotations/src/main/java/org/apache/directory/server/core/factory/ core-api/ core-api/src/main/java/org/apache/directory/server/core/api/changelog/ core-api/src/... Date: Mon, 30 Apr 2012 15:59:27 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120430155931.2773C23889FD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchWithIndexTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchWithIndexTest.java?rev=1332268&view=auto ============================================================================== --- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchWithIndexTest.java (added) +++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/search/SearchWithIndexTest.java Mon Apr 30 15:59:22 2012 @@ -0,0 +1,218 @@ +package org.apache.directory.shared.client.api.operations.search; + +import org.apache.directory.ldap.client.api.LdapNetworkConnection; +import org.apache.directory.server.annotations.CreateLdapServer; +import org.apache.directory.server.annotations.CreateTransport; +import org.apache.directory.server.core.annotations.ContextEntry; +import org.apache.directory.server.core.annotations.CreateDS; +import org.apache.directory.server.core.annotations.CreateIndex; +import org.apache.directory.server.core.annotations.CreatePartition; +import org.apache.directory.server.core.integ.AbstractLdapTestUnit; +import org.apache.directory.server.core.integ.FrameworkRunner; +import org.apache.directory.shared.client.api.LdapApiIntegrationUtils; +import org.apache.directory.shared.ldap.model.cursor.EntryCursor; +import org.apache.directory.shared.ldap.model.entry.DefaultEntry; +import org.apache.directory.shared.ldap.model.entry.Entry; +import org.apache.directory.shared.ldap.model.message.SearchScope; +import org.apache.directory.shared.ldap.model.name.Dn; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(FrameworkRunner.class) +@CreateDS( + name="AddPerfDS", + partitions = + { + @CreatePartition( + name = "example", + suffix = "dc=example,dc=com", + contextEntry = @ContextEntry( + entryLdif = + "dn: dc=example,dc=com\n" + + "dc: example\n" + + "objectClass: top\n" + + "objectClass: domain\n\n" ), + indexes = + { + @CreateIndex( attribute = "objectClass" ), + @CreateIndex( attribute = "sn" ), + @CreateIndex( attribute = "cn" ), + @CreateIndex( attribute = "displayName" ) + } ) + + }, + enableChangeLog = false ) +@CreateLdapServer(transports = + { + @CreateTransport(protocol = "LDAP"), + @CreateTransport(protocol = "LDAPS") + }) +public class SearchWithIndexTest extends AbstractLdapTestUnit +{ + private LdapNetworkConnection connection; + + + @Before + public void setup() throws Exception + { + connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); + + // Restart the service so that the index is created + getService().shutdown(); + getService().startup(); + } + + + @After + public void shutdown() throws Exception + { + LdapApiIntegrationUtils.releasePooledAdminConnection( connection, getLdapServer() ); + } + + /** + * Test an add operation performance + */ + @Test + @Ignore + public void testAddPer2f() throws Exception + { + Dn dn = new Dn( "cn=test,ou=system" ); + Entry entry = new DefaultEntry( getService().getSchemaManager(), dn, + "ObjectClass: top", + "ObjectClass: person", + "sn: TEST", + "cn: test" ); + + connection.add( entry ); + int nbIterations = 8000; + + //BufferedWriter out = new BufferedWriter( new FileWriter("/tmp/out.txt") ); + + long t0 = System.currentTimeMillis(); + long t00 = 0L; + long tt0 = System.currentTimeMillis(); + + for ( int i = 0; i < nbIterations; i++ ) + { + if ( i % 1000 == 0 ) + { + long tt1 = System.currentTimeMillis(); + + System.out.println( i + ", " + ( tt1 - tt0 ) ); + tt0 = tt1; + } + + if ( i == 5000 ) + { + t00 = System.currentTimeMillis(); + } + + dn = new Dn( "uid=" + i + ",dc=example,dc=com" ); + entry = new DefaultEntry( getService().getSchemaManager(), dn, + "objectClass: top", + "objectClass: person", + "objectClass: organizationalPerson", + "objectClass: inetOrgPerson", + "uid", Integer.toString( i ), + "mail: A-A-R.Awg-Rosli@acme.com", + "title: Snr Operations Technician (D)", + "sn: Awg-Rosli", + "departmentNumber: SMDS - UIA/G/MMO52D", + "cn: Awg-Rosli, Awg-Abd-Rahim SMDS-UIA/G/MMO52D", + "description: UI - S", + "telephoneNumber: 555-1212", + "givenName: Awg-Abd-Rahim", + "businessCategory: Ops MDS (Malaysia) Sdn Bhd", + "displayName", i + "Awg-Rosli, Awg-Abd-Rahim SMDS-UIA/G/MMO52D", + "employeeNumber: A-A-R.Awg-Rosli", + "pwdPolicySubEntry: ads-pwdId=cproint,ou=passwordPolicies,ads-interceptorId=authenticationInterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config" ); + + //out.write( LdifUtils.convertToLdif( entry ) ); + connection.add( entry ); + } + + //out.flush(); + //out.close(); + + long t1 = System.currentTimeMillis(); + + Long deltaWarmed = ( t1 - t00 ); + System.out.println( "Delta : " + deltaWarmed + "( " + ( ( ( nbIterations - 5000 ) * 1000 ) / deltaWarmed ) + " per s ) /" + ( t1 - t0 ) ); + + Entry entry1 = null; + Entry entry2 = null; + Entry entry3 = null; + + long ns0 = System.currentTimeMillis(); + EntryCursor results = connection.search("dc=example,dc=com", "(displayName=1234Awg-Rosli, Awg-Abd-Rahim SMDS-UIA/G/MMO52D)", SearchScope.SUBTREE, "*" ); + + while ( results.next() ) + { + entry1 = results.get(); + break; + } + + results.close(); + + long ns1 = System.currentTimeMillis(); + + System.out.println( "Delta search : " + ( ns1 - ns0 ) ); + + long ns2 = System.currentTimeMillis(); + results = connection.search("dc=example,dc=com", "(displayName=3456*)", SearchScope.SUBTREE, "*" ); + + while ( results.next() ) + { + entry2 = results.get(); + break; + } + results.close(); + long ns3 = System.currentTimeMillis(); + + System.out.println( "Delta search substring : " + ( ns3 - ns2 ) ); + + long ns4 = System.currentTimeMillis(); + results = connection.search("dc=example,dc=com", "(uid=6789)", SearchScope.SUBTREE, "*" ); + + while ( results.next() ) + { + entry3 = results.get(); + break; + } + + results.close(); + long ns5 = System.currentTimeMillis(); + + System.out.println( "Delta search no index : " + ( ns5 - ns4 ) ); + + System.out.println( "Entry 1 : " + entry1 ); + System.out.println( "Entry 2 : " + entry2 ); + System.out.println( "Entry 3 : " + entry3 ); + connection.close(); + + // Now, shutdown and restart the server once more + getService().shutdown(); + getService().startup(); + + // and do a search again + connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() ); + + long ns6 = System.currentTimeMillis(); + results = connection.search("dc=example,dc=com", "(displayName=3456*)", SearchScope.SUBTREE, "*" ); + + while ( results.next() ) + { + entry3 = results.get(); + break; + } + + results.close(); + long ns7 = System.currentTimeMillis(); + System.out.println( "New Delta search substring : " + ( ns7 - ns6 ) ); + + connection.close(); + } +} Propchange: directory/apacheds/trunk/ldif-partition/ ------------------------------------------------------------------------------ Merged /directory/apacheds/branches/index-work/ldif-partition:r1324715-1332211 Modified: directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java?rev=1332268&r1=1332267&r2=1332268&view=diff ============================================================================== --- directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java (original) +++ directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java Mon Apr 30 15:59:22 2012 @@ -34,14 +34,19 @@ import org.apache.directory.server.core. import org.apache.directory.server.core.api.interceptor.context.MoveOperationContext; import org.apache.directory.server.core.api.interceptor.context.RenameOperationContext; import org.apache.directory.server.i18n.I18n; +import org.apache.directory.server.xdbm.ForwardIndexEntry; import org.apache.directory.server.xdbm.IndexCursor; import org.apache.directory.server.xdbm.IndexEntry; +import org.apache.directory.server.xdbm.ParentIdAndRdn; +import org.apache.directory.server.xdbm.SingletonIndexCursor; +import org.apache.directory.server.xdbm.search.impl.DescendantCursor; import org.apache.directory.shared.ldap.model.constants.SchemaConstants; import org.apache.directory.shared.ldap.model.entry.DefaultEntry; import org.apache.directory.shared.ldap.model.entry.Entry; import org.apache.directory.shared.ldap.model.entry.Modification; import org.apache.directory.shared.ldap.model.exception.LdapException; import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException; +import org.apache.directory.shared.ldap.model.exception.LdapOperationErrorException; import org.apache.directory.shared.ldap.model.exception.LdapOperationException; import org.apache.directory.shared.ldap.model.ldif.LdifEntry; import org.apache.directory.shared.ldap.model.ldif.LdifReader; @@ -266,7 +271,7 @@ public class LdifPartition extends Abstr } // Get the modified entry and store it in the context for post usage - Entry modifiedEntry = lookup( id ); + Entry modifiedEntry = lookup( id, modifyContext.getDn() ); modifyContext.setAlteredEntry( modifiedEntry ); // just overwrite the existing file @@ -297,9 +302,16 @@ public class LdifPartition extends Abstr super.move( moveContext ); // Get the modified entry - Entry modifiedEntry = lookup( id ); + Entry modifiedEntry = lookup( id, moveContext.getNewDn() ); - entryMoved( oldDn, modifiedEntry, id ); + try + { + entryMoved( oldDn, modifiedEntry, id ); + } + catch ( Exception e ) + { + throw new LdapOperationErrorException( e.getMessage(), e ); + } } @@ -314,10 +326,17 @@ public class LdifPartition extends Abstr super.moveAndRename( moveAndRenameContext ); // Get the modified entry and store it in the context for post usage - Entry modifiedEntry = lookup( id ); + Entry modifiedEntry = lookup( id, moveAndRenameContext.getNewDn() ); moveAndRenameContext.setModifiedEntry( modifiedEntry ); - entryMoved( oldDn, modifiedEntry, id ); + try + { + entryMoved( oldDn, modifiedEntry, id ); + } + catch ( Exception e ) + { + throw new LdapOperationErrorException( e.getMessage(), e ); + } } @@ -333,12 +352,20 @@ public class LdifPartition extends Abstr super.rename( renameContext ); // Get the modified entry and store it in the context for post usage - Entry modifiedEntry = lookup( id ); + Dn newDn = oldDn.getParent().add( renameContext.getNewRdn() ); + Entry modifiedEntry = lookup( id, newDn ); renameContext.setModifiedEntry( modifiedEntry ); // Now move the potential children for the old entry // and remove the old entry - entryMoved( oldDn, modifiedEntry, id ); + try + { + entryMoved( oldDn, modifiedEntry, id ); + } + catch ( Exception e ) + { + throw new LdapOperationErrorException( e.getMessage(), e ); + } } @@ -352,19 +379,30 @@ public class LdifPartition extends Abstr * @param deleteOldEntry a flag to tell whether to delete the old entry files * @throws Exception */ - private void entryMoved( Dn oldEntryDn, Entry modifiedEntry, Long entryIdOld ) throws LdapException + private void entryMoved( Dn oldEntryDn, Entry modifiedEntry, Long entryIdOld ) throws Exception { // First, add the new entry addEntry( modifiedEntry ); + + Long baseId = getEntryId( modifiedEntry.getDn() ); + + ParentIdAndRdn parentIdAndRdn = getRdnIndex().reverseLookup( baseId ); + IndexEntry indexEntry = new ForwardIndexEntry(); + + indexEntry.setId(baseId); + indexEntry.setKey( parentIdAndRdn ); + + IndexCursor,Entry, Long> cursor = new SingletonIndexCursor, Long>( indexEntry ); + Long parentId = parentIdAndRdn.getParentId(); + + IndexCursor scopeCursor = new DescendantCursor( this, baseId, parentId, cursor ); // Then, if there are some children, move then to the new place try { - IndexCursor cursor = getSubLevelIndex().forwardCursor( entryIdOld ); - - while ( cursor.next() ) + while ( scopeCursor.next() ) { - IndexEntry entry = cursor.get(); + IndexEntry entry = scopeCursor.get(); // except the parent entry add the rest of entries if ( entry.getId() != entryIdOld ) @@ -373,13 +411,13 @@ public class LdifPartition extends Abstr } } - cursor.close(); + scopeCursor.close(); } catch ( Exception e ) { throw new LdapOperationException( e.getMessage(), e ); } - + // And delete the old entry's LDIF file File file = getFile( oldEntryDn, DELETE ); boolean deleted = deleteFile( file ); Modified: directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java?rev=1332268&r1=1332267&r2=1332268&view=diff ============================================================================== --- directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java (original) +++ directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java Mon Apr 30 15:59:22 2012 @@ -331,7 +331,7 @@ public class SingleFileLdifPartition ext IndexCursor,Entry,Long> cursor = rdnIdx.forwardCursor(); IndexEntry, Long> startingPos = new ForwardIndexEntry, Long>(); - startingPos.setValue( new ParentIdAndRdn( id, (Rdn[]) null ) ); + startingPos.setKey( new ParentIdAndRdn( id, (Rdn[]) null ) ); cursor.before( startingPos ); int countChildren = 0; @@ -346,7 +346,7 @@ public class SingleFileLdifPartition ext countChildren++; // And now, the children - int nbChildren = element.getValue().getNbChildren(); + int nbChildren = element.getKey().getNbChildren(); if ( nbChildren > 0 ) { Propchange: directory/apacheds/trunk/protocol-changepw/ ------------------------------------------------------------------------------ Merged /directory/apacheds/branches/index-work/protocol-changepw:r1324715-1332211 Propchange: directory/apacheds/trunk/protocol-dhcp/ ------------------------------------------------------------------------------ Merged /directory/apacheds/branches/index-work/protocol-dhcp:r1324715-1332211 Propchange: directory/apacheds/trunk/protocol-dns/ ------------------------------------------------------------------------------ Merged /directory/apacheds/branches/index-work/protocol-dns:r1324715-1332211 Propchange: directory/apacheds/trunk/protocol-kerberos/ ------------------------------------------------------------------------------ Merged /directory/apacheds/branches/index-work/protocol-kerberos:r1324715-1332211 Propchange: directory/apacheds/trunk/protocol-ldap/ ------------------------------------------------------------------------------ Merged /directory/apacheds/branches/index-work/protocol-ldap:r1324715-1332211 Propchange: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumerImpl.java ------------------------------------------------------------------------------ Merged /directory/apacheds/branches/index-work/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumerImpl.java:r1324715-1332211 Propchange: directory/apacheds/trunk/protocol-ntp/ ------------------------------------------------------------------------------ Merged /directory/apacheds/branches/index-work/protocol-ntp:r1324715-1332211 Propchange: directory/apacheds/trunk/protocol-shared/ ------------------------------------------------------------------------------ Merged /directory/apacheds/branches/index-work/protocol-shared:r1324715-1332211 Propchange: directory/apacheds/trunk/server-annotations/ ------------------------------------------------------------------------------ Merged /directory/apacheds/branches/index-work/server-annotations:r1324715-1332211 Propchange: directory/apacheds/trunk/server-config/ ------------------------------------------------------------------------------ Merged /directory/apacheds/branches/index-work/server-config:r1324715-1332211 Modified: directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java?rev=1332268&r1=1332267&r2=1332268&view=diff ============================================================================== --- directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java (original) +++ directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java Mon Apr 30 15:59:22 2012 @@ -728,8 +728,6 @@ public class ConfigPartitionReader // Prepare the search request AttributeType adsdAt = schemaManager.getAttributeType( SchemaConstants.OBJECT_CLASS_AT ); EqualityNode filter = new EqualityNode( adsdAt, new StringValue( name ) ); - SearchControls controls = new SearchControls(); - controls.setSearchScope( scope.ordinal() ); IndexCursor cursor = null; // Create a container for all the read beans @@ -738,7 +736,7 @@ public class ConfigPartitionReader try { // Do the search - cursor = se.cursor( baseDn, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls ); + cursor = se.cursor( baseDn, AliasDerefMode.NEVER_DEREF_ALIASES, filter, scope ); // First, check if we have some entries to process. if ( !cursor.next() ) Propchange: directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java ------------------------------------------------------------------------------ Merged /directory/apacheds/branches/index-work/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java:r1324715-1332211 Propchange: directory/apacheds/trunk/server-config/src/main/resources/ ------------------------------------------------------------------------------ Merged /directory/apacheds/branches/index-work/server-config/src/main/resources:r1324715-1332211 Propchange: directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java ------------------------------------------------------------------------------ Merged /directory/apacheds/branches/index-work/server-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java:r1324715-1332211 Propchange: directory/apacheds/trunk/server-integ/ ------------------------------------------------------------------------------ Merged /directory/apacheds/branches/index-work/server-integ:r1324715-1332211 Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchIT.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchIT.java?rev=1332268&r1=1332267&r2=1332268&view=diff ============================================================================== --- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchIT.java (original) +++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchIT.java Mon Apr 30 15:59:22 2012 @@ -124,306 +124,334 @@ import org.junit.runner.RunWith; }) public class ReferralSearchIT extends AbstractLdapTestUnit { - -@Before -public void setupReferrals() throws Exception -{ - String ldif = - "dn: c=europ,ou=Countries,ou=system\n" + - "objectClass: top\n" + - "objectClass: referral\n" + - "objectClass: extensibleObject\n" + - "c: europ\n" + - "ref: ldap://localhost:" + getLdapServer().getPort() + "/c=france,ou=system\n\n" + - - "dn: c=america,ou=Countries,ou=system\n" + - "objectClass: top\n" + - "objectClass: referral\n" + - "objectClass: extensibleObject\n" + - "c: america\n" + - "ref: ldap://localhost:" + getLdapServer().getPort() + "/c=usa,ou=system\n\n"; - - LdifReader reader = new LdifReader( new StringReader( ldif ) ); - - while ( reader.hasNext() ) - { - LdifEntry entry = reader.next(); - getLdapServer().getDirectoryService().getAdminSession().add( - new DefaultEntry( getLdapServer().getDirectoryService().getSchemaManager(), entry.getEntry() ) ); - } -} - - -@Test -public void testSearchBaseIsReferral() throws Exception -{ - DirContext ctx = getWiredContextThrowOnRefferal( getLdapServer() ); - SearchControls controls = new SearchControls(); - controls.setSearchScope( SearchControls.SUBTREE_SCOPE ); - - try - { - ctx.search( "ou=RemoteUsers,ou=system", "(objectClass=*)", controls ); - fail( "should never get here" ); - } - catch ( ReferralException e ) - { - assertEquals( "ldap://fermi:10389/ou=users,ou=system??sub", e.getReferralInfo() ); - assertTrue( e.skipReferral() ); - assertEquals( "ldap://hertz:10389/ou=users,dc=example,dc=com??sub", e.getReferralInfo() ); - assertTrue( e.skipReferral() ); - assertEquals( "ldap://maxwell:10389/ou=users,ou=system??sub", e.getReferralInfo() ); - assertFalse( e.skipReferral() ); - } -} - - -@Test -public void testSearchBaseParentIsReferral() throws Exception -{ - DirContext ctx = getWiredContextThrowOnRefferal( getLdapServer() ); - SearchControls controls = new SearchControls(); - controls.setSearchScope( SearchControls.OBJECT_SCOPE ); - - try + @Before + public void setupReferrals() throws Exception { - ctx.search( "cn=alex karasulu,ou=RemoteUsers,ou=system", "(objectClass=*)", controls ); + String ldif = + "dn: c=europ,ou=Countries,ou=system\n" + + "objectClass: top\n" + + "objectClass: referral\n" + + "objectClass: extensibleObject\n" + + "c: europ\n" + + "ref: ldap://localhost:" + getLdapServer().getPort() + "/c=france,ou=system\n\n" + + + "dn: c=america,ou=Countries,ou=system\n" + + "objectClass: top\n" + + "objectClass: referral\n" + + "objectClass: extensibleObject\n" + + "c: america\n" + + "ref: ldap://localhost:" + getLdapServer().getPort() + "/c=usa,ou=system\n\n"; + + LdifReader reader = new LdifReader( new StringReader( ldif ) ); + + while ( reader.hasNext() ) + { + LdifEntry entry = reader.next(); + getLdapServer().getDirectoryService().getAdminSession().add( + new DefaultEntry( getLdapServer().getDirectoryService().getSchemaManager(), entry.getEntry() ) ); + } } - catch ( ReferralException e ) + + + @Test + public void testSearchBaseIsReferral() throws Exception { - assertEquals( "ldap://fermi:10389/cn=alex%20karasulu,ou=users,ou=system??base", e.getReferralInfo() ); - assertTrue( e.skipReferral() ); - assertEquals( "ldap://hertz:10389/cn=alex%20karasulu,ou=users,dc=example,dc=com??base", e.getReferralInfo() ); - assertTrue( e.skipReferral() ); - assertEquals( "ldap://maxwell:10389/cn=alex%20karasulu,ou=users,ou=system??base", e.getReferralInfo() ); - assertFalse( e.skipReferral() ); - } -} - - -@Test -public void testSearchBaseAncestorIsReferral() throws Exception -{ - DirContext ctx = getWiredContextThrowOnRefferal( getLdapServer() ); - SearchControls controls = new SearchControls(); - controls.setSearchScope( SearchControls.OBJECT_SCOPE ); + DirContext ctx = getWiredContextThrowOnRefferal( getLdapServer() ); + SearchControls controls = new SearchControls(); + controls.setSearchScope( SearchControls.SUBTREE_SCOPE ); - try - { - ctx.search( "cn=alex karasulu,ou=apache,ou=RemoteUsers,ou=system", "(objectClass=*)", controls ); + try + { + ctx.search( "ou=RemoteUsers,ou=system", "(objectClass=*)", controls ); + fail( "should never get here" ); + } + catch ( ReferralException e ) + { + assertEquals( "ldap://fermi:10389/ou=users,ou=system??sub", e.getReferralInfo() ); + assertTrue( e.skipReferral() ); + assertEquals( "ldap://hertz:10389/ou=users,dc=example,dc=com??sub", e.getReferralInfo() ); + assertTrue( e.skipReferral() ); + assertEquals( "ldap://maxwell:10389/ou=users,ou=system??sub", e.getReferralInfo() ); + assertFalse( e.skipReferral() ); + } + finally + { + ctx.close(); + } } - catch ( ReferralException e ) + + + @Test + public void testSearchBaseParentIsReferral() throws Exception { - assertEquals( "ldap://fermi:10389/cn=alex%20karasulu,ou=apache,ou=users,ou=system??base", e.getReferralInfo() ); - assertTrue( e.skipReferral() ); - assertEquals( "ldap://hertz:10389/cn=alex%20karasulu,ou=apache,ou=users,dc=example,dc=com??base", e - .getReferralInfo() ); - assertTrue( e.skipReferral() ); - assertEquals( "ldap://maxwell:10389/cn=alex%20karasulu,ou=apache,ou=users,ou=system??base", e - .getReferralInfo() ); - assertFalse( e.skipReferral() ); + DirContext ctx = getWiredContextThrowOnRefferal( getLdapServer() ); + SearchControls controls = new SearchControls(); + controls.setSearchScope( SearchControls.OBJECT_SCOPE ); + + try + { + ctx.search( "cn=alex karasulu,ou=RemoteUsers,ou=system", "(objectClass=*)", controls ); + } + catch ( ReferralException e ) + { + assertEquals( "ldap://fermi:10389/cn=alex%20karasulu,ou=users,ou=system??base", e.getReferralInfo() ); + assertTrue( e.skipReferral() ); + assertEquals( "ldap://hertz:10389/cn=alex%20karasulu,ou=users,dc=example,dc=com??base", e.getReferralInfo() ); + assertTrue( e.skipReferral() ); + assertEquals( "ldap://maxwell:10389/cn=alex%20karasulu,ou=users,ou=system??base", e.getReferralInfo() ); + assertFalse( e.skipReferral() ); + } + finally + { + ctx.close(); + } } -} - - -@Test -public void testSearchContinuations() throws Exception -{ - DirContext ctx = getWiredContext( getLdapServer() ); - - SearchControls controls = new SearchControls(); - controls.setSearchScope( SearchControls.SUBTREE_SCOPE ); - NamingEnumeration list = ctx.search( "ou=system", "(objectClass=*)", controls ); - Map results = new HashMap(); - while ( list.hasMore() ) + + + @Test + public void testSearchBaseAncestorIsReferral() throws Exception { - SearchResult result = list.next(); - results.put( result.getName(), result ); + DirContext ctx = getWiredContextThrowOnRefferal( getLdapServer() ); + SearchControls controls = new SearchControls(); + controls.setSearchScope( SearchControls.OBJECT_SCOPE ); + + try + { + ctx.search( "cn=alex karasulu,ou=apache,ou=RemoteUsers,ou=system", "(objectClass=*)", controls ); + } + catch ( ReferralException e ) + { + assertEquals( "ldap://fermi:10389/cn=alex%20karasulu,ou=apache,ou=users,ou=system??base", e.getReferralInfo() ); + assertTrue( e.skipReferral() ); + assertEquals( "ldap://hertz:10389/cn=alex%20karasulu,ou=apache,ou=users,dc=example,dc=com??base", e + .getReferralInfo() ); + assertTrue( e.skipReferral() ); + assertEquals( "ldap://maxwell:10389/cn=alex%20karasulu,ou=apache,ou=users,ou=system??base", e + .getReferralInfo() ); + assertFalse( e.skipReferral() ); + } + finally + { + ctx.close(); + } } - - assertNotNull( results.get( "ou=users" ) ); - - // ------------------------------------------------------------------- - // Now we will throw exceptions when searching for referrals - // ------------------------------------------------------------------- - - ctx.addToEnvironment( Context.REFERRAL, "throw" ); - list = ctx.search( "ou=system", "(objectClass=*)", controls ); - results = new HashMap(); - - try + + + @Test + public void testSearchContinuations() throws Exception { + DirContext ctx = getWiredContext( getLdapServer() ); + + SearchControls controls = new SearchControls(); + controls.setSearchScope( SearchControls.SUBTREE_SCOPE ); + NamingEnumeration list = ctx.search( "ou=system", "(objectClass=*)", controls ); + Map results = new HashMap(); while ( list.hasMore() ) { SearchResult result = list.next(); results.put( result.getName(), result ); } - } - catch ( ReferralException e ) - { - // As we use the uuidIndex the order of search continuations returned by - // the server is not deterministic. So we collect all referrals first into - // an hashset and check afterwards if the expected URLs are included. - Set s = new HashSet(); - s.add( e.getReferralInfo() ); - while ( e.skipReferral() ) + + assertNotNull( results.get( "ou=users" ) ); + + // ------------------------------------------------------------------- + // Now we will throw exceptions when searching for referrals + // ------------------------------------------------------------------- + + ctx.addToEnvironment( Context.REFERRAL, "throw" ); + list = ctx.search( "ou=system", "(objectClass=*)", controls ); + results = new HashMap(); + + try { - try + while ( list.hasMore() ) { - Context ctx2 = e.getReferralContext(); - ctx2.list( "" ); + SearchResult result = list.next(); + results.put( result.getName(), result ); } - catch ( NamingException ne ) + } + catch ( ReferralException e ) + { + // As we use the uuidIndex the order of search continuations returned by + // the server is not deterministic. So we collect all referrals first into + // an hashset and check afterwards if the expected URLs are included. + Set s = new HashSet(); + s.add( e.getReferralInfo() ); + + while ( e.skipReferral() ) { - if ( ne instanceof ReferralException ) + try { - e = ( ReferralException ) ne; - s.add( e.getReferralInfo() ); + Context ctx2 = e.getReferralContext(); + ctx2.list( "" ); } - else + catch ( NamingException ne ) { - break; + if ( ne instanceof ReferralException ) + { + e = ( ReferralException ) ne; + s.add( e.getReferralInfo() ); + } + else + { + break; + } } } + + assertEquals( 5, s.size() ); + assertTrue( s.contains( "ldap://fermi:10389/ou=users,ou=system??sub" ) ); + assertTrue( s.contains( "ldap://hertz:10389/ou=users,dc=example,dc=com??sub" ) ); + assertTrue( s.contains( "ldap://maxwell:10389/ou=users,ou=system??sub" ) ); } - - assertEquals( 5, s.size() ); - assertTrue( s.contains( "ldap://fermi:10389/ou=users,ou=system??sub" ) ); - assertTrue( s.contains( "ldap://hertz:10389/ou=users,dc=example,dc=com??sub" ) ); - assertTrue( s.contains( "ldap://maxwell:10389/ou=users,ou=system??sub" ) ); - } - - assertNull( results.get( "ou=remoteusers" ) ); - - // try again but this time with single level scope - - controls.setSearchScope( SearchControls.ONELEVEL_SCOPE ); - list = ctx.search( "ou=system", "(objectClass=*)", controls ); - results = new HashMap(); - - try - { - while ( list.hasMore() ) + + assertNull( results.get( "ou=remoteusers" ) ); + list.close(); + + // try again but this time with single level scope + + controls.setSearchScope( SearchControls.ONELEVEL_SCOPE ); + list = ctx.search( "ou=system", "(objectClass=*)", controls ); + results = new HashMap(); + + try { - SearchResult result = list.next(); - results.put( result.getName(), result ); + while ( list.hasMore() ) + { + SearchResult result = list.next(); + results.put( result.getName(), result ); + } + } + catch ( ReferralException e ) + { + assertEquals( "ldap://fermi:10389/ou=users,ou=system??base", e.getReferralInfo() ); + assertTrue( e.skipReferral() ); + assertEquals( "ldap://hertz:10389/ou=users,dc=example,dc=com??base", e.getReferralInfo() ); + assertTrue( e.skipReferral() ); + assertEquals( "ldap://maxwell:10389/ou=users,ou=system??base", e.getReferralInfo() ); + } + + list.close(); + ctx.close(); + + assertNull( results.get( "ou=remoteusers" ) ); + } + + + /** + * Test of an search operation with a referral + * + * search for "cn=alex karasulu" on "c=america, ou=system" + * we should get a referral URL thrown, which point to + * "c=usa, ou=system", and ask for a subtree search + */ + @Test + public void testSearchWithReferralThrow() throws Exception + { + DirContext ctx = getWiredContextThrowOnRefferal( getLdapServer() ); + + try + { + SearchControls controls = new SearchControls(); + controls.setSearchScope( SearchControls.SUBTREE_SCOPE ); + ctx.search( "c=america,ou=Countries,ou=system", "(cn=alex karasulu)", controls ); + fail( "Should fail here throwing a ReferralException" ); + } + catch ( ReferralException re ) + { + String referral = ( String ) re.getReferralInfo(); + assertEquals( "ldap://localhost:" + getLdapServer().getPort() + "/c=usa,ou=system??sub", referral ); + } + finally + { + ctx.close(); } } - catch ( ReferralException e ) - { - assertEquals( "ldap://fermi:10389/ou=users,ou=system??base", e.getReferralInfo() ); - assertTrue( e.skipReferral() ); - assertEquals( "ldap://hertz:10389/ou=users,dc=example,dc=com??base", e.getReferralInfo() ); - assertTrue( e.skipReferral() ); - assertEquals( "ldap://maxwell:10389/ou=users,ou=system??base", e.getReferralInfo() ); - } - - assertNull( results.get( "ou=remoteusers" ) ); -} - - -/** - * Test of an search operation with a referral - * - * search for "cn=alex karasulu" on "c=america, ou=system" - * we should get a referral URL thrown, which point to - * "c=usa, ou=system", and ask for a subtree search - */ -@Test -public void testSearchWithReferralThrow() throws Exception -{ - DirContext ctx = getWiredContextThrowOnRefferal( getLdapServer() ); - - try + + + /** + * Test of an search operation with a referral + * + * search for "cn=alex karasulu" on "c=america, ou=system" + * we should get a referral URL thrown, which point to + * "c=usa, ou=system", and ask for a subtree search + */ + @Test + public void testSearchBaseWithReferralThrow() throws Exception { + DirContext ctx = getWiredContextThrowOnRefferal( getLdapServer() ); + SearchControls controls = new SearchControls(); - controls.setSearchScope( SearchControls.SUBTREE_SCOPE ); - ctx.search( "c=america,ou=Countries,ou=system", "(cn=alex karasulu)", controls ); - fail( "Should fail here throwing a ReferralException" ); - } - catch ( ReferralException re ) - { - String referral = ( String ) re.getReferralInfo(); - assertEquals( "ldap://localhost:" + getLdapServer().getPort() + "/c=usa,ou=system??sub", referral ); - } -} - - -/** - * Test of an search operation with a referral - * - * search for "cn=alex karasulu" on "c=america, ou=system" - * we should get a referral URL thrown, which point to - * "c=usa, ou=system", and ask for a subtree search - */ -@Test -public void testSearchBaseWithReferralThrow() throws Exception -{ - DirContext ctx = getWiredContextThrowOnRefferal( getLdapServer() ); - - SearchControls controls = new SearchControls(); - controls.setSearchScope( SearchControls.OBJECT_SCOPE ); - - try - { - ctx.search( "c=america,ou=Countries,ou=system", "(cn=alex karasulu)", controls ); - fail( "Should fail here throwing a ReferralException" ); - } - catch ( ReferralException re ) - { - String referral = ( String ) re.getReferralInfo(); - assertEquals( "ldap://localhost:" + getLdapServer().getPort() + "/c=usa,ou=system??base", referral ); - } -} - - -/** - * Test of an search operation with a referral after the entry - * has been renamed. - * - * search for "cn=alex karasulu" on "c=usa, ou=system" - * we should get a referral URL thrown, which point to - * "c=usa, ou=system", and ask for a subtree search - */ -@Test -public void testSearchBaseWithReferralThrowAfterRename() throws Exception -{ - DirContext ctx = getWiredContextThrowOnRefferal( getLdapServer() ); - - SearchControls controls = new SearchControls(); - controls.setSearchScope( SearchControls.OBJECT_SCOPE ); - - try - { - ctx.search( "c=america,ou=Countries,ou=system", "(cn=alex karasulu)", controls ); - fail( "Should fail here throwing a ReferralException" ); - } - catch ( ReferralException re ) - { - String referral = ( String ) re.getReferralInfo(); - assertEquals( "ldap://localhost:" + getLdapServer().getPort() + "/c=usa,ou=system??base", referral ); - } - - ( ( LdapContext ) ctx ).setRequestControls( new javax.naming.ldap.Control[] - { new ManageReferralControl() } ); - - // Now let's move the entry - ctx.rename( "c=america,ou=Countries,ou=system", "c=USA,ou=Countries,ou=system" ); - - controls.setSearchScope( SearchControls.OBJECT_SCOPE ); - - ( ( LdapContext ) ctx ).setRequestControls( new javax.naming.ldap.Control[] - {} ); - - try - { - ctx.search( "c=usa,ou=Countries,ou=system", "(cn=alex karasulu)", controls ); - fail( "Should fail here throwing a ReferralException" ); + controls.setSearchScope( SearchControls.OBJECT_SCOPE ); + + try + { + ctx.search( "c=america,ou=Countries,ou=system", "(cn=alex karasulu)", controls ); + fail( "Should fail here throwing a ReferralException" ); + } + catch ( ReferralException re ) + { + String referral = ( String ) re.getReferralInfo(); + assertEquals( "ldap://localhost:" + getLdapServer().getPort() + "/c=usa,ou=system??base", referral ); + } + finally + { + ctx.close(); + } } - catch ( ReferralException re ) + + + /** + * Test of an search operation with a referral after the entry + * has been renamed. + * + * search for "cn=alex karasulu" on "c=usa, ou=system" + * we should get a referral URL thrown, which point to + * "c=usa, ou=system", and ask for a subtree search + */ + @Test + public void testSearchBaseWithReferralThrowAfterRename() throws Exception { - String referral = ( String ) re.getReferralInfo(); - assertEquals( "ldap://localhost:" + getLdapServer().getPort() + "/c=usa,ou=system??base", referral ); + DirContext ctx = getWiredContextThrowOnRefferal( getLdapServer() ); + + SearchControls controls = new SearchControls(); + controls.setSearchScope( SearchControls.OBJECT_SCOPE ); + + try + { + ctx.search( "c=america,ou=Countries,ou=system", "(cn=alex karasulu)", controls ); + fail( "Should fail here throwing a ReferralException" ); + } + catch ( ReferralException re ) + { + String referral = ( String ) re.getReferralInfo(); + assertEquals( "ldap://localhost:" + getLdapServer().getPort() + "/c=usa,ou=system??base", referral ); + } + + ( ( LdapContext ) ctx ).setRequestControls( new javax.naming.ldap.Control[] + { new ManageReferralControl() } ); + + // Now let's move the entry + ctx.rename( "c=america,ou=Countries,ou=system", "c=USA,ou=Countries,ou=system" ); + + controls.setSearchScope( SearchControls.OBJECT_SCOPE ); + + ( ( LdapContext ) ctx ).setRequestControls( new javax.naming.ldap.Control[] + {} ); + + try + { + ctx.search( "c=usa,ou=Countries,ou=system", "(cn=alex karasulu)", controls ); + fail( "Should fail here throwing a ReferralException" ); + } + catch ( ReferralException re ) + { + String referral = ( String ) re.getReferralInfo(); + assertEquals( "ldap://localhost:" + getLdapServer().getPort() + "/c=usa,ou=system??base", referral ); + } + finally + { + ctx.close(); + } } -} } \ No newline at end of file Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java?rev=1332268&r1=1332267&r2=1332268&view=diff ============================================================================== --- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java (original) +++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java Mon Apr 30 15:59:22 2012 @@ -835,7 +835,9 @@ public class SearchIT extends AbstractLd { SearchResult sr = enm.next(); assertNotNull( sr ); - assertEquals( "Name in namespace", nameInNamespace, sr.getNameInNamespace() ); + Dn expectedDn = new Dn( nameInNamespace ).getParent().add( mixedRdn ); + + assertEquals( "Name in namespace", expectedDn, sr.getNameInNamespace() ); } else { Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchPerfIT.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchPerfIT.java?rev=1332268&r1=1332267&r2=1332268&view=diff ============================================================================== --- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchPerfIT.java (original) +++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchPerfIT.java Mon Apr 30 15:59:22 2012 @@ -6,16 +6,16 @@ * 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. - * + * under the License. + * */ package org.apache.directory.server.operations.search; @@ -23,6 +23,7 @@ package org.apache.directory.server.oper import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; +import org.apache.directory.ldap.client.api.EntryCursorImpl; import org.apache.directory.ldap.client.api.LdapConnection; import org.apache.directory.ldap.client.api.LdapNetworkConnection; import org.apache.directory.server.annotations.CreateLdapServer; @@ -31,7 +32,11 @@ import org.apache.directory.server.core. import org.apache.directory.server.core.integ.FrameworkRunner; import org.apache.directory.shared.ldap.model.cursor.EntryCursor; import org.apache.directory.shared.ldap.model.exception.LdapException; +import org.apache.directory.shared.ldap.model.message.AliasDerefMode; +import org.apache.directory.shared.ldap.model.message.SearchRequest; +import org.apache.directory.shared.ldap.model.message.SearchRequestImpl; import org.apache.directory.shared.ldap.model.message.SearchScope; +import org.apache.directory.shared.ldap.model.name.Dn; import org.junit.Test; import org.junit.runner.RunWith; @@ -52,10 +57,8 @@ public class SearchPerfIT extends Abstra * test a search request perf. */ @Test - public void testSearchRequestPerf() throws Exception + public void testSearchRequestObjectScopePerf() throws Exception { - //getLdapServer().getDirectoryService().getInterceptorChain().addFirst( new TimerInterceptor( "Start" ) ); - //getLdapServer().getDirectoryService().getInterceptorChain().addLast( new TimerInterceptor( "End" ) ); LdapConnection connection = new LdapNetworkConnection( "localhost", getLdapServer().getPort() ); try @@ -90,27 +93,251 @@ public class SearchPerfIT extends Abstra cursor.close(); } + Dn dn = new Dn( getService().getSchemaManager(), "uid=admin,ou=system" ); + + SearchRequest searchRequest = new SearchRequestImpl(); + + searchRequest.setBase( dn ); + searchRequest.setFilter( "(ObjectClass=*)" ); + searchRequest.setScope( SearchScope.OBJECT ); + searchRequest.addAttributes( "*" ); + searchRequest.setDerefAliases( AliasDerefMode.DEREF_ALWAYS ); + long t0 = System.currentTimeMillis(); + long t00 = 0L; + long tt0 = System.currentTimeMillis(); int nbIterations = 200000; for ( int j = 0; j < nbIterations; j++ ) { if ( j % 10000 == 0 ) { - System.out.println( j ); + long tt1 = System.currentTimeMillis(); + + System.out.println( j + ", " + ( tt1 - tt0 ) ); + tt0 = tt1; + } + + if ( j == 50000 ) + { + t00 = System.currentTimeMillis(); } - cursor = connection.search( "uid=admin,ou=system", "(ObjectClass=*)", SearchScope.OBJECT, "*" ); + cursor = new EntryCursorImpl( connection.search( searchRequest ) ); + + while ( cursor.next() ) + { + cursor.get(); + } + + cursor.close(); + } + + long t1 = System.currentTimeMillis(); + + Long deltaWarmed = ( t1 - t00 ); + System.out.println( "Delta : " + deltaWarmed + "( " + ( ( ( nbIterations - 50000 ) * 1000 ) / deltaWarmed ) + + " per s ) /" + ( t1 - t0 ) ); + } + catch ( LdapException e ) + { + e.printStackTrace(); + fail( "Should not have caught exception." ); + } + finally + { + connection.unBind(); + connection.close(); + } + } + + + /** + * test a search request perf. + */ + @Test + public void testSearchRequestOneLevelScopePerf() throws Exception + { + LdapConnection connection = new LdapNetworkConnection( "localhost", getLdapServer().getPort() ); + + try + { + // Use the client API as JNDI cannot be used to do a search without + // first binding. (hmmm, even client API won't allow searching without binding) + connection.bind( "uid=admin,ou=system", "secret" ); + + // Searches for all the entries in ou=system + EntryCursor cursor = connection.search( "ou=system", "(ObjectClass=*)", + SearchScope.ONELEVEL, "*" ); + + int i = 0; + + while ( cursor.next() ) + { + cursor.get(); + ++i; + } + + cursor.close(); + assertEquals( 5, i ); + + for ( int j = 0; j < 10000; j++ ) + { + cursor = connection.search( "ou=system", "(ObjectClass=*)", SearchScope.ONELEVEL, "*" ); + + while ( cursor.next() ) + { + cursor.get(); + } + + cursor.close(); + } + + Dn dn = new Dn( getService().getSchemaManager(), "uid=admin,ou=system" ); + + SearchRequest searchRequest = new SearchRequestImpl(); + + searchRequest.setBase( dn ); + searchRequest.setFilter( "(ObjectClass=*)" ); + searchRequest.setScope( SearchScope.ONELEVEL ); + searchRequest.addAttributes( "*" ); + searchRequest.setDerefAliases( AliasDerefMode.DEREF_ALWAYS ); + + long t0 = System.currentTimeMillis(); + long t00 = 0L; + long tt0 = System.currentTimeMillis(); + int nbIterations = 200000; + + for ( int j = 0; j < nbIterations; j++ ) + { + if ( j % 10000 == 0 ) + { + long tt1 = System.currentTimeMillis(); + + System.out.println( j + ", " + ( tt1 - tt0 ) ); + tt0 = tt1; + } + + if ( j == 50000 ) + { + t00 = System.currentTimeMillis(); + } + + cursor = new EntryCursorImpl( connection.search( searchRequest ) ); + + while ( cursor.next() ) + { + cursor.get(); + } + + cursor.close(); + } + + long t1 = System.currentTimeMillis(); + + Long deltaWarmed = ( t1 - t00 ); + System.out.println( "Delta : " + deltaWarmed + "( " + ( ( ( nbIterations - 50000 ) * 1000 ) / deltaWarmed ) + + " per s ) /" + ( t1 - t0 ) ); + } + catch ( LdapException e ) + { + e.printStackTrace(); + fail( "Should not have caught exception." ); + } + finally + { + connection.unBind(); + connection.close(); + } + } + + + /** + * test a search request perf. + */ + @Test + public void testSearchRequestSubtreeLevelScopePerf() throws Exception + { + LdapConnection connection = new LdapNetworkConnection( "localhost", getLdapServer().getPort() ); + connection.setTimeOut( 0 ); + + try + { + // Use the client API as JNDI cannot be used to do a search without + // first binding. (hmmm, even client API won't allow searching without binding) + connection.bind( "uid=admin,ou=system", "secret" ); + + // Searches for all the entries in ou=system + EntryCursor cursor = connection.search( "ou=system", "(ObjectClass=*)", + SearchScope.SUBTREE, "*" ); + + int i = 0; + + while ( cursor.next() ) + { + cursor.get(); + ++i; + } + + cursor.close(); + assertEquals( 10, i ); + + for ( int j = 0; j < 10000; j++ ) + { + cursor = connection.search( "ou=system", "(ObjectClass=*)", SearchScope.SUBTREE, "*" ); + + while ( cursor.next() ) + { + cursor.get(); + } + + cursor.close(); + } + + Dn dn = new Dn( getService().getSchemaManager(), "uid=admin,ou=system" ); + + SearchRequest searchRequest = new SearchRequestImpl(); + + searchRequest.setBase( dn ); + searchRequest.setFilter( "(ObjectClass=*)" ); + searchRequest.setScope( SearchScope.SUBTREE ); + searchRequest.addAttributes( "*" ); + searchRequest.setDerefAliases( AliasDerefMode.DEREF_ALWAYS ); + + long t0 = System.currentTimeMillis(); + long t00 = 0L; + long tt0 = System.currentTimeMillis(); + int nbIterations = 200000; + + for ( int j = 0; j < nbIterations; j++ ) + { + if ( j % 10000 == 0 ) + { + long tt1 = System.currentTimeMillis(); + + System.out.println( j + ", " + ( tt1 - tt0 ) ); + tt0 = tt1; + } + + if ( j == 50000 ) + { + t00 = System.currentTimeMillis(); + } + + cursor = new EntryCursorImpl( connection.search( searchRequest ) ); + while ( cursor.next() ) { + cursor.get(); } + cursor.close(); } long t1 = System.currentTimeMillis(); - Long deltaWarmed = ( t1 - t0 ); - System.out.println( "Delta : " + deltaWarmed + "( " + ( ( nbIterations * 1000 ) / deltaWarmed ) + Long deltaWarmed = ( t1 - t00 ); + System.out.println( "Delta : " + deltaWarmed + "( " + ( ( ( nbIterations - 50000 ) * 1000 ) / deltaWarmed ) + " per s ) /" + ( t1 - t0 ) ); } catch ( LdapException e ) Propchange: directory/apacheds/trunk/server-jndi/ ------------------------------------------------------------------------------ Merged /directory/apacheds/branches/index-work/server-jndi:r1324715-1332211 Propchange: directory/apacheds/trunk/server-replication/ ------------------------------------------------------------------------------ Merged /directory/apacheds/branches/index-work/server-replication:r1324715-1332211 Propchange: directory/apacheds/trunk/server-tools/ ------------------------------------------------------------------------------ Merged /directory/apacheds/branches/index-work/server-tools:r1324715-1332211 Propchange: directory/apacheds/trunk/service/ ------------------------------------------------------------------------------ Merged /directory/apacheds/branches/index-work/service:r1324715-1332211 Propchange: directory/apacheds/trunk/service-builder/ ------------------------------------------------------------------------------ Merged /directory/apacheds/branches/index-work/service-builder:r1324715-1332211 Propchange: directory/apacheds/trunk/test-framework/ ------------------------------------------------------------------------------ Merged /directory/apacheds/branches/index-work/test-framework:r1324715-1332211 Propchange: directory/apacheds/trunk/xdbm-partition/ ------------------------------------------------------------------------------ Merged /directory/apacheds/branches/index-work/xdbm-partition:r1324715-1332211 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=1332268&r1=1332267&r2=1332268&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 Apr 30 15:59:22 2012 @@ -23,24 +23,20 @@ package org.apache.directory.server.core import java.io.IOException; import java.io.OutputStream; import java.net.URI; -import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; -import javax.naming.directory.SearchControls; - import org.apache.directory.server.constants.ApacheSchemaConstants; import org.apache.directory.server.core.api.entry.ClonedServerEntry; import org.apache.directory.server.core.api.filtering.BaseEntryFilteringCursor; import org.apache.directory.server.core.api.filtering.EntryFilteringCursor; import org.apache.directory.server.core.api.interceptor.context.AddOperationContext; import org.apache.directory.server.core.api.interceptor.context.DeleteOperationContext; -import org.apache.directory.server.core.api.interceptor.context.GetRootDseOperationContext; import org.apache.directory.server.core.api.interceptor.context.HasEntryOperationContext; import org.apache.directory.server.core.api.interceptor.context.ListOperationContext; import org.apache.directory.server.core.api.interceptor.context.LookupOperationContext; @@ -60,14 +56,11 @@ import org.apache.directory.server.xdbm. import org.apache.directory.server.xdbm.IndexNotFoundException; import org.apache.directory.server.xdbm.MasterTable; import org.apache.directory.server.xdbm.ParentIdAndRdn; -import org.apache.directory.server.xdbm.ReverseIndexEntry; import org.apache.directory.server.xdbm.Store; import org.apache.directory.server.xdbm.search.Optimizer; import org.apache.directory.server.xdbm.search.SearchEngine; import org.apache.directory.server.xdbm.search.impl.ChildrenCursor; -import org.apache.directory.server.xdbm.search.impl.OneLevelScopeCursor; import org.apache.directory.shared.ldap.model.constants.SchemaConstants; -import org.apache.directory.shared.ldap.model.cursor.Cursor; import org.apache.directory.shared.ldap.model.entry.Attribute; import org.apache.directory.shared.ldap.model.entry.Entry; import org.apache.directory.shared.ldap.model.entry.Modification; @@ -84,6 +77,7 @@ import org.apache.directory.shared.ldap. import org.apache.directory.shared.ldap.model.filter.ExprNode; import org.apache.directory.shared.ldap.model.message.AliasDerefMode; import org.apache.directory.shared.ldap.model.message.ResultCodeEnum; +import org.apache.directory.shared.ldap.model.message.SearchScope; import org.apache.directory.shared.ldap.model.name.Ava; import org.apache.directory.shared.ldap.model.name.Dn; import org.apache.directory.shared.ldap.model.name.Rdn; @@ -150,9 +144,6 @@ public abstract class AbstractBTreeParti /** a system index on objectClass attribute*/ protected Index objectClassIdx; - /** a system index on the entries of descendants of root Dn */ - protected Index subLevelIdx; - /** the attribute presence index */ protected Index presenceIdx; @@ -180,8 +171,8 @@ public abstract class AbstractBTreeParti private static final boolean NO_REVERSE = Boolean.FALSE; private static final boolean WITH_REVERSE = Boolean.TRUE; - private static final boolean ADD_CHILD = true; - private static final boolean REMOVE_CHILD = false; + protected static final boolean ADD_CHILD = true; + protected static final boolean REMOVE_CHILD = false; // ------------------------------------------------------------------------ // C O N S T R U C T O R S @@ -296,12 +287,6 @@ public abstract class AbstractBTreeParti addIndex( index ); } - if ( getSubLevelIndex() == null ) - { - Index index = createSystemIndex( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID, partitionPath, WITH_REVERSE ); - addIndex( index ); - } - if ( getRdnIndex() == null ) { Index, Entry, ID> index = createSystemIndex( ApacheSchemaConstants.APACHE_RDN_AT_OID, partitionPath, WITH_REVERSE ); @@ -355,7 +340,6 @@ public abstract class AbstractBTreeParti // set index shortcuts rdnIdx = ( Index, Entry, ID> ) systemIndices.get( ApacheSchemaConstants.APACHE_RDN_AT_OID ); presenceIdx = ( Index ) systemIndices.get( ApacheSchemaConstants.APACHE_PRESENCE_AT_OID ); - subLevelIdx = ( Index ) systemIndices.get( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID ); aliasIdx = ( Index ) systemIndices.get( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ); oneAliasIdx = ( Index ) systemIndices.get( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID ); subAliasIdx = ( Index ) systemIndices.get( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID ); @@ -550,13 +534,13 @@ public abstract class AbstractBTreeParti } - private void dumpRdnIdx( ID id, String tabs ) throws Exception + public void dumpRdnIdx( ID id, String tabs ) throws Exception { // Start with the root IndexCursor,Entry,ID> cursor = rdnIdx.forwardCursor(); IndexEntry, ID> startingPos = new ForwardIndexEntry, ID>(); - startingPos.setValue( new ParentIdAndRdn( id, (Rdn[]) null ) ); + startingPos.setKey( new ParentIdAndRdn( id, (Rdn[]) null ) ); cursor.before( startingPos ); while ( cursor.next() ) @@ -575,7 +559,7 @@ public abstract class AbstractBTreeParti IndexCursor,Entry,ID> cursor = rdnIdx.forwardCursor(); IndexEntry, ID> startingPos = new ForwardIndexEntry, ID>(); - startingPos.setValue( new ParentIdAndRdn( id, (Rdn[]) null ) ); + startingPos.setKey( new ParentIdAndRdn( id, (Rdn[]) null ) ); cursor.before( startingPos ); int countChildren = 0; @@ -586,7 +570,7 @@ public abstract class AbstractBTreeParti countChildren++; // And now, the children - int nbChildren = entry.getValue().getNbChildren(); + int nbChildren = entry.getKey().getNbChildren(); if ( nbChildren > 0 ) { @@ -683,18 +667,6 @@ public abstract class AbstractBTreeParti addAliasIndices( id, entryDn, aliasAttr.getString() ); } - // Update the SubLevel index - ID tempId = parentId; - - while ( ( tempId != null ) && ( !tempId.equals( getRootId() ) ) && ( !tempId.equals( getSuffixId() ) ) ) - { - subLevelIdx.add( tempId, id ); - tempId = getParentId( tempId ); - } - - // making entry an ancestor/descendent of itself in sublevel index - subLevelIdx.add( id, id ); - // Update the EntryCsn index Attribute entryCsn = entry.get( ENTRY_CSN_AT ); @@ -794,7 +766,7 @@ public abstract class AbstractBTreeParti } - private void updateRdnIdx( ID parentId, boolean addRemove, int nbDescendant ) throws Exception + protected void updateRdnIdx( ID parentId, boolean addRemove, int nbDescendant ) throws Exception { boolean isFirst = true; @@ -831,6 +803,8 @@ public abstract class AbstractBTreeParti } // Inject the modified element into the index + // we first need to drop it so that the key can be replaced + rdnIdx.drop( parentId ); rdnIdx.add( parent, parentId ); parentId = parent.getParentId(); @@ -879,7 +853,6 @@ public abstract class AbstractBTreeParti dumpRdnIdx(); - subLevelIdx.drop( id ); entryCsnIdx.drop( entry.get( ENTRY_CSN_AT ).getString(), id ); entryUuidIdx.drop( entry.get( ENTRY_UUID_AT ).getString(), id ); @@ -950,7 +923,7 @@ public abstract class AbstractBTreeParti IndexCursor,Entry, ID> cursor = rdnIdx.forwardCursor(); IndexEntry, ID> startingPos = new ForwardIndexEntry, ID>(); - startingPos.setValue( new ParentIdAndRdn( id, (Rdn[]) null ) ); + startingPos.setKey( new ParentIdAndRdn( id, (Rdn[]) null ) ); cursor.before( startingPos ); dumpRdnIdx(); @@ -974,13 +947,13 @@ public abstract class AbstractBTreeParti { try { - SearchControls searchCtls = searchContext.getSearchControls(); + SearchScope scope = searchContext.getScope(); IndexCursor underlying; Dn dn = searchContext.getDn(); AliasDerefMode derefMode = searchContext.getAliasDerefMode(); ExprNode filter = searchContext.getFilter(); - underlying = searchEngine.cursor( dn, derefMode, filter, searchCtls ); + underlying = searchEngine.cursor( dn, derefMode, filter, scope ); return new BaseEntryFilteringCursor( new EntryCursorAdaptor( this, underlying ), searchContext ); } @@ -1011,7 +984,7 @@ public abstract class AbstractBTreeParti return null; } - Entry entry = lookup( id ); + Entry entry = lookup( id, lookupContext.getDn() ); // Remove all the attributes if the NO_ATTRIBUTE flag is set and there is no requested attribute if ( lookupContext.hasNoAttribute() @@ -1124,6 +1097,36 @@ public abstract class AbstractBTreeParti } + /** + * Get back an entry knowing its ID + * + * @param id The Entry ID we want to get back + * @return The found Entry, or null if not found + * @throws Exception If the lookup failed for any reason (except a not found entry) + */ + public Entry lookup( ID id, Dn dn ) throws LdapException + { + try + { + Entry entry = master.get( id ); + + if ( entry != null ) + { + // We have to store the DN in this entry + entry.setDn( dn ); + + return new ClonedServerEntry( entry ); + } + + return null; + } + catch ( Exception e ) + { + throw new LdapOperationErrorException( e.getMessage(), e ); + } + } + + //--------------------------------------------------------------------------------------------- // The Modify operation //--------------------------------------------------------------------------------------------- @@ -1526,12 +1529,6 @@ public abstract class AbstractBTreeParti */ dropMovedAliasIndices( oldDn ); - /* - * Drop the old parent child relationship and add the new one - * Set the new parent id for the child replacing the old parent id - */ - updateSubLevelIndex( entryId, oldParentId, newParentId ); - // Update the Rdn index // First drop the old entry ParentIdAndRdn movedEntry = rdnIdx.reverseLookup( entryId ); @@ -1711,12 +1708,6 @@ public abstract class AbstractBTreeParti dropMovedAliasIndices( oldDn ); /* - * Drop the old parent child relationship and add the new one - * Set the new parent id for the child replacing the old parent id - */ - updateSubLevelIndex( entryId, oldParentId, newParentId ); - - /* * Update the Rdn index */ // First drop the old entry @@ -1910,9 +1901,18 @@ public abstract class AbstractBTreeParti * No need to calculate the new Dn. */ ID parentId = getParentId( oldId ); + + // Get the old parentIdAndRdn to get the nb of children and descendant + ParentIdAndRdn parentIdAndRdn = rdnIdx.reverseLookup( oldId ); + + // Now we can drop it rdnIdx.drop( oldId ); - ParentIdAndRdn key = new ParentIdAndRdn( parentId, newRdn ); - rdnIdx.add( key, oldId ); + + // Update the descendants + parentIdAndRdn.setParentId( parentId ); + parentIdAndRdn.setRdns( newRdn ); + + rdnIdx.add( parentIdAndRdn, oldId ); if ( isSyncOnWrite.get() ) { @@ -1944,7 +1944,7 @@ public abstract class AbstractBTreeParti { ID id = getEntryId( entryContext.getDn() ); - Entry entry = lookup( id ); + Entry entry = lookup( id, entryContext.getDn() ); return entry != null; } @@ -1973,69 +1973,6 @@ public abstract class AbstractBTreeParti } - /** - * Updates the SubLevel Index as part of a move operation. - * - * @param entryId child id to be moved - * @param oldParentId old parent's id - * @param newParentId new parent's id - * @throws Exception - */ - private void updateSubLevelIndex( ID entryId, ID oldParentId, ID newParentId ) throws Exception - { - ID tempId = oldParentId; - List parentIds = new ArrayList(); - - // find all the parents of the oldParentId - while ( ( tempId != null ) && !tempId.equals( getRootId() ) && !tempId.equals( getSuffixId() ) ) - { - parentIds.add( tempId ); - tempId = getParentId( tempId ); - } - - // find all the children of the childId - Cursor> cursor = subLevelIdx.forwardCursor( entryId ); - - List childIds = new ArrayList(); - childIds.add( entryId ); - - while ( cursor.next() ) - { - childIds.add( cursor.get().getId() ); - } - - cursor.close(); - - // detach the childId and all its children from oldParentId and all it parents excluding the root - for ( ID pid : parentIds ) - { - for ( ID cid : childIds ) - { - subLevelIdx.drop( pid, cid ); - } - } - - parentIds.clear(); - tempId = newParentId; - - // find all the parents of the newParentId - while ( ( tempId != null ) && !tempId.equals( getRootId() ) && !tempId.equals( getSuffixId() ) ) - { - parentIds.add( tempId ); - tempId = getParentId( tempId ); - } - - // attach the childId and all its children to newParentId and all it parents excluding the root - for ( ID id : parentIds ) - { - for ( ID cid : childIds ) - { - subLevelIdx.add( id, cid ); - } - } - } - - // ------------------------------------------------------------------------ // Index and master table Operations // ------------------------------------------------------------------------ @@ -2051,8 +1988,9 @@ public abstract class AbstractBTreeParti ID parentId = id; ID rootId = getRootId(); - StringBuilder upName = new StringBuilder(); - boolean isFirst = true; + // Create an array of 10 rdns, just in case. We will extend it if needed + Rdn[] rdnArray = new Rdn[10]; + int pos = 0; do { @@ -2061,23 +1999,22 @@ public abstract class AbstractBTreeParti for ( Rdn rdn : rdns ) { - if ( isFirst ) - { - isFirst = false; - } - else + if ( ( pos > 0 ) && (pos % 10 == 0 ) ) { - upName.append( ',' ); + // extend the array + Rdn[] newRdnArray = new Rdn[pos + 10]; + System.arraycopy( rdnArray, 0, newRdnArray, 0, pos ); + rdnArray = newRdnArray; } - - upName.append( rdn.getName() ); + + rdnArray[pos++]= rdn; } parentId = cur.getParentId(); } while ( !parentId.equals( rootId ) ); - Dn dn = new Dn( schemaManager, upName.toString() ); + Dn dn = new Dn( schemaManager, Arrays.copyOf( rdnArray, pos ) ); return dn; } @@ -2343,16 +2280,6 @@ public abstract class AbstractBTreeParti * {@inheritDoc} */ @SuppressWarnings("unchecked") - public Index getSubLevelIndex() - { - return ( Index ) systemIndices.get( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID ); - } - - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") public Index getAliasIndex() { return ( Index ) systemIndices.get( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ); Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/IndexEnumeration.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/IndexEnumeration.java?rev=1332268&r1=1332267&r2=1332268&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/IndexEnumeration.java (original) +++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/IndexEnumeration.java Mon Apr 30 15:59:22 2012 @@ -170,7 +170,7 @@ public class IndexEnumeration impleme // If regex is null just transfer into prefetched from tmp record // but if it is not then use it to match. Successful match shorts // while loop. - if ( null == re || re.matcher( ( String ) tmp.getValue() ).matches() ) + if ( null == re || re.matcher( ( String ) tmp.getKey() ).matches() ) { prefetched.copy( tmp ); return; Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractIndexEntry.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractIndexEntry.java?rev=1332268&r1=1332267&r2=1332268&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractIndexEntry.java (original) +++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractIndexEntry.java Mon Apr 30 15:59:22 2012 @@ -28,10 +28,10 @@ import org.apache.directory.shared.ldap. * Abstract class managing the object for index entries. * * @author Apache Directory Project - * @param The value stored in the Tuple, associated key for the object + * @param The key stored in the Tuple, associated key for the object * @param The ID of the object */ -public abstract class AbstractIndexEntry implements IndexEntry +public abstract class AbstractIndexEntry implements IndexEntry { /** The referenced Entry if loaded from the store */ private Entry entry; @@ -51,13 +51,13 @@ public abstract class AbstractIndexEntry /** * {@inheritDoc} */ - public abstract V getValue(); + public abstract K getKey(); /** * {@inheritDoc} */ - public abstract void setValue( V value ); + public abstract void setKey( K value ); /** @@ -108,7 +108,7 @@ public abstract class AbstractIndexEntry /** * {@inheritDoc} */ - public void copy( IndexEntry entry ) + public void copy( IndexEntry entry ) { this.entry = entry.getEntry(); } Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ForwardIndexEntry.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ForwardIndexEntry.java?rev=1332268&r1=1332267&r2=1332268&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ForwardIndexEntry.java (original) +++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ForwardIndexEntry.java Mon Apr 30 15:59:22 2012 @@ -29,13 +29,13 @@ import org.apache.directory.shared.ldap. * indexed Entry if one has already been loaded. * * @author Apache Directory Project - * @param The value stored in the Tuple, associated key for the object + * @param The key stored in the Tuple, associated key for the object * @param The ID of the object */ -public class ForwardIndexEntry extends AbstractIndexEntry +public class ForwardIndexEntry extends AbstractIndexEntry { /** The underlying Tuple */ - private final Tuple tuple = new Tuple(); + private final Tuple tuple = new Tuple(); /** @@ -55,7 +55,7 @@ public class ForwardIndexEntry ex * @param tuple the tuple for the ForwardIndexEntry * @param entry the resuscitated Entry if any */ - public void setTuple( Tuple tuple, Entry entry ) + public void setTuple( Tuple tuple, Entry entry ) { setEntry( entry ); this.tuple.setKey( tuple.getKey() ); @@ -75,7 +75,7 @@ public class ForwardIndexEntry ex /** * {@inheritDoc} */ - public V getValue() + public K getKey() { return tuple.getKey(); } @@ -93,7 +93,7 @@ public class ForwardIndexEntry ex /** * {@inheritDoc} */ - public void setValue( V value ) + public void setKey( K value ) { tuple.setKey( value ); } @@ -102,7 +102,7 @@ public class ForwardIndexEntry ex /** * {@inheritDoc} */ - public Tuple getTuple() + public Tuple getTuple() { return tuple; } @@ -122,10 +122,10 @@ public class ForwardIndexEntry ex /** * {@inheritDoc} */ - public void copy( IndexEntry entry ) + public void copy( IndexEntry entry ) { super.copy( entry ); - tuple.setKey( entry.getValue() ); + tuple.setKey( entry.getKey() ); tuple.setValue( entry.getId() ); } Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/IndexEntry.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/IndexEntry.java?rev=1332268&r1=1332267&r2=1332268&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/IndexEntry.java (original) +++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/IndexEntry.java Mon Apr 30 15:59:22 2012 @@ -26,29 +26,29 @@ import org.apache.directory.shared.ldap. /** * Interface for index entries. An index entry associate an Entry with - * a value (the key) and the Entry ID in the table where it's stored. The Entry + * a key and the Entry ID in the table where it's stored. The Entry * may be present in this instance once we read it from the table. * * @author Apache Directory Project * @param The value stored in the Tuple, associated key for the object * @param The ID of the object */ -public interface IndexEntry +public interface IndexEntry { /** - * Gets the value referred to by this IndexEntry. + * Gets the key referred to by this IndexEntry. * - * @return the value of the Entry referred to + * @return the key of the Entry referred to */ - V getValue(); + K getKey(); /** - * Sets the value referred to by this IndexEntry. + * Sets the key referred to by this IndexEntry. * - * @param value the value of the Entry referred to + * @param key the key of the Entry referred to */ - void setValue( V value ); + void setKey( K key ); /** @@ -102,5 +102,5 @@ public interface IndexEntry * * @param entry the entry to copy fields of */ - void copy( IndexEntry entry ); + void copy( IndexEntry entry ); } Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java?rev=1332268&r1=1332267&r2=1332268&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java (original) +++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/ParentIdAndRdn.java Mon Apr 30 15:59:22 2012 @@ -125,7 +125,7 @@ public class ParentIdAndRdn