directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r950897 - in /directory/apacheds/trunk/jdbm-store/src: main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/
Date Thu, 03 Jun 2010 07:21:38 GMT
Author: kayyagari
Date: Thu Jun  3 07:21:38 2010
New Revision: 950897

URL: http://svn.apache.org/viewvc?rev=950897&view=rev
Log:
o JdbmIndex files are named after the corresponding AttributeType's OID (see DIRSERVER-1510)
o updated test cases

Modified:
    directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
    directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java
    directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
    directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
    directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java
    directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java

Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java?rev=950897&r1=950896&r2=950897&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
(original)
+++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
Thu Jun  3 07:21:38 2010
@@ -21,6 +21,7 @@ package org.apache.directory.server.core
 
 
 import java.io.File;
+import java.io.FileWriter;
 import java.io.IOException;
 
 import jdbm.RecordManager;
@@ -171,7 +172,7 @@ public class JdbmIndex<K, O> implements 
             this.wkDirPath = wkDirPath;
         }
 
-        File file = new File( this.wkDirPath.getPath() + File.separator + attribute.getName()
);
+        File file = new File( this.wkDirPath.getPath() + File.separator + attribute.getOid()
);
         String path = file.getAbsolutePath();
         BaseRecordManager base = new BaseRecordManager( path );
         base.disableTransactions();
@@ -188,6 +189,12 @@ public class JdbmIndex<K, O> implements 
             throw e;
         }
 
+        // finally write a text file in the format <OID>-<attribute-name>.txt
+        FileWriter fw = new FileWriter( new File( this.wkDirPath.getPath() + File.separator
+ attribute.getOid() + "-" + attribute.getName() + ".txt" ) );
+        // write the AttributeType description
+        fw.write( attribute.toString() );
+        fw.close();
+        
         initialized = true;
     }
 
@@ -220,7 +227,7 @@ public class JdbmIndex<K, O> implements 
         LongComparator.INSTANCE.setSchemaManager( schemaManager );
         comp.setSchemaManager( schemaManager );
 
-        forward = new JdbmTable<K, Long>( schemaManager, attribute.getName() + FORWARD_BTREE,
numDupLimit, recMan,
+        forward = new JdbmTable<K, Long>( schemaManager, attribute.getOid() + FORWARD_BTREE,
numDupLimit, recMan,
             comp, LongComparator.INSTANCE, null, LongSerializer.INSTANCE );
 
         /*
@@ -231,12 +238,12 @@ public class JdbmIndex<K, O> implements 
          */
         if ( attribute.isSingleValued() )
         {
-            reverse = new JdbmTable<Long, K>( schemaManager, attribute.getName() +
REVERSE_BTREE, recMan,
+            reverse = new JdbmTable<Long, K>( schemaManager, attribute.getOid() + REVERSE_BTREE,
recMan,
                 LongComparator.INSTANCE, LongSerializer.INSTANCE, null );
         }
         else
         {
-            reverse = new JdbmTable<Long, K>( schemaManager, attribute.getName() +
REVERSE_BTREE, numDupLimit, recMan,
+            reverse = new JdbmTable<Long, K>( schemaManager, attribute.getOid() + REVERSE_BTREE,
numDupLimit, recMan,
                 LongComparator.INSTANCE, comp, LongSerializer.INSTANCE, null );
         }
     }

Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java?rev=950897&r1=950896&r2=950897&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java
(original)
+++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndex.java
Thu Jun  3 07:21:38 2010
@@ -22,6 +22,7 @@ package org.apache.directory.server.core
 
 
 import java.io.File;
+import java.io.FileWriter;
 import java.io.IOException;
 
 import jdbm.helper.MRU;
@@ -82,7 +83,7 @@ public class JdbmRdnIndex<E> extends Jdb
             this.wkDirPath = wkDirPath;
         }
 
-        File file = new File( this.wkDirPath.getPath() + File.separator + attribute.getName()
);
+        File file = new File( this.wkDirPath.getPath() + File.separator + attribute.getOid()
);
         String path = file.getAbsolutePath();
         BaseRecordManager base = new BaseRecordManager( path );
         base.disableTransactions();
@@ -99,6 +100,12 @@ public class JdbmRdnIndex<E> extends Jdb
             throw e;
         }
 
