Skip to content

Commit

Permalink
Add handling for clusterConfig == null in updateSwappingInstances and…
Browse files Browse the repository at this point in the history
… fix AssignableNode to check for clusterTopologyConfig when attempting to get logicalId.
  • Loading branch information
zpinto committed Oct 27, 2023
1 parent a6557cf commit d3887bd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -888,10 +888,17 @@ private void updateDisabledInstances(Collection<InstanceConfig> instanceConfigs,

private void updateSwappingInstances(Collection<InstanceConfig> instanceConfigs,
Set<String> liveEnabledInstances, ClusterConfig clusterConfig) {
ClusterTopologyConfig clusterTopologyConfig =
ClusterTopologyConfig.createFromClusterConfig(clusterConfig);
_swapOutInstanceNameToSwapInInstanceName.clear();
_enabledLiveSwapInInstanceNames.clear();

if (clusterConfig == null) {
logger.warn("Skip refreshing swapping instances because clusterConfig is null.");
return;
}

ClusterTopologyConfig clusterTopologyConfig =
ClusterTopologyConfig.createFromClusterConfig(clusterConfig);

Map<String, String> swapOutLogicalIdsByInstanceName = new HashMap<>();
Map<String, String> swapInInstancesByLogicalId = new HashMap<>();
instanceConfigs.forEach(instanceConfig -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class AssignableNode implements Comparable<AssignableNode> {
InstanceConfig instanceConfig, String instanceName) {
_instanceName = instanceName;
_logicaId =
clusterConfig != null ? instanceConfig.getLogicalId(clusterTopologyConfig.getEndNodeType())
clusterTopologyConfig != null ? instanceConfig.getLogicalId(clusterTopologyConfig.getEndNodeType())
: instanceName;
Map<String, Integer> instanceCapacity = fetchInstanceCapacity(clusterConfig, instanceConfig);
_faultZone = computeFaultZone(clusterConfig, instanceConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ public void testRebalanceOverwrite() throws HelixRebalanceException, IOException
instances.add(offlineInstance);
when(clusterData.getAllInstances()).thenReturn(instances);
when(clusterData.getEnabledInstances()).thenReturn(instances);
when(clusterData.getEnabledLiveInstances()).thenReturn(ImmutableSet.of(instance0, instance1, instance2));
when(clusterData.getEnabledLiveInstances()).thenReturn(new HashSet<>(Set.of(instance0, instance1, instance2)));
Map<String, Long> instanceOfflineTimeMap = new HashMap<>();
instanceOfflineTimeMap.put(offlineInstance, System.currentTimeMillis() + Integer.MAX_VALUE);
when(clusterData.getInstanceOfflineTimeMap()).thenReturn(instanceOfflineTimeMap);
Expand Down

0 comments on commit d3887bd

Please sign in to comment.