use of org.apache.airavata.model.ComponentStatus in project airavata by apache.
the class JsonWorkflowParser method readApplication.
private ApplicationNode readApplication(JsonReader jsonReader) throws IOException, ParserException {
jsonReader.beginObject();
NodeModel nodeModel = new NodeModel();
ComponentStatus status = new ComponentStatus();
status.setState(ComponentState.CREATED);
status.setReason("Created");
nodeModel.setStatus(status);
ApplicationNode applicationNode = new ApplicationNodeImpl(nodeModel);
String name;
while (jsonReader.hasNext()) {
name = jsonReader.nextName();
if (name.equals(APPLICATION_ID)) {
nodeModel.setApplicationId(jsonReader.nextString());
} else if (name.equals(NAME)) {
nodeModel.setName(jsonReader.nextString());
} else if (name.equals(DESCRIPTION)) {
nodeModel.setDescription(jsonReader.nextString());
} else if (name.equals(APPTYPE)) {
jsonReader.skipValue();
} else if (name.equals(INPUTS)) {
applicationNode.addInputPorts(readApplicationInputs(jsonReader));
} else if (name.equals(OUTPUTS)) {
applicationNode.addOutPorts(readApplicationOutputs(jsonReader));
} else if (name.equals(POSITION)) {
readPosition(jsonReader);
} else if (name.equals(NODE_ID)) {
nodeModel.setNodeId(jsonReader.nextString());
} else if (name.equals(PARALLEL_EXECUTION)) {
jsonReader.skipValue();
} else if (name.equals(PROPERTIES)) {
readProperties(jsonReader);
}
}
jsonReader.endObject();
return applicationNode;
}
use of org.apache.airavata.model.ComponentStatus in project airavata by apache.
the class JsonWorkflowParser method readWorkflowOutputs.
private void readWorkflowOutputs(JsonReader jsonReader) throws IOException, ParserException {
JsonToken peek = jsonReader.peek();
OutputNode outputNode;
NodeModel nodeModel;
ComponentStatus status;
String name;
if (peek == JsonToken.NULL) {
throw new ParserException("Error! workflow outputs can't be null");
} else if (peek == JsonToken.BEGIN_ARRAY) {
jsonReader.beginArray();
while (jsonReader.hasNext()) {
jsonReader.beginObject();
nodeModel = new NodeModel();
status = new ComponentStatus();
status.setState(ComponentState.CREATED);
status.setReason("Created");
nodeModel.setStatus(status);
outputNode = new OutputNodeImpl(nodeModel);
while (jsonReader.hasNext()) {
name = jsonReader.nextName();
if (name.equals(NAME)) {
nodeModel.setName(jsonReader.nextString());
} else if (name.equals(ID)) {
nodeModel.setNodeId(jsonReader.nextString());
} else if (name.equals(DATATYPE)) {
jsonReader.skipValue();
} else if (name.equals(DESCRIPTION)) {
nodeModel.setDescription(jsonReader.nextString());
} else if (name.equals(POSITION)) {
readPosition(jsonReader);
} else if (name.equals(NODE_ID)) {
jsonReader.skipValue();
// nodeModel.setNodeId(jsonReader.nextString());
} else if (name.equals(DEFAULT_VALUE)) {
jsonReader.skipValue();
} else {
jsonReader.skipValue();
}
}
jsonReader.endObject();
outputs.add(outputNode);
}
jsonReader.endArray();
} else {
throw new ParserException("Error! Unsupported value for Workflow Outputs, exptected " + getTokenString(JsonToken.BEGIN_OBJECT) + " but found" + getTokenString(peek));
}
}
use of org.apache.airavata.model.ComponentStatus 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);
}
}
}
}
use of org.apache.airavata.model.ComponentStatus in project airavata by apache.
the class JsonWorkflowParser method readWorkflowInputs.
private void readWorkflowInputs(JsonReader jsonReader) throws ParserException, IOException {
JsonToken peek = jsonReader.peek();
InputNode inputNode;
NodeModel nodeModel;
ComponentStatus status;
String name;
if (peek == JsonToken.NULL) {
throw new ParserException("Error! workflow inputs can't be null");
} else if (peek == JsonToken.BEGIN_ARRAY) {
jsonReader.beginArray();
while (jsonReader.hasNext()) {
jsonReader.beginObject();
nodeModel = new NodeModel();
status = new ComponentStatus();
status.setState(ComponentState.CREATED);
status.setReason("Created");
nodeModel.setStatus(status);
inputNode = new InputNodeImpl(nodeModel);
while (jsonReader.hasNext()) {
name = jsonReader.nextName();
if (name.equals(NAME)) {
nodeModel.setName(jsonReader.nextString());
} else if (name.equals(ID)) {
nodeModel.setNodeId(jsonReader.nextString());
} else if (name.equals(DATATYPE)) {
inputNode.setDataType(DataType.valueOf(jsonReader.nextString()));
} else if (name.equals(DESCRIPTION)) {
nodeModel.setDescription(jsonReader.nextString());
} else if (name.equals(POSITION)) {
readPosition(jsonReader);
} else if (name.equals(NODE_ID)) {
jsonReader.skipValue();
// nodeModel.setNodeId(jsonReader.nextString());
} else if (name.equals(DEFAULT_VALUE)) {
inputNode.setValue(jsonReader.nextString());
} else {
jsonReader.skipValue();
}
}
jsonReader.endObject();
inputs.add(inputNode);
}
jsonReader.endArray();
} else {
throw new ParserException("Error! Unsupported value for Workflow Inputs, exptected " + getTokenString(JsonToken.BEGIN_OBJECT) + " but found" + getTokenString(peek));
}
}
Aggregations