Search in sources :

Example 6 with ApplicationNode

use of org.apache.airavata.workflow.core.dag.nodes.ApplicationNode in project airavata by apache.

the class WorkflowInterpreter method handleProcessStatusChangeEvent.

/*    synchronized void handleTaskOutputChangeEvent(ProcessStatusChangeEvent taskOutputChangeEvent) {

        String taskId = taskOutputChangeEvent.getTaskIdentity().getTaskId();
        log.debug("Task Output changed event received for workflow node : " +
                taskOutputChangeEvent.getTaskIdentity().getWorkflowNodeId() + ", task : " + taskId);
        WorkflowNode workflowNode = processingQueue.get(taskId);
        Set<WorkflowNode> tempWfNodeSet = new HashSet<>();
        if (workflowNode != null) {
            if (workflowNode instanceof ApplicationNode) {
                ApplicationNode applicationNode = (ApplicationNode) workflowNode;
                // Workflow node can have one to many output ports and each output port can have one to many links
                for (OutPort outPort : applicationNode.getOutputPorts()) {
                    for (OutputDataObjectType outputDataObjectType : taskOutputChangeEvent.getOutput()) {
                        if (outPort.getOutputObject().getName().equals(outputDataObjectType.getName())) {
                            outPort.getOutputObject().setValue(outputDataObjectType.getValue());
                            break;
                        }
                    }
                    for (Edge edge : outPort.getEdges()) {
                        edge.getToPort().getInputObject().setValue(outPort.getOutputObject().getValue());
                        if (edge.getToPort().getNode().isReady()) {
                            addToReadyQueue(edge.getToPort().getNode());
                        }
                    }
                }
                addToCompleteQueue(applicationNode);
                log.debug("removed task from processing queue : " + taskId);
            }
            try {
                processReadyList();
            } catch (Exception e) {
                log.error("Error while processing ready workflow nodes", e);
                continueWorkflow = false;
            }
        }
    }*/
void handleProcessStatusChangeEvent(ProcessStatusChangeEvent processStatusChangeEvent) {
    ProcessState processState = processStatusChangeEvent.getState();
    ProcessIdentifier processIdentity = processStatusChangeEvent.getProcessIdentity();
    String processId = processIdentity.getProcessId();
    ApplicationNode applicationNode = (ApplicationNode) processingQueue.get(processId);
    if (applicationNode != null) {
        ComponentState state = applicationNode.getState();
        switch(processState) {
            case CREATED:
            case VALIDATED:
            case STARTED:
                break;
            case CONFIGURING_WORKSPACE:
            case PRE_PROCESSING:
            case INPUT_DATA_STAGING:
            case EXECUTING:
            case OUTPUT_DATA_STAGING:
            case POST_PROCESSING:
                state = ComponentState.RUNNING;
                break;
            case COMPLETED:
                state = ComponentState.COMPLETED;
                // FIXME: read output form registry and set it to node outputport then continue to next application.
                break;
            case FAILED:
                state = ComponentState.FAILED;
                // FIXME: fail workflow.
                break;
            case CANCELED:
            case CANCELLING:
                state = ComponentState.CANCELED;
                // FIXME: cancel workflow.
                break;
            default:
                break;
        }
        if (state != applicationNode.getState()) {
            try {
                updateWorkflowNodeStatus(applicationNode, new ComponentStatus(state));
            } catch (RegistryException e) {
                log.error("Error! Couldn't update new application state to registry. nodeInstanceId : {} " + applicationNode.getId() + " status to: " + applicationNode.getState().toString(), e);
            }
        }
    }
}
Also used : ProcessState(org.apache.airavata.model.status.ProcessState) ComponentStatus(org.apache.airavata.model.ComponentStatus) ApplicationNode(org.apache.airavata.workflow.core.dag.nodes.ApplicationNode) RegistryException(org.apache.airavata.registry.cpi.RegistryException) ProcessIdentifier(org.apache.airavata.model.messaging.event.ProcessIdentifier) ComponentState(org.apache.airavata.model.ComponentState)

Example 7 with ApplicationNode

use of org.apache.airavata.workflow.core.dag.nodes.ApplicationNode in project airavata by apache.

the class JsonWorkflowParser method getNodeInPortsMap.

private Map<String, InPort> getNodeInPortsMap(List<ApplicationNode> applicationNodes) {
    Map<String, InPort> nodeInPortsMap = new HashMap<>();
    if (applicationNodes != null) {
        for (ApplicationNode applicationNode : applicationNodes) {
            for (InPort inPort : applicationNode.getInputPorts()) {
                inPort.setNode(applicationNode);
                nodeInPortsMap.put(applicationNode.getId() + "," + inPort.getId(), inPort);
            }
        }
    }
    return nodeInPortsMap;
}
Also used : InPort(org.apache.airavata.workflow.core.dag.port.InPort) HashMap(java.util.HashMap) ApplicationNode(org.apache.airavata.workflow.core.dag.nodes.ApplicationNode)

Aggregations

ApplicationNode (org.apache.airavata.workflow.core.dag.nodes.ApplicationNode)7 HashMap (java.util.HashMap)2 ComponentStatus (org.apache.airavata.model.ComponentStatus)2 InputNode (org.apache.airavata.workflow.core.dag.nodes.InputNode)2 OutputNode (org.apache.airavata.workflow.core.dag.nodes.OutputNode)2 WorkflowNode (org.apache.airavata.workflow.core.dag.nodes.WorkflowNode)2 InPort (org.apache.airavata.workflow.core.dag.port.InPort)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 AiravataException (org.apache.airavata.common.exception.AiravataException)1 ComponentState (org.apache.airavata.model.ComponentState)1 NodeModel (org.apache.airavata.model.NodeModel)1 ProcessIdentifier (org.apache.airavata.model.messaging.event.ProcessIdentifier)1 ProcessState (org.apache.airavata.model.status.ProcessState)1 AppCatalogException (org.apache.airavata.registry.cpi.AppCatalogException)1 RegistryException (org.apache.airavata.registry.cpi.RegistryException)1 DirectedEdge (org.apache.airavata.workflow.core.dag.edge.DirectedEdge)1