Skip to content

Commit

Permalink
cleanup logging
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantPSpencer committed Jan 27, 2025
1 parent 45190e9 commit 9463094
Showing 1 changed file with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,27 @@ public void execute(ClusterEvent event) throws Exception {
}
}

if (!participantsToDeregister.isEmpty()) {
Set<String> successfullyDeregisteredParticipants =
deregisterParticipants(manager, cache, participantsToDeregister);
if (!successfullyDeregisteredParticipants.isEmpty()) {
LOG.info("Successfully deregistered {} participants from cluster {}",
successfullyDeregisteredParticipants.size(), cache.getClusterName());
}
}
deregisterParticipants(manager, cache, participantsToDeregister);

// Schedule the next deregister task
if (nextDeregisterTime != Long.MAX_VALUE) {
long delay = Math.max(nextDeregisterTime - System.currentTimeMillis(), 0);
scheduleOnDemandPipeline(manager.getClusterName(), delay);
}
}

private Set<String> deregisterParticipants(HelixManager manager, ResourceControllerDataProvider cache,
private void deregisterParticipants(HelixManager manager, ResourceControllerDataProvider cache,
Set<String> instancesToDeregister) {
Set<String> successfullyDeregisteredInstances = new HashSet<>();

if (manager == null || !manager.isConnected() || cache == null || instancesToDeregister == null) {
LOG.info("ParticipantDeregistrationStage failed due to HelixManager being null or not connected!");
return successfullyDeregisteredInstances;
LOG.warn("ParticipantDeregistrationStage failed due to HelixManager being null or not connected!");
return;
}

if (instancesToDeregister.isEmpty()) {
LOG.debug("There are no instances to deregister from cluster {}", cache.getClusterName());
return;
}

// Perform safety checks before deregistering the instances
Expand All @@ -104,11 +103,10 @@ private Set<String> deregisterParticipants(HelixManager manager, ResourceControl
try {
manager.getClusterManagmentTool().dropInstance(cache.getClusterName(), instanceConfig);
successfullyDeregisteredInstances.add(instanceName);
LOG.info("Successfully deregistered instance {} from cluster {}", instanceName, cache.getClusterName());
} catch (HelixException e) {
LOG.warn("Failed to deregister instance {} from cluster {}", instanceName, cache.getClusterName(), e);
}
}

return successfullyDeregisteredInstances;
}
}

0 comments on commit 9463094

Please sign in to comment.