Permalink
Browse files

Bump zookeeper to 3.4.6 and fix a flaky d2 test

RB=707829
G=si-dev
R=ssheng,xzhu,dhoa,cxu
A=ssheng,xzhu
  • Loading branch information...
1 parent 9b386c2 commit 3929716e9502a7bda8e5154abf3e4b4f981c38f4 Ang Xu committed Mar 28, 2016
View
@@ -1,5 +1,10 @@
+6.0.2
+------
+
+
6.0.1
------
+Bump zookeeper library from 3.3.4 to 3.4.6
6.0.0
------
View
@@ -66,7 +66,7 @@ project.ext.externalDependency = [
'snappy': 'org.iq80.snappy:snappy:0.3',
'testng': 'org.testng:testng:6.4',
'velocity': 'org.apache.velocity:velocity:1.5',
- 'zookeeper': 'org.apache.zookeeper:zookeeper:3.3.4',
+ 'zookeeper': 'org.apache.zookeeper:zookeeper:3.4.6',
// for restli-spring-bridge ONLY, we must keep these dependencies isolated
'springCore': 'org.springframework:spring-core:3.2.3.RELEASE',
@@ -27,10 +27,11 @@
import java.nio.channels.ServerSocketChannel;
import java.util.Map;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.io.FileUtils;
-import org.apache.zookeeper.server.NIOServerCnxn;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
import org.apache.zookeeper.server.ZKDatabase;
import org.apache.zookeeper.server.ZooKeeperServer;
import org.apache.zookeeper.server.persistence.FileTxnSnapLog;
@@ -94,8 +95,8 @@ public void setQuorumPeer(int peersCount,
Map<Long, QuorumServer> peersView,
FileTxnSnapLog fts) throws IOException
{
- NIOServerCnxn.Factory cnxnFactory =
- new NIOServerCnxn.Factory(new InetSocketAddress("127.0.0.1", _clientPort), _maxClientCnxns);
+ NIOServerCnxnFactory cnxnFactory = new NIOServerCnxnFactory();
+ cnxnFactory.configure(new InetSocketAddress("127.0.0.1", _clientPort), _maxClientCnxns);
_peer = new QuorumPeer();
_peer.setClientPortAddress(new InetSocketAddress("127.0.0.1", _clientPort));
@@ -333,8 +334,8 @@ public void killQuorumPeer()
Field cnxnFactoryField = QuorumPeer.class.getDeclaredField("cnxnFactory");
cnxnFactoryField.setAccessible(true);
- NIOServerCnxn.Factory cnxnFactory =
- (NIOServerCnxn.Factory) cnxnFactoryField.get(_peer);
+ NIOServerCnxnFactory cnxnFactory =
+ (NIOServerCnxnFactory) cnxnFactoryField.get(_peer);
cnxnFactory.shutdown();
Field ssField = cnxnFactory.getClass().getDeclaredField("ss");
@@ -360,8 +361,8 @@ public void killPeerZkServer()
Field cnxnFactoryField = ZooKeeperServer.class.getDeclaredField("serverCnxnFactory");
cnxnFactoryField.setAccessible(true);
- NIOServerCnxn.Factory cnxnFactory =
- (NIOServerCnxn.Factory) cnxnFactoryField.get(zserver);
+ NIOServerCnxnFactory cnxnFactory =
+ (NIOServerCnxnFactory) cnxnFactoryField.get(zserver);
cnxnFactory.shutdown();
Field ssField = cnxnFactory.getClass().getDeclaredField("ss");
@@ -40,6 +40,7 @@
import com.linkedin.r2.message.Request;
import com.linkedin.r2.message.RequestContext;
import java.util.Arrays;
+import java.util.concurrent.TimeUnit;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -258,13 +259,8 @@ public void testMapKeysConcurrency() throws Exception
futures.add(executor.submit(runnables.get(i)));
}
- // wait for threads to finish
- Thread.sleep(3000);
-
- // every thread should have finished, otherwise there is a deadlock
- for (int i = 0; i < numPartitions; i++)
- {
- Assert.assertTrue(futures.get(i).isDone());
+ for (Future future : futures) {
+ future.get(30, TimeUnit.SECONDS);
}
}
@@ -26,6 +26,7 @@
import java.util.concurrent.CountDownLatch;
import org.apache.commons.io.FileUtils;
import org.apache.zookeeper.server.NIOServerCnxn;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
import org.apache.zookeeper.server.ZooKeeperServer;
/**
@@ -37,7 +38,7 @@
public class ZKServer
{
private volatile ZooKeeperServer _zk;
- private volatile NIOServerCnxn.Factory _factory;
+ private volatile NIOServerCnxnFactory _factory;
private final File _dataDir;
private final File _logDir;
private final int _port;
@@ -80,7 +81,8 @@ public ZKServer(File dataDir, File logDir, int port, boolean erase) throws IOExc
_logDir = logDir;
_port = port;
_zk = new ZooKeeperServer(dataDir, logDir, 5000);
- _factory = new NIOServerCnxn.Factory(new InetSocketAddress(port));
+ _factory = new NIOServerCnxnFactory();
+ _factory.configure(new InetSocketAddress(port), 60 /* default maximum client sockets */);
_erase = erase;
}
@@ -94,7 +96,6 @@ public void startup() throws IOException, InterruptedException
{
ensureDir(_dataDir);
ensureDir(_logDir);
- _zk.startup();
_factory.startup(_zk);
}
@@ -132,7 +133,8 @@ public void restart()
shutdown(false);
_zk = new ZooKeeperServer(_dataDir, _logDir, 5000);
- _factory = new NIOServerCnxn.Factory(new InetSocketAddress(_port));
+ _factory = new NIOServerCnxnFactory();
+ _factory.configure(new InetSocketAddress(_port), 60);
startup();
}
View
@@ -1,4 +1,4 @@
-version=6.0.0
+version=6.0.1
sonatypeUsername=please_set_in_home_dir_if_uploading_to_maven_central
sonatypePassword=please_set_in_home_dir_if_uploading_to_maven_central

0 comments on commit 3929716

Please sign in to comment.