use of org.apache.airavata.workflow.core.dag.nodes.ApplicationNode 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.workflow.core.dag.nodes.ApplicationNode in project airavata by apache.
the class JsonWorkflowParser method readApplications.
private void readApplications(JsonReader jsonReader) throws IOException, ParserException {
jsonReader.beginArray();
ApplicationNode appNode = null;
while (jsonReader.hasNext()) {
appNode = readApplication(jsonReader);
applications.add(appNode);
}
jsonReader.endArray();
}
use of org.apache.airavata.workflow.core.dag.nodes.ApplicationNode in project airavata by apache.
the class JsonWorkflowParser method buildWorkflowGraph.
private void buildWorkflowGraph() throws Exception {
// TODO construct runtime model
Queue<WorkflowNode> queue = new LinkedList<>();
queue.addAll(inputs);
Map<String, List<Link>> linkMap = getEdgesMap(links);
Map<String, InPort> nodeInportMap = getNodeInPortsMap(getApplicationNodes());
nodeInportMap.putAll(getNodeInPortMap(getOutputNodes()));
Set<String> processedNodes = new HashSet<>();
while (!queue.isEmpty()) {
WorkflowNode node = queue.poll();
if (processedNodes.contains(node.getId())) {
continue;
}
if (node instanceof InputNode) {
InputNode input = ((InputNode) node);
OutPort outPort = ((OutPort) node);
Map<String, Edge> edgeMap = addEdges(outPort, linkMap.get(outPort.getNodeId() + "," + outPort.getId()));
for (Map.Entry<String, Edge> entry : edgeMap.entrySet()) {
InPort inPort = nodeInportMap.get(entry.getKey());
if (inPort != null) {
// inPort.addEdge(entry.getValue());
entry.getValue().setToPort(inPort);
queue.add(inPort.getNode());
}
}
} else if (node instanceof ApplicationNode) {
ApplicationNode appNode = ((ApplicationNode) node);
for (OutPort outPort : appNode.getOutputPorts()) {
outPort.setNode(appNode);
Map<String, Edge> edgeMap = addEdges(outPort, linkMap.get(outPort.getNodeId() + "," + outPort.getId()));
for (Map.Entry<String, Edge> entry : edgeMap.entrySet()) {
InPort inPort = nodeInportMap.get(entry.getKey());
if (inPort != null) {
// inPort.addEdge(entry.getValue());
entry.getValue().setToPort(inPort);
queue.add(inPort.getNode());
}
}
}
} else if (node instanceof OutputNode) {
OutputNode outputNode = ((OutputNode) node);
InPort inPort = ((InPort) node);
outputNode.setInputObject(inPort.getInputObject());
}
// marke node as precessed node, we don't need to process it again.
processedNodes.add(node.getId());
}
}
use of org.apache.airavata.workflow.core.dag.nodes.ApplicationNode in project airavata by apache.
the class JsonWorkflowParserTest method testApplications.
private void testApplications(JsonWorkflowParser jwp) throws Exception {
List<ApplicationNode> applicationNodes = jwp.getApplicationNodes();
Assert.assertNotNull(applicationNodes);
Assert.assertEquals(1, applicationNodes.size());
ApplicationNode node = applicationNodes.get(0);
Assert.assertEquals("App Name", node.getName());
Assert.assertEquals("appId_1", node.getApplicationId());
}
use of org.apache.airavata.workflow.core.dag.nodes.ApplicationNode in project airavata by apache.
the class WorkflowInterpreter method processReadyList.
// try to remove synchronization tag
/**
* Package-Private method.
*
* @throws RegistryException
* @throws AiravataException
*/
void processReadyList() throws RegistryException, AiravataException {
if (readyList.isEmpty() && processingQueue.isEmpty() && !waitingList.isEmpty()) {
throw new AiravataException("No workflow application node is in ready state to run");
}
for (WorkflowNode readyNode : readyList.values()) {
if (readyNode instanceof OutputNode) {
OutputNode outputNode = (OutputNode) readyNode;
outputNode.getOutputObject().setValue(outputNode.getInPort().getInputObject().getValue());
addToCompleteOutputNodeList(outputNode);
} else if (readyNode instanceof InputNode) {
// FIXME: set input object of applications and add applications to ready List.
} else if (readyNode instanceof ApplicationNode) {
// FIXME: call orchestrator to create process for the application
} else {
throw new RuntimeException("Unsupported workflow node type");
}
}
if (processingQueue.isEmpty() && waitingList.isEmpty()) {
try {
saveWorkflowOutputs();
} catch (AppCatalogException e) {
throw new AiravataException("Error while updating completed workflow outputs to registry", e);
}
}
}
Aggregations