directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1190202 - in /directory/apacheds/branches/apacheds-txns: core-api/src/main/java/org/apache/directory/server/core/log/ core/src/main/java/org/apache/directory/server/core/log/ core/src/test/java/org/apache/directory/server/core/log/
Date Fri, 28 Oct 2011 08:27:10 GMT
Author: saya
Date: Fri Oct 28 08:27:10 2011
New Revision: 1190202

URL: http://svn.apache.org/viewvc?rev=1190202&view=rev
Log:
Implemented the requested sync interface.

Modified:
    directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/log/Log.java
    directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/DefaultLog.java
    directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/LogFlushManager.java
    directory/apacheds/branches/apacheds-txns/core/src/test/java/org/apache/directory/server/core/log/LogTest.java

Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/log/Log.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/log/Log.java?rev=1190202&r1=1190201&r2=1190202&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/log/Log.java
(original)
+++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/log/Log.java
Fri Oct 28 08:27:10 2011
@@ -75,4 +75,12 @@ public interface Log
      * @param newAnchor
      */
     void advanceMinNeededLogPosition( LogAnchor newAnchor );
+    
+    /**
+     * Syncs the log upto the given lsn. If lsn is equal to unknow lsn, then the log is 
+     * flushed upto the latest logged lsn.
+     *
+     * @param uptoLSN lsn to flush upto. Unkown lsn if caller just wants to sync the log
upto the latest logged lsn.
+     */
+    void sync( long uptoLSN ) throws IOException, InvalidLogException;
 }

Modified: directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/DefaultLog.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/DefaultLog.java?rev=1190202&r1=1190201&r2=1190202&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/DefaultLog.java
(original)
+++ directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/DefaultLog.java
Fri Oct 28 08:27:10 2011
@@ -90,4 +90,12 @@ public class DefaultLog implements Log
     {
        logManager.advanceMinLogAnchor( newAnchor ); 
     }
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void sync( long uptoLSN ) throws IOException, InvalidLogException
+    {
+       logFlushManager.sync( uptoLSN ); 
+    }
 }

Modified: directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/LogFlushManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/LogFlushManager.java?rev=1190202&r1=1190201&r2=1190202&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/LogFlushManager.java
(original)
+++ directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/LogFlushManager.java
Fri Oct 28 08:27:10 2011
@@ -254,6 +254,30 @@ import org.apache.directory.server.i18n.
         }
     }
     
+    /**
+     * Syncs the log upto the given lsn. If lsn is equal to unknow lsn, then the log is 
+     * flushed upto the latest logged lsn.
+     *
+     * @param uptoLSN lsn to flush upto. Unkown lsn if caller just wants to sync the log
upto the latest logged lsn.
+     */
+    void sync( long uptoLSN ) throws IOException, InvalidLogException
+    {
+       if ( uptoLSN == LogAnchor.UNKNOWN_LSN )
+       {
+           appendLock.lock();
+           uptoLSN = logLSN - 1;
+           appendLock.unlock();
+       }
+       
+       // If nothing to flush, then just return
+       if ( uptoLSN == LogAnchor.UNKNOWN_LSN )
+       {
+           
+           return;
+       }
+       
+       flush( uptoLSN, null, 0, 0, false );
+    }
     
     /**
      * Flushes the changes in the log buffer upto the given point. The given point is determined
as follows:

Modified: directory/apacheds/branches/apacheds-txns/core/src/test/java/org/apache/directory/server/core/log/LogTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core/src/test/java/org/apache/directory/server/core/log/LogTest.java?rev=1190202&r1=1190201&r2=1190202&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core/src/test/java/org/apache/directory/server/core/log/LogTest.java
(original)
+++ directory/apacheds/branches/apacheds-txns/core/src/test/java/org/apache/directory/server/core/log/LogTest.java
Fri Oct 28 08:27:10 2011
@@ -90,9 +90,12 @@ public class LogTest
                 Arrays.fill( recordData, (byte )i );
             
                 userLogRecord.setData( recordData, dataLength );
-                log.log( userLogRecord, true );
+                log.log( userLogRecord, false );
             }
             
+            // Sync everything
+            log.sync( LogAnchor.UNKNOWN_LSN );
+            
             LogScanner logScanner = log.beginScan( startingLogAnchor );
             int recordNumber = 0;
             



Mime
View raw message