Search in sources :

Example 1 with ProcessIdentifier

use of org.apache.airavata.model.messaging.event.ProcessIdentifier in project airavata by apache.

the class MessagingFactory method statusRoutingkey.

private static String statusRoutingkey(MessageContext msgCtx) {
    String gatewayId = msgCtx.getGatewayId();
    String routingKey = null;
    if (msgCtx.getType() == MessageType.EXPERIMENT) {
        ExperimentStatusChangeEvent event = (ExperimentStatusChangeEvent) msgCtx.getEvent();
        routingKey = gatewayId + "." + event.getExperimentId();
    } else if (msgCtx.getType() == MessageType.TASK) {
        TaskStatusChangeEvent event = (TaskStatusChangeEvent) msgCtx.getEvent();
        routingKey = gatewayId + "." + event.getTaskIdentity().getExperimentId() + "." + event.getTaskIdentity().getProcessId() + "." + event.getTaskIdentity().getTaskId();
    } else if (msgCtx.getType() == MessageType.PROCESSOUTPUT) {
        TaskOutputChangeEvent event = (TaskOutputChangeEvent) msgCtx.getEvent();
        routingKey = gatewayId + "." + event.getTaskIdentity().getExperimentId() + "." + event.getTaskIdentity().getProcessId() + "." + event.getTaskIdentity().getTaskId();
    } else if (msgCtx.getType() == MessageType.PROCESS) {
        ProcessStatusChangeEvent event = (ProcessStatusChangeEvent) msgCtx.getEvent();
        ProcessIdentifier processIdentifier = event.getProcessIdentity();
        routingKey = gatewayId + "." + processIdentifier.getExperimentId() + "." + processIdentifier.getProcessId();
    } else if (msgCtx.getType() == MessageType.JOB) {
        JobStatusChangeEvent event = (JobStatusChangeEvent) msgCtx.getEvent();
        JobIdentifier identity = event.getJobIdentity();
        routingKey = gatewayId + "." + identity.getExperimentId() + "." + identity.getProcessId() + "." + identity.getTaskId() + "." + identity.getJobId();
    }
    return routingKey;
}
Also used : TaskStatusChangeEvent(org.apache.airavata.model.messaging.event.TaskStatusChangeEvent) TaskOutputChangeEvent(org.apache.airavata.model.messaging.event.TaskOutputChangeEvent) ExperimentStatusChangeEvent(org.apache.airavata.model.messaging.event.ExperimentStatusChangeEvent) JobStatusChangeEvent(org.apache.airavata.model.messaging.event.JobStatusChangeEvent) ProcessStatusChangeEvent(org.apache.airavata.model.messaging.event.ProcessStatusChangeEvent) JobIdentifier(org.apache.airavata.model.messaging.event.JobIdentifier) ProcessIdentifier(org.apache.airavata.model.messaging.event.ProcessIdentifier)

Example 2 with ProcessIdentifier

use of org.apache.airavata.model.messaging.event.ProcessIdentifier in project airavata by apache.

the class GfacServerHandler method publishProcessStatus.

private void publishProcessStatus(ProcessSubmitEvent event, ProcessStatus status) throws AiravataException {
    ProcessIdentifier identifier = new ProcessIdentifier(event.getProcessId(), event.getExperimentId(), event.getGatewayId());
    ProcessStatusChangeEvent processStatusChangeEvent = new ProcessStatusChangeEvent(status.getState(), identifier);
    MessageContext msgCtx = new MessageContext(processStatusChangeEvent, MessageType.PROCESS, AiravataUtils.getId(MessageType.PROCESS.name()), event.getGatewayId());
    msgCtx.setUpdatedTime(AiravataUtils.getCurrentTimestamp());
    statusPublisher.publish(msgCtx);
}
Also used : ProcessStatusChangeEvent(org.apache.airavata.model.messaging.event.ProcessStatusChangeEvent) MessageContext(org.apache.airavata.messaging.core.MessageContext) ProcessIdentifier(org.apache.airavata.model.messaging.event.ProcessIdentifier)

Example 3 with ProcessIdentifier

use of org.apache.airavata.model.messaging.event.ProcessIdentifier 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

ProcessIdentifier (org.apache.airavata.model.messaging.event.ProcessIdentifier)3 ProcessStatusChangeEvent (org.apache.airavata.model.messaging.event.ProcessStatusChangeEvent)2 MessageContext (org.apache.airavata.messaging.core.MessageContext)1 ComponentState (org.apache.airavata.model.ComponentState)1 ComponentStatus (org.apache.airavata.model.ComponentStatus)1 ExperimentStatusChangeEvent (org.apache.airavata.model.messaging.event.ExperimentStatusChangeEvent)1 JobIdentifier (org.apache.airavata.model.messaging.event.JobIdentifier)1 JobStatusChangeEvent (org.apache.airavata.model.messaging.event.JobStatusChangeEvent)1 TaskOutputChangeEvent (org.apache.airavata.model.messaging.event.TaskOutputChangeEvent)1 TaskStatusChangeEvent (org.apache.airavata.model.messaging.event.TaskStatusChangeEvent)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