Repository: helix Updated Branches: refs/heads/helix-0.6.x 812b83f0a -> cd89a267e
Add back old getInstanceEnabledForPartition function Add back old getInstanceEnabledForPartition to make backward compatible. Project: http://git-wip-us.apache.org/repos/asf/helix/repo Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/cd89a267 Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/cd89a267 Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/cd89a267 Branch: refs/heads/helix-0.6.x Commit: cd89a267e7ce8973535c17a6714ab84ea0f337fb Parents: 50ff94a Author: Junkai Xue <[email protected]> Authored: Wed Mar 8 15:41:26 2017 -0800 Committer: dasahcc <[email protected]> Committed: Sun Mar 12 12:16:34 2017 -0700 ---------------------------------------------------------------------- .../org/apache/helix/model/InstanceConfig.java | 37 +++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/helix/blob/cd89a267/helix-core/src/main/java/org/apache/helix/model/InstanceConfig.java ---------------------------------------------------------------------- diff --git a/helix-core/src/main/java/org/apache/helix/model/InstanceConfig.java b/helix-core/src/main/java/org/apache/helix/model/InstanceConfig.java index 0db18fd..8dcd1ef 100644 --- a/helix-core/src/main/java/org/apache/helix/model/InstanceConfig.java +++ b/helix-core/src/main/java/org/apache/helix/model/InstanceConfig.java @@ -223,6 +223,24 @@ public class InstanceConfig extends HelixProperty { /** * Check if this instance is enabled for a given partition + * This API is deprecated, and will be removed in next major release. + * + * @param partition the partition name to check + * @return true if the instance is enabled for the partition, false otherwise + */ + @Deprecated + public boolean getInstanceEnabledForPartition(String partition) { + boolean enabled = true; + Map<String, String> disabledPartitionMap = + _record.getMapField(InstanceConfigProperty.HELIX_DISABLED_PARTITION.name()); + for (String resourceName : disabledPartitionMap.keySet()) { + enabled &= getInstanceEnabledForPartition(resourceName, partition); + } + return enabled; + } + + /** + * Check if this instance is enabled for a given partition * @param partition the partition name to check * @return true if the instance is enabled for the partition, false otherwise */ @@ -314,11 +332,22 @@ public class InstanceConfig extends HelixProperty { */ @Deprecated public void setInstanceEnabledForPartition(String partitionName, boolean enabled) { - Map<String, String> disabledPartitionMap = - _record.getMapField(InstanceConfigProperty.HELIX_DISABLED_PARTITION.name()); - for (String resourceName : disabledPartitionMap.keySet()) { - setInstanceEnabledForPartition(resourceName, partitionName, enabled); + List<String> list = + _record.getListField(InstanceConfigProperty.HELIX_DISABLED_PARTITION.toString()); + Set<String> disabledPartitions = new HashSet<String>(); + if (list != null) { + disabledPartitions.addAll(list); + } + + if (enabled) { + disabledPartitions.remove(partitionName); + } else { + disabledPartitions.add(partitionName); } + + list = new ArrayList<String>(disabledPartitions); + Collections.sort(list); + _record.setListField(InstanceConfigProperty.HELIX_DISABLED_PARTITION.toString(), list); } public void setInstanceEnabledForPartition(String resourceName, String partitionName,
