zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iv...@apache.org
Subject svn commit: r1544452 - in /zookeeper/bookkeeper/trunk: CHANGES.txt bookkeeper-server/pom.xml bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieShutdownTest.java
Date Fri, 22 Nov 2013 09:40:15 GMT
Author: ivank
Date: Fri Nov 22 09:40:15 2013
New Revision: 1544452

URL: http://svn.apache.org/r1544452
Log:
BOOKKEEPER-678: BookieServer shutdown hangs indefinitely at NioServerSocketChannelFactory.releaseExternalResources
(rakeshr via ivank)

Modified:
    zookeeper/bookkeeper/trunk/CHANGES.txt
    zookeeper/bookkeeper/trunk/bookkeeper-server/pom.xml
    zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieShutdownTest.java

Modified: zookeeper/bookkeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/CHANGES.txt?rev=1544452&r1=1544451&r2=1544452&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/CHANGES.txt (original)
+++ zookeeper/bookkeeper/trunk/CHANGES.txt Fri Nov 22 09:40:15 2013
@@ -122,6 +122,8 @@ Trunk (unreleased changes)
 
         BOOKKEEPER-700: GarbageCollectorThread exsiting with ArrayIndexOutOfBoundsException
(rakeshr via ivank)
 
+        BOOKKEEPER-678: BookieServer shutdown hangs indefinitely at NioServerSocketChannelFactory.releaseExternalResources
(rakeshr via ivank)
+
       hedwig-server:
 
         BOOKKEEPER-601: readahead cache size isn't updated correctly (sijie via fpj)

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/pom.xml
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/pom.xml?rev=1544452&r1=1544451&r2=1544452&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/pom.xml (original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/pom.xml Fri Nov 22 09:40:15 2013
@@ -75,7 +75,7 @@
     <dependency>
       <groupId>org.jboss.netty</groupId>
       <artifactId>netty</artifactId>
-      <version>3.2.4.Final</version>
+      <version>3.2.9.Final</version>
       <scope>compile</scope>
     </dependency>
     <dependency>

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieShutdownTest.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieShutdownTest.java?rev=1544452&r1=1544451&r2=1544452&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieShutdownTest.java
(original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieShutdownTest.java
Fri Nov 22 09:40:15 2013
@@ -20,17 +20,88 @@
  */
 package org.apache.bookkeeper.bookie;
 
+import java.nio.ByteBuffer;
+import java.util.Random;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.bookkeeper.client.BKException;
+import org.apache.bookkeeper.client.LedgerHandle;
+import org.apache.bookkeeper.client.AsyncCallback.AddCallback;
+import org.apache.bookkeeper.client.BookKeeper.DigestType;
 import org.apache.bookkeeper.conf.ServerConfiguration;
 import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class BookieShutdownTest extends BookKeeperClusterTestCase {
 
+    private final static Logger LOG = LoggerFactory.getLogger(BookieShutdownTest.class);
+
     public BookieShutdownTest() {
-        super(1);
+        super(3);
+    }
+
+    private LedgerHandle lh;
+    private int numEntriesToWrite = 200;
+    private int maxInt = 2147483647;
+    private Random rng = new Random(System.currentTimeMillis());
+    private DigestType digestType = DigestType.CRC32;
+
+    class SyncObj {
+    }
+
+    /**
+     * Tests verifies the bookkeeper shutdown while writing entries.
+     * Continuously restarting the bookie server to see all the external
+     * resources are releasing properly. BOOKKEEPER-678
+     */
+    @Test(timeout = 150000)
+    public void testBookieRestartContinuously() throws Exception {
+        for (int index = 0; index < 100; index++) {
+            SyncObj sync = new SyncObj();
+            try {
+                // Create a ledger
+                lh = bkc.createLedger(3, 2, digestType, "aaa".getBytes());
+                LOG.info("Ledger ID: " + lh.getId());
+                for (int i = 0; i < numEntriesToWrite; i++) {
+                    ByteBuffer entry = ByteBuffer.allocate(4);
+                    entry.putInt(rng.nextInt(maxInt));
+                    entry.position(0);
+
+                    lh.asyncAddEntry(entry.array(),
+                            new LedgerEntryAddCallback(), sync);
+                }
+
+                LOG.info("Wrote " + numEntriesToWrite
+                        + " and now going to fail bookie.");
+                // Shutdown one Bookie server and restarting new one to continue
+                // writing
+                bsConfs.remove(0);
+                bs.get(0).shutdown();
+                bs.remove(0);
+                startNewBookie();
+                LOG.info("Shutdown one bookie server and started new bookie server...");
+            } catch (BKException e) {
+                LOG.error("Caught BKException", e);
+                fail(e.toString());
+            } catch (InterruptedException e) {
+                LOG.error("Caught InterruptedException", e);
+                fail(e.toString());
+            }
+        }
+    }
+
+    private class LedgerEntryAddCallback implements AddCallback {
+        @Override
+        public void addComplete(int rc, LedgerHandle lh, long entryId,
+                Object ctx) {
+            SyncObj x = (SyncObj) ctx;
+            synchronized (x) {
+                x.notify();
+            }
+        }
     }
 
     /**



Mime
View raw message