Return-Path: Delivered-To: apmail-hadoop-zookeeper-commits-archive@minotaur.apache.org Received: (qmail 52674 invoked from network); 7 Apr 2009 02:44:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Apr 2009 02:44:03 -0000 Received: (qmail 54391 invoked by uid 500); 7 Apr 2009 02:44:02 -0000 Delivered-To: apmail-hadoop-zookeeper-commits-archive@hadoop.apache.org Received: (qmail 54364 invoked by uid 500); 7 Apr 2009 02:44:02 -0000 Mailing-List: contact zookeeper-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: zookeeper-dev@ Delivered-To: mailing list zookeeper-commits@hadoop.apache.org Received: (qmail 54354 invoked by uid 99); 7 Apr 2009 02:44:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Apr 2009 02:44:02 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Apr 2009 02:44:00 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4A6B02388A69; Tue, 7 Apr 2009 02:43:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: zookeeper-commits@hadoop.apache.org From: mahadev@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090407024339.4A6B02388A69@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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"); + } + + } + }