use of org.apache.airavata.workflow.model.graph.impl.NodeImpl in project airavata by apache.
the class GraphUtil method partitionGraphOnLabel.
/**
* @param wsGraph
* @return
*/
public static HashMap<String, LinkedList<Node>> partitionGraphOnLabel(WSGraph wsGraph) {
HashMap<String, LinkedList<Node>> returnMap = new HashMap<String, LinkedList<Node>>();
List<NodeImpl> nodes = wsGraph.getNodes();
for (NodeImpl node : nodes) {
if (!isInputOutputNode(node)) {
LinkedList<Node> list = returnMap.get(node.getLabel());
if (null == list) {
list = new LinkedList<Node>();
returnMap.put(node.getLabel(), list);
}
list.add(node);
}
}
return returnMap;
}
use of org.apache.airavata.workflow.model.graph.impl.NodeImpl in project airavata by apache.
the class WSPort method copyType.
/**
* @see org.apache.airavata.workflow.model.graph.DataPort#copyType(org.apache.airavata.workflow.model.graph.DataPort)
*/
@Override
public void copyType(DataPort port) throws GraphException {
DataType newType = port.getType();
DataType type = getType();
NodeImpl node = port.getNode();
if (node instanceof ForEachNode || node instanceof EndForEachNode) {
// from WSDL.
return;
}
if (!(newType == null || newType.equals(WSConstants.XSD_ANY_TYPE) || type == null || type.equals(WSConstants.XSD_ANY_TYPE) || newType.equals(type))) {
String message = "The type (" + newType + ") must be same as the type " + " (" + type + ") of " + getID() + ".";
throw new GraphException(message);
}
}
use of org.apache.airavata.workflow.model.graph.impl.NodeImpl in project airavata by apache.
the class LaunchApplicationWindow method execute.
private void execute() throws AiravataClientConnectException, InvalidRequestException, AiravataClientException, AiravataSystemException, TException {
List<NodeImpl> nodes = workflow.getGraph().getNodes();
String gatewayId = engine.getConfiguration().getThriftClientData(ThriftServiceType.API_SERVICE).getGatewayId();
String appId = null;
NodeImpl node = null;
for (int i = 0; i < nodes.size(); i++) {
node = nodes.get(i);
String html = node.getComponent().toHTML();
String nodeType = html.substring(html.indexOf("<h1>") + 4, html.indexOf(":")).trim();
if (nodeType.equals("Application")) {
appId = html.substring(html.indexOf("</h2>") + 6, html.indexOf("<br")).trim();
break;
}
}
String hostId = null;
String hostName = (String) host.getSelectedItem();
hostId = hostNames.get(hostName);
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;
}
// previous instance name
if (!instanceNameTextField.getText().equals("")) {
this.instanceNameTextField.setText("");
}
Project project = new Project();
project.setName("project1");
String owner = this.thriftClientData.getUsername();
if (owner.equals(""))
owner = "NotKnown";
project.setOwner(owner);
project.setProjectID(airavataClient.createProject(gatewayId, project));
// final List<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph());
final List<DataPort> inputPorts = node.getInputPorts();
final Experiment experiment = new Experiment();
experiment.setApplicationId(appId);
ComputationalResourceScheduling scheduling = new ComputationalResourceScheduling();
scheduling.setResourceHostId(hostId);
if (hostName.trim().equals("trestles.sdsc.xsede.org")) {
scheduling.setComputationalProjectAccount("sds128");
} else if (hostName.trim().equals("stampede.tacc.xsede.org")) {
scheduling.setComputationalProjectAccount("TG-STA110014S");
}
scheduling.setNodeCount(1);
scheduling.setTotalCPUCount(1);
scheduling.setWallTimeLimit(15);
scheduling.setQueueName("normal");
UserConfigurationData userConfigurationData = new UserConfigurationData();
userConfigurationData.setAiravataAutoSchedule(false);
userConfigurationData.setOverrideManualScheduledParams(false);
userConfigurationData.setComputationalResourceScheduling(scheduling);
experiment.setUserConfigurationData(userConfigurationData);
experiment.setName(instanceName);
experiment.setProjectID(project.getProjectID());
experiment.setUserName(thriftClientData.getUsername());
for (int i = 0; i < inputPorts.size(); i++) {
DataPort inputPort = inputPorts.get(i);
XBayaTextField parameterTextField = this.parameterTextFields.get(i);
String value = parameterTextField.getText();
InputDataObjectType elem = new InputDataObjectType();
elem.setName(inputPort.getName());
elem.setType(elem.getType());
elem.setValue(value);
experiment.addToExperimentInputs(elem);
}
final List<DataPort> outputPorts = node.getOutputPorts();
for (int i = 0; i < outputPorts.size(); i++) {
DataPort outputPort = outputPorts.get(i);
OutputDataObjectType elem = new OutputDataObjectType();
elem.setName(outputPort.getName());
elem.setType(elem.getType());
elem.setValue("");
experiment.addToExperimentOutputs(elem);
}
experiment.setExperimentID(airavataClient.createExperiment(gatewayId, experiment));
airavataClient.launchExperiment(experiment.getExperimentID(), "testToken");
hide();
JOptionPane.showMessageDialog(null, "Experiment Launched. You will be alerted on completion.");
String status = airavataClient.getExperimentStatus(experiment.getExperimentID()).getExperimentState().toString().trim();
while (!status.equals("COMPLETED") && !status.equals("FAILED")) {
try {
Thread.sleep(1000);
status = airavataClient.getExperimentStatus(experiment.getExperimentID()).getExperimentState().toString().trim();
} catch (InterruptedException e) {
logger.error(e.getMessage(), e);
}
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
logger.error(e.getMessage(), e);
}
if (status.equals("COMPLETED")) {
String output = "";
;
String fullOutput = "";
while (output.equals("")) {
output = "";
fullOutput = "Experiment Completed Successfully. Output(s) are shown below:\n";
List<OutputDataObjectType> outputs = airavataClient.getExperimentOutputs(experiment.getExperimentID());
for (int i1 = 0; i1 < outputs.size(); i1++) {
output = outputs.get(i1).getValue();
fullOutput += outputs.get(i1).getName() + ": " + output + "\n";
}
}
JOptionPane.showMessageDialog(null, fullOutput);
} else {
JOptionPane.showMessageDialog(null, "Experiment Failed");
return;
}
new Thread() {
@Override
public void run() {
}
}.start();
hide();
}
use of org.apache.airavata.workflow.model.graph.impl.NodeImpl in project airavata by apache.
the class MonitorEventHandler method getOutputNodes.
private LinkedList<OutputNode> getOutputNodes(WSGraph graph) {
List<NodeImpl> nodes = graph.getNodes();
LinkedList<OutputNode> outputNodes = new LinkedList<OutputNode>();
for (NodeImpl nodeImpl : nodes) {
if (nodeImpl instanceof OutputNode) {
outputNodes.add((OutputNode) nodeImpl);
}
}
return outputNodes;
}
use of org.apache.airavata.workflow.model.graph.impl.NodeImpl in project airavata by apache.
the class MonitorEventHandler method getInputNodes.
/**
* @param graph
* @return
*/
private LinkedList<InputNode> getInputNodes(WSGraph graph) {
List<NodeImpl> nodes = graph.getNodes();
LinkedList<InputNode> inputNodes = new LinkedList<InputNode>();
for (NodeImpl nodeImpl : nodes) {
if (nodeImpl instanceof InputNode) {
inputNodes.add((InputNode) nodeImpl);
}
}
return inputNodes;
}
Aggregations