use of org.apache.airavata.workflow.model.graph.DataPort in project airavata by apache.
the class GraphCanvas method rerunSelectedNode.
private void rerunSelectedNode() {
if (this.selectedNode != null) {
ArrayList<Node> exploreNodes = new ArrayList<Node>();
exploreNodes.add(this.selectedNode);
while (exploreNodes.size() != 0) {
Node node = exploreNodes.get(0);
List<DataPort> outputPorts = node.getOutputPorts();
for (DataPort dataPort : outputPorts) {
exploreNodes.addAll(dataPort.getToNodes());
}
node.setState(NodeExecutionState.WAITING);
exploreNodes.remove(0);
}
this.repaint();
}
}
use of org.apache.airavata.workflow.model.graph.DataPort in project airavata by apache.
the class GraphCanvas method mouseClicked.
private void mouseClicked(MouseEvent event) {
/*
* If there is multi-selected and a click on a node, switch to that node or deselect node if it is already
* selected
*/
Point point = event.getPoint();
GraphPiece clicked = NodeController.getGUI(this.graph).getGraphPieceAt(point);
if ((clicked instanceof Node) && this.multipleSelectedNodes != null) {
Node node = (Node) clicked;
if (!this.crtlPressed) {
selectNode(node);
}
return;
} else if ((clicked instanceof Port) && event.getClickCount() == 2) {
// double click to add Input/Output nodes and connect with them when a DataPort is double clicked
Port port = (Port) clicked;
Point pos = port.getNode().getPosition();
Node node = null;
int xgap = (int) (1.5 * NodeGUI.MINIMUM_WIDTH);
int ygap = (int) (NodeGUI.MINIMUM_HEIGHT / 2);
Point nodePos = null;
switch(port.getKind()) {
case DATA_IN:
if (port.getFromNode() == null) {
nodePos = new Point(Math.max(0, pos.x - xgap), Math.max(0, pos.y - ygap));
node = addNode(new InputComponent(), nodePos);
connect(node.getOutputPorts().get(0), port);
}
break;
case DATA_OUT:
nodePos = new Point(pos.x + NodeGUI.MINIMUM_WIDTH + xgap, pos.y + ygap);
node = addNode(new OutputComponent(), nodePos);
connect(port, node.getInputPorts().get(0));
break;
default:
}
}
// delegate the event.
NodeController.getGUI(this.graph).mouseClicked(event, this.engine);
}
use of org.apache.airavata.workflow.model.graph.DataPort in project airavata by apache.
the class NodeGUI method resetTokens.
/**
*/
public void resetTokens() {
List<DataPort> inputPorts = getNode().getInputPorts();
for (DataPort dataPort : inputPorts) {
NodeController.getGUI(dataPort).reset();
}
List<DataPort> outputPorts = getNode().getOutputPorts();
for (DataPort dataPort : outputPorts) {
NodeController.getGUI(dataPort).reset();
}
}
use of org.apache.airavata.workflow.model.graph.DataPort 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.DataPort in project airavata by apache.
the class DoWhileNode method removeInputPort.
public void removeInputPort() throws GraphException {
List<DataPort> inputPorts = getInputPorts();
// Remove the last one.
DataPort inputPort = inputPorts.get(inputPorts.size() - 1);
removeInputPort(inputPort);
}
Aggregations