You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by ka...@apache.org on 2014/11/21 06:47:21 UTC
helix git commit: [HELIX-555] Fix deficiency in ClusterStateVerifier
api
Repository: helix
Updated Branches:
refs/heads/helix-0.6.x 9ddd0af34 -> b2794e744
[HELIX-555] Fix deficiency in ClusterStateVerifier api
Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/b2794e74
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/b2794e74
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/b2794e74
Branch: refs/heads/helix-0.6.x
Commit: b2794e744e945da966c7ac6ae6408636951281d3
Parents: 9ddd0af
Author: Antony T Curtis <ac...@linkedin.com>
Authored: Thu Nov 20 20:36:01 2014 -0800
Committer: Antony T Curtis <ac...@linkedin.com>
Committed: Thu Nov 20 20:36:01 2014 -0800
----------------------------------------------------------------------
.../helix/tools/ClusterStateVerifier.java | 34 +++++++++++++-------
1 file changed, 23 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/helix/blob/b2794e74/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier.java b/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier.java
index bd749c3..1428896 100644
--- a/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier.java
+++ b/helix-core/src/main/java/org/apache/helix/tools/ClusterStateVerifier.java
@@ -126,11 +126,17 @@ public class ClusterStateVerifier {
}
+ private static ZkClient validateAndGetClient(String zkAddr, String clusterName) {
+ if (zkAddr == null || clusterName == null) {
+ throw new IllegalArgumentException("requires zkAddr|clusterName");
+ }
+ return ZKClientPool.getZkClient(zkAddr);
+ }
+
/**
* verifier that verifies best possible state and external view
*/
public static class BestPossAndExtViewZkVerifier implements ZkVerifier {
- private final String zkAddr;
private final String clusterName;
private final Map<String, Map<String, String>> errStates;
private final ZkClient zkClient;
@@ -147,13 +153,17 @@ public class ClusterStateVerifier {
public BestPossAndExtViewZkVerifier(String zkAddr, String clusterName,
Map<String, Map<String, String>> errStates, Set<String> resources) {
- if (zkAddr == null || clusterName == null) {
- throw new IllegalArgumentException("requires zkAddr|clusterName");
+ this(validateAndGetClient(zkAddr, clusterName), clusterName, errStates, resources);
+ }
+
+ public BestPossAndExtViewZkVerifier(ZkClient zkClient, String clusterName,
+ Map<String, Map<String, String>> errStates, Set<String> resources) {
+ if (zkClient == null || clusterName == null) {
+ throw new IllegalArgumentException("requires zkClient|clusterName");
}
- this.zkAddr = zkAddr;
this.clusterName = clusterName;
this.errStates = errStates;
- this.zkClient = ZKClientPool.getZkClient(zkAddr); // null;
+ this.zkClient = zkClient;
this.resources = resources;
}
@@ -186,22 +196,24 @@ public class ClusterStateVerifier {
String verifierName = getClass().getName();
verifierName =
verifierName.substring(verifierName.lastIndexOf('.') + 1, verifierName.length());
- return verifierName + "(" + clusterName + "@" + zkAddr + ")";
+ return verifierName + "(" + clusterName + "@" + zkClient.getServers() + ")";
}
}
public static class MasterNbInExtViewVerifier implements ZkVerifier {
- private final String zkAddr;
private final String clusterName;
private final ZkClient zkClient;
public MasterNbInExtViewVerifier(String zkAddr, String clusterName) {
- if (zkAddr == null || clusterName == null) {
- throw new IllegalArgumentException("requires zkAddr|clusterName");
+ this(validateAndGetClient(zkAddr, clusterName), clusterName);
+ }
+
+ public MasterNbInExtViewVerifier(ZkClient zkClient, String clusterName) {
+ if (zkClient == null || clusterName == null) {
+ throw new IllegalArgumentException("requires zkClient|clusterName");
}
- this.zkAddr = zkAddr;
this.clusterName = clusterName;
- this.zkClient = ZKClientPool.getZkClient(zkAddr);
+ this.zkClient = zkClient;
}
@Override