use of org.apache.airavata.workflow.model.graph.DataPort in project airavata by apache.
the class WorkflowInterpreter method setupNodeDetailsInput.
private void setupNodeDetailsInput(Node node, WorkflowNodeDetails nodeDetails) {
List<DataPort> inputPorts = node.getInputPorts();
for (DataPort dataPort : inputPorts) {
Node fromNode = dataPort.getFromNode();
String portInputValue = null;
if (fromNode instanceof InputNode) {
portInputValue = (String) ((InputNode) fromNode).getDefaultValue();
} else if (fromNode instanceof WSNode) {
Map<String, String> outputData = nodeOutputData.get(fromNode);
portInputValue = outputData.get(dataPort.getName());
if (portInputValue == null) {
portInputValue = outputData.get(dataPort.getEdge(0).getFromPort().getName());
}
}
// 123456789
InputDataObjectType elem = new InputDataObjectType();
elem.setName(dataPort.getName());
elem.setValue(portInputValue);
if (dataPort instanceof WSPort) {
WSPort port = (WSPort) dataPort;
elem.setInputOrder(port.getComponentPort().getInputOrder());
elem.setApplicationArgument((port.getComponentPort().getApplicationArgument() != null ? port.getComponentPort().getApplicationArgument() : ""));
elem.setType(port.getType());
}
nodeDetails.addToNodeInputs(elem);
}
try {
getExperimentCatalog().update(ExperimentCatalogModelType.WORKFLOW_NODE_DETAIL, nodeDetails, nodeDetails.getNodeInstanceId());
} catch (RegistryException e) {
log.error(e.getMessage(), e);
}
}
use of org.apache.airavata.workflow.model.graph.DataPort in project airavata by apache.
the class WorkflowInterpreter method runInThread.
private void runInThread(final LinkedList<String> listOfValues, ForEachNode forEachNode, final Node middleNode, List<Node> endForEachNodes, Map<Node, Invoker> tempInvoker, AtomicInteger counter, final Integer[] inputNumber) throws WorkflowException, RegistryException, TException {
final LinkedList<String> taskIdList = new LinkedList<String>();
if (inputNumber.length > 1) {
List<String> inputValues = createInputValues(listOfValues, inputNumber);
for (final Iterator<String> iterator = inputValues.iterator(); iterator.hasNext(); ) {
final String input = iterator.next();
WSComponent wsComponent = (WSComponent) middleNode.getComponent();
final String invoker2 = createInvokerForEachSingleWSNode(middleNode, wsComponent);
taskIdList.add(invoker2);
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
log.error(e.getLocalizedMessage(), e);
}
}
} else {
String invoker = null;
for (Iterator<String> iterator = listOfValues.iterator(); iterator.hasNext(); ) {
String input = iterator.next();
WSComponent wsComponent = (WSComponent) middleNode.getComponent();
taskIdList.add(invoker);
// find inputs
List<DataPort> inputPorts = middleNode.getInputPorts();
// for (DataPort port : inputPorts) {
// Object inputVal = InterpreterUtil.findInputFromPort(port, this.invokerMap);
// /*
// * Handle ForEachNode
// */
// Node fromNode = port.getFromNode();
// // if (fromNode instanceof ForEachNode) {
// inputVal = WorkflowInputUtil.parseValue((WSComponentPort) port.getComponentPort(), input);
// // }
//
// if (null == inputVal) {
// throw new WorkFlowInterpreterException("Unable to find inputs for the node:" + middleNode.getID());
// }
// }
invoker = createInvokerForEachSingleWSNode(middleNode, wsComponent);
}
}
// String arrayElementName = foreachWSNode.getOperationName() +
// "ArrayResponse";
// String outputStr = "<" + arrayElementName + ">";
// invokerMap size and endForEachNodes size can be difference
// because we can create endForEachNode with n number of input/output
// ports so always have to use
// middleNode.getOutputPorts when iterate
String[] outputStr = new String[middleNode.getOutputPorts().size()];
int i = 0;
for (DataPort port : middleNode.getOutputPorts()) {
String outputString = "";
// for (Iterator<Invoker> iterator = taskIdList.iterator(); iterator.hasNext();) {
// Invoker workflowInvoker = iterator.next();
//
// // /
// Object output = workflowInvoker.getOutput(port.getName());
// if (output instanceof org.xmlpull.v1.builder.XmlElement) {
// org.xmlpull.v1.builder.XmlElement element = (org.xmlpull.v1.builder.XmlElement) ((org.xmlpull.v1.builder.XmlElement) output).children()
// .next();
// outputString += "\n" + XMLUtil.xmlElementToString(element);
// } else {
// outputString += "\n<value>" + output + "</value>";
// }
// counter.incrementAndGet();
// }
outputStr[i] = outputString;
System.out.println(outputStr[i]);
i++;
}
i = 0;
// outputStr += "\n</" + arrayElementName + ">";
int outputPortIndex = 0;
for (DataPort port : middleNode.getOutputPorts()) {
for (Node endForEachNode : endForEachNodes) {
if (tempInvoker.get(endForEachNode) != null) {
if (!(endForEachNode instanceof OutputNode)) {
((SystemComponentInvoker) tempInvoker.get(endForEachNode)).addOutput(port.getName(), outputStr[i]);
}
}
outputPortIndex++;
}
i++;
}
forEachNode.setState(NodeExecutionState.FINISHED);
}
use of org.apache.airavata.workflow.model.graph.DataPort in project airavata by apache.
the class WorkflowInterpreter method handleSubWorkComponent.
private void handleSubWorkComponent(Node node) throws WorkflowException {
// TODO we will not support this in 0.13
notifyViaInteractor(WorkflowExecutionMessage.OPEN_SUBWORKFLOW, node);
// setting the inputs
Workflow subWorkflow = ((SubWorkflowNode) node).getWorkflow();
ArrayList<Node> subWorkflowInputNodes = getInputNodes(subWorkflow);
List<DataPort> inputPorts = node.getInputPorts();
for (DataPort port : inputPorts) {
Object inputVal = InterpreterUtil.findInputFromPort(port, this.invokerMap);
if (null == inputVal) {
throw new WorkFlowInterpreterException("Unable to find inputs for the subworkflow node node:" + node.getID());
}
for (Iterator<Node> iterator = subWorkflowInputNodes.iterator(); iterator.hasNext(); ) {
InputNode inputNode = (InputNode) iterator.next();
if (inputNode.getName().equals(port.getName())) {
inputNode.setDefaultValue(inputVal);
}
}
}
for (Iterator<Node> iterator = subWorkflowInputNodes.iterator(); iterator.hasNext(); ) {
InputNode inputNode = (InputNode) iterator.next();
if (inputNode.getDefaultValue() == null) {
throw new WorkFlowInterpreterException("Input not set for :" + inputNode.getID());
}
}
try {
WorkflowInterpreter subworkflowInterpreter = (WorkflowInterpreter) getInputViaInteractor(WorkflowExecutionMessage.INPUT_WORKFLOWINTERPRETER_FOR_WORKFLOW, subWorkflow);
subworkflowInterpreter.scheduleDynamically();
} catch (Exception e) {
throw new WorkflowException(e);
}
}
use of org.apache.airavata.workflow.model.graph.DataPort in project airavata by apache.
the class WorkflowInterpreter method taskOutputChanged.
@Subscribe
public void taskOutputChanged(TaskOutputChangeEvent taskOutputEvent) {
String taskId = taskOutputEvent.getTaskIdentity().getTaskId();
if (isTaskAwaiting(taskId)) {
ProcessState state = ProcessState.COMPLETED;
Node node = getAwaitingNodeForTask(taskId);
List<OutputDataObjectType> applicationOutputs = taskOutputEvent.getOutput();
Map<String, String> outputData = new HashMap<String, String>();
for (OutputDataObjectType outputObj : applicationOutputs) {
List<DataPort> outputPorts = node.getOutputPorts();
for (DataPort dataPort : outputPorts) {
if (dataPort.getName().equals(outputObj.getName())) {
outputData.put(outputObj.getName(), outputObj.getValue());
}
}
}
nodeOutputData.put(node, outputData);
setupNodeDetailsOutput(node);
node.setState(NodeExecutionState.FINISHED);
try {
publishNodeStatusChange(WorkflowNodeState.COMPLETED, node.getID(), experiment.getExperimentID());
updateWorkflowNodeStatus(nodeInstanceList.get(node), state);
} catch (RegistryException e) {
log.error(e.getMessage(), e);
} catch (AiravataException e) {
log.error(e.getMessage(), e);
}
}
}
use of org.apache.airavata.workflow.model.graph.DataPort in project airavata by apache.
the class WorkflowInterpreter method setupNodeDetailsOutput.
private void setupNodeDetailsOutput(Node node) {
WorkflowNodeDetails nodeDetails = nodeInstanceList.get(node);
List<DataPort> outputPorts = node.getOutputPorts();
Map<String, String> outputData = nodeOutputData.get(node);
for (DataPort dataPort : outputPorts) {
String portInputValue = outputData.get(dataPort.getName());
OutputDataObjectType elem = new OutputDataObjectType();
elem.setName(dataPort.getName());
elem.setValue(portInputValue);
nodeDetails.addToNodeOutputs(elem);
}
try {
getExperimentCatalog().update(ExperimentCatalogModelType.WORKFLOW_NODE_DETAIL, nodeDetails, nodeDetails.getNodeInstanceId());
} catch (RegistryException e) {
log.error(e.getMessage(), e);
}
}
Aggregations