+        // finally write a text file in the format <OID>-<attribute-name>.txt
+        FileWriter fw = new FileWriter( new File( this.wkDirPath.getPath() + File.separator
+ attribute.getOid() + "-" + attribute.getName() + ".txt" ) );
+        // write the AttributeType description
+        fw.write( attribute.toString() );
+        fw.close();
+        
         initialized = true;
     }
 
@@ -123,9 +130,9 @@ public class JdbmRdnIndex<E> extends Jdb
 
         LongComparator.INSTANCE.setSchemaManager( schemaManager );
 
-        forward = new JdbmTable<ParentIdAndRdn<Long>, Long>( schemaManager, attribute.getName()
+ FORWARD_BTREE,
+        forward = new JdbmTable<ParentIdAndRdn<Long>, Long>( schemaManager, attribute.getOid()
+ FORWARD_BTREE,
             recMan, comp, null, LongSerializer.INSTANCE );
-        reverse = new JdbmTable<Long, ParentIdAndRdn<Long>>( schemaManager, attribute.getName()
+ REVERSE_BTREE,
+        reverse = new JdbmTable<Long, ParentIdAndRdn<Long>>( schemaManager, attribute.getOid()
+ REVERSE_BTREE,
             recMan, LongComparator.INSTANCE, LongSerializer.INSTANCE, null );
     }
 

Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?rev=950897&r1=950896&r2=950897&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
(original)
+++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
Thu Jun  3 07:21:38 2010
@@ -157,7 +157,7 @@ public class JdbmStore<E> extends Abstra
         List<String> allIndices = new ArrayList<String>();
         for( Index i : systemIndices.values() )
         {
-            allIndices.addAll( i.getAttribute().getNames() );
+            allIndices.add( i.getAttribute().getOid() );
         }
 
         // this loop is used for two purposes
@@ -166,10 +166,10 @@ public class JdbmStore<E> extends Abstra
         // just to avoid another iteration for determining which is the new index
         for( Index i : userIndices.values() )
         {
-            allIndices.addAll( i.getAttribute().getNames() );
+            allIndices.add( i.getAttribute().getOid() );
 
             // take the part after removing .db from the  
-            String name = i.getAttribute().getName() + JDBM_DB_FILE_EXTN;
+            String name = i.getAttribute().getOid() + JDBM_DB_FILE_EXTN;
 
             // if the name doesn't exist in the list of index DB files
             // this is a new index and we need to build it
@@ -347,6 +347,26 @@ public class JdbmStore<E> extends Abstra
                 if( deleted )
                 {
                     LOG.info( "Deleted unused index file {}", file.getAbsolutePath() );
+
+                    try
+                    {
+                        String atName = schemaManager.lookupAttributeTypeRegistry( name ).getName();
+                        File txtFile = new File( file.getParent(), name + "-" + atName +
".txt" );
+                        
+                        deleted = txtFile.delete();
+                        
+                        if( !deleted )
+                        {
+                            LOG.info( "couldn't delete the index name helper file {}", txtFile
);
+                        }
+                    }
+                    catch( Exception e )
+                    {
+                        LOG.warn( "couldn't find the attribute's name with oid {}", name
);
+                        LOG.warn( "", e );
+                    }
+                    
+                    
                 }
                 else
                 {

Modified: directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java?rev=950897&r1=950896&r2=950897&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
(original)
+++ directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
Thu Jun  3 07:21:38 2010
@@ -120,11 +120,11 @@ public class JdbmIndexTest
             idx.close();
 
             // created by this test
-            File dbFile = new File( idx.getWkDirPath(), idx.getAttribute().getName() + ".db"
);
+            File dbFile = new File( idx.getWkDirPath(), idx.getAttribute().getOid() + ".db"
);
             assertTrue( dbFile.delete() );
 
             // created by TransactionManager, if transactions are not disabled
-            File logFile = new File( idx.getWkDirPath(), idx.getAttribute().getName() + ".lg"
);
+            File logFile = new File( idx.getWkDirPath(), idx.getAttribute().getOid() + ".lg"
);
             if ( logFile.exists() )
             {
                 assertTrue( logFile.delete() );

Modified: directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java?rev=950897&r1=950896&r2=950897&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java
(original)
+++ directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmRdnIndexTest.java
Thu Jun  3 07:21:38 2010
@@ -121,11 +121,11 @@ public class JdbmRdnIndexTest
             idx.close();
 
             // created by this test
-            File dbFile = new File( idx.getWkDirPath(), idx.getAttribute().getName() + ".db"
);
+            File dbFile = new File( idx.getWkDirPath(), idx.getAttribute().getOid() + ".db"
);
             assertTrue( dbFile.delete() );
 
             // created by TransactionManager, if transactions are not disabled
-            File logFile = new File( idx.getWkDirPath(), idx.getAttribute().getName() + ".lg"
);
+            File logFile = new File( idx.getWkDirPath(), idx.getAttribute().getOid() + ".lg"
);
             if ( logFile.exists() )
             {
                 assertTrue( logFile.delete() );

Modified: directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=950897&r1=950896&r2=950897&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
(original)
+++ directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
Thu Jun  3 07:21:38 2010
@@ -623,7 +623,12 @@ public class JdbmStoreTest
     @Test
     public void testConvertIndex() throws Exception
     {
-        Index nonJdbmIndex = new GenericIndex( "ou", 10, new File( "." ) );
+        // just create the new directory under working directory
+        // so this gets cleaned up automatically
+        File testSpecificDir = new File( wkdir, "testConvertIndex" );
+        testSpecificDir.mkdirs();
+        
+        Index nonJdbmIndex = new GenericIndex( "ou", 10,  testSpecificDir );
 
         Method convertIndex = store.getClass().getDeclaredMethod( "convertAndInit", Index.class
);
         convertIndex.setAccessible( true );
@@ -894,11 +899,15 @@ public class JdbmStoreTest
     @Test
     public void testDeleteUnusedIndexFiles() throws Exception
     {
-        File ouIndexDbFile = new File( wkdir, "ou.db" );
-        File uuidIndexDbFile = new File( wkdir, "entryUUID.db" );
+        File ouIndexDbFile = new File( wkdir, SchemaConstants.OU_AT_OID + ".db" );
+        File ouIndexTxtFile = new File( wkdir, SchemaConstants.OU_AT_OID + "-ou.txt" );
+        File uuidIndexDbFile = new File( wkdir, SchemaConstants.ENTRY_UUID_AT_OID + ".db"
);
+        File uuidIndexTxtFile = new File( wkdir, SchemaConstants.ENTRY_UUID_AT_OID + "-entryUUID.txt"
);
         
         assertTrue( ouIndexDbFile.exists() );
+        assertTrue( ouIndexTxtFile.exists() );
         assertTrue( uuidIndexDbFile.exists() );
+        assertTrue( uuidIndexTxtFile.exists() );
         
         // destroy the store to manually start the init phase
         // by keeping the same work dir
@@ -906,7 +915,9 @@ public class JdbmStoreTest
         
         // just assert again that ou and entryUUID files exist even after destroying the
store
         assertTrue( ouIndexDbFile.exists() );
+        assertTrue( ouIndexTxtFile.exists() );
         assertTrue( uuidIndexDbFile.exists() );
+        assertTrue( uuidIndexTxtFile.exists() );
         
         store = new JdbmStore<Entry>();
         store.setId( "example" );
@@ -924,7 +935,10 @@ public class JdbmStoreTest
         store.init( schemaManager );
 
         assertFalse( ouIndexDbFile.exists() );
+        assertFalse( ouIndexTxtFile.exists() );
+
         assertTrue( uuidIndexDbFile.exists() );
+        assertTrue( uuidIndexTxtFile.exists() );
     }
     
 }



Mime
View raw message