directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r580566 [1/2] - in /directory/apacheds/branches/bigbang: bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/ btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ core-unit/src/test/ja...
Date Sat, 29 Sep 2007 09:54:39 GMT
Author: akarasulu
Date: Sat Sep 29 02:54:34 2007
New Revision: 580566

URL: http://svn.apache.org/viewvc?rev=580566&view=rev
Log:
Although the IndexConfiguration and the JdbmStoreConfiguration have not been 
removed fully they're pretty close to being yangked out - will take care of 
the rest of this tomorrow.


Modified:
    directory/apacheds/branches/bigbang/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java
    directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/IndexConfiguration.java
    directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ShutdownITest.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
    directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
    directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
    directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreConfiguration.java
    directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/commands/dumpcmd/DumpCommandExecutor.java

Modified: directory/apacheds/branches/bigbang/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java?rev=580566&r1=580565&r2=580566&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java (original)
+++ directory/apacheds/branches/bigbang/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java Sat Sep 29 02:54:34 2007
@@ -20,60 +20,22 @@
 package org.apache.directory.server.core.bootstrap.plugin;
 
 
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.Arrays;
-import java.util.List;
-import java.net.URLClassLoader;
-import java.net.URL;
-import java.net.MalformedURLException;
-
-import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.DirContext;
-
 import org.apache.directory.server.constants.ApacheSchemaConstants;
 import org.apache.directory.server.constants.MetaSchemaConstants;
 import org.apache.directory.server.core.partition.impl.btree.Index;
 import org.apache.directory.server.core.partition.impl.btree.IndexNotFoundException;
+import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
-import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStoreConfiguration;
 import org.apache.directory.server.schema.SerializableComparator;
-import org.apache.directory.server.schema.bootstrap.ApacheSchema;
-import org.apache.directory.server.schema.bootstrap.ApachemetaSchema;
-import org.apache.directory.server.schema.bootstrap.BootstrapSchema;
-import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
-import org.apache.directory.server.schema.bootstrap.CoreSchema;
-import org.apache.directory.server.schema.bootstrap.Schema;
-import org.apache.directory.server.schema.bootstrap.SystemSchema;
-import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.server.schema.registries.ComparatorRegistry;
-import org.apache.directory.server.schema.registries.DefaultOidRegistry;
-import org.apache.directory.server.schema.registries.DefaultRegistries;
-import org.apache.directory.server.schema.registries.MatchingRuleRegistry;
-import org.apache.directory.server.schema.registries.NormalizerRegistry;
-import org.apache.directory.server.schema.registries.ObjectClassRegistry;
-import org.apache.directory.server.schema.registries.Registries;
-import org.apache.directory.server.schema.registries.SyntaxCheckerRegistry;
-import org.apache.directory.server.schema.registries.SyntaxRegistry;
+import org.apache.directory.server.schema.bootstrap.*;
+import org.apache.directory.server.schema.registries.*;
 import org.apache.directory.server.utils.AttributesFactory;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.message.AttributeImpl;
 import org.apache.directory.shared.ldap.message.AttributesImpl;
 import org.apache.directory.shared.ldap.message.ModificationItemImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.schema.AttributeType;
-import org.apache.directory.shared.ldap.schema.MatchingRule;
-import org.apache.directory.shared.ldap.schema.ObjectClass;
-import org.apache.directory.shared.ldap.schema.SchemaObject;
-import org.apache.directory.shared.ldap.schema.Syntax;
+import org.apache.directory.shared.ldap.schema.*;
 import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
 import org.apache.directory.shared.ldap.util.DateUtils;
 import org.apache.maven.plugin.AbstractMojo;
