directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r939710 - in /directory/apacheds/trunk: jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ jdbm/src/main/java/jdbm/recman/ server-xml/src/test/java/org/apache/directory/server/
Date Fri, 30 Apr 2010 15:23:10 GMT
Author: seelmann
Date: Fri Apr 30 15:23:10 2010
New Revision: 939710

URL: http://svn.apache.org/viewvc?rev=939710&view=rev
Log:
lazy initialize the transaction manager only if needed because it is expensive to create and
close it, speeds up xdbm-search and jdbm-store tests

Modified:
    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/src/main/java/jdbm/recman/BaseRecordManager.java
    directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/RecordFile.java
    directory/apacheds/trunk/server-xml/src/test/java/org/apache/directory/server/SpringServerTest.java

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=939710&r1=939709&r2=939710&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
Fri Apr 30 15:23:10 2010
@@ -121,11 +121,14 @@ public class JdbmIndexTest
 
             // created by this test
             File dbFile = new File( idx.getWkDirPath(), idx.getAttribute().getName() + ".db"
);
-            assert dbFile.delete();
+            assertTrue( dbFile.delete() );
 
-            // created by TransactionManager
+            // created by TransactionManager, if transactions are not disabled
             File logFile = new File( idx.getWkDirPath(), idx.getAttribute().getName() + ".lg"
);
-            assert logFile.delete();
+            if ( logFile.exists() )
+            {
+                assertTrue( logFile.delete() );
+            }
         }
 
         idx = null;

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=939710&r1=939709&r2=939710&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
Fri Apr 30 15:23:10 2010
@@ -122,11 +122,14 @@ public class JdbmRdnIndexTest
 
             // created by this test
             File dbFile = new File( idx.getWkDirPath(), idx.getAttribute().getName() + ".db"
);
-            assert dbFile.delete();
+            assertTrue( dbFile.delete() );
 
-            // created by TransactionManager
+            // created by TransactionManager, if transactions are not disabled
             File logFile = new File( idx.getWkDirPath(), idx.getAttribute().getName() + ".lg"
);
-            assert logFile.delete();
+            if ( logFile.exists() )
+            {
+                assertTrue( logFile.delete() );
+            }
         }
 
         idx = null;

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/BaseRecordManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/BaseRecordManager.java?rev=939710&r1=939709&r2=939710&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/BaseRecordManager.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/BaseRecordManager.java Fri Apr
30 15:23:10 2010
@@ -130,10 +130,10 @@ public final class BaseRecordManager
     /**
      * Get the underlying Transaction Manager
      */
-    public synchronized TransactionManager getTransactionManager()
+    public synchronized TransactionManager getTransactionManager() throws IOException
     {
         checkIfClosed();
-        return recordFile.txnMgr;
+        return recordFile.getTxnMgr();
     }
 
 

Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/RecordFile.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/RecordFile.java?rev=939710&r1=939709&r2=939710&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/RecordFile.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/RecordFile.java Fri Apr 30 15:23:10
2010
@@ -63,7 +63,7 @@ import org.apache.directory.server.i18n.
  */
 public final class RecordFile 
 {
-    final TransactionManager txnMgr;
+    private TransactionManager transactionManager;
 
     // state transitions: free -> inUse -> dirty -> inTxn -> free
     // free is a cache, thus a FIFO. The rest are hashes.
@@ -101,10 +101,23 @@ public final class RecordFile 
     {
         this.fileName = fileName;
         file = new RandomAccessFile(fileName + extension, "rw");
-        txnMgr = new TransactionManager( this );
     }
 
-    
+
+    TransactionManager getTxnMgr() throws IOException
+    {
+        if ( transactionsDisabled )
+        {
+            throw new IllegalStateException( "Transactions are disabled." );
+        }
+        if ( transactionManager == null )
+        {
+            transactionManager = new TransactionManager( this );
+        }
+        return transactionManager;
+    }
+
+
     /**
      * Returns the file name.
      */
@@ -276,7 +289,7 @@ public final class RecordFile 
         
         if ( ! transactionsDisabled ) 
         {
-            txnMgr.start();
+            getTxnMgr().start();
         }
 
         
@@ -296,14 +309,14 @@ public final class RecordFile 
             }
             else 
             {
-                txnMgr.add( node );
+                getTxnMgr().add( node );
                 inTxn.put( node.getBlockId(), node );
             }
         }
 
         if ( ! transactionsDisabled ) 
         {
-            txnMgr.commit();
+            getTxnMgr().commit();
         }
     }
 
@@ -323,7 +336,10 @@ public final class RecordFile 
         //  System.out.println("rollback...");
         dirty.clear();
 
-        txnMgr.synchronizeLogFromDisk();
+        if ( ! transactionsDisabled ) 
+        {
+            getTxnMgr().synchronizeLogFromDisk();
+        }
 
         if ( ! inTxn.isEmpty() ) 
         {
@@ -343,7 +359,10 @@ public final class RecordFile 
             commit();
         }
         
-        txnMgr.shutdown();
+        if( ! transactionsDisabled )
+        {
+            getTxnMgr().shutdown();
+        }
 
         if ( ! inTxn.isEmpty() ) 
         {
@@ -379,8 +398,11 @@ public final class RecordFile 
      */
     void forceClose() throws IOException 
     {
-      txnMgr.forceClose();
-      file.close();
+        if ( ! transactionsDisabled ) 
+        {
+            getTxnMgr().forceClose();
+        }
+        file.close();
     }
 
     
@@ -481,4 +503,4 @@ public final class RecordFile 
             pos += read;
         }
     }
-}
\ No newline at end of file
+}

Modified: directory/apacheds/trunk/server-xml/src/test/java/org/apache/directory/server/SpringServerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-xml/src/test/java/org/apache/directory/server/SpringServerTest.java?rev=939710&r1=939709&r2=939710&view=diff
==============================================================================
--- directory/apacheds/trunk/server-xml/src/test/java/org/apache/directory/server/SpringServerTest.java
(original)
+++ directory/apacheds/trunk/server-xml/src/test/java/org/apache/directory/server/SpringServerTest.java
Fri Apr 30 15:23:10 2010
@@ -189,15 +189,16 @@ public class SpringServerTest
             File tmpOCdb = new File( tmpDir, "dc.db" );
             assertTrue( tmpOCdb.exists() );
     
-            File tmpOClg = new File( tmpDir, "dc.lg" );
-            assertTrue( tmpOClg.exists() );
+            // if transactions are disabled there is no dc.lg file
+            //File tmpOClg = new File( tmpDir, "dc.lg" );
+            //assertTrue( tmpOClg.exists() );
             
             // Shutdown and cleanup
             apacheDS.shutdown();
             
             // Clean the /tmp/objectClass.* files
             tmpOCdb.delete();
-            tmpOClg.delete();
+            //tmpOClg.delete();
         }
         else
         {



Mime
View raw message