zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iv...@apache.org
Subject svn commit: r1506582 - in /zookeeper/bookkeeper/trunk: ./ bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/ bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/ bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/
Date Wed, 24 Jul 2013 14:55:31 GMT
Author: ivank
Date: Wed Jul 24 14:55:31 2013
New Revision: 1506582

URL: http://svn.apache.org/r1506582
Log:
BOOKKEEPER-642: Bookie returns incorrect exitcode, ExitCode.ZK_REG_FAIL is getting overridden
(Rakesh via ivank)

Modified:
    zookeeper/bookkeeper/trunk/CHANGES.txt
    zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
    zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieServer.java
    zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieInitializationTest.java

Modified: zookeeper/bookkeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/CHANGES.txt?rev=1506582&r1=1506581&r2=1506582&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/CHANGES.txt (original)
+++ zookeeper/bookkeeper/trunk/CHANGES.txt Wed Jul 24 14:55:31 2013
@@ -80,6 +80,8 @@ Trunk (unreleased changes)
 
         BOOKKEEPER-652: Logger class name is wrong in LedgerCacheImpl.java (Rakesh via sijie)
 
+        BOOKKEEPER-642: Bookie returns incorrect exitcode, ExitCode.ZK_REG_FAIL is getting
overridden (Rakesh via ivank)
+
       hedwig-server:
 
         BOOKKEEPER-601: readahead cache size isn't updated correctly (sijie via fpj)

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java?rev=1506582&r1=1506581&r2=1506582&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
(original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
Wed Jul 24 14:55:31 2013
@@ -25,7 +25,6 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.FilenameFilter;
-import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.UnknownHostException;
 import java.nio.ByteBuffer;
@@ -1136,4 +1135,13 @@ public class Bookie extends Thread {
         long end = MathUtils.now();
         System.out.println("Took " + (end-start) + "ms");
     }
+
+    /**
+     * Returns exit code - cause of failure
+     *
+     * @return {@link ExitCode}
+     */
+    public int getExitCode() {
+        return exitCode;
+    }
 }

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieServer.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieServer.java?rev=1506582&r1=1506581&r2=1506582&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieServer.java
(original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieServer.java
Wed Jul 24 14:55:31 2013
@@ -87,6 +87,11 @@ public class BookieServer {
 
     public void start() throws IOException, UnavailableException {
         this.bookie.start();
+        // fail fast, when bookie startup is not successful
+        if (!this.bookie.isRunning()) {
+            exitCode = bookie.getExitCode();
+            return;
+        }
         if (isAutoRecoveryDaemonEnabled && this.autoRecoveryMain != null) {
             this.autoRecoveryMain.start();
         }

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieInitializationTest.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieInitializationTest.java?rev=1506582&r1=1506581&r2=1506582&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieInitializationTest.java
(original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieInitializationTest.java
Wed Jul 24 14:55:31 2013
@@ -88,6 +88,38 @@ public class BookieInitializationTest {
     }
 
     /**
+     * Verify the bookie server exit code. On ZooKeeper exception, should return
+     * exit code ZK_REG_FAIL = 4
+     */
+    @Test(timeout = 20000)
+    public void testExitCodeZK_REG_FAIL() throws Exception {
+        File tmpDir = File.createTempFile("bookie", "test");
+        tmpDir.delete();
+        tmpDir.mkdir();
+
+        final ServerConfiguration conf = new ServerConfiguration()
+                .setZkServers(null).setJournalDirName(tmpDir.getPath())
+                .setLedgerDirNames(new String[] { tmpDir.getPath() });
+
+        // simulating ZooKeeper exception by assigning a closed zk client to bk
+        BookieServer bkServer = new BookieServer(conf) {
+            protected Bookie newBookie(ServerConfiguration conf)
+                    throws IOException, KeeperException, InterruptedException,
+                    BookieException {
+                MockBookie bookie = new MockBookie(conf);
+                bookie.zk = zkc;
+                zkc.close();
+                return bookie;
+            };
+        };
+
+        bkServer.start();
+        bkServer.join();
+        Assert.assertEquals("Failed to return ExitCode.ZK_REG_FAIL",
+                ExitCode.ZK_REG_FAIL, bkServer.getExitCode());
+    }
+
+    /**
      * Verify the bookie reg. Restarting bookie server will wait for the session
      * timeout when previous reg node exists in zk. On zNode delete event,
      * should continue startup



Mime
View raw message