@@ -81,6 +43,18 @@
 import org.apache.maven.plugin.MojoFailureException;
 import org.codehaus.plexus.util.FileUtils;
 
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.*;
+
 
 /**
  * A plugin used to pre-load meta schema entries into the schema partition.
@@ -234,10 +208,10 @@
                 getLog().info( "------------------------------------------------------------------------" );
                 getLog().info( "" );
 
-                for ( int ii = 0; ii < disabledSchemas.length; ii++ )
+                for ( String disabledSchema : disabledSchemas )
                 {
-                    disableSchema( disabledSchemas[ii] );
-                    getLog().info( "\t\t o " + disabledSchemas[ii] );
+                    disableSchema( disabledSchema );
+                    getLog().info( "\t\t o " + disabledSchema );
                 }
 
                 getLog().info( "" );
@@ -617,34 +591,33 @@
      */
     private void initializePartition( File workingDirectory ) throws MojoFailureException
     {
-        JdbmStoreConfiguration storeConfig = new JdbmStoreConfiguration();
-        storeConfig.setAttributeTypeRegistry( registries.getAttributeTypeRegistry() );
-        storeConfig.setCacheSize( 1000 );
-        storeConfig.setEnableOptimizer( false );
-        storeConfig.setName( "schema" );
-        storeConfig.setOidRegistry( registries.getOidRegistry() );
-        storeConfig.setSuffixDn( SchemaConstants.OU_AT + "=schema" );
-        storeConfig.setSyncOnWrite( false );
-        storeConfig.setWorkingDirectory( workingDirectory );
+        store.setCacheSize( 1000 );
+        store.setEnableOptimizer( false );
+        store.setName( "schema" );
+        store.setSuffixDn( SchemaConstants.OU_AT + "=schema" );
+        store.setSyncOnWrite( false );
+        store.setWorkingDirectory( workingDirectory );
 
         // add the indices
-        Set<String> indexSet = new HashSet<String>();
+        Set<JdbmIndex> userIndices = new HashSet<JdbmIndex>();
         
         for ( String indexedAttribute:indexedAttributes )
         {
-            indexSet.add( indexedAttribute );
+            JdbmIndex index = new JdbmIndex();
+            index.setAttributeId( indexedAttribute );
+            userIndices.add( index );
         }
         
-        storeConfig.setIndexedAttributes( indexSet );
+        store.setUserIndices( userIndices );
 
         Attributes rootEntry = new AttributesImpl( SchemaConstants.OBJECT_CLASS_AT, 
             SchemaConstants.ORGANIZATIONAL_UNIT_OC, true );
         rootEntry.put( SchemaConstants.OU_AT, "schema" );
-        storeConfig.setContextEntry( rootEntry );
+        store.setContextEntry( rootEntry );
 
         try
         {
-            store.init( storeConfig );
+            store.init( this.registries.getOidRegistry(), this.registries.getAttributeTypeRegistry() );
         }
         catch ( NamingException e )
         {
@@ -857,7 +830,7 @@
         StringBuffer buf = new StringBuffer();
         buf.append( "schema/master.db\n" );
 
-        Iterator<String> systemIndices = store.getSystemIndices();
+        Iterator<String> systemIndices = store.systemIndices();
         
         while ( systemIndices.hasNext() )
         {

Modified: directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/IndexConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/IndexConfiguration.java?rev=580566&r1=580565&r2=580566&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/IndexConfiguration.java (original)
+++ directory/apacheds/branches/bigbang/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/IndexConfiguration.java Sat Sep 29 02:54:34 2007
@@ -29,7 +29,6 @@
 public class IndexConfiguration
 {
     public static final int DEFAULT_INDEX_CACHE_SIZE = 100;
-
     public static final int DEFAULT_DUPLICATE_LIMIT = 512;
     
     private String attributeId;

Modified: directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ShutdownITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ShutdownITest.java?rev=580566&r1=580565&r2=580566&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ShutdownITest.java (original)
+++ directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/jndi/ShutdownITest.java Sat Sep 29 02:54:34 2007
@@ -21,6 +21,7 @@
 
 
 import org.apache.directory.server.core.configuration.ShutdownConfiguration;
+import org.apache.directory.server.core.configuration.SyncConfiguration;
 import org.apache.directory.server.core.unit.AbstractAdminTestCase;
 
 
@@ -47,6 +48,12 @@
      */
     public void testShutdownNonNullContext() throws Exception
     {
+        // for some reason if we don't synch first windows blows chuncks when
+        // attempting to delete the db files - perhaps this buys more time rather
+        // because there is less to sync when shutting down so shutdown happens
+        // faster before the doDelete method is called. Regardless this does
+        // deserve some investigation at some point after the bigbang cleanup.
+        setContextRoots( "uid=admin,ou=system", "secret", new SyncConfiguration() );
         setContextRoots( "uid=admin,ou=system", "secret", new ShutdownConfiguration() );
         assertNotNull( sysRoot );
         doDelete( configuration.getWorkingDirectory() );
@@ -60,6 +67,7 @@
      */
     public void testShutdownRestart() throws Exception
     {
+        setContextRoots( "uid=admin,ou=system", "secret", new SyncConfiguration() );
         setContextRoots( "uid=admin,ou=system", "secret", new ShutdownConfiguration() );
         assertNotNull( sysRoot );
 

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java?rev=580566&r1=580565&r2=580566&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java Sat Sep 29 02:54:34 2007
@@ -20,34 +20,26 @@
 package org.apache.directory.server.core.partition.impl.btree.jdbm;
 
 
-import java.io.File;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-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.AddOperationContext;
-import org.apache.directory.server.core.interceptor.context.BindOperationContext;
-import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
-import org.apache.directory.server.core.interceptor.context.MoveAndRenameOperationContext;
-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.UnbindOperationContext;
+import org.apache.directory.server.core.interceptor.context.*;
 import org.apache.directory.server.core.partition.Partition;
-import org.apache.directory.server.core.partition.impl.btree.BTreePartition;
-import org.apache.directory.server.core.partition.impl.btree.BTreePartitionConfiguration;
-import org.apache.directory.server.core.partition.impl.btree.Index;
-import org.apache.directory.server.core.partition.impl.btree.IndexNotFoundException;
+import org.apache.directory.server.core.partition.impl.btree.*;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.exception.LdapAuthenticationNotSupportedException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import java.io.File;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
 
 /**
  * A {@link Partition} that stores entries in
@@ -88,30 +80,45 @@
         initRegistries1( factoryCfg.getRegistries() );
         
         // initialize the store
-        JdbmStoreConfiguration storeConfig = new JdbmStoreConfiguration();
-        storeConfig.setAttributeTypeRegistry( attributeTypeRegistry );
-        storeConfig.setCacheSize( cfg.getCacheSize() );
-        storeConfig.setContextEntry( cfg.getContextEntry() );
-        storeConfig.setIndexedAttributes( cfg.getIndexedAttributes() );
-        storeConfig.setName( cfg.getName() );
-        storeConfig.setOidRegistry( oidRegistry );
-        storeConfig.setSuffixDn( cfg.getSuffix() );
-        
-        storeConfig.setWorkingDirectory( new File( 
+        store.setCacheSize( cfg.getCacheSize() );
+        store.setContextEntry( cfg.getContextEntry() );
+        store.setName( cfg.getName() );
+        store.setSuffixDn( cfg.getSuffix() );
+        store.setWorkingDirectory( new File(
             factoryCfg.getStartupConfiguration().getWorkingDirectory().getPath()
             + File.separator + cfg.getName() ) );
-        
+
+        Set<JdbmIndex> userIndices = new HashSet<JdbmIndex>();
+        for ( Object obj : cfg.getIndexedAttributes() )
+        {
+            JdbmIndex index = new JdbmIndex();
+            userIndices.add( index );
+
+            if ( obj instanceof String )
+            {
+                index.setAttributeId( ( String ) obj );
+            }
+            else if ( obj instanceof IndexConfiguration )
+            {
+                IndexConfiguration indexConfiguration = ( IndexConfiguration ) obj;
+                index.setAttributeId( indexConfiguration.getAttributeId() );
+                index.setCacheSize( indexConfiguration.getCacheSize() );
+                index.setNumDupLimit( indexConfiguration.getDuplicateLimit() );
+            }
+        }
+        store.setUserIndices( userIndices );
+
         if ( cfg instanceof BTreePartitionConfiguration )
         {
-            storeConfig.setSyncOnWrite( ( ( BTreePartitionConfiguration ) cfg ).isSynchOnWrite() );
+            store.setSyncOnWrite( ( ( BTreePartitionConfiguration ) cfg ).isSynchOnWrite() );
         }
         
         if ( cfg instanceof BTreePartitionConfiguration )
         {
-            storeConfig.setEnableOptimizer( ( ( BTreePartitionConfiguration ) cfg ).isOptimizerEnabled() );
+            store.setEnableOptimizer( ( ( BTreePartitionConfiguration ) cfg ).isOptimizerEnabled() );
         }
         
-        store.init( storeConfig );
+        store.init( oidRegistry, attributeTypeRegistry );
     }
 
 
@@ -139,7 +146,11 @@
 
     public final void addIndexOn( AttributeType spec, int cacheSize, int numDupLimit ) throws NamingException
     {
-        store.addIndexOn( spec, cacheSize, numDupLimit );
+        JdbmIndex index = new JdbmIndex();
+        index.setAttributeId( spec.getName() );
+        index.setCacheSize( cacheSize );
+        index.setNumDupLimit( numDupLimit );
+        store.addIndex( index );
     }
 
 
@@ -151,7 +162,11 @@
 
     public final void setExistanceIndexOn( AttributeType attrType, int cacheSize, int numDupLimit ) throws NamingException
     {
-        store.setExistanceIndexOn( attrType, cacheSize, numDupLimit );
+        JdbmIndex index = new JdbmIndex();
+        index.setAttributeId( attrType.getName() );
+        index.setCacheSize( cacheSize );
+        index.setNumDupLimit( numDupLimit );
+        store.setExistanceIndex( index );
     }
 
 
@@ -163,7 +178,11 @@
 
     public final void setHierarchyIndexOn( AttributeType attrType, int cacheSize, int numDupLimit ) throws NamingException
     {
-        store.setHierarchyIndexOn( attrType, cacheSize, numDupLimit );
+        JdbmIndex index = new JdbmIndex();
+        index.setAttributeId( attrType.getName() );
+        index.setCacheSize( cacheSize );
+        index.setNumDupLimit( numDupLimit );
+        store.setHierarchyIndex( index );
     }
 
 
@@ -175,7 +194,11 @@
 
     public final void setAliasIndexOn( AttributeType attrType, int cacheSize, int numDupLimit ) throws NamingException
     {
-        store.setAliasIndexOn( attrType, cacheSize, numDupLimit );
+        JdbmIndex index = new JdbmIndex();
+        index.setAttributeId( attrType.getName() );
+        index.setCacheSize( cacheSize );
+        index.setNumDupLimit( numDupLimit );
+        store.setAliasIndex( index );
     }
 
 
@@ -187,7 +210,11 @@
 
     public final void setOneAliasIndexOn( AttributeType attrType, int cacheSize, int numDupLimit ) throws NamingException
     {
-        store.setOneAliasIndexOn( attrType, cacheSize, numDupLimit );
+        JdbmIndex index = new JdbmIndex();
+        index.setAttributeId( attrType.getName() );
+        index.setCacheSize( cacheSize );
+        index.setNumDupLimit( numDupLimit );
+        store.setOneAliasIndex( index );
     }
 
 
@@ -199,7 +226,11 @@
 
     public final void setSubAliasIndexOn( AttributeType attrType, int cacheSize, int numDupLimit ) throws NamingException
     {
-        store.setSubAliasIndexOn( attrType, cacheSize, numDupLimit );
+        JdbmIndex index = new JdbmIndex();
+        index.setAttributeId( attrType.getName() );
+        index.setCacheSize( cacheSize );
+        index.setNumDupLimit( numDupLimit );
+        store.setSubAliasIndex( index );
     }
 
 
@@ -211,7 +242,11 @@
 
     public final void setUpdnIndexOn( AttributeType attrType, int cacheSize, int numDupLimit ) throws NamingException
     {
-        store.setUpdnIndexOn( attrType, cacheSize, numDupLimit );
+        JdbmIndex index = new JdbmIndex();
+        index.setAttributeId( attrType.getName() );
+        index.setCacheSize( cacheSize );
+        index.setNumDupLimit( numDupLimit );
+        store.setUpdnIndex( index );
     }
 
 
@@ -223,19 +258,23 @@
 
     public final void setNdnIndexOn( AttributeType attrType, int cacheSize, int numDupLimit ) throws NamingException
     {
-        store.setNdnIndexOn( attrType, cacheSize, numDupLimit );
+        JdbmIndex index = new JdbmIndex();
+        index.setAttributeId( attrType.getName() );
+        index.setCacheSize( cacheSize );
+        index.setNumDupLimit( numDupLimit );
+        store.setNdnIndex( index );
     }
 
 
     public final Iterator getUserIndices()
     {
-        return store.getUserIndices();
+        return store.userIndices();
     }
 
 
     public final Iterator getSystemIndices()
     {
-        return store.getSystemIndices();
+        return store.systemIndices();
     }
 
 
@@ -301,7 +340,7 @@
 
     public final String getEntryUpdn( String dn ) throws NamingException
     {
-        return getEntryUpdn( dn );
+        return store.getEntryUpdn( dn );
     }
 
 
@@ -404,9 +443,9 @@
     {
         // does nothing
         throw new LdapAuthenticationNotSupportedException(
-            "Bind requests only tunnel down into partitions if there are no authenticators to handle the mechanism.\n"
-                + "Check to see if you have correctly configured authenticators for the server.",
-            ResultCodeEnum.AUTH_METHOD_NOT_SUPPORTED );
+                "Bind requests only tunnel down into partitions if there are no authenticators to handle the mechanism.\n"
+                        + "Check to see if you have correctly configured authenticators for the server.",
+                ResultCodeEnum.AUTH_METHOD_NOT_SUPPORTED );
     }
 
     public final void bind( BindOperationContext bindContext ) throws NamingException

Modified: directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java?rev=580566&r1=580565&r2=580566&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java (original)
+++ directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java Sat Sep 29 02:54:34 2007
@@ -20,23 +20,12 @@
 package org.apache.directory.server.core.partition.impl.btree.jdbm;
 
 
-import java.io.File;
-import java.io.IOException;
-import java.util.regex.Pattern;
-
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-
 import jdbm.RecordManager;
 import jdbm.helper.MRU;
 import jdbm.recman.BaseRecordManager;
 import jdbm.recman.CacheRecordManager;
-
 import org.apache.directory.server.core.partition.impl.btree.Index;
 import org.apache.directory.server.core.partition.impl.btree.IndexComparator;
-import org.apache.directory.server.core.partition.impl.btree.IndexConfiguration;
 import org.apache.directory.server.core.partition.impl.btree.IndexEnumeration;
 import org.apache.directory.server.core.partition.impl.btree.Tuple;
 import org.apache.directory.server.schema.SerializableComparator;
@@ -44,6 +33,14 @@
 import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.SynchronizedLRUMap;
 
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import java.io.File;
+import java.io.IOException;
+import java.util.regex.Pattern;
+
 
 /** 
  * A Jdbm based index implementation.
@@ -53,63 +50,108 @@
  */
 public class JdbmIndex implements Index
 {
-    /**  */
+    /** default cache size to use */
+    public static final int DEFAULT_INDEX_CACHE_SIZE = 100;
+    /**
+     * default duplicate limit before duplicate keys switch to using a btree for values
+     */
+    public static final int DEFAULT_DUPLICATE_LIMIT = 512;
+
+    /**  the key used for the forward btree name */
     public static final String FORWARD_BTREE = "_forward";
-    /** */
+    /**  the key used for the reverse btree name */
     public static final String REVERSE_BTREE = "_reverse";
 
-    /** */
+
+    /** the attribute type resolved for this JdbmIndex */
     private AttributeType attribute;
-    /** */
-    private JdbmTable forward = null;
-    /** */
-    private JdbmTable reverse = null;
-    /** */
-    private RecordManager recMan = null;
-    /** 
+    /**
+     * the forward btree where the btree key is the value of the indexed attribute and
+     * the value of the btree is the entry id of the entry containing an attribute with
+     * that value
+     */
+    private JdbmTable forward;
+    /**
+     * the reverse btree where the btree key is the entry id of the entry containing a
+     * value for the indexed attribute, and the btree value is the value of the indexed
+     * attribute
+     */
+    private JdbmTable reverse;
+    /**
+     * the JDBM record manager for the file containing this index
+     */
+    private RecordManager recMan;
+    /**
+     * the normalized value cache for this index
      * @todo I don't think the keyCache is required anymore since the normalizer
      * will cache values for us.
      */
-    private SynchronizedLRUMap keyCache = null;
-    
-    private int numDupLimit = IndexConfiguration.DEFAULT_DUPLICATE_LIMIT;
+    private SynchronizedLRUMap keyCache;
+    /** the size (number of index entries) for the cache */
+    private int cacheSize = DEFAULT_INDEX_CACHE_SIZE;
+    /**
+     * duplicate limit before duplicate keys switch to using a btree for values
+     */
+    private int numDupLimit = DEFAULT_DUPLICATE_LIMIT;
+    /**
+     * the attribute identifier set at configuration time for this index which may not
+     * be the OID but an alias name for the attributeType associated with this Index
+     */
+    private String attributeId;
+    /** whether or not this index has been initialized */
+    private boolean initialized;
+    /** a customm working directory path when specified in configuration */
+    private File wkDirPath;
+
+
+    /*
+     * NOTE: Duplicate Key Limit
+     *
+     * Jdbm cannot store duplicate keys: meaning it cannot have more than one value
+     * for the same key in the btree.  Thus as a workaround we stuff values for the
+     * same key into a TreeSet.  This is only effective up to some threshold after
+     * which we run into problems with serialization on and off disk.  A threshold
+     * is used to determine when to switch from using a TreeSet to start using another
+     * btree in the same index file just for the values.  This value only btree just
+     * has keys populated without a value for it's btree entries. When the switch
+     * occurs the value for the key in the index btree contains a pointer to the
+     * btree containing it's values.
+     *
+     * This numDupLimit is the threshold at which we switch from using in memory
+     * containers for values of the same key to using a btree for those values
+     * instead with indirection.
+     */
 
 
     // ------------------------------------------------------------------------
     // C O N S T R U C T O R S
     // ------------------------------------------------------------------------
 
-//    /**
-//     * Creates an Index using an existing record manager based on a file.  The
-//     * index table B+Tree are created and saved within this file rather than
-//     * creating a new file.
-//     *
-//     * @param attribute the attribute specification to base this index on
-//     * @param recMan the record manager
-//     * @throws NamingException if we fail to create B+Trees using recMan
-//     */
-//    public JdbmIndex( AttributeType attribute, RecordManager recMan ) throws NamingException
-//    {
-//        this.attribute = attribute;
-//        keyCache = new SynchronizedLRUMap( 1000 );
-//        this.recMan = recMan;
-//        initTables();
-//    }
+
+    public JdbmIndex()
+    {
+        initialized = false;
+    }
 
 
-    public JdbmIndex( AttributeType attribute, File wkDirPath, int cacheSize, int numDupLimit ) throws NamingException
+    public void init( AttributeType attributeType, File wkDirPath ) throws NamingException
     {
-        this.numDupLimit = numDupLimit;
-        File file = new File( wkDirPath.getPath() + File.separator + attribute.getName() );
-        this.attribute = attribute;
-        keyCache = new SynchronizedLRUMap( cacheSize );
+        this.keyCache = new SynchronizedLRUMap( cacheSize );
+        this.attribute = attributeType;
+        if ( this.wkDirPath ==  null )
+        {
+            this.wkDirPath = wkDirPath;
+        }
+
+        File file = new File( this.wkDirPath.getPath() + File.separator + attribute.getName() );
+
 
         try
         {
             String path = file.getAbsolutePath();
             BaseRecordManager base = new BaseRecordManager( path );
             base.disableTransactions();
-            recMan = new CacheRecordManager( base, new MRU( cacheSize ) );
+            this.recMan = new CacheRecordManager( base, new MRU( cacheSize ) );
         }
         catch ( IOException e )
         {
@@ -119,6 +161,7 @@
         }
 
         initTables();
+        initialized = true;
     }
 
 
@@ -140,8 +183,8 @@
          */
         forward = new JdbmTable( 
             attribute.getName() + FORWARD_BTREE, 
-            true, 
-            numDupLimit, 
+            true,
+            numDupLimit,
             recMan, 
             new IndexComparator( comp, true ),
             null, null );
@@ -155,8 +198,8 @@
          */
         reverse = new JdbmTable( 
             attribute.getName() + REVERSE_BTREE, 
-            !attribute.isSingleValue(), 
-            numDupLimit, 
+            !attribute.isSingleValue(),
+            numDupLimit,
             recMan,
             new IndexComparator( comp, false ),
             null, //LongSerializer.INSTANCE,
@@ -174,9 +217,128 @@
 
 
     // ------------------------------------------------------------------------
+    // C O N F I G U R A T I O N   M E T H O D S
+    // ------------------------------------------------------------------------
+
+
+    /**
+     * Protects configuration properties from being set after initialization.
+     *
+     * @param property the property to protect
+     */
+    private void protect( String property )
+    {
+        if ( initialized )
+        {
+            throw new IllegalStateException( "The " + property
+                    + " property for an index cannot be set after it has been initialized." );
+        }
+    }
+
+
+    /**
+     * Gets the attribute identifier set at configuration time for this index which may not
+     * be the OID but an alias name for the attributeType associated with this Index
+     *
+     * @return configured attribute oid or alias name
+     */
+    public String getAttributeId()
+    {
+        return attributeId;
+    }
+
+
+    /**
+     * Sets the attribute identifier set at configuration time for this index which may not
+     * be the OID but an alias name for the attributeType associated with this Index
+     *
+     * @param attributeId configured attribute oid or alias name
+     */
+    public void setAttributeId( String attributeId )
+    {
+        protect( "attributeId" );
+        this.attributeId = attributeId;
+    }
+
+
+    /**
+     * Gets the threshold at which point duplicate keys use btree indirection to store
+     * their values.
+     *
+     * @return the threshold for storing a keys values in another btree
+     */
+    public int getNumDupLimit()
+    {
+        return numDupLimit;
+    }
+
+
+    /**
+     * Sets the threshold at which point duplicate keys use btree indirection to store
+     * their values.
+     *
+     * @param numDupLimit the threshold for storing a keys values in another btree
+     */
+    public void setNumDupLimit( int numDupLimit )
+    {
+        protect( "numDupLimit" );
+        this.numDupLimit = numDupLimit;
+    }
+
+
+    /**
+     * Gets the size of the index cache in terms of the number of index entries to be cached.
+     *
+     * @return the size of the index cache
+     */
+    public int getCacheSize()
+    {
+        return cacheSize;
+    }
+
+
+    /**
+     * Sets the size of the index cache in terms of the number of index entries to be cached.
+     *
+     * @param cacheSize the size of the index cache
+     */
+    public void setCacheSize( int cacheSize )
+    {
+        protect( "cacheSize" );
+        this.cacheSize = cacheSize;
+    }
+
+
+    /**
+     * Sets the working directory path to something other than the default. Sometimes more
+     * performance is gained by locating indices on separate disk spindles.
+     *
+     * @param wkDirPath optional working directory path
+     */
+    public void setWkDirPath( File wkDirPath )
+    {
+        protect( "wkDirPath" );
+        this.wkDirPath = wkDirPath;
+    }
+
+
+    /**
+     * Gets the working directory path to something other than the default. Sometimes more
+     * performance is gained by locating indices on separate disk spindles.
+     *
+     * @return optional working directory path 
+     */
+    public File getWkDirPath()
+    {
+        return wkDirPath;
+    }
+
+
+    // ------------------------------------------------------------------------
     // Scan Count Methods
     // ------------------------------------------------------------------------
 
+
     /**
      * @see Index#count()
      */
@@ -208,6 +370,7 @@
     // Forward and Reverse Lookups
     // ------------------------------------------------------------------------
 
+
     /**
      * @see Index#forwardLookup(java.lang.Object)
      */
@@ -218,7 +381,7 @@
 
 
     /**
-     * @see Index#reverseLookup(java.math.BigInteger)
+     * @see Index#reverseLookup(Object)
      */
     public Object reverseLookup( Object id ) throws NamingException
     {
@@ -230,9 +393,9 @@
     // Add/Drop Methods
     // ------------------------------------------------------------------------
 
+
     /**
-     * @see org.apache.directory.server.core.partition.impl.btree.Index#add(java.lang.Object,
-     * java.math.BigInteger)
+     * @see Index#add(Object,Object)
      */
     public synchronized void add( Object attrVal, Object id ) throws NamingException
     {
@@ -242,8 +405,7 @@
 
 
     /**
-     * @see org.apache.directory.server.core.partition.impl.btree.Index#add(
-     * javax.naming.directory.Attribute, java.math.BigInteger)
+     * @see Index#add(Attribute, Object)
      */
     public synchronized void add( Attribute attr, Object id ) throws NamingException
     {
@@ -261,8 +423,7 @@
 
 
     /**
-     * @see Index#add(
-     * javax.naming.directory.Attributes, java.math.BigInteger)
+     * @see Index#add(Attributes, Object)
      */
     public synchronized void add( Attributes attrs, Object id ) throws NamingException
     {
@@ -271,8 +432,7 @@
 
 
     /**
-     * @see org.apache.directory.server.core.partition.impl.btree.Index#drop(java.lang.Object,
-     * java.math.BigInteger)
+     * @see Index#drop(Object,Object)
      */
     public synchronized void drop( Object attrVal, Object id ) throws NamingException
     {
@@ -282,7 +442,7 @@
 
 
     /**
-     * @see Index#drop(java.math.BigInteger)
+     * @see Index#drop(Object)
      */
     public void drop( Object entryId ) throws NamingException
     {
@@ -298,8 +458,7 @@
 
 
     /**
-     * @see Index#drop(
-     * javax.naming.directory.Attribute, java.math.BigInteger)
+     * @see Index#drop(Attribute, Object)
      */
     public void drop( Attribute attr, Object id ) throws NamingException
     {
@@ -325,8 +484,7 @@
 
 
     /**
-     * @see org.apache.directory.server.core.partition.impl.btree.Index#drop(
-     * javax.naming.directory.Attributes, java.math.BigInteger)
+     * @see Index#drop(Attributes, Object)
      */
     public void drop( Attributes attrs, Object id ) throws NamingException
     {
@@ -338,8 +496,9 @@
     // Index Listing Operations
     // ------------------------------------------------------------------------
 
+
     /**
-     * @see Index#listReverseIndices(BigInteger)
+     * @see Index#listReverseIndices(Object)
      */
     public IndexEnumeration listReverseIndices( Object id ) throws NamingException
     {
@@ -357,7 +516,7 @@
 
 
     /**
-     * @see org.apache.directory.server.core.partition.impl.btree.Index#listIndices(java.lang.Object)
+     * @see Index#listIndices(Object)
      */
     public IndexEnumeration listIndices( Object attrVal ) throws NamingException
     {
@@ -366,8 +525,7 @@
 
 
     /**
-     * @see org.apache.directory.server.core.partition.impl.btree.Index#listIndices(java.lang.Object,
-     * boolean)
+     * @see Index#listIndices(Object,boolean)
      */
     public IndexEnumeration<Tuple> listIndices( Object attrVal, boolean isGreaterThan ) throws NamingException
     {
@@ -376,7 +534,7 @@
 
 
     /**
-     * @see Index#listIndices(org.apache.regexp.RE)
+     * @see Index#listIndices(Pattern)
      */
     public IndexEnumeration<Tuple> listIndices( Pattern regex ) throws NamingException
     {
@@ -385,8 +543,7 @@
 
 
     /**
-     * @see Index#listIndices(org.apache.regexp.RE,
-     * java.lang.String)
+     * @see Index#listIndices(Pattern,String)
      */
     public IndexEnumeration<Tuple> listIndices( Pattern regex, String prefix ) throws NamingException
     {
@@ -398,9 +555,10 @@
     // Value Assertion (a.k.a Index Lookup) Methods //
     // ------------------------------------------------------------------------
 
+    
     /**
      * @see Index#hasValue(java.lang.Object,
-     * java.math.BigInteger)
+     * Object)
      */
     public boolean hasValue( Object attrVal, Object id ) throws NamingException
     {
@@ -410,7 +568,7 @@
 
     /**
      * @see Index#hasValue(java.lang.Object,
-     * java.math.BigInteger, boolean)
+     * Object, boolean)
      */
     public boolean hasValue( Object attrVal, Object id, boolean isGreaterThan ) throws NamingException
     {
@@ -419,8 +577,7 @@
 
 
     /**
-     * @see Index#hasValue(org.apache.regexp.RE,
-     * java.math.BigInteger)
+     * @see Index#hasValue(Pattern,Object)
      */
     public boolean hasValue( Pattern regex, Object id ) throws NamingException
     {
@@ -435,6 +592,7 @@
     // Maintenance Methods 
     // ------------------------------------------------------------------------
 
+    
     /**
      * @see Index#close()
      */

Modified: directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?rev=580566&r1=580565&r2=580566&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java (original)
+++ directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java Sat Sep 29 02:54:34 2007
@@ -19,21 +19,6 @@
  */
 package org.apache.directory.server.core.partition.impl.btree.jdbm;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-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 javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
-import javax.naming.directory.DirContext;
 
 import jdbm.RecordManager;
 import jdbm.helper.MRU;
@@ -41,12 +26,7 @@
 import jdbm.recman.CacheRecordManager;
 
 import org.apache.directory.server.core.partition.Oid;
-import org.apache.directory.server.core.partition.impl.btree.Index;
-import org.apache.directory.server.core.partition.impl.btree.IndexAssertion;
-import org.apache.directory.server.core.partition.impl.btree.IndexAssertionEnumeration;
-import org.apache.directory.server.core.partition.impl.btree.IndexConfiguration;
-import org.apache.directory.server.core.partition.impl.btree.IndexNotFoundException;
-import org.apache.directory.server.core.partition.impl.btree.IndexRecord;
+import org.apache.directory.server.core.partition.impl.btree.*;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.server.schema.registries.OidRegistry;
 import org.apache.directory.server.schema.registries.Registries;
@@ -61,68 +41,61 @@
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.NamespaceTools;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+
 
 public class JdbmStore
 {
-    private static final Logger log = LoggerFactory.getLogger( JdbmStore.class );
-
+    /** static logger */
+    private static final Logger LOG = LoggerFactory.getLogger( JdbmStore.class );
     /** The default cache size is set to 10 000 objects */
     private static final int DEFAULT_CACHE_SIZE = 10000;
 
+
     /** the JDBM record manager used by this database */
     private RecordManager recMan;
-    
     /** the normalized suffix DN of this backend database */
     private LdapDN normSuffix;
-    
     /** the user provided suffix DN of this backend database */
     private LdapDN upSuffix;
-    
     /** the working directory to use for files */
     private File workingDirectory;
-    
     /** the master table storing entries by primary key */
     private JdbmMasterTable master;
-    
-    /** a map of attribute names to user indices */
-    private Map<String, Index> indices;
-    
-    /** a map of index names to system indices */
-    private Map<String, Index> sysIndices;
-
-    /** true if open */
+    /** a map of attributeType numeric ids to user userIndices */
+    private Map<String, JdbmIndex> userIndices = new HashMap<String, JdbmIndex>();
+    /** a map of attributeType numeric ids to system userIndices */
+    private Map<String, JdbmIndex> systemIndices = new HashMap<String, JdbmIndex>();
+    /** true if initialized */
     private boolean initialized;
-    
     /** true if we sync disks on every write operation */
     private boolean isSyncOnWrite = true;
 
-    /**
-     * Declaration of the system indices we need in the server
-     */
-    
     /** the normalized distinguished name index */
-    private Index ndnIdx;
-    
+    private JdbmIndex ndnIdx;
     /** the user provided distinguished name index */
-    private Index updnIdx;
-    
+    private JdbmIndex updnIdx;
     /** the attribute existance index */
-    private Index existanceIdx;
-    
+    private JdbmIndex existanceIdx;
     /** the parent child relationship index */
-    private Index hierarchyIdx;
-    
+    private JdbmIndex hierarchyIdx;
     /** the one level scope alias index */
-    private Index oneAliasIdx;
-    
+    private JdbmIndex oneAliasIdx;
     /** the subtree scope alias index */
-    private Index subAliasIdx;
-    
+    private JdbmIndex subAliasIdx;
     /** a system index on aliasedObjectName attribute */
-    private Index aliasIdx;
+    private JdbmIndex aliasIdx;
     
     /** Two static declaration to avoid lookup all over the code */
     private static AttributeType OBJECT_CLASS_AT;
@@ -134,276 +107,172 @@
     /** A pointer on the OID registry */
     private OidRegistry oidRegistry;
 
+
     // ------------------------------------------------------------------------
     // C O N S T R U C T O R S
     // ------------------------------------------------------------------------
 
+    
     /**
      * Creates a store based on JDBM B+Trees.
      */
-    public JdbmStore()
+    public JdbmStore() 
     {
     }
 
-    /**
-     * Initialize the user declared indices
-     */
-    private void initCustomIndex( Object index, Set<String> sysOidSet, Set<String> customAddedSystemIndices ) throws NamingException
+
+    // -----------------------------------------------------------------------
+    // C O N F I G U R A T I O N   M E T H O D S
+    // -----------------------------------------------------------------------
+
+
+    private Attributes contextEntry;
+    private String suffixDn;
+    private boolean enableOptimizer;
+    private int cacheSize = DEFAULT_CACHE_SIZE;
+    private String name;
+
+
+    private void protect( String property )
     {
-        String name = null;
-        int cacheSize = IndexConfiguration.DEFAULT_INDEX_CACHE_SIZE;
-        int numDupLimit = IndexConfiguration.DEFAULT_DUPLICATE_LIMIT;
-        
-        // no custom cacheSize info is available so default sticks
-        if ( index instanceof String ) 
+        if ( initialized )
         {
-            name = ( String )index;
-            
-            if ( log.isDebugEnabled() )
-            {
-	            log.debug( "Using default cache size of {} for index on attribute {}", 
-	                new Integer( cacheSize ), name );
-            }
+            throw new IllegalStateException( "Cannot set jdbm store property " + property + " after initialization." );
         }
-        else if ( index instanceof IndexConfiguration )
-        {
-            // custom cache size is used
-            IndexConfiguration indexConfiguration = ( IndexConfiguration )index;
-            name = indexConfiguration.getAttributeId();
-            cacheSize = indexConfiguration.getCacheSize();
-            numDupLimit = indexConfiguration.getDuplicateLimit();
-            
-            if ( cacheSize <= 0 ) 
-            {
-                log.warn( "Cache size {} for index on attribute is null or negative. Using default value.", 
-                    new Integer(cacheSize), name );
-                cacheSize = IndexConfiguration.DEFAULT_INDEX_CACHE_SIZE;
-            }
-            else
-            {
-                log.info( "Using cache size of {} for index on attribute {}", 
-                    new Integer( cacheSize ), name );
-            }
-            
-            if ( cacheSize <= 0 ) 
-            {
-                log.warn( "Duplicate limit {} for index on attribute is null or negative. Using default value.", 
-                    new Integer(numDupLimit), name );
-                cacheSize = IndexConfiguration.DEFAULT_INDEX_CACHE_SIZE;
-            }
-            else
-            {
-                log.info( "Using duplicate limit of {} for index on attribute {}", 
-                    new Integer( numDupLimit ), name );
-            }
-        }
-        
-        String oid = oidRegistry.getOid( name );
-        AttributeType type = attributeTypeRegistry.lookup( oid );
+    }
 
-        // check if attribute is a system attribute
-        if ( sysOidSet.contains( oid ) )
-        {
-            if ( oid.equals( Oid.EXISTANCE ) )
-            {
-                setExistanceIndexOn( type, cacheSize, numDupLimit );
-                customAddedSystemIndices.add( Oid.EXISTANCE );
-            }
-            else if ( oid.equals( Oid.HIERARCHY ) )
-            {
-                setHierarchyIndexOn( type, cacheSize, numDupLimit );
-                customAddedSystemIndices.add( Oid.HIERARCHY );
-            }
-            else if ( oid.equals( Oid.UPDN ) )
-            {
-                setUpdnIndexOn( type, cacheSize, numDupLimit );
-                customAddedSystemIndices.add( Oid.UPDN );
-            }
-            else if ( oid.equals( Oid.NDN ) )
-            {
-                setNdnIndexOn( type, cacheSize, numDupLimit );
-                customAddedSystemIndices.add( Oid.NDN );
-            }
-            else if ( oid.equals( Oid.ONEALIAS ) )
-            {
-                setOneAliasIndexOn( type, cacheSize, numDupLimit );
-                customAddedSystemIndices.add( Oid.ONEALIAS );
-            }
-            else if ( oid.equals( Oid.SUBALIAS ) )
-            {
-                setSubAliasIndexOn( type, cacheSize, numDupLimit );
-                customAddedSystemIndices.add( Oid.SUBALIAS);
-            }
-            else if ( oid.equals( Oid.ALIAS ) )
-            {
-                setAliasIndexOn( type, cacheSize, numDupLimit );
-                customAddedSystemIndices.add( Oid.ALIAS );
-            }
-            else
-            {
-                throw new NamingException( "Unidentified system index " + oid );
-            }
-        }
-        else
-        {
-            addIndexOn( type, cacheSize, numDupLimit );
-        }
+
+    public void setWorkingDirectory( File workingDirectory )
+    {
+        protect( "workingDirectory" );
+        this.workingDirectory = workingDirectory;
     }
-    
-    /**
-     * Initialize the system indices
-     */
-    private void initSystemIndices( String systemIndexName, Set<String> customAddedSystemIndices ) throws NamingException
+
+
+    public File getWorkingDirectory()
     {
-        if ( ! customAddedSystemIndices.contains( systemIndexName ) )
-        {
-            AttributeType type = attributeTypeRegistry.lookup( systemIndexName );
-            
-            if ( log.isDebugEnabled() )
-            {
-            	log.debug( "Using default cache size of {} for index on attribute {}", 
-            			new Integer( IndexConfiguration.DEFAULT_INDEX_CACHE_SIZE ), systemIndexName );
-            }
-            
-            if ( systemIndexName.equals( Oid.EXISTANCE ) )
-            {
-                setExistanceIndexOn( type, IndexConfiguration.DEFAULT_INDEX_CACHE_SIZE, 
-                    IndexConfiguration.DEFAULT_DUPLICATE_LIMIT );
-            }
-            else if ( systemIndexName.equals( Oid.HIERARCHY ) )
-            {
-                setHierarchyIndexOn( type, IndexConfiguration.DEFAULT_INDEX_CACHE_SIZE,
-                    IndexConfiguration.DEFAULT_DUPLICATE_LIMIT );
-            }
-            else if ( systemIndexName.equals( Oid.UPDN ) )
-            {
-                setUpdnIndexOn( type, IndexConfiguration.DEFAULT_INDEX_CACHE_SIZE,
-                    IndexConfiguration.DEFAULT_DUPLICATE_LIMIT );
-            }
-            else if ( systemIndexName.equals( Oid.NDN ) )
-            {
-                setNdnIndexOn( type, IndexConfiguration.DEFAULT_INDEX_CACHE_SIZE,
-                    IndexConfiguration.DEFAULT_DUPLICATE_LIMIT );
-            }
-            else if ( systemIndexName.equals( Oid.ONEALIAS ) )
-            {
-                setOneAliasIndexOn( type, IndexConfiguration.DEFAULT_INDEX_CACHE_SIZE,
-                    IndexConfiguration.DEFAULT_DUPLICATE_LIMIT );
-            }
-            else if ( systemIndexName.equals( Oid.SUBALIAS ) )
-            {
-                setSubAliasIndexOn( type, IndexConfiguration.DEFAULT_INDEX_CACHE_SIZE,
-                    IndexConfiguration.DEFAULT_DUPLICATE_LIMIT );
-            }
-            else if ( systemIndexName.equals( Oid.ALIAS ) )
-            {
-                setAliasIndexOn( type, IndexConfiguration.DEFAULT_INDEX_CACHE_SIZE,
-                    IndexConfiguration.DEFAULT_DUPLICATE_LIMIT );
-            }
-            else
-            {
-                throw new NamingException( "Unidentified system index " + systemIndexName );
-            }
-        }
+        return workingDirectory;
     }
-    
-    /**
-     * Use this method to initialize the indices.  Only call this after
-     * the registries and the optimizer have been enabled.  The '2' at the end
-     * shows this is the 3rd init method called in the init sequence.
-     * 
-     * @param indices The set of indices to initialize, found in the configuration file.
-     * @throws NamingException
-     */
-    protected void initIndices2( Set indices ) throws NamingException
+
+
+    public void setUserIndices( Set<JdbmIndex> userIndices )
     {
-        Set<String> sysOidSet = new HashSet<String>();
-        sysOidSet.add( Oid.EXISTANCE );
-        sysOidSet.add( Oid.HIERARCHY );
-        sysOidSet.add( Oid.UPDN );
-        sysOidSet.add( Oid.NDN );
-        sysOidSet.add( Oid.ONEALIAS );
-        sysOidSet.add( Oid.SUBALIAS );
-        sysOidSet.add( Oid.ALIAS );
-
-        // Used to calculate the system indices we must automatically add
-        Set<String> customAddedSystemIndices = new HashSet<String>();
-        
-        for ( Object indexName:indices )
-        {
-            /*
-             * NOTE
-             * ====
-             * 
-             * The object returned by the indexedAttributes property
-             * of the configuration may include just a simple set of <String> 
-             * names for the attributes being index OR may include a set 
-             * of IndexConfiguration objects.
-             * 
-             * If the objects are strings extra information about the
-             * cacheSize of an index is not available and so the default is
-             * used.  If an IndexConfiguration is available then the custom
-             * cacheSize is used.
-             */
-            initCustomIndex( indexName, sysOidSet, customAddedSystemIndices );
-        }
-        
-        // -------------------------------------------------------------------
-        // Add all system indices that were not custom configured by iterating
-        // through all system index oids and checking of that index is 
-        // contained within the customAddedSystemIndices set.  If it is not
-        // contained in this set then the system index was not custom 
-        // configured above and must be configured with defaults below.
-        // -------------------------------------------------------------------
-        
-        for ( String systemIndexName:sysOidSet )
+        protect( "userIndices" );
+        for ( JdbmIndex index : userIndices )
         {
-        	initSystemIndices( systemIndexName, customAddedSystemIndices );
+            this.userIndices.put( index.getAttributeId(), index );
         }
     }
 
-    
-    /**
-     * Called last (4th) to check if the suffix entry has been created on disk,
-     * and if not it is created.
-     *  
-     * @param suffix
-     * @param entry
-     * @throws NamingException
-     */
-    protected void initSuffixEntry3( String suffix, Attributes entry ) throws NamingException
+
+    public Set<JdbmIndex> getUserIndices()
     {
-        // add entry for context, if it does not exist
-        Attributes suffixOnDisk = getSuffixEntry();
-        
-        if ( suffixOnDisk == null )
-        {
-            LdapDN dn = new LdapDN( suffix );
-            LdapDN normalizedSuffix = LdapDN.normalize( dn, attributeTypeRegistry.getNormalizerMapping() );
-            add( normalizedSuffix, entry );
-        }
+        return new HashSet<JdbmIndex>( userIndices.values() );
+    }
+
+
+    public void setContextEntry( Attributes contextEntry )
+    {
+        protect( "contextEntry" );
+        this.contextEntry = contextEntry;
+    }
+
+
+    public Attributes getContextEntry()
+    {
+        return contextEntry;
+    }
+
+
+    public void setSuffixDn( String suffixDn )
+    {
+        protect( "suffixDn" );
+        this.suffixDn = suffixDn;
+    }
+
+
+    public String getSuffixDn()
+    {
+        return suffixDn;
+    }
+
+
+    public void setSyncOnWrite( boolean isSyncOnWrite )
+    {
+        protect( "syncOnWrite" );
+        this.isSyncOnWrite = isSyncOnWrite;
+    }
+
+
+    public boolean isSyncOnWrite()
+    {
+        return isSyncOnWrite;
+    }
+
+
+    public void setEnableOptimizer( boolean enableOptimizer )
+    {
+        protect( "enableOptimizer" );
+        this.enableOptimizer = enableOptimizer;
+    }
+
+
+    public boolean isEnableOptimizer()
+    {
+        return enableOptimizer;
+    }
+
+
+    public void setCacheSize( int cacheSize )
+    {
+        protect( "cacheSize" );
+        this.cacheSize = cacheSize;
+    }
+
+
+    public int getCacheSize()
+    {
+        return cacheSize;
+    }
+
+
+    public void setName( String name )
+    {
+        protect( "name" );
+        this.name = name;
+    }
+
+
+    public String getName()
+    {
+        return name;
     }
 
+
+    // -----------------------------------------------------------------------
+    // E N D   C O N F I G U R A T I O N   M E T H O D S
+    // -----------------------------------------------------------------------
+
+
+
     /**
      * Initialize the JDBM storage system.
-     * 
-     * @param config The configuration conatining all the information about indices, cahce, etc.
-     * @throws NamingException If we get some error
+     *
+     * @param oidRegistry an OID registry to resolve numeric identifiers from names
+     * @param attributeTypeRegistry an attributeType specification registry to lookup type specs
+     * @throws NamingException on failure to create proper database files
      */
-    public synchronized void init( JdbmStoreConfiguration config ) throws NamingException
+    public synchronized void init( OidRegistry oidRegistry, AttributeTypeRegistry attributeTypeRegistry )
+            throws NamingException
     {
-        isSyncOnWrite = config.isSyncOnWrite();
-
-        oidRegistry = config.getOidRegistry();
-        attributeTypeRegistry = config.getAttributeTypeRegistry();
+        this.oidRegistry = oidRegistry;
+        this.attributeTypeRegistry = attributeTypeRegistry;
 
         OBJECT_CLASS_AT = attributeTypeRegistry.lookup( SchemaConstants.OBJECT_CLASS_AT );
         ALIASED_OBJECT_NAME_AT = attributeTypeRegistry.lookup( SchemaConstants.ALIASED_OBJECT_NAME_AT );
-        
-        this.upSuffix = new LdapDN( config.getSuffixDn() );
-        this.normSuffix = LdapDN.normalize( upSuffix, attributeTypeRegistry.getNormalizerMapping() );
 
-        workingDirectory = config.getWorkingDirectory();
+        this.upSuffix = new LdapDN( suffixDn );
+        this.normSuffix = LdapDN.normalize( upSuffix, attributeTypeRegistry.getNormalizerMapping() );
         workingDirectory.mkdirs();
 
         try
@@ -412,29 +281,25 @@
             String path = workingDirectory.getPath() + File.separator + "master";
             BaseRecordManager base = new BaseRecordManager( path );
             base.disableTransactions();
-            
-            int cacheSize = config.getCacheSize();
-            
+
             if ( cacheSize < 0 )
             {
                 cacheSize = DEFAULT_CACHE_SIZE;
-                
-                if ( log.isDebugEnabled() )
+
+                if ( LOG.isDebugEnabled() )
                 {
-	                log.debug( "Using the default entry cache size of {} for {} partition", 
-	                    new Integer( cacheSize ), config.getName() );
+	                LOG.debug( "Using the default entry cache size of {} for {} partition", cacheSize, name );
                 }
             }
             else
             {
-            	if ( log.isDebugEnabled() )
+            	if ( LOG.isDebugEnabled() )
             	{
-	                log.debug( "Using the custom configured cache size of {} for {} partition", 
-	                    new Integer( cacheSize ), config.getName() );
+	                LOG.debug( "Using the custom configured cache size of {} for {} partition", cacheSize, name );
             	}
             }
-            
-            // Now, create the entry cache for this partition 
+
+            // Now, create the entry cache for this partition
             recMan = new CacheRecordManager( base, new MRU( cacheSize ) );
         }
         catch ( IOException e )
@@ -446,20 +311,136 @@
 
         // Create the master table (the table wcontaining all the entries)
         master = new JdbmMasterTable( recMan );
-        
-        // Initializes this partition indices
-        indices = new HashMap<String,Index>();
-        sysIndices = new HashMap<String,Index>();
 
-        initIndices2( config.getIndexedAttributes() );
-        initSuffixEntry3( config.getSuffixDn(), config.getContextEntry() );
-        
+        // -------------------------------------------------------------------
+        // Initializes the user and system indices
+        // -------------------------------------------------------------------
+
+        setupSystemIndices();
+        setupUserIndices();
+        initSuffixEntry3( suffixDn, contextEntry );
+
         // We are done !
         initialized = true;
     }
 
+
+    private void setupSystemIndices() throws NamingException
+    {
+        if ( systemIndices.size() > 0 )
+        {
+            HashMap<String,JdbmIndex> tmp = new HashMap<String,JdbmIndex>();
+            for ( JdbmIndex index : systemIndices.values() )
+            {
+                String oid = oidRegistry.getOid( index.getAttributeId() );
+                tmp.put( oid, index );
+                index.init( attributeTypeRegistry.lookup( oid ), workingDirectory );
+            }
+            systemIndices = tmp;
+        }
+
+        if ( ndnIdx == null )
+        {
+            ndnIdx = new JdbmIndex();
+            ndnIdx.setAttributeId( Oid.NDN );
+            systemIndices.put( Oid.NDN, ndnIdx );
+            ndnIdx.init( attributeTypeRegistry.lookup( Oid.NDN ), workingDirectory );
+        }
+
+        if ( updnIdx == null )
+        {
+            updnIdx = new JdbmIndex();
+            updnIdx.setAttributeId( Oid.UPDN );
+            systemIndices.put( Oid.UPDN, updnIdx );
+            updnIdx.init( attributeTypeRegistry.lookup( Oid.UPDN ), workingDirectory );
+        }
+
+        if ( existanceIdx == null )
+        {
+            existanceIdx = new JdbmIndex();
+            existanceIdx.setAttributeId( Oid.EXISTANCE );
+            systemIndices.put( Oid.EXISTANCE, existanceIdx );
+            existanceIdx.init( attributeTypeRegistry.lookup( Oid.EXISTANCE ), workingDirectory );
+        }
+
+        if ( hierarchyIdx == null )
+        {
+            hierarchyIdx = new JdbmIndex();
+            hierarchyIdx.setAttributeId( Oid.HIERARCHY );
+            systemIndices.put( Oid.HIERARCHY, hierarchyIdx );
+            hierarchyIdx.init( attributeTypeRegistry.lookup( Oid.HIERARCHY ), workingDirectory );
+        }
+
+        if ( oneAliasIdx == null )
+        {
+            oneAliasIdx = new JdbmIndex();
+            oneAliasIdx.setAttributeId( Oid.ONEALIAS );
+            systemIndices.put( Oid.ONEALIAS, oneAliasIdx );
+            oneAliasIdx.init( attributeTypeRegistry.lookup( Oid.ONEALIAS ), workingDirectory );
+        }
+
+        if ( subAliasIdx == null )
+        {
+            subAliasIdx = new JdbmIndex();
+            subAliasIdx.setAttributeId( Oid.SUBALIAS );
+            systemIndices.put( Oid.SUBALIAS, subAliasIdx );
+            subAliasIdx.init( attributeTypeRegistry.lookup( Oid.SUBALIAS ), workingDirectory );
+        }
+
+        if ( aliasIdx == null )
+        {
+            aliasIdx = new JdbmIndex();
+            aliasIdx.setAttributeId( Oid.ALIAS );
+            systemIndices.put( Oid.ALIAS, aliasIdx );
+            aliasIdx.init( attributeTypeRegistry.lookup( Oid.ALIAS ), workingDirectory );
+        }
+    }
+
+
+    private void setupUserIndices() throws NamingException
+    {
+        if ( userIndices != null && userIndices.size() > 0 )
+        {
+            HashMap<String,JdbmIndex> tmp = new HashMap<String,JdbmIndex>();
+            for ( JdbmIndex index : userIndices.values() )
+            {
+                String oid = oidRegistry.getOid( index.getAttributeId() );
+                tmp.put( oid, index );
+                index.init( attributeTypeRegistry.lookup( oid ), workingDirectory );
+            }
+            userIndices = tmp;
+        }
+        else
+        {
+            userIndices = new HashMap<String,JdbmIndex>();
+        }
+    }
+
+
+    /**
+     * Called last (4th) to check if the suffix entry has been created on disk,
+     * and if not it is created.
+     *  
+     * @param suffix the suffix for the store
+     * @param entry the root entry of the store
+     * @throws NamingException on failre to add the root entry
+     */
+    protected void initSuffixEntry3( String suffix, Attributes entry ) throws NamingException
+    {
+        // add entry for context, if it does not exist
+        Attributes suffixOnDisk = getSuffixEntry();
+        
+        if ( suffixOnDisk == null )
+        {
+            LdapDN dn = new LdapDN( suffix );
+            LdapDN normalizedSuffix = LdapDN.normalize( dn, attributeTypeRegistry.getNormalizerMapping() );
+            add( normalizedSuffix, entry );
+        }
+    }
+
+
     /**
-     * Close the parttion : we have to close all the indices and the master table. 
+     * Close the parttion : we have to close all the userIndices and the master table.
      *
      */
     public synchronized void destroy()
@@ -469,8 +450,8 @@
             return;
         }
 
-        List<Index> array = new ArrayList<Index>();
-        array.addAll( indices.values() );
+        List<JdbmIndex> array = new ArrayList<JdbmIndex>();
+        array.addAll( userIndices.values() );
 
         if ( null != ndnIdx )
         {
@@ -507,7 +488,7 @@
             array.add( existanceIdx );
         }
 
-        for ( Index index:array )
+        for ( JdbmIndex index:array )
         {
             try
             {
@@ -515,7 +496,7 @@
             }
             catch ( Throwable t )
             {
-                log.error( "Failed to close an index.", t );
+                LOG.error( "Failed to close an index.", t );
             }
         }
 
@@ -525,7 +506,7 @@
         }
         catch ( Throwable t )
         {
-            log.error( "Failed to close the master.", t );
+            LOG.error( "Failed to close the master.", t );
         }
 
         try
@@ -534,24 +515,29 @@
         }
         catch ( Throwable t )
         {
-            log.error( "Failed to close the record manager", t );
+            LOG.error( "Failed to close the record manager", t );
         }
 
         initialized = false;
     }
 
+
     /**
-     * @return True is the partition store is initialized
+     * Gets whether the store is initialized.
+     *
+     * @return true if the partition store is initialized
      */
     public boolean isInitialized()
     {
         return initialized;
     }
 
+
     /**
      * This method is called when the synch thread is waking up, to write
      * the modified data.
-     * @throws NamingException
+     * 
+     * @throws NamingException on failures to sync to disk
      */
     public synchronized void sync() throws NamingException
     {
@@ -561,7 +547,7 @@
         }
 
         List<Index> array = new ArrayList<Index>();
-        array.addAll( indices.values() );
+        array.addAll( userIndices.values() );
         array.add( ndnIdx );
         array.add( updnIdx );
         array.add( aliasIdx );
@@ -570,7 +556,7 @@
         array.add( hierarchyIdx );
         array.add( existanceIdx );
 
-        // Sync all user defined indices
+        // Sync all user defined userIndices
         for ( Index idx:array )
         {
             idx.sync();
@@ -594,174 +580,136 @@
     // I N D E X   M E T H O D S
     // ------------------------------------------------------------------------
 
-    public void addIndexOn( AttributeType spec, int cacheSize, int numDupLimit ) throws NamingException
+
+    public void addIndex( JdbmIndex index ) throws NamingException
     {
-        Index idx = new JdbmIndex( spec, workingDirectory, cacheSize, numDupLimit );
-        indices.put( spec.getOid(), idx );
+        userIndices.put( index.getAttributeId(), index );
     }
 
 
-    public Index getExistanceIndex()
+    public JdbmIndex getExistanceIndex()
     {
         return existanceIdx;
     }
 
 
-    public void setExistanceIndexOn( AttributeType attrType, int cacheSize, int numDupLimit ) throws NamingException
+    public void setExistanceIndex( JdbmIndex index ) throws NamingException
     {
-        if ( existanceIdx != null )
-        {
-            NamingException e = new NamingException( "Index already set!" );
-            throw e;
-        }
-
-        existanceIdx = new JdbmIndex( attrType, workingDirectory, cacheSize, numDupLimit );
-        sysIndices.put( attrType.getOid(), existanceIdx );
+        protect( "existanceIndex" );
+        existanceIdx = index;
+        systemIndices.put( index.getAttributeId(), existanceIdx );
     }
 
 
-    public Index getHierarchyIndex()
+    public JdbmIndex getHierarchyIndex()
     {
         return hierarchyIdx;
     }
 
 
-    public void setHierarchyIndexOn( AttributeType attrType, int cacheSize, int numDupLimit ) throws NamingException
+    public void setHierarchyIndex( JdbmIndex index ) throws NamingException
     {
-        if ( hierarchyIdx != null )
-        {
-            NamingException e = new NamingException( "Index already set!" );
-            throw e;
-        }
-
-        hierarchyIdx = new JdbmIndex( attrType, workingDirectory, cacheSize, numDupLimit );
-        sysIndices.put( attrType.getOid(), hierarchyIdx );
+        protect( "hierarchyIndex" );
+        hierarchyIdx = index;
+        systemIndices.put( index.getAttributeId(), hierarchyIdx );
     }
 
 
-    public Index getAliasIndex()
+    public JdbmIndex getAliasIndex()
     {
         return aliasIdx;
     }
 
 
-    public void setAliasIndexOn( AttributeType attrType, int cacheSize, int numDupLimit ) throws NamingException
+    public void setAliasIndex( JdbmIndex index ) throws NamingException
     {
-        if ( aliasIdx != null )
-        {
-            NamingException e = new NamingException( "Index already set!" );
-            throw e;
-        }
-
-        aliasIdx = new JdbmIndex( attrType, workingDirectory, cacheSize, numDupLimit );
-        sysIndices.put( attrType.getOid(), aliasIdx );
+        protect( "aliasIndex" );
+        aliasIdx = index;
+        systemIndices.put( index.getAttributeId() , aliasIdx );
     }
 
 
-    public Index getOneAliasIndex()
+    public JdbmIndex getOneAliasIndex()
     {
         return oneAliasIdx;
     }
 
 
-    public void setOneAliasIndexOn( AttributeType attrType, int cacheSize, int numDupLimit ) throws NamingException
+    public void setOneAliasIndex( JdbmIndex index ) throws NamingException
     {
-        if ( oneAliasIdx != null )
-        {
-            NamingException e = new NamingException( "Index already set!" );
-            throw e;
-        }
-
-        oneAliasIdx = new JdbmIndex( attrType, workingDirectory, cacheSize, numDupLimit );
-        sysIndices.put( attrType.getOid(), oneAliasIdx );
+        protect( "oneAliasIndex" );
+        oneAliasIdx = index;
+        systemIndices.put( index.getAttributeId(), oneAliasIdx );
     }
 
 
-    public Index getSubAliasIndex()
+    public JdbmIndex getSubAliasIndex()
     {
         return subAliasIdx;
     }
 
 
-    public void setSubAliasIndexOn( AttributeType attrType, int cacheSize, int numDupLimit ) throws NamingException
+    public void setSubAliasIndex( JdbmIndex index ) throws NamingException
     {
-        if ( subAliasIdx != null )
-        {
-            NamingException e = new NamingException( "Index already set!" );
-            throw e;
-        }
-
-        subAliasIdx = new JdbmIndex( attrType, workingDirectory, cacheSize, numDupLimit );
-        sysIndices.put( attrType.getOid(), subAliasIdx );
+        protect( "subAliasIndex" );
+        subAliasIdx = index;
+        systemIndices.put( index.getAttributeId(), subAliasIdx );
     }
 
 
-    public Index getUpdnIndex()
+    public JdbmIndex getUpdnIndex()
     {
         return updnIdx;
     }
 
 
-    public void setUpdnIndexOn( AttributeType attrType, int cacheSize, int numDupLimit ) throws NamingException
+    public void setUpdnIndex( JdbmIndex index ) throws NamingException
     {
-        if ( updnIdx != null )
-        {
-            NamingException e = new NamingException( "Index already set!" );
-            throw e;
-        }
-
-        updnIdx = new JdbmIndex( attrType, workingDirectory, cacheSize, numDupLimit );
-        sysIndices.put( attrType.getOid(), updnIdx );
+        protect( "updnIndex" );
+        updnIdx = index;
+        systemIndices.put( index.getAttributeId(), updnIdx );
     }
 
 
-    public Index getNdnIndex()
+    public JdbmIndex getNdnIndex()
     {
         return ndnIdx;
     }
 
 
-    public void setNdnIndexOn( AttributeType attrType, int cacheSize, int numDupLimit ) throws NamingException
+    public void setNdnIndex( JdbmIndex index ) throws NamingException
     {
-        if ( ndnIdx != null )
-        {
-            NamingException e = new NamingException( "Index already set!" );
-            throw e;
-        }
-
-        ndnIdx = new JdbmIndex( attrType, workingDirectory, cacheSize, numDupLimit );
-        sysIndices.put( attrType.getOid(), ndnIdx );
+        protect( "ndnIndex" );
+        ndnIdx = index;
+        systemIndices.put( index.getAttributeId(), ndnIdx );
     }
 
 
-    public Iterator getUserIndices()
+    public Iterator<String> userIndices()
     {
-        return indices.keySet().iterator();
+        return userIndices.keySet().iterator();
     }
 
 
-    public Iterator<String> getSystemIndices()
+    public Iterator<String> systemIndices()
     {
-        return sysIndices.keySet().iterator();
+        return systemIndices.keySet().iterator();
     }
 
 
     public boolean hasUserIndexOn( String id ) throws NamingException
     {
-        return indices.containsKey( oidRegistry.getOid( id ) );
+        return userIndices.containsKey( oidRegistry.getOid( id ) );
     }
 
 
     public boolean hasSystemIndexOn( String id ) throws NamingException
     {
-        return sysIndices.containsKey( oidRegistry.getOid( id ) );
+        return systemIndices.containsKey( oidRegistry.getOid( id ) );
     }
 
 
-    /**
-     * @see org.apache.directory.server.core.partition.impl.btree.BTreePartition#getUserIndex(String)
-     */
-    public Index getUserIndex( String id ) throws IndexNotFoundException
+    public JdbmIndex getUserIndex( String id ) throws IndexNotFoundException
     {
         try
         {
@@ -769,17 +717,17 @@
         }
         catch ( NamingException e )
         {
-            log.error( "Failed to identify OID for: " + id, e );
+            LOG.error( "Failed to identify OID for: " + id, e );
             throw new IndexNotFoundException( "Failed to identify OID for: " + id, id, e );
         }
 
-        if ( indices.containsKey( id ) )
+        if ( userIndices.containsKey( id ) )
         {
-            return indices.get( id );
+            return userIndices.get( id );
         }
         else
         {
-            String name = "unknown";
+            String name;
             
             try
             {
@@ -788,7 +736,7 @@
             catch ( NamingException e )
             {
                 String msg = "Failed to resolve primary name for " + id + " in user index lookup";
-                log.error( msg, e );
+                LOG.error( msg, e );
                 throw new IndexNotFoundException( msg, id, e );
             }
             
@@ -798,10 +746,7 @@
     }
 
 
-    /**
-     * @see BTreePartition#getEntryId(String)
-     */
-    public Index getSystemIndex( String id ) throws IndexNotFoundException
+    public JdbmIndex getSystemIndex( String id ) throws IndexNotFoundException
     {
         try
         {
@@ -809,18 +754,18 @@
         }
         catch ( NamingException e )
         {
-            log.error( "Failed to identify OID for: " + id, e );
+            LOG.error( "Failed to identify OID for: " + id, e );
             throw new IndexNotFoundException( "Failed to identify OID for: " + id, id, e );
         }
 
 
-        if ( sysIndices.containsKey( id ) )
+        if ( systemIndices.containsKey( id ) )
         {
-            return sysIndices.get( id );
+            return systemIndices.get( id );
         }
         else
         {
-            String name = "unknown";
+            String name;
             
             try
             {
@@ -829,7 +774,7 @@
             catch ( NamingException e )
             {
                 String msg = "Failed to resolve primary name for " + id + " in user index lookup";
-                log.error( msg, e );
+                LOG.error( msg, e );
                 throw new IndexNotFoundException( msg, id, e );
             }
             
@@ -841,7 +786,7 @@
 
     public Long getEntryId( String dn ) throws NamingException
     {
-        return (Long)ndnIdx.forwardLookup( dn );
+        return ndnIdx.forwardLookup( dn );
     }
 
 
@@ -853,7 +798,7 @@
 
     public Long getParentId( String dn ) throws NamingException
     {
-        Long childId = (Long)ndnIdx.forwardLookup( dn );
+        Long childId = ndnIdx.forwardLookup( dn );
         return ( Long ) hierarchyIdx.reverseLookup( childId );
     }
 
@@ -872,7 +817,7 @@
 
     public String getEntryUpdn( String dn ) throws NamingException
     {
-        Long id = (Long)ndnIdx.forwardLookup( dn );
+        Long id = ndnIdx.forwardLookup( dn );
         return ( String ) updnIdx.reverseLookup( id );
     }
 
@@ -889,7 +834,7 @@
      * 
      * @todo Optimize this by walking the hierarchy index instead of the name 
      * @param aliasId the id of the alias entry in the master table
-     * @throws NamingException if we cannot delete the indices
+     * @throws NamingException if we cannot delete the userIndices
      */
     private void dropAliasIndices( Long aliasId ) throws NamingException
     {
@@ -900,7 +845,7 @@
         Long ancestorId = getEntryId( ancestorDn.toString() );
 
         /*
-         * We cannot just drop all tuples in the one level and subtree indices
+         * We cannot just drop all tuples in the one level and subtree userIndices
          * linking baseIds to the targetId.  If more than one alias refers to
          * the target then droping all tuples with a value of targetId would
          * make all other aliases to the target inconsistent.
@@ -927,7 +872,7 @@
 
 
     /**
-     * Adds indices for an aliasEntry to be added to the database while checking
+     * Adds userIndices for an aliasEntry to be added to the database while checking
      * for constrained alias constructs like alias cycles and chaining.
      * 
      * @param aliasDn normalized distinguished name for the alias entry
@@ -938,10 +883,10 @@
      */
     private void addAliasIndices( Long aliasId, LdapDN aliasDn, String aliasTarget ) throws NamingException
     {
-        LdapDN normalizedAliasTargetDn = null; // Name value of aliasedObjectName
-        Long targetId = null; // Id of the aliasedObjectName
-        LdapDN ancestorDn = null; // Name of an alias entry relative
-        Long ancestorId = null; // Id of an alias entry relative
+        LdapDN normalizedAliasTargetDn; // Name value of aliasedObjectName
+        Long targetId; // Id of the aliasedObjectName
+        LdapDN ancestorDn; // Name of an alias entry relative
+        Long ancestorId; // Id of an alias entry relative
 
         // Access aliasedObjectName, normalize it and generate the Name 
         normalizedAliasTargetDn = new LdapDN( aliasTarget );
@@ -986,7 +931,7 @@
         }
 
         // L O O K U P   T A R G E T   I D
-        targetId = (Long)ndnIdx.forwardLookup( normalizedAliasTargetDn.toNormName() );
+        targetId = ndnIdx.forwardLookup( normalizedAliasTargetDn.toNormName() );
 
         /*
          * Check For Target Existance
@@ -1064,7 +1009,7 @@
     public void add( LdapDN normName, Attributes entry ) throws NamingException
     {
         Long id;
-        Long parentId = null;
+        Long parentId;
 
         id = master.getNextId();
 
@@ -1101,7 +1046,7 @@
             throw new LdapSchemaViolationException( msg, ResultCodeEnum.OBJECT_CLASS_VIOLATION );
         }
 
-        // Start adding the system indices
+        // Start adding the system userIndices
         // Why bother doing a lookup if this is not an alias.
 
         if ( objectClass.contains( SchemaConstants.ALIAS_OC ) )
@@ -1114,7 +1059,7 @@
         updnIdx.add( normName.getUpName(), id );
         hierarchyIdx.add( parentId, id );
 
-        // Now work on the user defined indices
+        // Now work on the user defined userIndices
         NamingEnumeration list = entry.getIDs();
         
         while ( list.hasMore() )
@@ -1267,7 +1212,7 @@
         attributes.put( "_parent", getParentId( id ) );
 
         // Get all standard index attribute to value mappings
-        for ( Index index:this.indices.values() )
+        for ( Index index:this.userIndices.values() )
         {
             NamingEnumeration list = index.listReverseIndices( id );
             
@@ -1330,7 +1275,7 @@
 
 
     /**
-     * Adds a set of attribute values while affecting the appropriate indices. 
+     * Adds a set of attribute values while affecting the appropriate userIndices.
      * The entry is not persisted: it is only changed in anticipation for a put 
      * into the master table.
      *
@@ -1381,7 +1326,7 @@
 
     /**
      * Completely removes the set of values for an attribute having the values 
-     * supplied while affecting the appropriate indices.  The entry is not 
+     * supplied while affecting the appropriate userIndices.  The entry is not
      * persisted: it is only changed in anticipation for a put into the master 
      * table.  Note that an empty attribute w/o values will remove all the 
      * values within the entry where as an attribute w/ values will remove those
@@ -1450,7 +1395,7 @@
 
     /**
      * Completely replaces the existing set of values for an attribute with the
-     * modified values supplied affecting the appropriate indices.  The entry
+     * modified values supplied affecting the appropriate userIndices.  The entry
      * is not persisted: it is only changed in anticipation for a put into the
      * master table.
      *
@@ -1509,7 +1454,7 @@
 
     public void modify( LdapDN dn, int modOp, Attributes mods ) throws NamingException
     {
-        NamingEnumeration attrs = null;
+        NamingEnumeration attrs;
         Long id = getEntryId( dn.toString() );
         Attributes entry = master.get( id );
 
@@ -1569,24 +1514,24 @@
         Long id = getEntryId( dn.toString() );
         Attributes entry = master.get( id );
 
-        for ( int ii = 0; ii < mods.length; ii++ )
+        for ( ModificationItemImpl mod : mods )
         {
-            Attribute attrMods = mods[ii].getAttribute();
+            Attribute attrMods = mod.getAttribute();
 
-            switch ( mods[ii].getModificationOp() )
+            switch ( mod.getModificationOp() )
             {
-                case ( DirContext.ADD_ATTRIBUTE  ):
+                case ( DirContext.ADD_ATTRIBUTE ):
                     add( id, entry, attrMods );
                     break;
-                    
-                case ( DirContext.REMOVE_ATTRIBUTE  ):
-                    remove( id, entry, attrMods );
+
+                case ( DirContext.REMOVE_ATTRIBUTE ):
+                    remove(id, entry, attrMods);
                     break;
-                    
-                case ( DirContext.REPLACE_ATTRIBUTE  ):
+
+                case ( DirContext.REPLACE_ATTRIBUTE ):
                     replace( id, entry, attrMods );
                     break;
-                    
+
                 default:
                     throw new NamingException( "Unidentified modification operation" );
             }
@@ -1741,14 +1686,14 @@
      * @param id the primary key of the entry
      * @param updn User provided distinguished name to set as the new DN
      * @param isMove whether or not the name change is due to a move operation
-     * which affects alias indices.
+     * which affects alias userIndices.
      * @throws NamingException if something goes wrong
      */
     private void modifyDn( Long id, LdapDN updn, boolean isMove ) throws NamingException
     {
-        String aliasTarget = null;
+        String aliasTarget;
 
-        // Now we can handle the appropriate name indices for all cases
+        // Now we can handle the appropriate name userIndices for all cases
         ndnIdx.drop( id );
         
         LdapDN normalizedDn = ( updn.isNormalized() ? updn : LdapDN.normalize( updn, attributeTypeRegistry.getNormalizerMapping() ) );
@@ -1762,7 +1707,7 @@
          * Read Alias Index Tuples
          * 
          * If this is a name change due to a move operation then the one and
-         * subtree indices for aliases were purged before the aliases were 
+         * subtree userIndices for aliases were purged before the aliases were
          * moved.  Now we must add them for each alias entry we have moved.  
          * 
          * aliasTarget is used as a marker to tell us if we're moving an 
@@ -1836,6 +1781,7 @@
      * propagating down through the moved child and its descendants.
      * 
      * @param oldChildDn the normalized dn of the child to be moved
+     * @param childId the id of the child being moved
      * @param newParentDn the normalized dn of the new parent for the child
      * @throws NamingException if something goes wrong
      */
@@ -1847,7 +1793,7 @@
 
         /*
          * All aliases including and below oldChildDn, will be affected by
-         * the move operation with respect to one and subtree indices since 
+         * the move operation with respect to one and subtree userIndices since
          * their relationship to ancestors above oldChildDn will be 
          * destroyed.  For each alias below and including oldChildDn we will
          * drop the index tuples mapping ancestor ids above oldChildDn to the
@@ -1883,7 +1829,7 @@
      * that will no longer be ancestors after the move.
      * 
      * @param movedBase the base at which the move occured - the moved node
-     * @throws NamingException if system indices fail
+     * @throws NamingException if system userIndices fail
      */
     private void dropMovedAliasIndices( final LdapDN movedBase ) throws NamingException
     {
@@ -1893,12 +1839,7 @@
             public boolean assertCandidate( IndexRecord rec ) throws NamingException
             {
                 String dn = getEntryDn( (Long)rec.getEntryId() );
-                if ( dn.endsWith( movedBase.toString() ) )
-                {
-                    return true;
-                }
-
-                return false;
+                return dn.endsWith( movedBase.toString() );
             }
         };
 
@@ -1926,7 +1867,7 @@
      * 
      * @param aliasId the id of the alias 
      * @param movedBase the base where the move occured
-     * @throws NamingException if indices fail
+     * @throws NamingException if userIndices fail
      */
     private void dropAliasIndices( Long aliasId, LdapDN movedBase ) throws NamingException
     {
@@ -1942,7 +1883,7 @@
         Long ancestorId = getEntryId( ancestorDn.toString() );
 
         /*
-         * We cannot just drop all tuples in the one level and subtree indices
+         * We cannot just drop all tuples in the one level and subtree userIndices
          * linking baseIds to the targetId.  If more than one alias refers to
          * the target then droping all tuples with a value of targetId would
          * make all other aliases to the target inconsistent.

Modified: directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreConfiguration.java?rev=580566&r1=580565&r2=580566&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreConfiguration.java (original)
+++ directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreConfiguration.java Sat Sep 29 02:54:34 2007
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.server.core.partition.impl.btree.jdbm;
 
+
 import java.io.File;
 import java.util.Set;
 



Mime
View raw message