This is an automated email from the ASF dual-hosted git repository. hulee pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/helix.git
commit 9f326a131444ed6026f91f341f601375182d3761 Author: Yi Wang <[email protected]> AuthorDate: Tue Mar 19 14:16:16 2019 -0700 Interface design for zone mapping information RB=1578905 BUG=helix-1646 G=helix-reviewers A=jxue Signed-off-by: Hunter Lee <[email protected]> --- .../java/org/apache/helix/model/ClusterConfig.java | 31 +++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/helix-core/src/main/java/org/apache/helix/model/ClusterConfig.java b/helix-core/src/main/java/org/apache/helix/model/ClusterConfig.java index 713b18a..f78f586 100644 --- a/helix-core/src/main/java/org/apache/helix/model/ClusterConfig.java +++ b/helix-core/src/main/java/org/apache/helix/model/ClusterConfig.java @@ -20,6 +20,7 @@ package org.apache.helix.model; */ import com.google.common.collect.Maps; +import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -31,6 +32,7 @@ import org.apache.helix.ZNRecord; import org.apache.helix.api.config.HelixConfigProperty; import org.apache.helix.api.config.StateTransitionThrottleConfig; import org.apache.helix.api.config.StateTransitionTimeoutConfig; +import org.apache.helix.api.config.ViewClusterSourceConfig; /** * Cluster configurations @@ -130,6 +132,23 @@ public class ClusterConfig extends HelixProperty { } /** + * Set a list of ViewClusterSourceConfig to ClusterConfig. Current source config will be + * overwritten + * @param sourceConfigList + */ + public void setViewClusterSourceConfigs(List<ViewClusterSourceConfig> sourceConfigList) { + List<String> sourceConfigs = new ArrayList<>(); + for (ViewClusterSourceConfig config : sourceConfigList) { + try { + sourceConfigs.add(config.toJson()); + } catch (IOException e) { + throw new IllegalArgumentException("Invalid source config. Error: " + e.toString()); + } + } + _record.setListField(ClusterConfigProperty.VIEW_CLUSTER_SOURCES.name(), sourceConfigs); + } + + /** * Set task quota type with the ratio of this quota. * @param quotaType String * @param quotaRatio int @@ -207,6 +226,16 @@ public class ClusterConfig extends HelixProperty { refreshPeriod); } + public List<ViewClusterSourceConfig> getViewClusterSourceConfigs() { + List<ViewClusterSourceConfig> sourceConfigList = new ArrayList<>(); + for (String configJSON : _record + .getListField(ClusterConfigProperty.VIEW_CLUSTER_SOURCES.name())) { + ViewClusterSourceConfig config = ViewClusterSourceConfig.fromJson(configJSON); + sourceConfigList.add(config); + } + return sourceConfigList; + } + public int getViewClusterRefershPeriod() { return _record.getIntField(ClusterConfigProperty.VIEW_CLUSTER_REFRESH_PERIOD.name(), DEFAULT_VIEW_CLUSTER_REFRESH_PERIOD); @@ -737,4 +766,4 @@ public class ClusterConfig extends HelixProperty { public String getClusterName() { return _record.getId(); } -} \ No newline at end of file +}
