Repository: curator Updated Branches: refs/heads/CURATOR-397 e4a7e0917 -> beac06f13
CURATOR-409: Fix unintentional override of getQuorumPeer in TestingQuorumPeerMain Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/95617662 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/95617662 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/95617662 Branch: refs/heads/CURATOR-397 Commit: 956176629f5cc9d7c53b52068e4ebdcbdfb86e68 Parents: f898959 Author: Stig Rohde Døssing <[email protected]> Authored: Fri May 5 20:44:10 2017 +0200 Committer: Stig Rohde Døssing <[email protected]> Committed: Fri May 5 20:44:10 2017 +0200 ---------------------------------------------------------------------- .../apache/curator/test/TestingQuorumPeerMain.java | 3 +-- .../apache/curator/test/TestingZooKeeperMain.java | 7 ------- .../apache/curator/test/TestingZooKeeperServer.java | 15 +++++++++++---- .../org/apache/curator/test/ZooKeeperMainFace.java | 3 --- 4 files changed, 12 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/95617662/curator-test/src/main/java/org/apache/curator/test/TestingQuorumPeerMain.java ---------------------------------------------------------------------- diff --git a/curator-test/src/main/java/org/apache/curator/test/TestingQuorumPeerMain.java b/curator-test/src/main/java/org/apache/curator/test/TestingQuorumPeerMain.java index e1c1f89..3ae464c 100644 --- a/curator-test/src/main/java/org/apache/curator/test/TestingQuorumPeerMain.java +++ b/curator-test/src/main/java/org/apache/curator/test/TestingQuorumPeerMain.java @@ -52,8 +52,7 @@ class TestingQuorumPeerMain extends QuorumPeerMain implements ZooKeeperMainFace } } - @Override - public QuorumPeer getQuorumPeer() + public QuorumPeer getTestingQuorumPeer() { return quorumPeer; } http://git-wip-us.apache.org/repos/asf/curator/blob/95617662/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java ---------------------------------------------------------------------- diff --git a/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java b/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java index 19535a6..f0cf68a 100644 --- a/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java +++ b/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperMain.java @@ -28,7 +28,6 @@ import org.apache.zookeeper.server.ServerConfig; import org.apache.zookeeper.server.ZKDatabase; import org.apache.zookeeper.server.ZooKeeperServer; import org.apache.zookeeper.server.persistence.FileTxnSnapLog; -import org.apache.zookeeper.server.quorum.QuorumPeer; import org.apache.zookeeper.server.quorum.QuorumPeerConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -139,12 +138,6 @@ public class TestingZooKeeperMain implements ZooKeeperMainFace } } - @Override - public QuorumPeer getQuorumPeer() - { - throw new UnsupportedOperationException(); - } - @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") @Override public void blockUntilStarted() throws Exception http://git-wip-us.apache.org/repos/asf/curator/blob/95617662/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperServer.java ---------------------------------------------------------------------- diff --git a/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperServer.java b/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperServer.java index c14e3e4..225e3f7 100644 --- a/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperServer.java +++ b/curator-test/src/main/java/org/apache/curator/test/TestingZooKeeperServer.java @@ -32,7 +32,7 @@ import java.util.concurrent.atomic.AtomicReference; /** * Thanks to Jeremie BORDIER (ahfeel) for this code */ -public class TestingZooKeeperServer extends QuorumPeerMain implements Closeable +public class TestingZooKeeperServer implements Closeable { private static final Logger logger = LoggerFactory.getLogger(TestingZooKeeperServer.class); @@ -55,12 +55,19 @@ public class TestingZooKeeperServer extends QuorumPeerMain implements Closeable { this.configBuilder = configBuilder; this.thisInstanceIndex = thisInstanceIndex; - main = (configBuilder.size() > 1) ? new TestingQuorumPeerMain() : new TestingZooKeeperMain(); + main = isCluster() ? new TestingQuorumPeerMain() : new TestingZooKeeperMain(); } + private boolean isCluster() { + return configBuilder.size() > 1; + } + public QuorumPeer getQuorumPeer() { - return main.getQuorumPeer(); + if (isCluster()) { + return ((TestingQuorumPeerMain) main).getTestingQuorumPeer(); + } + throw new UnsupportedOperationException(); } public Collection<InstanceSpec> getInstanceSpecs() @@ -99,7 +106,7 @@ public class TestingZooKeeperServer extends QuorumPeerMain implements Closeable // Set to a LATENT state so we can restart state.set(State.LATENT); - main = (configBuilder.size() > 1) ? new TestingQuorumPeerMain() : new TestingZooKeeperMain(); + main = isCluster() ? new TestingQuorumPeerMain() : new TestingZooKeeperMain(); start(); } http://git-wip-us.apache.org/repos/asf/curator/blob/95617662/curator-test/src/main/java/org/apache/curator/test/ZooKeeperMainFace.java ---------------------------------------------------------------------- diff --git a/curator-test/src/main/java/org/apache/curator/test/ZooKeeperMainFace.java b/curator-test/src/main/java/org/apache/curator/test/ZooKeeperMainFace.java index 6da29a4..946ac1a 100644 --- a/curator-test/src/main/java/org/apache/curator/test/ZooKeeperMainFace.java +++ b/curator-test/src/main/java/org/apache/curator/test/ZooKeeperMainFace.java @@ -18,7 +18,6 @@ */ package org.apache.curator.test; -import org.apache.zookeeper.server.quorum.QuorumPeer; import org.apache.zookeeper.server.quorum.QuorumPeerConfig; import java.io.Closeable; @@ -29,6 +28,4 @@ public interface ZooKeeperMainFace extends Closeable public void blockUntilStarted() throws Exception; public void kill(); - - public QuorumPeer getQuorumPeer(); }
