Search in sources :

Example 6 with WorkflowConditionNode

use of io.cdap.cdap.api.workflow.WorkflowConditionNode in project cdap by cdapio.

the class ApplicationVerificationStage method verifyWorkflowCondition.

private void verifyWorkflowCondition(ApplicationSpecification appSpec, WorkflowSpecification workflowSpec, WorkflowNode node, Set<String> existingNodeNames) {
    WorkflowConditionNode condition = (WorkflowConditionNode) node;
    verifyWorkflowNodeList(appSpec, workflowSpec, condition.getIfBranch(), existingNodeNames);
    verifyWorkflowNodeList(appSpec, workflowSpec, condition.getElseBranch(), existingNodeNames);
}
Also used : WorkflowConditionNode(io.cdap.cdap.api.workflow.WorkflowConditionNode)

Example 7 with WorkflowConditionNode

use of io.cdap.cdap.api.workflow.WorkflowConditionNode in project cdap by cdapio.

the class DefaultWorkflowConditionConfigurer method addWorkflowConditionNode.

@Override
public void addWorkflowConditionNode(Condition condition, List<WorkflowNode> ifBranch, List<WorkflowNode> elseBranch) {
    Preconditions.checkArgument(condition != null, "Condition is null.");
    ConditionSpecification spec = DefaultConditionConfigurer.configureCondition(condition, deployNamespace, artifactId, pluginFinder, pluginInstantiator, runtimeInfo, featureFlagsProvider);
    currentBranch.add(new WorkflowConditionNode(spec.getName(), spec, ifBranch, elseBranch));
}
Also used : DefaultConditionSpecification(io.cdap.cdap.internal.workflow.condition.DefaultConditionSpecification) ConditionSpecification(io.cdap.cdap.api.workflow.ConditionSpecification) WorkflowConditionNode(io.cdap.cdap.api.workflow.WorkflowConditionNode)

Example 8 with WorkflowConditionNode

use of io.cdap.cdap.api.workflow.WorkflowConditionNode in project cdap by cdapio.

the class DefaultWorkflowConditionConfigurer method addWorkflowConditionNode.

@Override
public void addWorkflowConditionNode(Predicate<WorkflowContext> predicate, List<WorkflowNode> ifBranch, List<WorkflowNode> elseBranch) {
    ConditionSpecification spec = new DefaultConditionSpecification(predicate.getClass().getName(), predicate.getClass().getSimpleName(), "", new HashMap<String, String>(), new HashSet<String>());
    currentBranch.add(new WorkflowConditionNode(spec.getName(), spec, ifBranch, elseBranch));
}
Also used : DefaultConditionSpecification(io.cdap.cdap.internal.workflow.condition.DefaultConditionSpecification) DefaultConditionSpecification(io.cdap.cdap.internal.workflow.condition.DefaultConditionSpecification) ConditionSpecification(io.cdap.cdap.api.workflow.ConditionSpecification) WorkflowConditionNode(io.cdap.cdap.api.workflow.WorkflowConditionNode)

Example 9 with WorkflowConditionNode

use of io.cdap.cdap.api.workflow.WorkflowConditionNode in project cdap by cdapio.

the class DistributedWorkflowProgramRunner method findDriverResources.

/**
 * Returns the {@link Resources} requirement for the workflow runnable deduced by Spark
 * or MapReduce driver resources requirement.
 */
private Resources findDriverResources(Collection<WorkflowNode> nodes, Map<String, Resources> runnablesResources) {
    // Find the resource requirements for the workflow based on the nodes memory requirements
    Resources resources = new Resources();
    for (WorkflowNode node : nodes) {
        switch(node.getType()) {
            case ACTION:
                String programName = ((WorkflowActionNode) node).getProgram().getProgramName();
                Resources runnableResources = runnablesResources.get(programName);
                if (runnableResources != null) {
                    resources = maxResources(resources, runnableResources);
                }
                break;
            case FORK:
                Resources forkResources = ((WorkflowForkNode) node).getBranches().stream().map(branches -> findDriverResources(branches, runnablesResources)).reduce(this::mergeForkResources).orElse(resources);
                resources = maxResources(resources, forkResources);
                break;
            case CONDITION:
                Resources branchesResources = maxResources(findDriverResources(((WorkflowConditionNode) node).getIfBranch(), runnablesResources), findDriverResources(((WorkflowConditionNode) node).getElseBranch(), runnablesResources));
                resources = maxResources(resources, branchesResources);
                break;
            default:
                // This shouldn't happen unless we add new node type
                LOG.warn("Ignoring unsupported Workflow node type {}", node.getType());
        }
    }
    return resources;
}
Also used : Resources(io.cdap.cdap.api.Resources) WorkflowForkNode(io.cdap.cdap.api.workflow.WorkflowForkNode) WorkflowNode(io.cdap.cdap.api.workflow.WorkflowNode) WorkflowConditionNode(io.cdap.cdap.api.workflow.WorkflowConditionNode)

Example 10 with WorkflowConditionNode

use of io.cdap.cdap.api.workflow.WorkflowConditionNode in project cdap by caskdata.

the class DefaultWorkflowConditionConfigurer method addWorkflowConditionNode.

@Override
public void addWorkflowConditionNode(Predicate<WorkflowContext> predicate, List<WorkflowNode> ifBranch, List<WorkflowNode> elseBranch) {
    ConditionSpecification spec = new DefaultConditionSpecification(predicate.getClass().getName(), predicate.getClass().getSimpleName(), "", new HashMap<String, String>(), new HashSet<String>());
    currentBranch.add(new WorkflowConditionNode(spec.getName(), spec, ifBranch, elseBranch));
}
Also used : DefaultConditionSpecification(io.cdap.cdap.internal.workflow.condition.DefaultConditionSpecification) DefaultConditionSpecification(io.cdap.cdap.internal.workflow.condition.DefaultConditionSpecification) ConditionSpecification(io.cdap.cdap.api.workflow.ConditionSpecification) WorkflowConditionNode(io.cdap.cdap.api.workflow.WorkflowConditionNode)

Aggregations

WorkflowConditionNode (io.cdap.cdap.api.workflow.WorkflowConditionNode)20 ConditionSpecification (io.cdap.cdap.api.workflow.ConditionSpecification)14 DefaultConditionSpecification (io.cdap.cdap.internal.workflow.condition.DefaultConditionSpecification)14 WorkflowNode (io.cdap.cdap.api.workflow.WorkflowNode)6 WorkflowForkNode (io.cdap.cdap.api.workflow.WorkflowForkNode)4 Resources (io.cdap.cdap.api.Resources)2 ScheduleProgramInfo (io.cdap.cdap.api.workflow.ScheduleProgramInfo)2 WorkflowActionNode (io.cdap.cdap.api.workflow.WorkflowActionNode)2 WorkflowSpecification (io.cdap.cdap.api.workflow.WorkflowSpecification)2