use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.
the class WorkflowInterpreterLaunchWindow method execute.
private void execute() throws AiravataClientConnectException, TException {
String instanceName = this.instanceNameTextField.getText();
if (instanceName.trim().equals("")) {
JOptionPane.showMessageDialog(engine.getGUI().getFrame(), "Experiment name cannot be empty", "Experiment Name", JOptionPane.ERROR_MESSAGE);
return;
}
ThriftClientData thriftClientData = engine.getConfiguration().getThriftClientData(ThriftServiceType.API_SERVICE);
Client airavataClient = XBayaUtil.getAiravataClient(thriftClientData);
String gatewayId = engine.getConfiguration().getThriftClientData(ThriftServiceType.API_SERVICE).getGatewayId();
final List<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph());
List<InputDataObjectType> inputDataTypes = new ArrayList<InputDataObjectType>();
List<OutputDataObjectType> outputDataTypes = new ArrayList<OutputDataObjectType>();
InputDataObjectType input = null;
for (int i = 0; i < inputNodes.size(); i++) {
InputNode inputNode = inputNodes.get(i);
XBayaTextField parameterTextField = this.parameterTextFields.get(i);
inputNode.getID();
String value = parameterTextField.getText();
input = new InputDataObjectType();
// inputNode.setDefaultValue(value);
input.setName(inputNode.getID());
input.setType(inputNode.getDataType());
input.setValue(value);
input.setApplicationArgument(inputNode.getApplicationArgument());
input.setInputOrder(inputNode.getInputOrder());
inputDataTypes.add(input);
}
final List<OutputNode> outputNodes = GraphUtil.getOutputNodes(this.workflow.getGraph());
OutputDataObjectType output = null;
for (OutputNode outputNode : outputNodes) {
output = new OutputDataObjectType();
output.setName(outputNode.getID());
output.setType(DataType.STRING);
outputDataTypes.add(output);
}
Workflow workflowClone = workflow.clone();
workflowClone.setName(workflowClone.getName() + UUID.randomUUID().toString());
org.apache.airavata.model.Workflow workflowModel = new org.apache.airavata.model.Workflow();
workflowModel.setName(workflowClone.getName());
workflowModel.setGraph(JSONUtil.jsonElementToString(workflowClone.toJSON()));
for (InputDataObjectType inputDataType : inputDataTypes) {
workflowModel.addToWorkflowInputs(inputDataType);
}
for (OutputDataObjectType outputDataType : outputDataTypes) {
workflowModel.addToWorkflowOutputs(outputDataType);
}
workflowModel.setTemplateId(airavataClient.registerWorkflow(gatewayId, workflowModel));
// Use topic as a base of workflow instance ID so that the monitor can
// find it.
Project project = new Project();
project.setName("project1");
project.setOwner(thriftClientData.getUsername());
project.setProjectID(airavataClient.createProject(gatewayId, project));
final Experiment experiment = new Experiment();
experiment.setApplicationId(workflowModel.getTemplateId());
experiment.setName(instanceName);
experiment.setProjectID(project.getProjectID());
experiment.setUserName(thriftClientData.getUsername());
for (InputDataObjectType inputDataType : inputDataTypes) {
experiment.addToExperimentInputs(inputDataType);
}
for (OutputDataObjectType outputDataType : outputDataTypes) {
experiment.addToExperimentOutputs(outputDataType);
}
// Add scheduling configurations
if (host != null && host.getSelectedIndex() >= 0) {
String selectedHostName = host.getSelectedItem().toString();
String computeResouceId = hostNames.get(selectedHostName);
ComputationalResourceScheduling computationalResourceScheduling;
if (selectedHostName.equals("localhost")) {
computationalResourceScheduling = ExperimentModelUtil.createComputationResourceScheduling(computeResouceId, 1, 1, 1, "normal", 1, 0, 1, "test");
} else if (selectedHostName.equals("trestles.sdsc.xsede.org")) {
computationalResourceScheduling = ExperimentModelUtil.createComputationResourceScheduling(computeResouceId, 1, 1, 1, "normal", 1, 0, 1, "sds128");
} else if (selectedHostName.equals("stampede.tacc.xsede.org")) {
computationalResourceScheduling = ExperimentModelUtil.createComputationResourceScheduling(computeResouceId, 2, 32, 1, "development", 90, 0, 1, "TG-STA110014S");
} else if (selectedHostName.equals("bigred2.uits.iu.edu")) {
computationalResourceScheduling = ExperimentModelUtil.createComputationResourceScheduling(computeResouceId, 1, 1, 1, "normal", 1, 0, 1, null);
} else {
// TODO handle for other computer resources too.
throw new IllegalArgumentException("Computational resource scheduling is not configured for host :" + computeResouceId);
}
UserConfigurationData userConfigurationData = new UserConfigurationData();
userConfigurationData.setAiravataAutoSchedule(false);
userConfigurationData.setOverrideManualScheduledParams(false);
userConfigurationData.setComputationalResourceScheduling(computationalResourceScheduling);
experiment.setUserConfigurationData(userConfigurationData);
} else {
throw new RuntimeException("Resource scheduling failed, target computer resource host name is not defined");
}
/*
// code snippet for load test.
for (int i = 0; i < 20; i++) {
experiment.setName(instanceName + "_" + i);
experiment.setExperimentID(airavataClient.createExperiment(experiment));
try {
this.engine.getMonitor().subscribe(experiment.getExperimentID());
this.engine.getMonitor().fireStartMonitoring(workflow.getName());
} catch (MonitorException e) {
logger.error("Error while subscribing with experiment Id : " + experiment.getExperimentID(), e);
}
airavataClient.launchExperiment(experiment.getExperimentID(), "testToken");
}*/
experiment.setExperimentID(airavataClient.createExperiment(gatewayId, experiment));
try {
this.engine.getMonitor().subscribe(experiment.getExperimentID());
this.engine.getMonitor().fireStartMonitoring(workflow.getName());
} catch (MonitorException e) {
logger.error("Error while subscribing with experiment Id : " + experiment.getExperimentID(), e);
}
airavataClient.launchExperiment(experiment.getExperimentID(), token.getText());
clean();
hide();
}
use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.
the class WSGraphFactory method createNode.
/**
* @see org.apache.airavata.workflow.model.graph.GraphFactory#createNode(org.xmlpull.infoset.XmlElement)
*/
public NodeImpl createNode(XmlElement nodeElement) throws GraphException {
String type = nodeElement.attributeValue(GraphSchema.NS, GraphSchema.NODE_TYPE_ATTRIBUTE);
if (type == null) {
// Old graphs don't have the namespace for the attribute.
type = nodeElement.attributeValue(GraphSchema.NODE_TYPE_ATTRIBUTE);
}
NodeImpl node;
if (GraphSchema.NODE_TYPE_WS.equals(type)) {
node = new WSNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_STREAM_SOURCE.equals(type)) {
node = new StreamSourceNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_WORKFLOW.equals(type)) {
node = new WorkflowNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_INPUT.equals(type)) {
node = new InputNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_OUTPUT.equals(type)) {
node = new OutputNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_CONSTANT.equals(type)) {
node = new ConstantNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_SPLIT.equals(type)) {
node = new ForEachNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_MERGE.equals(type)) {
node = new EndForEachNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_IF.equals(type)) {
node = new IfNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_ENDIF.equals(type)) {
node = new EndifNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_DOWHILE.equals(type)) {
node = new DoWhileNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_ENDDOWHILE.equals(type)) {
node = new EndDoWhileNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_MEMO.equals(type)) {
node = new MemoNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_RECEIVE.equals(type)) {
node = new ReceiveNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_BLOCK.equals(type)) {
node = new BlockNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_ENDBLOCK.equals(type)) {
node = new EndBlockNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_INSTANCE.equals(type)) {
node = new InstanceNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_TERMINATE.equals(type)) {
node = new TerminateInstanceNode(nodeElement);
} else {
// Default is WsNode for backward compatibility.
node = new WSNode(nodeElement);
}
return node;
}
use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.
the class WSGraphFactory method createNode.
public NodeImpl createNode(JsonObject nodeObject) throws GraphException {
String type = nodeObject.getAsJsonPrimitive(GraphSchema.NODE_TYPE_ATTRIBUTE).getAsString();
NodeImpl node;
if (GraphSchema.NODE_TYPE_WS.equals(type)) {
node = new WSNode(nodeObject);
} else if (GraphSchema.NODE_TYPE_WORKFLOW.equals(type)) {
node = new WorkflowNode(nodeObject);
} else if (GraphSchema.NODE_TYPE_INPUT.equals(type)) {
node = new InputNode(nodeObject);
} else if (GraphSchema.NODE_TYPE_OUTPUT.equals(type)) {
node = new OutputNode(nodeObject);
/* } else if (GraphSchema.NODE_TYPE_STREAM_SOURCE.equals(type)) {
node = new StreamSourceNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_CONSTANT.equals(type)) {
node = new ConstantNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_SPLIT.equals(type)) {
node = new ForEachNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_MERGE.equals(type)) {
node = new EndForEachNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_IF.equals(type)) {
node = new IfNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_ENDIF.equals(type)) {
node = new EndifNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_DOWHILE.equals(type)) {
node = new DoWhileNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_ENDDOWHILE.equals(type)) {
node = new EndDoWhileNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_MEMO.equals(type)) {
node = new MemoNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_RECEIVE.equals(type)) {
node = new ReceiveNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_BLOCK.equals(type)) {
node = new BlockNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_ENDBLOCK.equals(type)) {
node = new EndBlockNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_INSTANCE.equals(type)) {
node = new InstanceNode(nodeElement);
} else if (GraphSchema.NODE_TYPE_TERMINATE.equals(type)) {
node = new TerminateInstanceNode(nodeElement);*/
} else {
// Default is WsNode for backward compatibility.
node = new WSNode(nodeObject);
}
return node;
}
use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.
the class InterpreterUtil method getInputsForForEachNode.
/**
* This method returns the input values for given foreach node
*
* @param forEachNode
* @param listOfValues
* @param invokerMap
* @return
* @throws WorkflowException
*/
public static Object getInputsForForEachNode(final ForEachNode forEachNode, final LinkedList<String> listOfValues, Map<Node, Invoker> invokerMap) throws WorkflowException {
List<DataPort> inputPorts = forEachNode.getInputPorts();
Object returnValForProvenance = null;
for (DataPort inputPort : inputPorts) {
Node inputNode = inputPort.getFromNode();
// if input node for for-each is WSNode
if (inputNode instanceof InputNode) {
// for (DataPort dataPort : forEachNode.getInputPorts()) {
returnValForProvenance = InterpreterUtil.findInputFromPort(inputPort, invokerMap);
if (null == returnValForProvenance) {
throw new WorkFlowInterpreterException("Unable to find input for the node:" + forEachNode.getID());
}
String[] vals = StringUtil.getElementsFromString(returnValForProvenance.toString());
listOfValues.addAll(Arrays.asList(vals));
// }
}
}
return returnValForProvenance;
}
use of org.apache.airavata.workflow.model.graph.system.InputNode in project airavata by apache.
the class InputComponent method createNode.
/**
* @see org.apache.airavata.workflow.model.component.Component#createNode(org.apache.airavata.workflow.model.graph.Graph)
*/
@Override
public InputNode createNode(Graph graph) {
InputNode node = new InputNode(graph);
node.setName(NAME);
node.setComponent(this);
// Creates a unique ID for the node. This has to be after setName().
node.createID();
// Creates a output port
createPorts(node);
return node;
}
Aggregations