directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1302886 - in /directory/apacheds/trunk: jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/avl/ xdbm-partition/src/main/java...
Date Tue, 20 Mar 2012 13:39:26 GMT
Author: elecharny
Date: Tue Mar 20 13:39:26 2012
New Revision: 1302886

URL: http://svn.apache.org/viewvc?rev=1302886&view=rev
Log:
Moved the index creation into the specific implementation, using an absract method. This will
lead to the removal of the GenericIndex class later.

Modified:
    directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/avl/AvlPartition.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java

Modified: directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java?rev=1302886&r1=1302885&r2=1302886&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
(original)
+++ directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
Tue Mar 20 13:39:26 2012
@@ -23,6 +23,7 @@ package org.apache.directory.server.core
 import java.io.File;
 import java.io.FilenameFilter;
 import java.io.IOException;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -172,7 +173,7 @@ public class JdbmPartition extends Abstr
             {
                 allIndices.add( index.getAttributeId() );
 
-                // take the part after removing .db from the  
+                // take the part after removing .db from the
                 String name = index.getAttributeId() + JDBM_DB_FILE_EXTN;
 
                 // if the name doesn't exist in the list of index DB files
@@ -290,7 +291,7 @@ public class JdbmPartition extends Abstr
         for ( File file : dbFiles )
         {
             String name = file.getName();
-            // take the part after removing .db from the  
+            // take the part after removing .db from the
             name = name.substring( 0, name.lastIndexOf( JDBM_DB_FILE_EXTN ) );
 
             // remove the file if not found in the list of names of indices
@@ -407,4 +408,31 @@ public class JdbmPartition extends Abstr
             throw errors;
         }
     }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    protected final Index createSystemIndex( String oid, URI path )  throws Exception
+    {
+        LOG.debug( "Supplied index {} is not a JdbmIndex.  " +
+         "Will create new JdbmIndex using copied configuration parameters." );
+        JdbmIndex<?, Entry> jdbmIndex;
+
+        if ( oid.equals( ApacheSchemaConstants.APACHE_RDN_AT_OID ) )
+        {
+            jdbmIndex = new JdbmRdnIndex();
+            jdbmIndex.setAttributeId( ApacheSchemaConstants.APACHE_RDN_AT_OID );
+            jdbmIndex.setNumDupLimit( JdbmIndex.DEFAULT_DUPLICATE_LIMIT );
+        }
+        else
+        {
+            jdbmIndex = new JdbmIndex( oid );
+            jdbmIndex.setNumDupLimit( JdbmIndex.DEFAULT_DUPLICATE_LIMIT );
+        }
+
+        jdbmIndex.setWkDirPath( path );
+
+        return jdbmIndex;
+    }
 }

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/avl/AvlPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/avl/AvlPartition.java?rev=1302886&r1=1302885&r2=1302886&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/avl/AvlPartition.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/avl/AvlPartition.java
Tue Mar 20 13:39:26 2012
@@ -167,6 +167,31 @@ public class AvlPartition extends Abstra
         return avlIndex;
     }
 
