zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iv...@apache.org
Subject svn commit: r1490557 - in /zookeeper/bookkeeper/branches/branch-4.2: ./ bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/
Date Fri, 07 Jun 2013 09:46:16 GMT
Author: ivank
Date: Fri Jun  7 09:46:15 2013
New Revision: 1490557

URL: http://svn.apache.org/r1490557
Log:
BOOKKEEPER-585: Auditor logs noisily when a ledger has been deleted (ivank)

Modified:
    zookeeper/bookkeeper/branches/branch-4.2/CHANGES.txt
    zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java
    zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
    zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorPeriodicCheckTest.java

Modified: zookeeper/bookkeeper/branches/branch-4.2/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/branches/branch-4.2/CHANGES.txt?rev=1490557&r1=1490556&r2=1490557&view=diff
==============================================================================
--- zookeeper/bookkeeper/branches/branch-4.2/CHANGES.txt (original)
+++ zookeeper/bookkeeper/branches/branch-4.2/CHANGES.txt Fri Jun  7 09:46:15 2013
@@ -12,6 +12,8 @@ Release 4.2.2 - Unreleased
 
         BOOKKEEPER-583: Read from a ReadOnlyBookie fails if index fileinfo is not in ledger
cache (vinay via sijie)
 
+        BOOKKEEPER-585: Auditor logs noisily when a ledger has been deleted (ivank)
+
       hedwig-server:
 
         BOOKKEEPER-579: TestSubAfterCloseSub was put in a wrong package (sijie via ivank)

Modified: zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java?rev=1490557&r1=1490556&r2=1490557&view=diff
==============================================================================
--- zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java
(original)
+++ zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java
Fri Jun  7 09:46:15 2013
@@ -377,7 +377,7 @@ public class Auditor implements Watcher 
      * List all the ledgers and check them individually. This should not
      * be run very often.
      */
-    private void checkAllLedgers() throws BKAuditException, BKException,
+    void checkAllLedgers() throws BKAuditException, BKException,
             IOException, InterruptedException, KeeperException {
         ZooKeeperWatcherBase w = new ZooKeeperWatcherBase(conf.getZkTimeout());
         ZooKeeper newzk = ZkUtils.createConnectedZookeeperClient(conf.getZkServers(), w);
@@ -413,6 +413,11 @@ public class Auditor implements Watcher 
                     try {
                         lh = admin.openLedgerNoRecovery(ledgerId);
                         checker.checkLedger(lh, new ProcessLostFragmentsCb(lh, callback));
+                    } catch (BKException.BKNoSuchLedgerExistsException bknsle) {
+                        LOG.debug("Ledger was deleted before we could check it", bknsle);
+                        callback.processResult(BKException.Code.OK,
+                                               null, null);
+                        return;
                     } catch (BKException bke) {
                         LOG.error("Couldn't open ledger " + ledgerId, bke);
                         callback.processResult(BKException.Code.BookieHandleNotAvailableException,

Modified: zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java?rev=1490557&r1=1490556&r2=1490557&view=diff
==============================================================================
--- zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
(original)
+++ zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
Fri Jun  7 09:46:15 2013
@@ -246,6 +246,8 @@ public class ReplicationWorker implement
                     Thread.currentThread().interrupt();
                     LOG.info("InterruptedException "
                             + "while replicating fragments", e);
+                } catch (BKNoSuchLedgerExistsException bknsle) {
+                    LOG.debug("Ledger was deleted, safe to continue", bknsle);
                 } catch (BKException e) {
                     LOG.error("BKException while fencing the ledger"
                             + " for rereplication of postponed ledgers", e);

Modified: zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorPeriodicCheckTest.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorPeriodicCheckTest.java?rev=1490557&r1=1490556&r2=1490557&view=diff
==============================================================================
--- zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorPeriodicCheckTest.java
(original)
+++ zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorPeriodicCheckTest.java
Fri Jun  7 09:46:15 2013
@@ -23,6 +23,8 @@ package org.apache.bookkeeper.replicatio
 import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
 
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.CountDownLatch;
 import java.util.HashMap;
 import java.util.List;
 import java.util.LinkedList;
@@ -270,4 +272,50 @@ public class AuditorPeriodicCheckTest ex
         assertTrue("All should be underreplicated",
                 numUnderreplicated <= numLedgers && numUnderreplicated > 0);
     }
+
+    /**
+     * Test that the period check will succeed if a ledger is deleted midway
+     */
+    @Test(timeout=60000)
+    public void testPeriodicCheckWhenLedgerDeleted() throws Exception {
+        for (AuditorElector e : auditorElectors.values()) {
+            e.shutdown();
+        }
+
+        final int numLedgers = 100;
+        List<Long> ids = new LinkedList<Long>();
+        for (int i = 0; i < numLedgers; i++) {
+            LedgerHandle lh = bkc.createLedger(3, 3, DigestType.CRC32, "passwd".getBytes());
+            ids.add(lh.getId());
+            for (int j = 0; j < 10; j++) {
+                lh.addEntry("testdata".getBytes());
+            }
+            lh.close();
+        }
+        final Auditor auditor = new Auditor(
+                StringUtils.addrToString(Bookie.getBookieAddress(bsConfs.get(0))),
+                bsConfs.get(0), zkc);
+        final AtomicBoolean exceptionCaught = new AtomicBoolean(false);
+        final CountDownLatch latch = new CountDownLatch(1);
+        Thread t = new Thread() {
+                public void run() {
+                    try {
+                        latch.countDown();
+                        for (int i = 0; i < numLedgers; i++) {
+                            auditor.checkAllLedgers();
+                        }
+                    } catch (Exception e) {
+                        LOG.error("Caught exception while checking all ledgers", e);
+                        exceptionCaught.set(true);
+                    }
+                }
+            };
+        t.start();
+        latch.await();
+        for (Long id : ids) {
+            bkc.deleteLedger(id);
+        }
+        t.join();
+        assertFalse("Shouldn't have thrown exception", exceptionCaught.get());
+    }
 }



Mime
View raw message