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;
}
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);
}
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);
}
}
}
}
Aggregations