zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iv...@apache.org
Subject svn commit: r1506584 - in /zookeeper/bookkeeper/branches/branch-4.2: ./ 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/boo...
Date Wed, 24 Jul 2013 14:56:02 GMT
Author: ivank
Date: Wed Jul 24 14:56:01 2013
New Revision: 1506584

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

Modified:
    zookeeper/bookkeeper/branches/branch-4.2/CHANGES.txt
    zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
    zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieServer.java
    zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieInitializationTest.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=1506584&r1=1506583&r2=1506584&view=diff
==============================================================================
--- zookeeper/bookkeeper/branches/branch-4.2/CHANGES.txt (original)
+++ zookeeper/bookkeeper/branches/branch-4.2/CHANGES.txt Wed Jul 24 14:56:01 2013
@@ -50,6 +50,8 @@ Release 4.2.2 - Unreleased
 
         BOOKKEEPER-625: On OutOfMemoryError in NIOServerFactory thread bookie should shutdown
(vinay via ivank)
 
+        BOOKKEEPER-642: Bookie returns incorrect exitcode, ExitCode.ZK_REG_FAIL is getting
overridden (Rakesh via 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/bookie/Bookie.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java?rev=1506584&r1=1506583&r2=1506584&view=diff
==============================================================================
--- zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
(original)
+++ zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
Wed Jul 24 14:56:01 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;
@@ -1265,4 +1264,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/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieServer.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieServer.java?rev=1506584&r1=1506583&r2=1506584&view=diff
==============================================================================
--- zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieServer.java
(original)
+++ zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieServer.java
Wed Jul 24 14:56:01 2013
@@ -100,6 +100,11 @@ public class BookieServer implements NIO
         nioServerFactory = new NIOServerFactory(conf, this);
 
         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/branches/branch-4.2/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieInitializationTest.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieInitializationTest.java?rev=1506584&r1=1506583&r2=1506584&view=diff
==============================================================================
--- zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieInitializationTest.java
(original)
+++ zookeeper/bookkeeper/branches/branch-4.2/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieInitializationTest.java
Wed Jul 24 14:56:01 2013
@@ -87,6 +87,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