You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by wf...@apache.org on 2016/01/05 01:36:41 UTC
aurora git commit: Fixup ZooKeeperTestServer restartNetwork.
Repository: aurora
Updated Branches:
refs/heads/master f5d7e0106 -> 227a3a6e1
Fixup ZooKeeperTestServer restartNetwork.
With the upgrade to 3.4.2 and the switch from `NIOServerCnxn.Factory` to
`NIOServerCnxnFactory` came a change in the server internals. Calling
`connectionFactory.startup(zooKeeperServer)` now eventually calls
`ZooKeeperServer.startup` which calls `SessionTrackerImpl.start`. This
last is a problem since `SessionTrackerImpl` is a `Thread` and so throws
`IllegalThreadStateException`.
Reviewed at https://reviews.apache.org/r/41894/
Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/227a3a6e
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/227a3a6e
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/227a3a6e
Branch: refs/heads/master
Commit: 227a3a6e12622debcd9c19180e1c1412585c11d2
Parents: f5d7e01
Author: John Sirois <jo...@gmail.com>
Authored: Mon Jan 4 16:24:40 2016 -0800
Committer: Bill Farner <wf...@apache.org>
Committed: Mon Jan 4 16:24:40 2016 -0800
----------------------------------------------------------------------
.../zookeeper/testing/ZooKeeperTestServer.java | 28 +++++++++++---------
1 file changed, 16 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aurora/blob/227a3a6e/commons/src/main/java/org/apache/aurora/common/zookeeper/testing/ZooKeeperTestServer.java
----------------------------------------------------------------------
diff --git a/commons/src/main/java/org/apache/aurora/common/zookeeper/testing/ZooKeeperTestServer.java b/commons/src/main/java/org/apache/aurora/common/zookeeper/testing/ZooKeeperTestServer.java
index 54b0a09..dc4d389 100644
--- a/commons/src/main/java/org/apache/aurora/common/zookeeper/testing/ZooKeeperTestServer.java
+++ b/commons/src/main/java/org/apache/aurora/common/zookeeper/testing/ZooKeeperTestServer.java
@@ -42,11 +42,14 @@ public class ZooKeeperTestServer {
public static final Amount<Integer, Time> DEFAULT_SESSION_TIMEOUT =
Amount.of(100, Time.MILLISECONDS);
- protected final ZooKeeperServer zooKeeperServer;
+ private final LinkedList<Runnable> cleanupActions = Lists.newLinkedList();
+ private final File dataDir;
+ private final File snapDir;
+ private final Amount<Integer, Time> defaultSessionTimeout;
+
+ private ZooKeeperServer zooKeeperServer;
private ServerCnxnFactory connectionFactory;
private int port;
- private final Amount<Integer, Time> defaultSessionTimeout;
- private final LinkedList<Runnable> cleanupActions = Lists.newLinkedList();
/**
* @param defaultSessionTimeout the default session timeout for clients created with
@@ -59,7 +62,14 @@ public class ZooKeeperTestServer {
File snapDir) throws IOException {
this.defaultSessionTimeout = Preconditions.checkNotNull(defaultSessionTimeout);
+ this.dataDir = Preconditions.checkNotNull(dataDir);
+ this.snapDir = Preconditions.checkNotNull(snapDir);
+ }
+ /**
+ * Starts zookeeper up on an ephemeral port.
+ */
+ public void startNetwork() throws IOException, InterruptedException {
zooKeeperServer =
new ZooKeeperServer(
new FileTxnSnapLog(dataDir, snapDir),
@@ -71,19 +81,13 @@ public class ZooKeeperTestServer {
// noop
}
};
- }
- /**
- * Starts zookeeper up on an ephemeral port.
- */
- public void startNetwork() throws IOException, InterruptedException {
connectionFactory = new NIOServerCnxnFactory();
connectionFactory.configure(
new InetSocketAddress(port),
- 60 /* Semi-arbitrary, max 60 connections is the default used by NIOServerCnxnFactory */);
-
+ 60 /* Semi-arbitrary, max 60 connections is the default used by NIOServerCnxnFactory */);
connectionFactory.startup(zooKeeperServer);
- cleanupActions.addFirst((this::shutdownNetwork));
+ cleanupActions.addFirst(this::shutdownNetwork);
port = zooKeeperServer.getClientPort();
}
@@ -111,7 +115,7 @@ public class ZooKeeperTestServer {
*/
public final void shutdownNetwork() {
if (connectionFactory != null) {
- connectionFactory.shutdown();
+ connectionFactory.shutdown(); // Also shuts down zooKeeperServer.
connectionFactory = null;
}
}