zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f..@apache.org
Subject svn commit: r1418685 - in /zookeeper/bookkeeper/trunk: CHANGES.txt bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/TestPerChannelBookieClient.java bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieReadWriteTest.java
Date Sat, 08 Dec 2012 15:14:53 GMT
Author: fpj
Date: Sat Dec  8 15:14:52 2012
New Revision: 1418685

URL: http://svn.apache.org/viewvc?rev=1418685&view=rev
Log:
BOOKKEEPER-474:  BookieReadWriteTest#testShutdown doesn't make sense (ivank via fpj)


Modified:
    zookeeper/bookkeeper/trunk/CHANGES.txt
    zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/TestPerChannelBookieClient.java
    zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieReadWriteTest.java

Modified: zookeeper/bookkeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/CHANGES.txt?rev=1418685&r1=1418684&r2=1418685&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/CHANGES.txt (original)
+++ zookeeper/bookkeeper/trunk/CHANGES.txt Sat Dec  8 15:14:52 2012
@@ -126,6 +126,8 @@ Trunk (unreleased changes)
 
 	BOOKKEEPER-431: Duplicate definition of COOKIES_NODE (uma via fpj)
 
+	BOOKKEEPER-474:  BookieReadWriteTest#testShutdown doesn't make sense (ivank via fpj)
+
       hedwig-protocol:
 
         BOOKKEEPER-394: CompositeException message is not useful (Stu Hood via sijie)

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/TestPerChannelBookieClient.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/TestPerChannelBookieClient.java?rev=1418685&r1=1418684&r2=1418685&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/TestPerChannelBookieClient.java
(original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/TestPerChannelBookieClient.java
Sat Dec  8 15:14:52 2012
@@ -78,4 +78,37 @@ public class TestPerChannelBookieClient 
         channelFactory.releaseExternalResources();
         executor.shutdown();
     }
+
+    /**
+     * Test race scenario found in {@link https://issues.apache.org/jira/browse/BOOKKEEPER-5}
+     * where multiple clients try to connect a channel simultaneously. If not synchronised
+     * correctly, this causes the netty channel to get orphaned.
+     */
+    @Test(timeout=60000)
+    public void testConnectRace() {
+        GenericCallback<Void> nullop = new GenericCallback<Void>() {
+            @Override
+            public void operationComplete(int rc, Void result) {
+                // do nothing, we don't care about doing anything with the connection,
+                // we just want to trigger it connecting.
+            }
+        };
+        ClientSocketChannelFactory channelFactory
+            = new NioClientSocketChannelFactory(Executors.newCachedThreadPool(),
+                                                Executors.newCachedThreadPool());
+        OrderedSafeExecutor executor = new OrderedSafeExecutor(1);
+
+        InetSocketAddress addr = getBookie(0);
+        AtomicLong bytesOutstanding = new AtomicLong(0);
+        for (int i = 0; i < 100; i++) {
+            PerChannelBookieClient client = new PerChannelBookieClient(executor, channelFactory,
+                                                                       addr, bytesOutstanding);
+            for (int j = i; j < 10; j++) {
+                client.connectIfNeededAndDoOp(nullop);
+            }
+            client.close();
+        }
+        channelFactory.releaseExternalResources();
+        executor.shutdown();
+    }
 }
\ No newline at end of file

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieReadWriteTest.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieReadWriteTest.java?rev=1418685&r1=1418684&r2=1418685&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieReadWriteTest.java
(original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieReadWriteTest.java
Sat Dec  8 15:14:52 2012
@@ -771,54 +771,6 @@ public class BookieReadWriteTest extends
     }
 
     @Test
-    public void testShutdown() throws IOException {
-        try {
-            int numLedgers = 10000;
-            int throttle = (((Double) Math.max(1.0, ((double) 10000/numLedgers))).intValue());
-            bkc.getConf().setThrottleValue(throttle);
-            LedgerHandle[] lhArray = new LedgerHandle[numLedgers];
-            for(int i = 0; i < numLedgers; i++) {
-                lhArray[i] = bkc.createLedger(3, 2, BookKeeper.DigestType.CRC32, new byte[]
{'a', 'b'});
-                LOG.debug("Ledger handle: " + lhArray[i].getId());
-            }
-            LOG.info("Done creating ledgers.");
-            Random r = new Random();
-
-            for (int i = 0; i < numEntriesToWrite; i++) {
-                ByteBuffer entry = ByteBuffer.allocate(4);
-                entry.putInt(rng.nextInt(maxInt));
-                entry.position(0);
-
-                entries.add(entry.array());
-                entriesSize.add(entry.array().length);
-
-                int nextLh = r.nextInt(numLedgers);
-                lhArray[nextLh].asyncAddEntry(entry.array(), this, sync);
-            }
-
-            // wait for all entries to be acknowledged
-            synchronized (sync) {
-                while (sync.counter < numEntriesToWrite) {
-                    LOG.debug("Entries counter = " + sync.counter);
-                    sync.wait();
-                }
-            }
-
-            LOG.debug("*** WRITE COMPLETE ***");
-            // close ledger
-            for(int i = 0; i < lhArray.length; i++) {
-                lhArray[i].close();
-            }
-        } catch (BKException e) {
-            LOG.error("Test failed", e);
-            fail("Test failed due to BookKeeper exception");
-        } catch (InterruptedException e) {
-            LOG.error("Test failed", e);
-            fail("Test failed due to interruption");
-        }
-    }
-
-    @Test
     public void testReadFromOpenLedger() throws IOException {
         try {
             // Create a ledger



Mime
View raw message