+    
+    /**
+     * {@inheritDoc}
+     */
+    protected final Index createSystemIndex( String oid, URI path ) throws Exception
+    {
+        LOG.debug( "Supplied index {} is not a JdbmIndex.  "
+            + "Will create new JdbmIndex using copied configuration parameters." );
+
+        AvlIndex<?, Entry>  avlIndex;
+
+        if ( oid.equals( ApacheSchemaConstants.APACHE_RDN_AT_OID ) )
+        {
+            avlIndex = new AvlRdnIndex<Entry>( oid );
+        }
+        else
+        {
+            LOG.debug( "Supplied index {} is not a AvlIndex. "
+                + "Will create new AvlIndex using copied configuration parameters." );
+            avlIndex = new AvlIndex( oid );
+        }
+
+        return avlIndex;
+    }
+
 
     /**
      * {@inheritDoc}

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java?rev=1302886&r1=1302885&r2=1302886&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
Tue Mar 20 13:39:26 2012
@@ -52,7 +52,6 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.api.partition.AbstractPartition;
 import org.apache.directory.server.core.api.partition.Partition;
 import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.server.xdbm.GenericIndex;
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.xdbm.IndexEntry;
@@ -286,74 +285,61 @@ public abstract class AbstractBTreeParti
         // add missing system indices
         if ( getPresenceIndex() == null )
         {
-            Index<String, Entry, ID> index = new GenericIndex<String, Entry, ID>(
-                ApacheSchemaConstants.APACHE_PRESENCE_AT_OID );
-            index.setWkDirPath( partitionPath );
+            Index<String, Entry, ID> index = createSystemIndex( ApacheSchemaConstants.APACHE_PRESENCE_AT_OID,
partitionPath );
             addIndex( index );
         }
 
         if ( getOneLevelIndex() == null )
         {
-            Index<ID, Entry, ID> index = new GenericIndex<ID, Entry, ID>( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID
);
-            index.setWkDirPath( partitionPath );
+            Index<ID, Entry, ID> index = createSystemIndex( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID,
partitionPath );
             addIndex( index );
         }
 
         if ( getSubLevelIndex() == null )
         {
-            Index<ID, Entry, ID> index = new GenericIndex<ID, Entry, ID>( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID
);
-            index.setWkDirPath( partitionPath );
+            Index<ID, Entry, ID> index = createSystemIndex( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID,
partitionPath );
             addIndex( index );
         }
 
         if ( getRdnIndex() == null )
         {
-            Index<ParentIdAndRdn<ID>, Entry, ID> index = new GenericIndex<ParentIdAndRdn<ID>,
Entry, ID>(
-                ApacheSchemaConstants.APACHE_RDN_AT_OID );
-            index.setWkDirPath( partitionPath );
+            Index<ParentIdAndRdn<ID>, Entry, ID> index = createSystemIndex( ApacheSchemaConstants.APACHE_RDN_AT_OID,
partitionPath );
             addIndex( index );
         }
 
         if ( getAliasIndex() == null )
         {
-            Index<String, Entry, ID> index = new GenericIndex<String, Entry, ID>(
-                ApacheSchemaConstants.APACHE_ALIAS_AT_OID );
-            index.setWkDirPath( partitionPath );
+            Index<String, Entry, ID> index = createSystemIndex( ApacheSchemaConstants.APACHE_ALIAS_AT_OID,
partitionPath );
             addIndex( index );
         }
 
         if ( getOneAliasIndex() == null )
         {
-            Index<ID, Entry, ID> index = new GenericIndex<ID, Entry, ID>( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID
);
-            index.setWkDirPath( partitionPath );
+            Index<ID, Entry, ID> index = createSystemIndex( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID,
partitionPath );
             addIndex( index );
         }
 
         if ( getSubAliasIndex() == null )
         {
-            Index<ID, Entry, ID> index = new GenericIndex<ID, Entry, ID>( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID
);
-            index.setWkDirPath( partitionPath );
+            Index<ID, Entry, ID> index = createSystemIndex( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID,
partitionPath );
             addIndex( index );
         }
 
         if ( getObjectClassIndex() == null )
         {
-            Index<String, Entry, ID> index = new GenericIndex<String, Entry, ID>(
SchemaConstants.OBJECT_CLASS_AT_OID );
-            index.setWkDirPath( partitionPath );
+            Index<String, Entry, ID> index = createSystemIndex( SchemaConstants.OBJECT_CLASS_AT_OID,
partitionPath );
             addIndex( index );
         }
 
         if ( getEntryUuidIndex() == null )
         {
-            Index<String, Entry, ID> index = new GenericIndex<String, Entry, ID>(
SchemaConstants.ENTRY_UUID_AT_OID );
-            index.setWkDirPath( partitionPath );
+            Index<String, Entry, ID> index = createSystemIndex( SchemaConstants.ENTRY_UUID_AT_OID,
partitionPath );
             addIndex( index );
         }
 
         if ( getEntryCsnIndex() == null )
         {
-            Index<String, Entry, ID> index = new GenericIndex<String, Entry, ID>(
SchemaConstants.ENTRY_CSN_AT_OID );
-            index.setWkDirPath( partitionPath );
+            Index<String, Entry, ID> index = createSystemIndex( SchemaConstants.ENTRY_CSN_AT_OID,
partitionPath );
             addIndex( index );
         }
 
@@ -2617,4 +2603,15 @@ public abstract class AbstractBTreeParti
     {
         return "Partition<" + id + ">";
     }
+
+
+    /**
+     * Create a new Index for a given OID
+     * 
+     * @param indexOid The Attribute OID
+     * @param path The working directory where this indew will be stored
+     * @return The created index
+     * @throws Exception If the index can't be created
+     */
+     protected abstract Index createSystemIndex( String indexOid, URI path ) throws Exception;
 }



Mime
View raw message