zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iv...@apache.org
Subject svn commit: r1215156 - in /zookeeper/bookkeeper/trunk: CHANGES.txt bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/EntryLogTest.java
Date Fri, 16 Dec 2011 14:32:59 GMT
Author: ivank
Date: Fri Dec 16 14:32:58 2011
New Revision: 1215156

URL: http://svn.apache.org/viewvc?rev=1215156&view=rev
Log:
BOOKKEEPER-141: Run extracting ledger id from entry log files in GC thread to speed up bookie
restart (Sijie Gou via ivank)

Modified:
    zookeeper/bookkeeper/trunk/CHANGES.txt
    zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java
    zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/EntryLogTest.java

Modified: zookeeper/bookkeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/CHANGES.txt?rev=1215156&r1=1215155&r2=1215156&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/CHANGES.txt (original)
+++ zookeeper/bookkeeper/trunk/CHANGES.txt Fri Dec 16 14:32:58 2011
@@ -14,6 +14,8 @@ Trunk (unreleased changes)
 
         BOOKKEEPER-142: Parsing last log id is wrong, which may make entry log files overwritten
(Sijie Gou via ivank)
 
+        BOOKKEEPER-141: Run extracting ledger id from entry log files in GC thread to speed
up bookie restart (Sijie Gou via ivank)
+
     IMPROVEMENTS:
 
 Release 4.0.0 - 2011-11-30

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java?rev=1215156&r1=1215155&r2=1215156&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java
(original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/EntryLogger.java
Fri Dec 16 14:32:58 2011
@@ -137,9 +137,17 @@ public class EntryLogger {
                         continue;
                     }
                 }
+                // Extract all of the ledger ID's that comprise all of the entry logs
+                // (except for the current new one which is still being written to).
+                try {
+                    extractLedgersFromEntryLogs();
+                } catch (IOException ie) {
+                    LOG.warn("Exception when extracting ledgers from entry logs : ", ie);
+                }
+
                 // Initialization check. No need to run any logic if we are still starting
up.
-                if (bookie.zk == null || entryLogs2LedgersMap.isEmpty() ||
-                    bookie.ledgerCache == null) {
+                if (bookie == null ||
+                    bookie.zk == null || bookie.ledgerCache == null) {
                     continue;
                 }
 
@@ -225,9 +233,6 @@ public class EntryLogger {
         for(File f: dirs) {
             setLastLogId(f, logId);
         }
-        // Extract all of the ledger ID's that comprise all of the entry logs
-        // (except for the current new one which is still being written to).
-        extractLedgersFromEntryLogs();
     }
 
     /**
@@ -391,7 +396,8 @@ public class EntryLogger {
         // by 1 when the log fills up and we roll to a new one.
         ByteBuffer sizeBuff = ByteBuffer.allocate(4);
         BufferedChannel bc;
-        for (long entryLogId = 0; entryLogId < logId; entryLogId++) {
+        long curLogId = logId;
+        for (long entryLogId = 0; entryLogId < curLogId; entryLogId++) {
             // Comb the current entry log file if it has not already been extracted.
             if (entryLogs2LedgersMap.containsKey(entryLogId)) {
                 continue;

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/EntryLogTest.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/EntryLogTest.java?rev=1215156&r1=1215155&r2=1215156&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/EntryLogTest.java
(original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/EntryLogTest.java
Fri Dec 16 14:32:58 2011
@@ -45,11 +45,13 @@ public class EntryLogTest extends TestCa
     }
 
     @Test
-    public void testCorruptEntryLog() throws IOException, SecurityException, NoSuchFieldException,
IllegalArgumentException, IllegalAccessException {
+    public void testCorruptEntryLog() throws Exception {
         File tmpDir = File.createTempFile("bkTest", ".dir");
         tmpDir.delete();
         tmpDir.mkdir();
+        int gcWaitTime = 1000;
         ServerConfiguration conf = new ServerConfiguration();
+        conf.setGcWaitTime(gcWaitTime);
         conf.setLedgerDirNames(new String[] {tmpDir.toString()});
         // create some entries
         EntryLogger logger = new EntryLogger(conf, null);
@@ -64,6 +66,7 @@ public class EntryLogTest extends TestCa
         raf.close();
         // now see which ledgers are in the log
         logger = new EntryLogger(conf, null);
+        Thread.sleep(2 * gcWaitTime);
         Field entryLogs2LedgersMapField = logger.getClass().getDeclaredField("entryLogs2LedgersMap");
         entryLogs2LedgersMapField.setAccessible(true);
         @SuppressWarnings("unchecked")



Mime
View raw message