From commits-return-15652-apmail-directory-commits-archive=directory.apache.org@directory.apache.org Mon Oct 01 00:42:35 2007 Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 92198 invoked from network); 1 Oct 2007 00:42:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 Oct 2007 00:42:34 -0000 Received: (qmail 48460 invoked by uid 500); 1 Oct 2007 00:42:24 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 48423 invoked by uid 500); 1 Oct 2007 00:42:24 -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 48411 invoked by uid 99); 1 Oct 2007 00:42:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 Sep 2007 17:42:24 -0700 X-ASF-Spam-Status: No, hits=-98.8 required=10.0 tests=ALL_TRUSTED,DNS_FROM_DOB,RCVD_IN_DOB X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Oct 2007 00:42:25 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 16B7B1A9832; Sun, 30 Sep 2007 17:42:02 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r580816 [1/2] - in /directory/apacheds/branches/bigbang: core-unit/src/main/java/org/apache/directory/server/core/unit/ core-unit/src/test/java/org/apache/directory/server/core/ core-unit/src/test/java/org/apache/directory/server/core/confi... Date: Mon, 01 Oct 2007 00:41:56 -0000 To: commits@directory.apache.org From: akarasulu@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071001004205.16B7B1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: akarasulu Date: Sun Sep 30 17:41:53 2007 New Revision: 580816 URL: http://svn.apache.org/viewvc?rev=580816&view=rev Log: removed PartitionConfiguration: now filling StartupConfigurations with actual Partitions Removed: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/MutablePartitionConfiguration.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/PartitionConfiguration.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartitionConfiguration.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/MutableBTreePartitionConfiguration.java Modified: directory/apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractPerformanceTest.java directory/apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractTestCase.java directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/SearchOpsITest.java directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/configuration/DirectoryPartitionConfigurationITest.java directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/MixedCaseITest.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/AddPartitionConfiguration.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/Configuration.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/MutableStartupConfiguration.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/StartupConfiguration.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/AddContextPartitionOperationContext.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/AbstractContextFactory.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/Partition.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultOptimizer.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/NoOpOptimizer.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/tree/LeafNode.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/referral/ReferralService.java directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java directory/apacheds/branches/bigbang/mitosis/src/main/java/org/apache/directory/mitosis/operation/Operation.java directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/MutableServerStartupConfiguration.java directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/dumpcmd/DumpCommandExecutor.java directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/DIRSERVER951ITest.java directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/KeyDerivationServiceITest.java directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/MiscTest.java directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/NegationOperatorITest.java directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/NtpITest.java directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/PasswordPolicyServiceITest.java directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/SaslBindITest.java directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/SaslGssapiBindITest.java directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/jndi/ServerContextFactoryTest.java Modified: directory/apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractPerformanceTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractPerformanceTest.java?rev=580816&r1=580815&r2=580816&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractPerformanceTest.java (original) +++ directory/apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractPerformanceTest.java Sun Sep 30 17:41:53 2007 @@ -20,11 +20,11 @@ package org.apache.directory.server.core.unit; -import org.apache.directory.server.core.configuration.PartitionConfiguration; +import org.apache.directory.server.core.partition.Partition; import org.apache.directory.server.core.partition.PartitionNexus; import org.apache.directory.server.core.partition.impl.btree.Index; -import org.apache.directory.server.core.partition.impl.btree.MutableBTreePartitionConfiguration; import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex; +import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition; import org.apache.directory.shared.ldap.constants.SchemaConstants; import org.apache.directory.shared.ldap.ldif.ChangeType; import org.apache.directory.shared.ldap.ldif.Entry; @@ -146,14 +146,14 @@ attributes.put( "ou", "test" ); // Add apache.org paritition since all work will be done here - MutableBTreePartitionConfiguration partConfig = new MutableBTreePartitionConfiguration(); - partConfig.setIndexedAttributes( indexedAttributes ); - partConfig.setName( "test" ); - partConfig.setSuffix( "ou=test" ); - partConfig.setContextEntry( attributes ); + JdbmPartition partition = new JdbmPartition(); + partition.setIndexedAttributes( indexedAttributes ); + partition.setId( "test" ); + partition.setSuffix( "ou=test" ); + partition.setContextEntry( attributes ); configuration.setShutdownHookEnabled( false ); - configuration.setPartitionConfigurations( Collections.singleton( ( PartitionConfiguration ) partConfig ) ); + configuration.setPartitions( Collections.singleton( partition ) ); super.setUp(); Modified: directory/apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractTestCase.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractTestCase.java?rev=580816&r1=580815&r2=580816&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractTestCase.java (original) +++ directory/apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractTestCase.java Sun Sep 30 17:41:53 2007 @@ -162,11 +162,8 @@ // ------------------------------------------------------------------- LdifReader reader = new LdifReader(); - List entries = reader.parseLdif( LDIF ); - Entry entry = ( Entry ) entries.get(0); - testEntries.add( entry ); // ------------------------------------------------------------------- Modified: directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/SearchOpsITest.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/SearchOpsITest.java?rev=580816&r1=580815&r2=580816&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/SearchOpsITest.java (original) +++ directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/SearchOpsITest.java Sun Sep 30 17:41:53 2007 @@ -21,8 +21,8 @@ import org.apache.directory.server.core.partition.impl.btree.Index; -import org.apache.directory.server.core.partition.impl.btree.MutableBTreePartitionConfiguration; import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex; +import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition; import org.apache.directory.server.core.unit.AbstractAdminTestCase; import org.apache.directory.shared.ldap.message.AttributeImpl; import org.apache.directory.shared.ldap.message.AttributesImpl; @@ -62,19 +62,19 @@ if ( getName().indexOf( "WithIndices" ) != -1 ) { - MutableBTreePartitionConfiguration sysConf = new MutableBTreePartitionConfiguration(); - sysConf.setName( "system" ); + JdbmPartition partition = new JdbmPartition(); + partition.setId( "system" ); Attributes attrs = new AttributesImpl( "objectClass", "top", true ); attrs.get( "objectClass" ).add( "organizationalUnit" ); attrs.put( "ou", "system" ); - sysConf.setContextEntry( attrs ); - sysConf.setSuffix( "ou=system" ); + partition.setContextEntry( attrs ); + partition.setSuffix( "ou=system" ); Set indices = new HashSet(); - indices.addAll( sysConf.getIndexedAttributes() ); + indices.addAll( partition.getIndexedAttributes() ); indices.add( new JdbmIndex( "gidNumber" ) ); - sysConf.setIndexedAttributes( indices ); - configuration.setSystemPartitionConfiguration( sysConf ); + partition.setIndexedAttributes( indices ); + configuration.setSystemPartition( partition ); } super.setUp(); Modified: directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/configuration/DirectoryPartitionConfigurationITest.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/configuration/DirectoryPartitionConfigurationITest.java?rev=580816&r1=580815&r2=580816&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/configuration/DirectoryPartitionConfigurationITest.java (original) +++ directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/configuration/DirectoryPartitionConfigurationITest.java Sun Sep 30 17:41:53 2007 @@ -20,21 +20,18 @@ package org.apache.directory.server.core.configuration; -import java.util.Hashtable; +import junit.framework.Assert; +import org.apache.directory.server.core.jndi.CoreContextFactory; +import org.apache.directory.server.core.partition.Partition; +import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition; +import org.apache.directory.server.core.unit.AbstractAdminTestCase; +import org.apache.directory.shared.ldap.message.AttributesImpl; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NameNotFoundException; import javax.naming.directory.Attributes; - -import junit.framework.Assert; - -import org.apache.directory.server.core.configuration.AddPartitionConfiguration; -import org.apache.directory.server.core.configuration.MutablePartitionConfiguration; -import org.apache.directory.server.core.configuration.RemovePartitionConfiguration; -import org.apache.directory.server.core.jndi.CoreContextFactory; -import org.apache.directory.server.core.unit.AbstractAdminTestCase; -import org.apache.directory.shared.ldap.message.AttributesImpl; +import java.util.Hashtable; /** @@ -53,16 +50,16 @@ public void testAddAndRemove() throws Exception { - MutablePartitionConfiguration partitionCfg = new MutablePartitionConfiguration(); - partitionCfg.setName( "removable" ); - partitionCfg.setSuffix( "ou=removable" ); + Partition partition = new JdbmPartition(); + partition.setId( "removable" ); + partition.setSuffix( "ou=removable" ); Attributes ctxEntry = new AttributesImpl( true ); ctxEntry.put( "objectClass", "top" ); ctxEntry.put( "ou", "removable" ); - partitionCfg.setContextEntry( ctxEntry ); + partition.setContextEntry( ctxEntry ); // Test AddContextPartition - AddPartitionConfiguration addCfg = new AddPartitionConfiguration( partitionCfg ); + AddPartitionConfiguration addCfg = new AddPartitionConfiguration( partition ); Hashtable env = new Hashtable(); env.put( Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() ); Modified: directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/MixedCaseITest.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/MixedCaseITest.java?rev=580816&r1=580815&r2=580816&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/MixedCaseITest.java (original) +++ directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/MixedCaseITest.java Sun Sep 30 17:41:53 2007 @@ -20,10 +20,10 @@ package org.apache.directory.server.core.jndi; -import org.apache.directory.server.core.configuration.MutablePartitionConfiguration; +import org.apache.directory.server.core.partition.Partition; import org.apache.directory.server.core.partition.impl.btree.Index; -import org.apache.directory.server.core.partition.impl.btree.MutableBTreePartitionConfiguration; import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex; +import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition; import org.apache.directory.server.core.unit.AbstractAdminTestCase; import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException; import org.apache.directory.shared.ldap.message.AttributeImpl; @@ -51,9 +51,8 @@ public void setUp() throws Exception { - - MutableBTreePartitionConfiguration partition = new MutableBTreePartitionConfiguration(); - partition.setName( "apache" ); + JdbmPartition partition = new JdbmPartition(); + partition.setId( "apache" ); partition.setSuffix( suffix ); HashSet indexedAttributes = new HashSet(); @@ -72,10 +71,10 @@ partition.setContextEntry( attrs ); - Set partitions = new HashSet(); + Set partitions = new HashSet(); partitions.add( partition ); - configuration.setPartitionConfigurations( partitions ); + configuration.setPartitions( partitions ); super.overrideEnvironment( Context.PROVIDER_URL, suffix ); super.setUp(); Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=580816&r1=580815&r2=580816&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java (original) +++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java Sun Sep 30 17:41:53 2007 @@ -23,7 +23,6 @@ import org.apache.directory.server.core.authz.AuthorizationService; import org.apache.directory.server.core.configuration.Configuration; import org.apache.directory.server.core.configuration.ConfigurationException; -import org.apache.directory.server.core.configuration.PartitionConfiguration; import org.apache.directory.server.core.configuration.StartupConfiguration; import org.apache.directory.server.core.interceptor.Interceptor; import org.apache.directory.server.core.interceptor.InterceptorChain; @@ -35,10 +34,10 @@ import org.apache.directory.server.core.jndi.DeadContext; import org.apache.directory.server.core.jndi.ServerLdapContext; import org.apache.directory.server.core.partition.DefaultPartitionNexus; +import org.apache.directory.server.core.partition.Partition; import org.apache.directory.server.core.partition.PartitionNexus; -import org.apache.directory.server.core.partition.impl.btree.BTreePartitionConfiguration; +import org.apache.directory.server.core.partition.impl.btree.BTreePartition; import org.apache.directory.server.core.partition.impl.btree.Index; -import org.apache.directory.server.core.partition.impl.btree.MutableBTreePartitionConfiguration; import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex; import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition; import org.apache.directory.server.core.schema.PartitionSchemaLoader; @@ -833,11 +832,11 @@ // -------------------------------------------------------------------- // Initialize schema partition // -------------------------------------------------------------------- - - MutableBTreePartitionConfiguration schemaPartitionConfig = new MutableBTreePartitionConfiguration(); - schemaPartitionConfig.setName( "schema" ); - schemaPartitionConfig.setCacheSize( 1000 ); - + + JdbmPartition schemaPartition = new JdbmPartition(); + schemaPartition.setId( "schema" ); + schemaPartition.setCacheSize( 1000 ); + DbFileListing listing = null; try { @@ -855,16 +854,15 @@ indexedAttributes.add( new JdbmIndex( attributeId ) ); } - schemaPartitionConfig.setIndexedAttributes( indexedAttributes ); - schemaPartitionConfig.setSuffix( "ou=schema" ); + schemaPartition.setIndexedAttributes( indexedAttributes ); + schemaPartition.setSuffix( "ou=schema" ); Attributes entry = new AttributesImpl(); entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC ); entry.get( SchemaConstants.OBJECT_CLASS_AT ).add( SchemaConstants.ORGANIZATIONAL_UNIT_OC ); entry.put( SchemaConstants.OU_AT, "schema" ); - schemaPartitionConfig.setContextEntry( entry ); - JdbmPartition schemaPartition = new JdbmPartition(); - schemaPartition.init( configuration, schemaPartitionConfig ); + schemaPartition.setContextEntry( entry ); + schemaPartition.init( configuration ); // -------------------------------------------------------------------- // Enable schemas of all indices of partition configurations @@ -879,25 +877,15 @@ SchemaPartitionDao dao = new SchemaPartitionDao( schemaPartition, registries ); Map schemaMap = dao.getSchemas(); - PartitionConfiguration pc = startupConfiguration.getSystemPartitionConfiguration(); - Set pcs = new HashSet(); - if ( pc != null ) - { - pcs.add( pc ); - } - else - { - log.warn( "Encountered null configuration." ); - } - - - pcs.addAll( startupConfiguration.getPartitionConfigurations() ); - - for ( PartitionConfiguration pconf : pcs ) + Set partitions = new HashSet(); + partitions.add( startupConfiguration.getSystemPartition() ); + partitions.addAll( startupConfiguration.getPartitions() ); + + for ( Partition partition : partitions ) { - if ( pconf instanceof BTreePartitionConfiguration ) + if ( partition instanceof BTreePartition ) { - BTreePartitionConfiguration btpconf = ( BTreePartitionConfiguration ) pconf; + JdbmPartition btpconf = ( JdbmPartition ) partition; Iterator indices = btpconf.getIndexedAttributes().iterator(); while ( indices.hasNext() ) { @@ -996,9 +984,8 @@ } partitionNexus = new DefaultPartitionNexus( new AttributesImpl() ); - partitionNexus.init( configuration, null ); - partitionNexus.addContextPartition( - new AddContextPartitionOperationContext( schemaPartitionConfig, schemaPartition ) ); + partitionNexus.init( configuration ); + partitionNexus.addContextPartition( new AddContextPartitionOperationContext( schemaPartition ) ); interceptorChain = new InterceptorChain(); interceptorChain.init( configuration ); Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/AddPartitionConfiguration.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/AddPartitionConfiguration.java?rev=580816&r1=580815&r2=580816&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/AddPartitionConfiguration.java (original) +++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/AddPartitionConfiguration.java Sun Sep 30 17:41:53 2007 @@ -19,6 +19,9 @@ */ package org.apache.directory.server.core.configuration; +import org.apache.directory.server.core.partition.Partition; +import org.apache.directory.server.core.partition.PartitionNexus; + /** * A {@link Configuration} that adds a new {@link Partition} to @@ -33,28 +36,22 @@ { private static final long serialVersionUID = -6690435863387769527L; - private final PartitionConfiguration directoryPartitionConfiguration; + private final Partition partition; - public AddPartitionConfiguration(PartitionConfiguration directoryPartitionConfiguration) + public AddPartitionConfiguration( Partition partition ) { - if ( directoryPartitionConfiguration == null ) + if ( partition == null ) { throw new NullPointerException( "directoryPartitionConfiguration" ); } - this.directoryPartitionConfiguration = directoryPartitionConfiguration; - } - - - public PartitionConfiguration getDirectoryPartitionConfiguration() - { - return directoryPartitionConfiguration; + this.partition = partition; } - public void validate() + public Partition getPartition() { - directoryPartitionConfiguration.validate(); + return partition; } } Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/Configuration.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/Configuration.java?rev=580816&r1=580815&r2=580816&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/Configuration.java (original) +++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/Configuration.java Sun Sep 30 17:41:53 2007 @@ -20,6 +20,8 @@ package org.apache.directory.server.core.configuration; +import org.apache.directory.server.core.DirectoryService; + import java.io.Serializable; import java.util.Hashtable; Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/MutableStartupConfiguration.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/MutableStartupConfiguration.java?rev=580816&r1=580815&r2=580816&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/MutableStartupConfiguration.java (original) +++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/MutableStartupConfiguration.java Sun Sep 30 17:41:53 2007 @@ -20,12 +20,13 @@ package org.apache.directory.server.core.configuration; +import org.apache.directory.server.core.authn.Authenticator; +import org.apache.directory.server.core.partition.Partition; + import java.io.File; import java.util.List; import java.util.Set; -import org.apache.directory.server.core.authn.Authenticator; - /** * A mutable version of {@link StartupConfiguration}. @@ -58,9 +59,9 @@ } - public void setSystemPartitionConfiguration( PartitionConfiguration systemPartitionConfiguration ) + public void setSystemPartition( Partition systemPartition ) { - super.setSystemPartitionConfiguration( systemPartitionConfiguration ); + super.setSystemPartition( systemPartition ); } @@ -80,9 +81,9 @@ * * @param paritionConfigurations partitions to start */ - public void setPartitionConfigurations( Set paritionConfigurations ) + public void setPartitions( Set paritionConfigurations ) { - super.setPartitionConfigurations( paritionConfigurations ); + super.setPartitions( paritionConfigurations ); } Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/StartupConfiguration.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/StartupConfiguration.java?rev=580816&r1=580815&r2=580816&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/StartupConfiguration.java (original) +++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/configuration/StartupConfiguration.java Sun Sep 30 17:41:53 2007 @@ -34,10 +34,11 @@ import org.apache.directory.server.core.authz.DefaultAuthorizationService; import org.apache.directory.server.core.collective.CollectiveAttributeService; import org.apache.directory.server.core.event.EventService; +import org.apache.directory.server.core.normalization.NormalizationService; import org.apache.directory.server.core.exception.ExceptionService; import org.apache.directory.server.core.interceptor.Interceptor; -import org.apache.directory.server.core.normalization.NormalizationService; import org.apache.directory.server.core.operational.OperationalAttributeService; +import org.apache.directory.server.core.partition.Partition; import org.apache.directory.server.core.referral.ReferralService; import org.apache.directory.server.core.schema.SchemaService; import org.apache.directory.server.core.subtree.SubentryService; @@ -46,6 +47,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.naming.directory.Attributes; +import java.io.File; +import java.util.*; + /** * A {@link Configuration} that starts up ApacheDS. @@ -77,9 +82,8 @@ private int maxSizeLimit = MAX_SIZE_LIMIT_DEFAULT; // set to default value private int maxTimeLimit = MAX_TIME_LIMIT_DEFAULT; // set to default value (milliseconds) private List interceptors; - private PartitionConfiguration systemPartitionConfiguration; - private Set partitionConfigurations = - new HashSet(); + private Partition systemPartition; + private Set partitions = new HashSet(); private List testEntries = new ArrayList(); // List @@ -137,31 +141,30 @@ /** - * Returns {@link PartitionConfiguration}s to configure context partitions. + * Returns {@link Partition}s to configure context partitions. */ - public Set getPartitionConfigurations() + public Set getPartitions() { - Set cloned = new HashSet(); - cloned.addAll( partitionConfigurations ); + Set cloned = new HashSet(); + cloned.addAll( partitions ); return cloned; } /** - * Sets {@link PartitionConfiguration}s to configure context partitions. + * Sets {@link Partition}s to configure context partitions. */ - protected void setPartitionConfigurations( Set contextParitionConfigurations ) + protected void setPartitions( Set contextParitions ) { - Set cloned = new HashSet(); - cloned.addAll( contextParitionConfigurations ); + Set cloned = new HashSet(); + cloned.addAll( contextParitions ); Set names = new HashSet(); - Iterator i = cloned.iterator(); + Iterator i = cloned.iterator(); while ( i.hasNext() ) { - PartitionConfiguration cfg = i.next(); - cfg.validate(); + Partition p = i.next(); - String id = cfg.getName(); + String id = p.getId(); if ( names.contains( id ) ) { throw new ConfigurationException( "Duplicate partition id: " + id ); @@ -169,7 +172,7 @@ names.add( id ); } - this.partitionConfigurations = cloned; + this.partitions = cloned; } @@ -353,15 +356,15 @@ return maxTimeLimit; } - protected void setSystemPartitionConfiguration( PartitionConfiguration systemPartitionConfiguration ) + protected void setSystemPartition( Partition systemPartition ) { - this.systemPartitionConfiguration = systemPartitionConfiguration; + this.systemPartition = systemPartition; } - public PartitionConfiguration getSystemPartitionConfiguration() + public Partition getSystemPartition() { - return systemPartitionConfiguration; + return systemPartition; } Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/AddContextPartitionOperationContext.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/AddContextPartitionOperationContext.java?rev=580816&r1=580815&r2=580816&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/AddContextPartitionOperationContext.java (original) +++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/AddContextPartitionOperationContext.java Sun Sep 30 17:41:53 2007 @@ -20,14 +20,7 @@ package org.apache.directory.server.core.interceptor.context; -import javax.naming.NamingException; - -import org.apache.directory.server.core.configuration.PartitionConfiguration; import org.apache.directory.server.core.partition.Partition; -import org.apache.directory.shared.ldap.exception.LdapConfigurationException; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** @@ -41,10 +34,6 @@ */ public class AddContextPartitionOperationContext extends EmptyOperationContext { - private static final Logger log = LoggerFactory.getLogger( AddContextPartitionOperationContext.class ); - - /** The context partition configuration */ - private PartitionConfiguration partitionConfiguration; /** the instantiated partition class */ private Partition partition; @@ -52,23 +41,11 @@ /** * Creates a new instance of AddContextPartitionOperationContext. * - * @param entryDn The partition configuration to add + * @param partition The partition to add */ - public AddContextPartitionOperationContext( PartitionConfiguration cfg ) + public AddContextPartitionOperationContext( Partition partition ) { super(); - this.partitionConfiguration = cfg; - } - - - /** - * Creates a new instance of AddContextPartitionOperationContext. - * - * @param entryDn The partition configuration to add - */ - public AddContextPartitionOperationContext( PartitionConfiguration cfg, Partition partition ) - { - this( cfg ); this.partition = partition; } @@ -78,83 +55,26 @@ */ public String toString() { - return "AddContextPartitionOperationContext for partition context '" + partitionConfiguration.getName() + "'"; + return "AddContextPartitionOperationContext for partition context '" + partition.getId() + "'"; } /** - * @return The partition configuration + * @return The partition */ - public PartitionConfiguration getPartitionConfiguration() + public Partition getPartition() { - return partitionConfiguration; + return partition; } /** - * Set the partition configuration + * Set the partition. * - * @param partitionConfiguration The configuration - */ - public void setPartitionConfiguration( PartitionConfiguration partitionConfiguration ) - { - this.partitionConfiguration = partitionConfiguration; - } - - - /** - * Get's the partition instance. - * - * @return the partition to add + * @param partition the partition */ - public Partition getPartition() throws NamingException + public void setPartitionConfiguration( Partition partition ) { - if ( partition != null ) - { - return partition; - } - - if ( partitionConfiguration == null ) - { - throw new IllegalStateException( "Cannot get instance of partition without a proper " + - "partition configuration." ); - } - - Class partitionClass; - try - { - partitionClass = Class.forName( partitionConfiguration.getPartitionClassName() ); - } - catch ( ClassNotFoundException e ) - { - String msg = "Could not load partition implementation class '" - + partitionConfiguration.getPartitionClassName() + "' for partition with id " - + partitionConfiguration.getName(); - log.error( msg ); - throw new LdapConfigurationException( msg, e ); - } - - try - { - partition = ( Partition ) partitionClass.newInstance(); - } - catch ( InstantiationException e ) - { - String msg = "No default constructor in partition implementation class '" - + partitionConfiguration.getPartitionClassName() + "' for partition with id " - + partitionConfiguration.getName(); - log.error( msg ); - throw new LdapConfigurationException( msg, e ); - } - catch ( IllegalAccessException e ) - { - String msg = "Default constructor for partition implementation class '" - + partitionConfiguration.getPartitionClassName() + "' for partition with id " - + partitionConfiguration.getName() + " is not publicly accessible."; - log.error( msg ); - throw new LdapConfigurationException( msg, e ); - } - - return partition; + this.partition = partition; } } Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/AbstractContextFactory.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/AbstractContextFactory.java?rev=580816&r1=580815&r2=580816&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/AbstractContextFactory.java (original) +++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/AbstractContextFactory.java Sun Sep 30 17:41:53 2007 @@ -128,7 +128,7 @@ else if ( cfg instanceof AddPartitionConfiguration ) { AddContextPartitionOperationContext ctxPartition = - new AddContextPartitionOperationContext( ( ( AddPartitionConfiguration ) cfg ).getDirectoryPartitionConfiguration() ); + new AddContextPartitionOperationContext( ( ( AddPartitionConfiguration ) cfg ).getPartition() ); Context ctx = service.getJndiContext( principalDn, principal, credential, authentication, "" ); Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java?rev=580816&r1=580815&r2=580816&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java (original) +++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java Sun Sep 30 17:41:53 2007 @@ -22,17 +22,11 @@ import javax.naming.NameNotFoundException; import javax.naming.NamingException; -import javax.naming.OperationNotSupportedException; import javax.naming.directory.Attributes; import org.apache.directory.server.core.DirectoryServiceConfiguration; -import org.apache.directory.server.core.configuration.PartitionConfiguration; import org.apache.directory.server.core.interceptor.context.EntryOperationContext; import org.apache.directory.server.core.interceptor.context.LookupOperationContext; -import org.apache.directory.server.core.interceptor.context.MoveOperationContext; -import org.apache.directory.server.core.interceptor.context.RenameOperationContext; -import org.apache.directory.server.core.interceptor.context.ReplaceOperationContext; -import org.apache.directory.shared.ldap.name.LdapDN; /** @@ -45,14 +39,10 @@ */ public abstract class AbstractPartition implements Partition { - /** {@link DirectoryServiceConfiguration} specified at {@link #init(DirectoryServiceConfiguration, PartitionConfiguration)}. */ - private DirectoryServiceConfiguration factoryCfg; - /** {@link PartitionConfiguration} specified at {@link #init(DirectoryServiceConfiguration, PartitionConfiguration)}. */ - private PartitionConfiguration cfg; + /** {@link DirectoryServiceConfiguration} specified at {@link #init(DirectoryServiceConfiguration)}. */ + protected DirectoryServiceConfiguration factoryCfg; /** true if and only if this partition is initialized. */ - private boolean initialized; - /** the normalized suffix DN for this partition */ - private LdapDN suffixDn; + protected boolean initialized; protected AbstractPartition() @@ -67,8 +57,7 @@ * without any errors. {@link #destroy()} is called automatically as a clean-up process * if {@link #doInit()} throws an exception. */ - public final void init( DirectoryServiceConfiguration factoryCfg, PartitionConfiguration cfg ) - throws NamingException + public final void init( DirectoryServiceConfiguration factoryCfg ) throws NamingException { if ( initialized ) { @@ -77,7 +66,6 @@ } this.factoryCfg = factoryCfg; - this.cfg = cfg; try { doInit(); @@ -108,12 +96,6 @@ */ public final void destroy() { - if ( cfg == null ) - { - // Already destroyed. - return; - } - try { doDestroy(); @@ -122,7 +104,6 @@ { initialized = false; factoryCfg = null; - cfg = null; } } @@ -146,7 +127,8 @@ /** * Returns {@link DirectoryServiceConfiguration} that is provided from - * {@link #init(DirectoryServiceConfiguration, PartitionConfiguration)}. + * {@link #init(DirectoryServiceConfiguration)}. + * @return return the directory service */ public final DirectoryServiceConfiguration getFactoryConfiguration() { @@ -155,28 +137,6 @@ /** - * Returns {@link PartitionConfiguration} that is provided from - * {@link #init(DirectoryServiceConfiguration, PartitionConfiguration)}. - */ - public final PartitionConfiguration getConfiguration() - { - return cfg; - } - - - public final LdapDN getSuffix() throws NamingException - { - if ( suffixDn == null ) - { - suffixDn = new LdapDN( cfg.getSuffix() ); - suffixDn.normalize( factoryCfg.getRegistries().getAttributeTypeRegistry().getNormalizerMapping() ); - } - - return suffixDn; - } - - - /** * This method does nothing by default. */ public void sync() throws NamingException @@ -210,30 +170,5 @@ public Attributes lookup( LookupOperationContext lookupContext ) throws NamingException { return null; - } - - - /** - * This method calls {@link Partition#move(MoveOperationContext)} and - * {@link Partition#rename(RenameOperationContext)} subsequently - * by default. Please override this method if there is more effactive - * way for your implementation. - */ - public void move( LdapDN oldName, LdapDN newParentName, String newRdn, boolean deleteOldRn ) throws NamingException - { - LdapDN newName = ( LdapDN ) newParentName.clone(); - newName.add( newRdn ); - move( new MoveOperationContext( oldName, newParentName ) ); - rename( new RenameOperationContext( newName, newRdn, deleteOldRn ) ); - } - - - /** - * This method throws {@link OperationNotSupportedException} by default. - * Please override this method to implement move operation. - */ - public void replace( ReplaceOperationContext replaceContext ) throws NamingException - { - throw new OperationNotSupportedException( "Moving an entry to other parent entry is not supported." ); } } Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java?rev=580816&r1=580815&r2=580816&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java (original) +++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java Sun Sep 30 17:41:53 2007 @@ -21,10 +21,8 @@ import org.apache.directory.server.core.DirectoryServiceConfiguration; -import org.apache.directory.server.core.configuration.PartitionConfiguration; import org.apache.directory.server.core.interceptor.context.*; import org.apache.directory.server.core.partition.impl.btree.Index; -import org.apache.directory.server.core.partition.impl.btree.MutableBTreePartitionConfiguration; import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex; import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition; import org.apache.directory.server.core.partition.tree.BranchNode; @@ -76,10 +74,10 @@ */ public class DefaultPartitionNexus extends PartitionNexus { - private static final Logger log = LoggerFactory.getLogger( DefaultPartitionNexus.class ); + private static final Logger LOG = LoggerFactory.getLogger( DefaultPartitionNexus.class ); /** Speedup for logs */ - private static final boolean IS_DEBUG = log.isDebugEnabled(); + private static final boolean IS_DEBUG = LOG.isDebugEnabled(); /** the vendorName string proudly set to: Apache Software Foundation*/ private static final String ASF = "Apache Software Foundation"; @@ -112,6 +110,7 @@ private AttributeTypeRegistry attrRegistry; private OidRegistry oidRegistry; + private Object partitionLookupTreeLock = new Object(); /** @@ -121,6 +120,7 @@ * attributes are added to the rootDSE. * * @see Vendor Information + * @param rootDSE the root entry for the DSA */ public DefaultPartitionNexus( Attributes rootDSE ) { @@ -176,7 +176,7 @@ } catch ( IOException e ) { - log.error( "failed to log version properties" ); + LOG.error( "failed to LOG version properties" ); } attr = new AttributeImpl( VENDORVERSION_ATTR ); @@ -185,20 +185,97 @@ } - public PartitionConfiguration getConfiguration() + /** + * Always returns the string "NEXUS". + * + * @return the string "NEXUS" + */ + public String getId() { - throw new UnsupportedOperationException( "The NEXUS partition does not have a " + - "standard partition configuration associated with it." ); + return "NEXUS"; } - - public String getId() + + // ----------------------------------------------------------------------- + // C O N F I G U R A T I O N M E T H O D S + // ----------------------------------------------------------------------- + + + /** + * Not supported! + * + * @throws UnsupportedOperationException everytime + */ + public void setId( String id ) { - return "NEXUS"; + throw new UnsupportedOperationException( "The id cannot be set for the partition nexus." ); } - - public void init( DirectoryServiceConfiguration factoryCfg, PartitionConfiguration cfg ) + + /** + * Returns root the rootDSE. + * + * @return the root entry for the DSA + */ + public Attributes getContextEntry() + { + return rootDSE; + } + + + /** + * Sets root entry for this BTreePartition. + * + * @throws UnsupportedOperationException everytime + */ + public void setContextEntry( Attributes rootEntry ) + { + throw new UnsupportedOperationException( "Setting the RootDSE is not allowed." ); + } + + + /** + * Always returns the empty String "". + * @return the empty String "" + */ + public String getSuffix() + { + return ""; + } + + + /** + * Unsupported operation on the Nexus. + * @throws UnsupportedOperationException everytime + */ + public void setSuffix( String suffix ) + { + throw new UnsupportedOperationException(); + } + + + /** + * Not support! + */ + public void setCacheSize( int cacheSize ) + { + throw new UnsupportedOperationException( "You cannot set the cache size of the nexus" ); + } + + + /** + * Not supported! + * + * @throws UnsupportedOperationException always + */ + public int getCacheSize() + { + throw new UnsupportedOperationException( "There is no cache size associated with the nexus" ); + } + + + + public void init( DirectoryServiceConfiguration factoryCfg ) throws NamingException { // NOTE: We ignore ContextPartitionConfiguration parameter here. @@ -215,14 +292,15 @@ List initializedPartitions = new ArrayList(); initializedPartitions.add( 0, this.system ); - Iterator partitionConfigurations = - ( Iterator ) factoryCfg.getStartupConfiguration().getPartitionConfigurations().iterator(); + //noinspection unchecked + Iterator partitions = + ( Iterator ) factoryCfg.getStartupConfiguration().getPartitions().iterator(); try { - while ( partitionConfigurations.hasNext() ) + while ( partitions.hasNext() ) { - PartitionConfiguration c = partitionConfigurations.next(); - AddContextPartitionOperationContext opCtx = new AddContextPartitionOperationContext( c ); + Partition p = partitions.next(); + AddContextPartitionOperationContext opCtx = new AddContextPartitionOperationContext( p ); addContextPartition( opCtx ); initializedPartitions.add( opCtx.getPartition() ); } @@ -243,7 +321,7 @@ } catch ( Exception e ) { - log.warn( "Failed to destroy a partition: " + partition.getSuffix(), e ); + LOG.warn( "Failed to destroy a partition: " + partition.getSuffixDn(), e ); } finally { @@ -255,21 +333,13 @@ } - private PartitionConfiguration initializeSystemPartition() throws NamingException + private Partition initializeSystemPartition() throws NamingException { // initialize system partition first - MutableBTreePartitionConfiguration systemCfg; - PartitionConfiguration overrides = factoryCfg.getStartupConfiguration().getSystemPartitionConfiguration(); - if ( overrides != null ) + Partition override = factoryCfg.getStartupConfiguration().getSystemPartition(); + if ( override != null ) { - systemCfg = MutableBTreePartitionConfiguration.getConfiguration( overrides ); - - // --------------------------------------------------------------- - // Add some attributes w/ some only if they're missing. Allows - // users to add more attributes to the system namingConext root - // --------------------------------------------------------------- - - Attributes systemEntry = systemCfg.getContextEntry(); + Attributes systemEntry = override.getContextEntry(); Attribute objectClassAttr = systemEntry.get( SchemaConstants.OBJECT_CLASS_AT ); if ( objectClassAttr == null ) { @@ -283,51 +353,56 @@ systemEntry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() ); systemEntry.put( NamespaceTools.getRdnAttribute( PartitionNexus.SYSTEM_PARTITION_SUFFIX ), NamespaceTools.getRdnValue( PartitionNexus.SYSTEM_PARTITION_SUFFIX ) ); - systemCfg.setContextEntry( systemEntry ); + override.setContextEntry( systemEntry ); // --------------------------------------------------------------- // check a few things to make sure users configured it properly // --------------------------------------------------------------- - if ( ! systemCfg.getName().equals( "system" ) ) + if ( ! override.getId().equals( "system" ) ) { - throw new ConfigurationException( "System partition has wrong name: should be 'system' not '" + systemCfg.getName() + "'." ); + throw new ConfigurationException( "System partition has wrong name: should be 'system' not '" + + override.getId() + "'." ); } // add all attribute oids of index configs to a hashset - Set indices = systemCfg.getIndexedAttributes(); - Set indexOids = new HashSet(); - OidRegistry registry = factoryCfg.getRegistries().getOidRegistry(); - - for ( Index index : indices ) + if ( override instanceof JdbmPartition ) { - indexOids.add( registry.getOid( index.getAttributeId() ) ); - } + Set indices = ( ( JdbmPartition ) override ).getIndexedAttributes(); + Set indexOids = new HashSet(); + OidRegistry registry = factoryCfg.getRegistries().getOidRegistry(); - if ( ! indexOids.contains( registry.getOid( SchemaConstants.OBJECT_CLASS_AT ) ) ) - { - log.warn( "CAUTION: You have not included objectClass as an indexed attribute" + - "in the system partition configuration. This will lead to poor " + - "performance. The server is automatically adding this index for you." ); - JdbmIndex index = new JdbmIndex(); - index.setAttributeId( SchemaConstants.OBJECT_CLASS_AT ); - indices.add( index ); + for ( Index index : indices ) + { + indexOids.add( registry.getOid( index.getAttributeId() ) ); + } + + if ( ! indexOids.contains( registry.getOid( SchemaConstants.OBJECT_CLASS_AT ) ) ) + { + LOG.warn( "CAUTION: You have not included objectClass as an indexed attribute" + + "in the system partition configuration. This will lead to poor " + + "performance. The server is automatically adding this index for you." ); + JdbmIndex index = new JdbmIndex(); + index.setAttributeId( SchemaConstants.OBJECT_CLASS_AT ); + indices.add( index ); + } + + ( ( JdbmPartition ) override ).setIndexedAttributes( indices ); + + system = ( JdbmPartition ) override; } } else { - systemCfg = new MutableBTreePartitionConfiguration(); - systemCfg.setName( "system" ); - - // @TODO need to make this configurable for the system partition - systemCfg.setCacheSize( 500 ); - - systemCfg.setSuffix( PartitionNexus.SYSTEM_PARTITION_SUFFIX ); + system = new JdbmPartition(); + system.setId( "system" ); + system.setCacheSize( 500 ); + system.setSuffix( PartitionNexus.SYSTEM_PARTITION_SUFFIX ); - // Add indexed attributes for system partition - Set indexedAttrs = new HashSet(); + // Add objectClass attribute for the system partition + Set indexedAttrs = new HashSet(); indexedAttrs.add( new JdbmIndex( SchemaConstants.OBJECT_CLASS_AT ) ); - systemCfg.setIndexedAttributes( indexedAttrs ); + ( ( JdbmPartition ) system ).setIndexedAttributes( indexedAttrs ); // Add context entry for system partition Attributes systemEntry = new AttributesImpl(); @@ -340,12 +415,11 @@ systemEntry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() ); systemEntry.put( NamespaceTools.getRdnAttribute( PartitionNexus.SYSTEM_PARTITION_SUFFIX ), NamespaceTools.getRdnValue( PartitionNexus.SYSTEM_PARTITION_SUFFIX ) ); - systemCfg.setContextEntry( systemEntry ); + system.setContextEntry( systemEntry ); } - system = new JdbmPartition(); // using default implementation. - system.init( factoryCfg, systemCfg ); - String key = system.getSuffix().toString(); + system.init( factoryCfg ); + String key = system.getSuffixDn().toString(); if ( partitions.containsKey( key ) ) { @@ -355,13 +429,12 @@ synchronized ( partitionLookupTree ) { partitions.put( key, system ); - partitionLookupTree.recursivelyAddPartition( partitionLookupTree, system.getSuffix(), 0, system ); - + partitionLookupTree.recursivelyAddPartition( partitionLookupTree, system.getSuffixDn(), 0, system ); Attribute namingContexts = rootDSE.get( NAMINGCTXS_ATTR ); - namingContexts.add( system.getUpSuffix().getUpName() ); + namingContexts.add( system.getUpSuffixDn().getUpName() ); } - return systemCfg; + return system; } @@ -392,7 +465,7 @@ } catch ( NamingException e ) { - log.warn( "Failed to destroy a partition: " + suffix, e ); + LOG.warn( "Failed to destroy a partition: " + suffix, e ); } } @@ -406,19 +479,16 @@ public void sync() throws NamingException { MultiException error = null; - Iterator list = this.partitions.values().iterator(); - - while ( list.hasNext() ) - { - Partition partition = list.next(); + for ( Partition partition : this.partitions.values() ) + { try { partition.sync(); } catch ( NamingException e ) { - log.warn( "Failed to flush partition data out.", e ); + LOG.warn( "Failed to flush partition data out.", e ); if ( error == null ) { error = new MultiException( "Grouping many exceptions on root nexus sync()" ); @@ -512,11 +582,10 @@ public synchronized void addContextPartition( AddContextPartitionOperationContext opContext ) throws NamingException { - PartitionConfiguration config = opContext.getPartitionConfiguration(); Partition partition = opContext.getPartition(); // Turn on default indices - String key = config.getSuffix(); + String key = partition.getSuffix(); if ( partitions.containsKey( key ) ) { @@ -525,12 +594,12 @@ if ( ! partition.isInitialized() ) { - partition.init( factoryCfg, config ); + partition.init( factoryCfg ); } synchronized ( partitionLookupTree ) { - LdapDN partitionSuffix = partition.getSuffix(); + LdapDN partitionSuffix = partition.getSuffixDn(); if ( partitionSuffix == null ) { @@ -538,7 +607,7 @@ } partitions.put( partitionSuffix.toString(), partition ); - partitionLookupTree.recursivelyAddPartition( partitionLookupTree, partition.getSuffix(), 0, partition ); + partitionLookupTree.recursivelyAddPartition( partitionLookupTree, partition.getSuffixDn(), 0, partition ); Attribute namingContexts = rootDSE.get( NAMINGCTXS_ATTR ); @@ -547,7 +616,7 @@ throw new ConfigurationException( "The current partition does not have any suffix: " + partition.getId() ); } - LdapDN partitionUpSuffix = partition.getUpSuffix(); + LdapDN partitionUpSuffix = partition.getUpSuffixDn(); if ( partitionUpSuffix == null ) { @@ -570,7 +639,7 @@ } Attribute namingContexts = rootDSE.get( NAMINGCTXS_ATTR ); - namingContexts.remove( partition.getUpSuffix().getUpName() ); + namingContexts.remove( partition.getUpSuffixDn().getUpName() ); // Create a new partition list. // This is easier to create a new structure from scratch than to reorganize @@ -583,7 +652,7 @@ for ( Partition part : partitions.values() ) { - partitionLookupTree.recursivelyAddPartition( partitionLookupTree, part.getSuffix(), 0, partition ); + partitionLookupTree.recursivelyAddPartition( partitionLookupTree, part.getSuffixDn(), 0, partition ); } partition.sync(); @@ -628,12 +697,12 @@ } - public LdapDN getSuffix() + public LdapDN getSuffixDn() { return LdapDN.EMPTY_LDAPDN; } - public LdapDN getUpSuffix() + public LdapDN getUpSuffixDn() { return LdapDN.EMPTY_LDAPDN; } @@ -645,7 +714,7 @@ public LdapDN getSuffix ( GetSuffixOperationContext getSuffixContext ) throws NamingException { Partition backend = getPartition( getSuffixContext.getDn() ); - return backend.getSuffix(); + return backend.getSuffixDn(); } @@ -679,8 +748,8 @@ private void unregister( Partition partition ) throws NamingException { Attribute namingContexts = rootDSE.get( NAMINGCTXS_ATTR ); - namingContexts.remove( partition.getSuffix().getUpName() ); - partitions.remove( partition.getSuffix().toString() ); + namingContexts.remove( partition.getSuffixDn().getUpName() ); + partitions.remove( partition.getSuffixDn().toString() ); } @@ -940,7 +1009,7 @@ if ( IS_DEBUG ) { - log.debug( "Check if DN '" + dn + "' exists." ); + LOG.debug( "Check if DN '" + dn + "' exists." ); } if ( dn.size() == 0 ) @@ -994,7 +1063,7 @@ // This is synchronized so that we can't read the // partitionList when it is modified. - synchronized ( partitionLookupTree ) + synchronized ( partitionLookupTreeLock ) { // Iterate through all the RDN until we find the associated partition while ( rdns.hasMoreElements() ) @@ -1041,9 +1110,10 @@ supportedExtension = new AttributeImpl( "supportedExtension" ); rootDSE.put( supportedExtension ); } - for ( Iterator oids = extensionOids.iterator(); oids.hasNext(); ) + + for ( String extensionOid : extensionOids ) { - supportedExtension.add( oids.next() ); + supportedExtension.add( extensionOid ); } } } Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/Partition.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/Partition.java?rev=580816&r1=580815&r2=580816&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/Partition.java (original) +++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/Partition.java Sun Sep 30 17:41:53 2007 @@ -27,7 +27,6 @@ import javax.naming.directory.SearchResult; import org.apache.directory.server.core.DirectoryServiceConfiguration; -import org.apache.directory.server.core.configuration.PartitionConfiguration; import org.apache.directory.server.core.interceptor.context.AddOperationContext; import org.apache.directory.server.core.interceptor.context.BindOperationContext; import org.apache.directory.server.core.interceptor.context.DeleteOperationContext; @@ -56,26 +55,98 @@ */ public interface Partition { - /** - * Get's the configuration for this partition. - * - * @return the configuration for this partition. - */ - PartitionConfiguration getConfiguration(); + /** The name of reserved system partition */ + String SYSTEM_PARTITION_NAME = "system"; + /** default partition implementation class */ + String DEFAULT_PARTITION_IMPLEMENTATION = "org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition"; + /** the default entry cache size to use for a partition */ + int DEFAULT_CACHE_SIZE = 10000; + + // ----------------------------------------------------------------------- + // C O N F I G U R A T I O N M E T H O D S + // ----------------------------------------------------------------------- + /** - * Get's the unique identifier for this partition. + * Gets the unique identifier for this partition. * * @return the unique identifier for this partition */ String getId(); - - + + + /** + * Sets the unique identifier for this partition. + * + * @param id the unique identifier for this partition + */ + void setId( String id ); + + + /** + * Gets the root entry of the partition, the entry for the suffix. + * + * @return the entry for the suffix of this Partition. + */ + Attributes getContextEntry(); + + + /** + * Sets the root entry of the partition, the entry for the suffix. + * + * @param contextEntry the entry for the suffix of this Partition. + */ + void setContextEntry( Attributes contextEntry ); + + + /** + * Gets the non-normalized suffix for this Partition as a string. + * + * @return the suffix string for this Partition. + */ + String getSuffix(); + + + /** + * Sets the non-normalized suffix for this Partition as a string. + * + * @param suffix the suffix string for this Partition. + */ + void setSuffix( String suffix ); + + + + /** + * Used to specify the entry cache size for a Partition. Various Partition + * implementations may interpret this value in different ways: i.e. total cache + * size limit verses the number of entries to cache. + * + * @param cacheSize the size of the cache + */ + void setCacheSize( int cacheSize ); + + + /** + * Gets the entry cache size for this partition. + * + * @return the size of the cache + */ + int getCacheSize(); + + + // ----------------------------------------------------------------------- + // E N D C O N F I G U R A T I O N M E T H O D S + // ----------------------------------------------------------------------- + + /** * Initializes this partition. + * + * @param factoryCfg the configuration for the server. + * @throws NamingException if initialization fails in any way */ - void init( DirectoryServiceConfiguration factoryCfg, PartitionConfiguration cfg ) throws NamingException; + void init( DirectoryServiceConfiguration factoryCfg ) throws NamingException; /** @@ -86,12 +157,14 @@ /** * Checks to see if this partition is initialized or not. + * @return true if the partition is initialized, false otherwise */ boolean isInitialized(); /** * Flushes any changes made to this partition now. + * @throws NamingException if buffers cannot be flushed to disk */ void sync() throws NamingException; @@ -102,8 +175,9 @@ * * @return Name representing the distinguished/absolute name of this * ContextPartitions root context. + * @throws NamingException if access or suffix parsing fails */ - LdapDN getSuffix() throws NamingException; + LdapDN getSuffixDn() throws NamingException; /** * Gets the distinguished/absolute name of the suffix for all entries @@ -111,8 +185,9 @@ * * @return Name representing the distinguished/absolute name of this * ContextPartitions root context. + * @throws NamingException if access or suffix parsing fails */ - LdapDN getUpSuffix() throws NamingException; + LdapDN getUpSuffixDn() throws NamingException; /** * Deletes a leaf entry from this ContextPartition: non-leaf entries cannot be Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java?rev=580816&r1=580815&r2=580816&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java (original) +++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java Sun Sep 30 17:41:53 2007 @@ -44,7 +44,6 @@ import org.apache.directory.server.core.authn.AuthenticationService; import org.apache.directory.server.core.authz.AuthorizationService; import org.apache.directory.server.core.authz.DefaultAuthorizationService; -import org.apache.directory.server.core.configuration.PartitionConfiguration; import org.apache.directory.server.core.enumeration.SearchResultFilter; import org.apache.directory.server.core.enumeration.SearchResultFilteringEnumeration; import org.apache.directory.server.core.event.EventService; @@ -219,14 +218,49 @@ } - public PartitionConfiguration getConfiguration() + public void setId( String id ) { - throw new UnsupportedOperationException( "Nexus partition proxy objects do not have a " + - "partition configuration." ); + throw new UnsupportedOperationException( "Not supported by PartitionNexusProxy" ); } - public void init( DirectoryServiceConfiguration factoryCfg, PartitionConfiguration cfg ) throws NamingException + public Attributes getContextEntry() + { + throw new UnsupportedOperationException( "Not supported by PartitionNexusProxy" ); + } + + + public void setContextEntry( Attributes contextEntry ) + { + throw new UnsupportedOperationException( "Not supported by PartitionNexusProxy" ); + } + + + public String getSuffix() + { + throw new UnsupportedOperationException( "Not supported by PartitionNexusProxy" ); + } + + + public void setSuffix( String suffix ) + { + throw new UnsupportedOperationException( "Not supported by PartitionNexusProxy" ); + } + + + public void setCacheSize( int cacheSize ) + { + throw new UnsupportedOperationException( "Not supported by PartitionNexusProxy" ); + } + + + public int getCacheSize() + { + throw new UnsupportedOperationException( "Not supported by PartitionNexusProxy" ); + } + + + public void init( DirectoryServiceConfiguration factoryCfg ) throws NamingException { } @@ -248,14 +282,14 @@ } - public LdapDN getSuffix() throws NamingException + public LdapDN getSuffixDn() throws NamingException { - return this.configuration.getPartitionNexus().getSuffix(); + return this.configuration.getPartitionNexus().getSuffixDn(); } - public LdapDN getUpSuffix() throws NamingException + public LdapDN getUpSuffixDn() throws NamingException { - return this.configuration.getPartitionNexus().getUpSuffix(); + return this.configuration.getPartitionNexus().getUpSuffixDn(); } @@ -312,7 +346,7 @@ ensureStarted(); InvocationStack stack = InvocationStack.getInstance(); Object[] args = new Object[] {opContext}; - stack.push( new Invocation( this, caller, "getSuffix", args, bypass ) ); + stack.push( new Invocation( this, caller, "getSuffixDn", args, bypass ) ); try { return this.configuration.getInterceptorChain().getSuffix( opContext ); Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java?rev=580816&r1=580815&r2=580816&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java (original) +++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java Sun Sep 30 17:41:53 2007 @@ -53,7 +53,7 @@ */ public abstract class BTreePartition implements Partition { - protected final static Set SYS_INDEX_OIDS; + protected static final Set SYS_INDEX_OIDS; static { @@ -71,16 +71,22 @@ /** the search engine used to search the database */ protected SearchEngine searchEngine; protected Optimizer optimizer; - protected BTreePartitionConfiguration cfg; - + protected AttributeTypeRegistry attributeTypeRegistry; protected OidRegistry oidRegistry; + protected String id; + protected int cacheSize = -1; + protected LdapDN suffixDn; + protected String suffix; + protected Attributes contextEntry = new AttributesImpl( true ); + // ------------------------------------------------------------------------ // C O N S T R U C T O R S // ------------------------------------------------------------------------ + /** * Creates a B-tree based context partition. */ @@ -89,18 +95,84 @@ } - public BTreePartitionConfiguration getConfiguration() + // ------------------------------------------------------------------------ + // C O N F I G U R A T I O N M E T H O D S + // ------------------------------------------------------------------------ + + + /** + * Used to specify the entry cache size for a Partition. Various Partition + * implementations may interpret this value in different ways: i.e. total cache + * size limit verses the number of entries to cache. + * + * @param cacheSize the maximum size of the cache in the number of entries + */ + public void setCacheSize( int cacheSize ) { - return cfg; + this.cacheSize = cacheSize; } - - + + + /** + * Gets the entry cache size for this BTreePartition. + * + * @return the maximum size of the cache as the number of entries maximum before paging out + */ + public int getCacheSize() + { + return cacheSize; + } + + + /** + * Returns root entry for this BTreePartition. + * + * @return the root suffix entry for this BTreePartition + */ + public Attributes getContextEntry() + { + return ( Attributes ) contextEntry.clone(); + } + + + /** + * Sets root entry for this BTreePartition. + * + * @param rootEntry the root suffix entry of this BTreePartition + */ + public void setContextEntry( Attributes rootEntry ) + { + this.contextEntry = ( Attributes ) rootEntry.clone(); + } + + + /** + * Gets the unique identifier for this partition. + * + * @return the unique identifier for this partition + */ public String getId() { - return cfg.getName(); + return id; + } + + + /** + * Sets the unique identifier for this partition. + * + * @param id the unique identifier for this partition + */ + public void setId( String id ) + { + this.id = id; } + // ----------------------------------------------------------------------- + // E N D C O N F I G U R A T I O N M E T H O D S + // ----------------------------------------------------------------------- + + /** * Allows for schema entity registries to be swapped out during runtime. This is * primarily here to facilitate the swap out of a temporary bootstrap registry. @@ -129,9 +201,10 @@ // ------------------------------------------------------------------------ - // ContextPartition Interface Method Implementations + // Partition Interface Method Implementations // ------------------------------------------------------------------------ + public void delete( DeleteOperationContext opContext ) throws NamingException { LdapDN dn = opContext.getDn(); @@ -187,6 +260,7 @@ opContext.getFilter(), searchCtls ); + //noinspection unchecked return new BTreeSearchResultEnumeration( attrIds, underlying, this, attributeTypeRegistry ); } Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultOptimizer.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultOptimizer.java?rev=580816&r1=580815&r2=580816&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultOptimizer.java (original) +++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/DefaultOptimizer.java Sun Sep 30 17:41:53 2007 @@ -76,7 +76,7 @@ public void annotate( ExprNode node ) throws NamingException { // Start off with the worst case unless scan count says otherwise. - long count = Long.MAX_VALUE; + Long count = Long.MAX_VALUE; /* -------------------------------------------------------------------- * H A N D L E L E A F N O D E S Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/NoOpOptimizer.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/NoOpOptimizer.java?rev=580816&r1=580815&r2=580816&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/NoOpOptimizer.java (original) +++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/NoOpOptimizer.java Sun Sep 30 17:41:53 2007 @@ -48,12 +48,7 @@ BranchNode bnode = ( BranchNode ) node; if ( bnode.getChildren().size() == 0 ) { - return; - } - - if ( bnode.getChildren().size() == 1 ) - { - bnode.getChildren().get( 0 ).set( "count", MAX ); + bnode.set( "count", MAX ); return; } @@ -70,5 +65,7 @@ annotate( child ); } } + + bnode.set( "count", MAX ); } } Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java?rev=580816&r1=580815&r2=580816&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java (original) +++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java Sun Sep 30 17:41:53 2007 @@ -162,7 +162,7 @@ content.add( mainPnl, java.awt.BorderLayout.NORTH ); getContentPane().add( content, BorderLayout.CENTER ); // set title - setTitle( "Partition: " + this.partition.getSuffix().toString() ); + setTitle( "Partition: " + this.partition.getSuffixDn().toString() ); // add status bar getContentPane().add( statusBar, BorderLayout.SOUTH ); // add menu bar @@ -357,7 +357,7 @@ try { TreePath path = tree.getSelectionModel().getSelectionPath(); - String parentDn = partition.getSuffix().toString(); + String parentDn = partition.getSuffixDn().toString(); if ( null != path ) { @@ -401,7 +401,7 @@ if ( null == path ) { - return partition.getSuffix().toString(); + return partition.getSuffixDn().toString(); } Object last = path.getLastPathComponent(); @@ -420,7 +420,7 @@ } else { - base = partition.getSuffix().toString(); + base = partition.getSuffixDn().toString(); } return base; @@ -554,7 +554,7 @@ } else { - dialog.setBase( partition.getSuffix().toString() ); + dialog.setBase( partition.getSuffixDn().toString() ); } dialog.addActionListener( new ActionListener() @@ -869,7 +869,7 @@ nodes = new HashMap(); Attributes suffix = partition.getSuffixEntry(); - Long id = partition.getEntryId( partition.getSuffix().toString() ); + Long id = partition.getEntryId( partition.getSuffixDn().toString() ); root = new EntryNode( id, null, partition, suffix, nodes ); /* @@ -889,7 +889,7 @@ } }); - dialog.setBase(database.getSuffix().toString()); + dialog.setBase(database.getSuffixDn().toString()); dialog.setScope(FilterDialog.SUBTREE_SCOPE); //Center the frame on screen