use of org.apache.airavata.workflow.model.wf.Workflow in project airavata by apache.
the class XBayaToolBar method init.
private void init() {
this.toolbar = new JToolBar();
this.toolbar.setFloatable(false);
Border border = BorderFactory.createEtchedBorder();
this.toolbar.setBorder(border);
JButton addNodeButton = new JButton("Add Node");
addNodeButton.addActionListener(new AbstractAction() {
private static final long serialVersionUID = 1L;
public void actionPerformed(ActionEvent event) {
try {
XBayaToolBar.this.engine.getGUI().addNode();
} catch (RuntimeException e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
} catch (Error e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
}
}
});
JButton removeNodeButton = new JButton("Remove Node");
removeNodeButton.addActionListener(new AbstractAction() {
private static final long serialVersionUID = 1L;
public void actionPerformed(ActionEvent event) {
try {
XBayaToolBar.this.engine.getGUI().getGraphCanvas().removeSelectedNode();
} catch (GraphException e) {
// Should not happen
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
} catch (RuntimeException e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
} catch (Error e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
}
}
});
JButton connectEdgeButton = new JButton("Connect/Disconnect");
connectEdgeButton.addActionListener(new AbstractAction() {
private static final long serialVersionUID = 1L;
public void actionPerformed(ActionEvent event) {
try {
XBayaToolBar.this.engine.getGUI().getGraphCanvas().addOrRemoveEdge();
} catch (RuntimeException e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
} catch (Error e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
}
}
});
this.play = new JButton();
PAUSE_ICON = SwingUtil.createImageIcon(IMAGES_PAUSE_JPEG);
PLAY_ICON = SwingUtil.createImageIcon(IMAGES_PLAY_JPEG);
this.playAction = new AbstractAction(null, PAUSE_ICON) {
/**
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent e1) {
try {
Workflow workflow = engine.getGUI().getWorkflow();
WorkflowExecutionState executionState = workflow.getExecutionState();
if (executionState == WorkflowExecutionState.RUNNING || executionState == WorkflowExecutionState.STEP) {
workflow.setExecutionState(WorkflowExecutionState.PAUSED);
play.setIcon(PLAY_ICON);
} else if (executionState == WorkflowExecutionState.PAUSED) {
workflow.setExecutionState(WorkflowExecutionState.RUNNING);
play.setIcon(PAUSE_ICON);
} else {
throw new IllegalStateException("Unknown state :" + executionState);
}
} catch (RuntimeException e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
} catch (Error e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
}
}
};
this.play.setAction(this.playAction);
this.step = new JButton();
this.stepAction = new AbstractAction(null, SwingUtil.createImageIcon(IMAGES_STEP_JPEG)) {
/**
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent e2) {
try {
if (engine.getGUI().getWorkflow().getExecutionState() == WorkflowExecutionState.PAUSED) {
engine.getGUI().getWorkflow().setExecutionState(WorkflowExecutionState.STEP);
} else {
throw new IllegalStateException("Unknown state :" + engine.getGUI().getWorkflow().getExecutionState());
}
} catch (RuntimeException e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
} catch (Error e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
}
}
};
this.step.setAction(stepAction);
this.stop = new JButton();
this.stopAction = new AbstractAction(null, SwingUtil.createImageIcon(IMAGES_STOP_JPEG)) {
/**
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent e1) {
try {
if (engine.getGUI().getWorkflow().getExecutionState() != WorkflowExecutionState.NONE || engine.getGUI().getWorkflow().getExecutionState() != WorkflowExecutionState.STOPPED) {
engine.getGUI().getWorkflow().setExecutionState(WorkflowExecutionState.STOPPED);
} else {
throw new IllegalStateException("Unknown state :" + engine.getGUI().getWorkflow().getExecutionState());
}
} catch (RuntimeException e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
} catch (Error e) {
XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
}
}
};
this.stop.setAction(stopAction);
// this.toolbar.add(addNodeButton);
// this.toolbar.add(removeNodeButton);
// this.toolbar.addSeparator();
// this.toolbar.add(connectEdgeButton);
}
use of org.apache.airavata.workflow.model.wf.Workflow 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.wf.Workflow in project airavata by apache.
the class GraphCanvas method newWorkflow.
/**
* Creates a new graph.
*/
public synchronized void newWorkflow() {
Workflow newWorkflow = new Workflow();
setWorkflow(newWorkflow);
}
use of org.apache.airavata.workflow.model.wf.Workflow in project airavata by apache.
the class MonitorEventHandler method handleEvent.
private void handleEvent(EventData event, boolean forward) {
// EventType type = event.getType();
// todo currrently we do not set the workflowID properly its just node ID
// URI workflowID = event.getWorkflowID();
List<GraphCanvas> graphCanvases = this.xbayaGUI.getGraphCanvases();
for (GraphCanvas graphCanvas : graphCanvases) {
Workflow workflow = graphCanvas.getWorkflow();
// URI instanceID = workflow.getGPELInstanceID();
// if (instanceID == null) {
// If the workflow doesn't have an instance ID, it's a template.
// We handle it so that users can use a workflow template to
// monitor a workflow too.
// This is also needed in the case of jython workflow.
handleEvent(event, forward, workflow.getGraph());
graphCanvas.repaint();
// } else if (instanceID.equals(workflowID)) {
// This is the regular case.
// found = true;
// handleEvent(event, forward, workflow.getGraph());
// } else if (null != workflowID
// && -1 != WSDLUtil.findWorkflowName(workflowID).indexOf(WSDLUtil.findWorkflowName(instanceID))) {
// handleEvent(event, WSDLUtil.findWorkflowName(workflowID), workflow.getGraph());
// }
}
// // Load a sub-workflow.
// if (type == MonitorUtil.EventType.WORKFLOW_INITIALIZED) {
// if (forward) {
// // Check if the workflow instance is already open.
// for (GraphCanvas graphCanvas : graphCanvases) {
// Workflow workflow = graphCanvas.getWorkflow();
// URI instanceID = workflow.getGPELInstanceID();
// if (workflowID.equals(instanceID)) {
// // The workflow instance is already loaded.
// return;
// }
// }
// loadWorkflow(workflowID);
// } else {
// // Don't need to close the workflow when it's opened.
// }
// }
//
// if (found == false && workflowID != null) {
// // Loads the workflow instance ID in case a user started to monitor
// // in the middle.
// loadWorkflow(workflowID);
// }
//
// /*
// * Handle resource mapping message which contains resource from Amazon EC2 Since workflowID (workflowName) from
// * message and instanceID do not equal, so we have to handle it explicitly
// */
// if (type == EventType.RESOURCE_MAPPING && event.getMessage().contains("i-")) {
// String nodeID = event.getNodeID();
// for (GraphCanvas graphCanvas : graphCanvases) {
// Node node = graphCanvas.getWorkflow().getGraph().getNode(nodeID);
// if (node != null) {
// ControlPort control = node.getControlInPort();
// if (control != null) {
// Node fromNode = control.getFromNode();
// if (fromNode instanceof InstanceNode) {
// InstanceNode ec2Node = (InstanceNode) fromNode;
//
// /*
// * parse message and set output to InstanceNode
// */
// int start = event.getMessage().indexOf("i-");
// String instanceId = event.getMessage().substring(start, start + 10);
// ec2Node.setOutputInstanceId(instanceId);
//
// // make this node to not start a new instance
// ec2Node.setStartNewInstance(false);
// ec2Node.setInstanceId(instanceId);
// ec2Node.setAmiId(null);
// }
// }
// }
// }
// }
// TODO There is a possibility that XBaya misses to handle some
// notification while a workflow is being loaded. Create a thread for
// each workflow ID to handle notifications.
}
use of org.apache.airavata.workflow.model.wf.Workflow in project airavata by apache.
the class WorkflowNodeGUI method openWorkflowTab.
public void openWorkflowTab(XBayaEngine engine) {
try {
Workflow workflow = this.node.getComponent().getWorkflow();
engine.getGUI().selectOrCreateGraphCanvas(workflow);
} catch (GraphException e) {
engine.getGUI().getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
} catch (ComponentException e) {
engine.getGUI().getErrorWindow().error(ErrorMessages.COMPONENT_FORMAT_ERROR, e);
}
}
Aggregations