Github user afine commented on a diff in the pull request:
https://github.com/apache/zookeeper/pull/453#discussion_r168884819
--- Diff:
src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java ---
@@ -465,6 +470,37 @@ private void waitForAll(ZooKeeper[] zks, States state)
throws InterruptedExcepti
private static class Servers {
MainThread mt[];
ZooKeeper zk[];
+ int[] clientPorts;
+
+ public void shutDownAllServers() throws InterruptedException {
+ for (MainThread t: mt) {
+ t.shutdown();
+ }
+ }
+
+ public void restartAllServersAndClients(Watcher watcher) throws
IOException {
+ for (MainThread t : mt) {
+ if (!t.isAlive()) {
+ t.start();
+ }
+ }
+ for (int i = 0; i < zk.length; i++) {
+ restartClient(i, watcher);
+ }
+ }
+
+ public void restartClient(int i, Watcher watcher) throws
IOException {
+ zk[i] = new ZooKeeper("127.0.0.1:" + clientPorts[i],
ClientBase.CONNECTION_TIMEOUT, watcher);
+ }
+
+ public int findLeader() {
--- End diff --
there are other places in this test class that benefit from this
refactoring. Would you mind cleaning that up?
---