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 2013/11/07 02:19:38 UTC
[30/53] [abbrv] git commit: [HELIX-216] Allow HelixAdmin addResource
to accept the old rebalancing types
[HELIX-216] Allow HelixAdmin addResource to accept the old rebalancing types
Project: http://git-wip-us.apache.org/repos/asf/incubator-helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-helix/commit/84441d3c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-helix/tree/84441d3c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-helix/diff/84441d3c
Branch: refs/heads/master
Commit: 84441d3c00394f8c58d905e4c3dec3b789142e76
Parents: 71c62c4
Author: Kanak Biscuitwala <ka...@apache.org>
Authored: Mon Sep 30 09:44:38 2013 -0700
Committer: Kanak Biscuitwala <ka...@apache.org>
Committed: Wed Nov 6 13:17:35 2013 -0800
----------------------------------------------------------------------
.../apache/helix/manager/zk/ZKHelixAdmin.java | 8 ++------
.../java/org/apache/helix/model/IdealState.java | 21 ++++++++++++++++++++
2 files changed, 23 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/84441d3c/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
index 3c5502d..75d564f 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixAdmin.java
@@ -625,15 +625,11 @@ public class ZKHelixAdmin implements HelixAdmin {
throw new HelixException("cluster " + clusterName + " is not setup yet");
}
- RebalanceMode mode = RebalanceMode.SEMI_AUTO;
- try {
- mode = RebalanceMode.valueOf(rebalancerMode);
- } catch (Exception e) {
- logger.error("", e);
- }
IdealState idealState = new IdealState(resourceName);
idealState.setNumPartitions(partitions);
idealState.setStateModelDefId(StateModelDefId.from(stateModelRef));
+ RebalanceMode mode =
+ idealState.rebalanceModeFromString(rebalancerMode, RebalanceMode.SEMI_AUTO);
idealState.setRebalanceMode(mode);
idealState.setReplicas("" + 0);
idealState.setStateModelFactoryId(StateModelFactoryId
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/84441d3c/helix-core/src/main/java/org/apache/helix/model/IdealState.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/IdealState.java b/helix-core/src/main/java/org/apache/helix/model/IdealState.java
index 342acf2..5996391 100644
--- a/helix-core/src/main/java/org/apache/helix/model/IdealState.java
+++ b/helix-core/src/main/java/org/apache/helix/model/IdealState.java
@@ -725,6 +725,27 @@ public class IdealState extends HelixProperty {
}
/**
+ * Parse a rebalance mode from a string. It can also understand IdealStateModeProperty values
+ * @param mode string containing a RebalanceMode value
+ * @param defaultMode the mode to use if the string is not valid
+ * @return converted RebalanceMode value
+ */
+ public RebalanceMode rebalanceModeFromString(String mode, RebalanceMode defaultMode) {
+ RebalanceMode rebalanceMode = defaultMode;
+ try {
+ rebalanceMode = RebalanceMode.valueOf(mode);
+ } catch (Exception rebalanceModeException) {
+ try {
+ IdealStateModeProperty oldMode = IdealStateModeProperty.valueOf(mode);
+ rebalanceMode = normalizeRebalanceMode(oldMode);
+ } catch (Exception e) {
+ logger.error(e);
+ }
+ }
+ return rebalanceMode;
+ }
+
+ /**
* Convert a preference list of strings into a preference list of participants
* @param rawPreferenceList the list of strings representing participant names
* @return converted list