You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2022/04/12 18:53:24 UTC
[GitHub] [helix] qqu0127 commented on a diff in pull request #2032: Code refactor and cleanup on instance validation
qqu0127 commented on code in PR #2032:
URL: https://github.com/apache/helix/pull/2032#discussion_r848770399
##########
helix-core/src/main/java/org/apache/helix/controller/dataproviders/BaseControllerDataProvider.java:
##########
@@ -798,25 +799,18 @@ private void updateDisabledInstances(Collection<InstanceConfig> instanceConfigs,
_disabledInstanceSet.clear();
for (InstanceConfig config : instanceConfigs) {
Map<String, List<String>> disabledPartitionMap = config.getDisabledPartitionsMap();
- if (!config.getInstanceEnabled()) {
+ if (!InstanceValidationUtil.isInstanceEnabled(config, clusterConfig)) {
_disabledInstanceSet.add(config.getInstanceName());
}
for (String resource : disabledPartitionMap.keySet()) {
- if (!_disabledInstanceForPartitionMap.containsKey(resource)) {
- _disabledInstanceForPartitionMap.put(resource, new HashMap<>());
- }
+ _disabledInstanceForPartitionMap.putIfAbsent(resource, new HashMap<>());
for (String partition : disabledPartitionMap.get(resource)) {
- if (!_disabledInstanceForPartitionMap.get(resource).containsKey(partition)) {
- _disabledInstanceForPartitionMap.get(resource).put(partition, new HashSet<>());
- }
- _disabledInstanceForPartitionMap.get(resource).get(partition)
+ _disabledInstanceForPartitionMap.get(resource)
+ .computeIfAbsent(partition, key -> new HashSet<>())
.add(config.getInstanceName());
}
}
}
- if (clusterConfig != null && clusterConfig.getDisabledInstances() != null) {
- _disabledInstanceSet.addAll(clusterConfig.getDisabledInstances().keySet());
- }
Review Comment:
No longer needed. Everything related to instance disable is integrated into `InstanceValidationUtil.isInstanceEnabled`. It's done in a few lines above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org