hadoop-zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r762602 - in /hadoop/zookeeper/trunk: CHANGES.txt src/contrib/bookkeeper/src/java/org/apache/bookkeeper/client/LedgerRecoveryMonitor.java src/contrib/bookkeeper/test/org/apache/bookkeeper/test/LedgerRecoveryTest.java
Date Tue, 07 Apr 2009 02:43:39 GMT
Author: mahadev
Date: Tue Apr  7 02:43:38 2009
New Revision: 762602

URL: http://svn.apache.org/viewvc?rev=762602&view=rev
Log:
ZOOKEEPER-363. NPE when recovering ledger with no hint. (flavio via mahadev)

Modified:
    hadoop/zookeeper/trunk/CHANGES.txt
    hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/client/LedgerRecoveryMonitor.java
    hadoop/zookeeper/trunk/src/contrib/bookkeeper/test/org/apache/bookkeeper/test/LedgerRecoveryTest.java

Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=762602&r1=762601&r2=762602&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Tue Apr  7 02:43:38 2009
@@ -39,6 +39,8 @@
   ZOOKEEPER-362. Issues with FLENewEpochTest. (fix bug in Fast leader election)
 (flavio via mahadev)
 
+  ZOOKEEPER-363. NPE when recovering ledger with no hint. (flavio via mahadev)
+
 IMPROVEMENTS:
   ZOOKEEPER-308. improve the atomic broadcast performance 3x.
   (breed via mahadev)

Modified: hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/client/LedgerRecoveryMonitor.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/client/LedgerRecoveryMonitor.java?rev=762602&r1=762601&r2=762602&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/client/LedgerRecoveryMonitor.java
(original)
+++ hadoop/zookeeper/trunk/src/contrib/bookkeeper/src/java/org/apache/bookkeeper/client/LedgerRecoveryMonitor.java
Tue Apr  7 02:43:38 2009
@@ -145,8 +145,8 @@
         long readCounter = 0;
         while(notLegitimate){
             readCounter = getNextHint();
-            if(readCounter != -1){
-                lh.setLast(readCounter - 1);
+            if(readCounter > -1){
+                lh.setLast(readCounter);
                 boolean hasMore = true;
                 while(hasMore){
                     hasMore = false;

Modified: hadoop/zookeeper/trunk/src/contrib/bookkeeper/test/org/apache/bookkeeper/test/LedgerRecoveryTest.java
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/bookkeeper/test/org/apache/bookkeeper/test/LedgerRecoveryTest.java?rev=762602&r1=762601&r2=762602&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/bookkeeper/test/org/apache/bookkeeper/test/LedgerRecoveryTest.java
(original)
+++ hadoop/zookeeper/trunk/src/contrib/bookkeeper/test/org/apache/bookkeeper/test/LedgerRecoveryTest.java
Tue Apr  7 02:43:38 2009
@@ -260,4 +260,89 @@
         
     }
     
+    @Test
+    public void testEmptyLedgerRecovery(){
+        /*
+         * Instantiate BookKeeper object.
+         */
+        BookKeeper bk = null;
+        try{
+            bk = new BookKeeper(HOSTPORT);
+        } catch (KeeperException ke){
+            LOG.error("Error instantiating BookKeeper", ke);
+            fail("ZooKeeper error");
+        } catch (IOException ioe){
+            LOG.error(ioe);
+            fail("Failure due to IOException");
+        }
+        
+        /*
+         * Create ledger.
+         */
+        LedgerHandle beforelh = null;
+        try{
+            beforelh = bk.createLedger("".getBytes());
+        } catch (KeeperException ke){
+            LOG.error("Error creating a ledger", ke);
+            fail("ZooKeeper error");            
+        } catch (BKException bke){
+            LOG.error("BookKeeper error");
+            fail("BookKeeper error");
+        } catch (InterruptedException ie) {
+            LOG.error(ie);
+            fail("Failure due to interrupted exception");
+        } catch (IOException ioe) {
+            LOG.error(ioe);
+            fail("Failure due to IO exception");
+        }
+        
+        /*
+         * Write a 1 entry.
+         */
+        try{
+            String tmp = "BookKeeper is cool!";
+            for(int i = 0; i < 1; i++){
+                bk.addEntry(beforelh, tmp.getBytes());
+            }
+        } catch(InterruptedException e){
+            LOG.error("Interrupted when adding entry", e);
+            fail("Couldn't finish adding entries");
+        }
+        
+        ///*
+        // * Sleep.
+        // */
+        //try{
+        //    Thread.sleep(2000);
+        //} catch(InterruptedException e){
+        //    LOG.error("Interrupted while sleeping", e);
+        //    fail("Couldn't finish sleeping");
+        //}
+        
+        /*
+         * Try to open ledger.
+         */
+        try{
+            LedgerHandle afterlh = bk.openLedger(beforelh.getId(), "".getBytes());
+            
+            /*
+             * Check if has recovered properly.
+             */
+            assertTrue("Has not recovered correctly: " + afterlh.getLast(), afterlh.getLast()
== 1);
+        } catch (KeeperException e) {
+            LOG.error("Error when opening ledger", e);
+            fail("Couldn't open ledger");
+        } catch (InterruptedException ie) {
+            LOG.error("Interrupted exception", ie);
+            fail("Failure due to interrupted exception");
+        } catch (IOException ioe) {
+            LOG.error("IO Exception", ioe);
+            fail("Failure due to IO exception");
+        } catch (BKException bke){
+            LOG.error("BookKeeper error", bke);
+            fail("BookKeeper error");
+        }
+        
+    }
+    
 }



Mime
View raw message