Skip to content

Commit

Permalink
ONECOND-2336 - adding debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
pradeeppalat01 committed Aug 26, 2024
1 parent 3a4962e commit 261fc69
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ public List<String> handle(EventHandler.Action action, Object payload, EventExec
} else {
taskStatus = Task.Status.COMPLETED;
}

logger.debug("ReferenceKeysMatchAction: Task Status " + taskStatus);
Map<String, Object> titleKeysMap = ScriptEvaluator.evaluateMap(params.titleKeys, payload);
Map<String, Object> titleVersionMap = ScriptEvaluator.evaluateMap(params.titleVersion, payload);

ReferenceKey eventRefKeys = new ReferenceKey();
eventRefKeys.titleKeys = mapper.convertValue(titleKeysMap, TitleKeys.class);
eventRefKeys.titleVersion = mapper.convertValue(titleVersionMap, TitleVersion.class);

logger.debug("ReferenceKeysMatchAction: Task titleKeysMap " + titleKeysMap);
// Get the current logging context (owner)
String ndcValue = NDC.peek();

Expand All @@ -82,7 +82,7 @@ public List<String> handle(EventHandler.Action action, Object payload, EventExec
} else {
tasks = executor.getPendingSystemTasks(Wait.NAME);
}

logger.debug("ReferenceKeysMatchAction: List of tasks " + tasks);
boolean taskNamesDefined = CollectionUtils.isNotEmpty(params.taskRefNames);
tasks.parallelStream().forEach(task -> {
boolean ndcCleanup = false;
Expand All @@ -91,39 +91,41 @@ public List<String> handle(EventHandler.Action action, Object payload, EventExec
ndcCleanup = true;
NDC.push(ndcValue);
}
logger.debug("ReferenceKeysMatchAction: Check for referenceKeys");
if (!task.getInputData().containsKey("referenceKeys")) {
return;
}

logger.debug("ReferenceKeysMatchAction: Check for taskNamesDefined");
if (taskNamesDefined && !params.taskRefNames.contains(task.getReferenceTaskName())) {
return;
}

logger.debug("ReferenceKeysMatchAction: Check for Workflows");
Workflow workflow = executor.getWorkflow(task.getWorkflowInstanceId(), false);
if (workflow == null) {
logger.debug("No workflow found with id " + task.getWorkflowInstanceId() + ", skipping " + task);
logger.debug("ReferenceKeysMatchAction: No workflow found with id " + task.getWorkflowInstanceId() + ", skipping " + task);
return;
}

logger.debug("ReferenceKeysMatchAction: Check for isTeminal");
if (workflow.getStatus().isTerminal()) {
return;
}
logger.debug("ReferenceKeysMatchAction: Get taskReferenceKeys");
Object taskReferenceKeys = task.getInputData().get("referenceKeys");
if (taskReferenceKeys == null) {
return;
}
if (!(taskReferenceKeys instanceof List)) {
logger.warn("Task input referenceKeys is not a list for " + task);
logger.warn("ReferenceKeysMatchAction: Task input referenceKeys is not a list for " + task);
return;
}
List<ReferenceKey> taskRefKeys = mapper.convertValue(taskReferenceKeys, new TypeReference<List<ReferenceKey>>() {
});

logger.debug("ReferenceKeysMatchAction: Perform Array Match");
// Array match
if (!matches(taskRefKeys, eventRefKeys)) {
return;
}

logger.debug("ReferenceKeysMatchAction: Update Task Status " + taskStatus);
//Otherwise update the task as we found it
task.setStatus(taskStatus);
task.getOutputData().put("conductor.event.name", ee.getEvent());
Expand Down Expand Up @@ -330,6 +332,8 @@ private boolean matches(List<ReferenceKey> taskRefKeys, ReferenceKey erk) {
}

private static boolean equals(String s1, String s2){
boolean eval = "*".equals(s1) || Objects.equals(s1, s2);
logger.debug("Strings " + s1 + ", " + s2 + " = " + eval);
return "*".equals(s1) || Objects.equals(s1, s2);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ private void handle(ObservableQueue queue, Message msg) {
// see below when ack or unack decided
if (retryEnabled) {
boolean anyRunning = es.anyRunningWorkflowsByTags(tags);
logger.debug("Number of Running Workflows " + anyRunning);

if (!anyRunning) {
logger.debug("Handler did not find running workflows with tags. Handler={}, tags={}", handler.getName(), tags);
MetricService.getInstance()
Expand Down

0 comments on commit 261fc69

Please sign in to comment.