zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From si...@apache.org
Subject svn commit: r1460524 - in /zookeeper/bookkeeper/trunk: CHANGES.txt bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerCacheImpl.java bookkeeper-server/src/test/java/org/apache/bookkeeper/test/ReadOnlyBookieTest.java
Date Mon, 25 Mar 2013 05:48:01 GMT
Author: sijie
Date: Mon Mar 25 05:48:01 2013
New Revision: 1460524

URL: http://svn.apache.org/r1460524
Log:
BOOKKEEPER-583: Read from a ReadOnlyBookie fails if index fileinfo is not in ledger cache
(vinay via sijie)

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

Modified: zookeeper/bookkeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/CHANGES.txt?rev=1460524&r1=1460523&r2=1460524&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/CHANGES.txt (original)
+++ zookeeper/bookkeeper/trunk/CHANGES.txt Mon Mar 25 05:48:01 2013
@@ -52,6 +52,8 @@ Trunk (unreleased changes)
 
       BOOKKEEPER-557: Compiler error showing up badly with jdk 7 (ivank via sijie)
 
+      BOOKKEEPER-583: Read from a ReadOnlyBookie fails if index fileinfo is not in ledger
cache (vinay via sijie)
+
 Release 4.2.0 - 2013-01-14
 
   Non-backward compatible changes:

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerCacheImpl.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerCacheImpl.java?rev=1460524&r1=1460523&r2=1460524&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerCacheImpl.java
(original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerCacheImpl.java
Mon Mar 25 05:48:01 2013
@@ -263,9 +263,6 @@ public class LedgerCacheImpl implements 
                 }
                 evictFileInfoIfNecessary();
                 fi = new FileInfo(lf, masterKey);
-                if (ledgerDirsManager.isDirFull(getLedgerDirForLedger(fi))) {
-                    moveLedgerIndexFile(ledger, fi);
-                }
                 fileInfoCache.put(ledger, fi);
                 openLedgers.add(ledger);
             }

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/ReadOnlyBookieTest.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/ReadOnlyBookieTest.java?rev=1460524&r1=1460523&r2=1460524&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/ReadOnlyBookieTest.java
(original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/ReadOnlyBookieTest.java
Mon Mar 25 05:48:01 2013
@@ -184,4 +184,40 @@ public class ReadOnlyBookieTest extends 
             // Expected
         }
     }
+
+    /**
+     * Try to read closed ledger from restarted ReadOnlyBookie.
+     */
+    public void testReadFromReadOnlyBookieShouldBeSuccess() throws Exception {
+        LedgerHandle ledger = bkc.createLedger(2, 2, DigestType.MAC, "".getBytes());
+        for (int i = 0; i < 10; i++) {
+            ledger.addEntry("data".getBytes());
+        }
+        ledger.close();
+        bsConfs.get(1).setReadOnlyModeEnabled(true);
+        bsConfs.get(1).setDiskCheckInterval(500);
+        restartBookies();
+
+        // Check new bookie with readonly mode enabled.
+        File[] ledgerDirs = bsConfs.get(1).getLedgerDirs();
+        assertEquals("Only one ledger dir should be present", 1, ledgerDirs.length);
+        Bookie bookie = bs.get(1).getBookie();
+        LedgerDirsManager ledgerDirsManager = bookie.getLedgerDirsManager();
+
+        // Now add the current ledger dir to filled dirs list
+        ledgerDirsManager.addToFilledDirs(new File(ledgerDirs[0], "current"));
+
+        // Wait till Bookie converts to ReadOnly mode.
+        Thread.sleep(1000);
+        assertTrue("Bookie should be converted to readonly mode", bookie.isRunning() &&
bookie.isReadOnly());
+
+        // Now kill the other bookie and read entries from the readonly bookie
+        killBookie(0);
+
+        Enumeration<LedgerEntry> readEntries = ledger.readEntries(0, 9);
+        while (readEntries.hasMoreElements()) {
+            LedgerEntry entry = readEntries.nextElement();
+            assertEquals("Entry should contain correct data", "data", new String(entry.getEntry()));
+        }
+    }
 }



Mime
View raw message