Skip to content

Commit

Permalink
address minor comments
Browse files Browse the repository at this point in the history
Signed-off-by: Jackie Han <[email protected]>
  • Loading branch information
jackiehanyang committed Dec 27, 2023
1 parent 3ab2438 commit 5f0b865
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static WorkflowStepValidator parse(XContentParser parser) throws IOExcept
try {
timeout = TimeValue.parseTimeValue(parser.text(), TIMEOUT);
} catch (IllegalArgumentException e) {
logger.error("Failed to parse TIMEOUT value for field [" + fieldName + "]", e);
logger.error("Failed to parse TIMEOUT value for field [{}]", fieldName, e);
throw new FlowFrameworkException(
"Failed to parse workflow-step.json file for field [" + fieldName + "]",
RestStatus.INTERNAL_SERVER_ERROR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public List<ProcessNode> sortProcessNodes(Workflow workflow, String workflowId)
* @throws Exception if validation fails
*/
public void validate(List<ProcessNode> processNodes) throws Exception {
WorkflowValidator validator = readWorkflowValidator(processNodes.get(0).id());
WorkflowValidator validator = readWorkflowValidator();
validatePluginsInstalled(processNodes, validator);
validateGraph(processNodes, validator);
}
Expand Down Expand Up @@ -246,13 +246,13 @@ public void validateGraph(List<ProcessNode> processNodes, WorkflowValidator vali
}
}

private WorkflowValidator readWorkflowValidator(String workflowId) {
private WorkflowValidator readWorkflowValidator() {
try {
return WorkflowValidator.parse("mappings/workflow-steps.json");
} catch (Exception e) {
logger.error("Failed to read workflow-steps mapping file", e);
logger.error("Failed at reading workflow-steps mapping file", e);
throw new FlowFrameworkException(
"Workflow " + workflowId + " failed at reading workflow-steps mapping file",
"Failed at reading workflow-steps.json mapping file for a new workflow.",
RestStatus.INTERNAL_SERVER_ERROR
);
}
Expand All @@ -262,11 +262,11 @@ private WorkflowValidator readWorkflowValidator(String workflowId) {
* A method for parsing workflow timeout value.
* The value could be parsed from node NODE_TIMEOUT_FIELD, the timeout field in workflow-step.json,
* or the default NODE_TIMEOUT_DEFAULT_VALUE
* @param node the workflow nde
* @param node the workflow node
* @return the timeout value
*/
protected TimeValue parseTimeout(WorkflowNode node) {
WorkflowValidator validator = readWorkflowValidator(node.id());
WorkflowValidator validator = readWorkflowValidator();
TimeValue nodeTimeoutValue = Optional.ofNullable(validator.getWorkflowStepValidators().get(node.type()).getTimeout())
.orElse(NODE_TIMEOUT_DEFAULT_VALUE);
String nodeTimeoutAsString = nodeTimeoutValue.getSeconds() + "s";
Expand Down

0 comments on commit 5f0b865

Please sign in to comment.