Repository: incubator-slider Updated Branches: refs/heads/develop d4f1ae5b8 -> df20b51e4
SLIDER-862 TestZKIntegration fails with Zookeeper 3.5.0-alpha (not a fix, just add ability to extend session timeout, and increase default) Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/6cbec317 Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/6cbec317 Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/6cbec317 Branch: refs/heads/develop Commit: 6cbec3172a0a5cbd1ca42e6d32c867498aed049b Parents: 1a4c9ca Author: Steve Loughran <[email protected]> Authored: Mon Jul 20 12:07:20 2015 +0100 Committer: Steve Loughran <[email protected]> Committed: Mon Jul 20 12:07:20 2015 +0100 ---------------------------------------------------------------------- .../org/apache/slider/client/SliderClient.java | 3 ++- .../apache/slider/common/tools/SliderUtils.java | 3 +-- .../org/apache/slider/core/zk/ZKIntegration.java | 17 +++++++++++++---- .../slider/common/tools/TestZKIntegration.groovy | 7 ++++--- .../slider/test/YarnZKMiniClusterTestBase.groovy | 19 +++++++++++-------- 5 files changed, 31 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/6cbec317/slider-core/src/main/java/org/apache/slider/client/SliderClient.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java index a0ab6cf..ed02573 100644 --- a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java +++ b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java @@ -643,7 +643,8 @@ public class SliderClient extends AbstractSliderLaunchedService implements RunSe ZKIntegration client = null; try { BlockingZKWatcher watcher = new BlockingZKWatcher(); - client = ZKIntegration.newInstance(registryQuorum, user, clusterName, true, false, watcher); + client = ZKIntegration.newInstance(registryQuorum, user, clusterName, true, false, watcher, + ZKIntegration.SESSION_TIMEOUT); client.init(); watcher.waitForZKConnection(2 * 1000); } catch (InterruptedException e) { http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/6cbec317/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java b/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java index 057e61a..1deffb1 100644 --- a/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java +++ b/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java @@ -495,8 +495,7 @@ public final class SliderUtils { //if the fallback option is NOT set, enable it. //if it is explicitly set to anything -leave alone - if (conf.get(SliderXmlConfKeys.IPC_CLIENT_FALLBACK_TO_SIMPLE_AUTH) == - null) { + if (conf.get(SliderXmlConfKeys.IPC_CLIENT_FALLBACK_TO_SIMPLE_AUTH) == null) { conf.set(SliderXmlConfKeys.IPC_CLIENT_FALLBACK_TO_SIMPLE_AUTH, "true"); } return conf; http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/6cbec317/slider-core/src/main/java/org/apache/slider/core/zk/ZKIntegration.java ---------------------------------------------------------------------- diff --git a/slider-core/src/main/java/org/apache/slider/core/zk/ZKIntegration.java b/slider-core/src/main/java/org/apache/slider/core/zk/ZKIntegration.java index 9a9cae4..ca41e4b 100644 --- a/slider-core/src/main/java/org/apache/slider/core/zk/ZKIntegration.java +++ b/slider-core/src/main/java/org/apache/slider/core/zk/ZKIntegration.java @@ -57,7 +57,7 @@ public class ZKIntegration implements Watcher, Closeable { ZK_USERS_PATH_LIST.add(ZK_USERS); } - public static int SESSION_TIMEOUT = 5000; + public static int SESSION_TIMEOUT = 30000; protected static final Logger log = LoggerFactory.getLogger(ZKIntegration.class); private ZooKeeper zookeeper; @@ -80,7 +80,8 @@ public class ZKIntegration implements Watcher, Closeable { String clustername, boolean canBeReadOnly, boolean createClusterPath, - Watcher watchEventHandler + Watcher watchEventHandler, + int sessionTimeout ) throws IOException { this.username = username; this.clustername = clustername; @@ -88,6 +89,7 @@ public class ZKIntegration implements Watcher, Closeable { this.zkConnection = zkConnection; this.canBeReadOnly = canBeReadOnly; this.createClusterPath = createClusterPath; + this.sessionTimeout = sessionTimeout; this.userPath = mkSliderUserPath(username); } @@ -107,14 +109,21 @@ public class ZKIntegration implements Watcher, Closeable { * @return the new instance * @throws IOException */ - public static ZKIntegration newInstance(String zkConnection, String username, String clustername, boolean createClusterPath, boolean canBeReadOnly, Watcher watchEventHandler) throws IOException { + public static ZKIntegration newInstance(String zkConnection, + String username, + String clustername, + boolean createClusterPath, + boolean canBeReadOnly, + Watcher watchEventHandler, + int sessionTimeout) throws IOException { return new ZKIntegration(zkConnection, username, clustername, canBeReadOnly, createClusterPath, - watchEventHandler); + watchEventHandler, + sessionTimeout); } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/6cbec317/slider-core/src/test/groovy/org/apache/slider/common/tools/TestZKIntegration.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/common/tools/TestZKIntegration.groovy b/slider-core/src/test/groovy/org/apache/slider/common/tools/TestZKIntegration.groovy index d8dbfcd..6fed4cb 100644 --- a/slider-core/src/test/groovy/org/apache/slider/common/tools/TestZKIntegration.groovy +++ b/slider-core/src/test/groovy/org/apache/slider/common/tools/TestZKIntegration.groovy @@ -41,6 +41,7 @@ class TestZKIntegration extends YarnZKMiniClusterTestBase implements KeysForTest // as the static compiler doesn't resolve consistently public static final String USER = KeysForTests.USERNAME + public static final int CONNECT_TIMEOUT = 5000 private ZKIntegration zki @Before @@ -61,7 +62,7 @@ class TestZKIntegration extends YarnZKMiniClusterTestBase implements KeysForTest public ZKIntegration initZKI() { zki = createZKIntegrationInstance( - getZKBinding(), methodName.methodName, true, false, 5000) + getZKBinding(), methodName.methodName, true, false, CONNECT_TIMEOUT) return zki } @@ -114,7 +115,7 @@ class TestZKIntegration extends YarnZKMiniClusterTestBase implements KeysForTest assert zkPath == "/services/slider/users/" + USER + "/cl1", "zkPath must be as expected" assert path == zkPath assert zki == null, "ZKIntegration should be null." - zki = createZKIntegrationInstance(getZKBinding(), "cl1", true, false, 5000); + zki = createZKIntegrationInstance(getZKBinding(), "cl1", true, false, CONNECT_TIMEOUT); assert !zki.exists(zkPath) path = client.createZookeeperNode("cl1", false) @@ -145,7 +146,7 @@ class TestZKIntegration extends YarnZKMiniClusterTestBase implements KeysForTest @Override protected ZKIntegration getZkClient(String clusterName, String user) { - zki = createZKIntegrationInstance(getZKBinding(), clusterName, true, false, 5000) + zki = createZKIntegrationInstance(getZKBinding(), clusterName, true, false, CONNECT_TIMEOUT) return zki; } http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/6cbec317/slider-core/src/test/groovy/org/apache/slider/test/YarnZKMiniClusterTestBase.groovy ---------------------------------------------------------------------- diff --git a/slider-core/src/test/groovy/org/apache/slider/test/YarnZKMiniClusterTestBase.groovy b/slider-core/src/test/groovy/org/apache/slider/test/YarnZKMiniClusterTestBase.groovy index e907209..313ab46 100644 --- a/slider-core/src/test/groovy/org/apache/slider/test/YarnZKMiniClusterTestBase.groovy +++ b/slider-core/src/test/groovy/org/apache/slider/test/YarnZKMiniClusterTestBase.groovy @@ -46,17 +46,20 @@ public abstract class YarnZKMiniClusterTestBase extends YarnMiniClusterTestBase } public ZKIntegration createZKIntegrationInstance(String zkQuorum, - String clusterName, - boolean createClusterPath, - boolean canBeReadOnly, - int timeout) { + String clusterName, + boolean createClusterPath, + boolean canBeReadOnly, + int timeout, + int sessionTimeout = ZKIntegration.SESSION_TIMEOUT) { BlockingZKWatcher watcher = new BlockingZKWatcher(); ZKIntegration zki = ZKIntegration.newInstance(zkQuorum, - USERNAME, - clusterName, - createClusterPath, - canBeReadOnly, watcher) + USERNAME, + clusterName, + createClusterPath, + canBeReadOnly, + watcher, + sessionTimeout) zki.init() //here the callback may or may not have occurred. //optionally wait for it
