Skip to content

Commit

Permalink
Comment fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali Reza Zamani Zadeh Najari committed Feb 12, 2020
1 parent de0f8fb commit 0c4f575
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions helix-core/src/main/java/org/apache/helix/task/TaskUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -1040,29 +1040,33 @@ public static void purgeExpiredJobs(String workflow, WorkflowConfig workflowConf
/**
* The function that loops through the all existing workflow contexts and removes IdealState and
* workflow context of the workflow whose workflow config does not exist.
* Try-catch has been used to avoid concurrent modification exception while doing deep copy. Since
* Map.keySet() can produce concurrent modification exception.
* @param dataProvider
* @param manager
*/
public static void workflowGarbageCollection(final WorkflowControllerDataProvider dataProvider,
final HelixManager manager) {
// Garbage collections for conditions where workflow context exists but config is missing.

Set<String> existingWorkflowContexts;
Set<String> existingContexts;
/*
* Here try-catch is used to avoid concurrent modification exception while doing deep copy.
* Map.keySet() can produce concurrent modification exception.
* Reason: If the map is modified while an iteration over the set is in progress, concurrent
* modification exception will be thrown.
*/
try {
existingWorkflowContexts = new HashSet<>(dataProvider.getContexts().keySet());
existingContexts = new HashSet<>(dataProvider.getContexts().keySet());
} catch (Exception e) {
LOG.warn(
"Exception occurred while creating a list of all existing contexts with missing config!",
"Exception occurred while creating a list of all workflow/job context names!",
e);
return;
}

// toBeDeletedWorkflows is a set that contains the name of the workflows that their contexts
// should be deleted.
Set<String> toBeDeletedWorkflows = new HashSet<>();
for (String entry : existingWorkflowContexts) {
for (String entry : existingContexts) {
WorkflowConfig cfg = dataProvider.getWorkflowConfig(entry);
WorkflowContext ctx = dataProvider.getWorkflowContext(entry);
if (ctx != null && ctx.getId().equals(TaskUtil.WORKFLOW_CONTEXT_KW) && cfg == null) {
Expand Down

0 comments on commit 0c4f575

Please sign in to comment.