Search in sources :

Example 1 with ComponentState

use of org.apache.airavata.model.ComponentState 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)

Aggregations

ComponentState (org.apache.airavata.model.ComponentState)1 ComponentStatus (org.apache.airavata.model.ComponentStatus)1 ProcessIdentifier (org.apache.airavata.model.messaging.event.ProcessIdentifier)1 ProcessState (org.apache.airavata.model.status.ProcessState)1 RegistryException (org.apache.airavata.registry.cpi.RegistryException)1 ApplicationNode (org.apache.airavata.workflow.core.dag.nodes.ApplicationNode)1