use of co.cask.cdap.api.workflow.WorkflowNodeType in project cdap by caskdata.
the class WorkflowNodeCodec method deserialize.
@Override
public WorkflowNode deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject jsonObj = json.getAsJsonObject();
WorkflowNodeType type = context.deserialize(jsonObj.get("nodeType"), WorkflowNodeType.class);
switch(type) {
case ACTION:
return context.deserialize(json, WorkflowActionNode.class);
case FORK:
return context.deserialize(json, WorkflowForkNode.class);
case CONDITION:
return context.deserialize(json, WorkflowConditionNode.class);
}
return null;
}
use of co.cask.cdap.api.workflow.WorkflowNodeType in project cdap by caskdata.
the class ProgramSystemMetadataWriter method getWorkflowNodes.
private Iterable<String> getWorkflowNodes() {
if (ProgramType.WORKFLOW != programId.getType()) {
return ImmutableSet.of();
}
Preconditions.checkArgument(programSpec instanceof WorkflowSpecification, "Expected programSpec %s to be of type WorkflowSpecification", programSpec);
WorkflowSpecification workflowSpec = (WorkflowSpecification) this.programSpec;
Set<String> workflowNodeNames = new HashSet<>();
for (Map.Entry<String, WorkflowNode> entry : workflowSpec.getNodeIdMap().entrySet()) {
WorkflowNode workflowNode = entry.getValue();
WorkflowNodeType type = workflowNode.getType();
// Fork nodes have integers as node ids. Ignore them in system metadata.
if (WorkflowNodeType.FORK == type) {
continue;
}
workflowNodeNames.add(entry.getKey());
}
return workflowNodeNames;
}
use of co.cask.cdap.api.workflow.WorkflowNodeType in project cdap by caskdata.
the class WorkflowDriver method executeNode.
private void executeNode(ApplicationSpecification appSpec, WorkflowNode node, InstantiatorFactory instantiator, ClassLoader classLoader, WorkflowToken token) throws Exception {
WorkflowNodeType nodeType = node.getType();
((BasicWorkflowToken) token).setCurrentNode(node.getNodeId());
switch(nodeType) {
case ACTION:
WorkflowActionNode actionNode = (WorkflowActionNode) node;
if (SchedulableProgramType.CUSTOM_ACTION == actionNode.getProgram().getProgramType()) {
executeCustomAction(actionNode, instantiator, classLoader, token);
} else {
executeAction(actionNode, token);
}
break;
case FORK:
executeFork(appSpec, (WorkflowForkNode) node, instantiator, classLoader, token);
break;
case CONDITION:
executeCondition(appSpec, (WorkflowConditionNode) node, instantiator, classLoader, token);
break;
default:
break;
}
}
use of co.cask.cdap.api.workflow.WorkflowNodeType in project cdap by caskdata.
the class ApplicationVerificationStage method verifyWorkflowNode.
private void verifyWorkflowNode(ApplicationSpecification appSpec, WorkflowSpecification workflowSpec, WorkflowNode node, Set<String> existingNodeNames) {
WorkflowNodeType nodeType = node.getType();
// TODO CDAP-5640 Add check so that node id in the Workflow should not be same as name of the Workflow.
if (node.getNodeId().equals(workflowSpec.getName())) {
String msg = String.format("Node used in Workflow has same name as that of Workflow '%s'." + " This will conflict while getting the Workflow token details associated with" + " the node. Please use name for the node other than the name of the Workflow.", workflowSpec.getName());
LOG.warn(msg);
}
switch(nodeType) {
case ACTION:
verifyWorkflowAction(appSpec, node);
break;
case FORK:
verifyWorkflowFork(appSpec, workflowSpec, node, existingNodeNames);
break;
case CONDITION:
verifyWorkflowCondition(appSpec, workflowSpec, node, existingNodeNames);
break;
default:
break;
}
}
Aggregations