use of org.apache.airavata.xbaya.messaging.MonitorException in project airavata by apache.
the class XBayaGUI method createFrame.
/**
* Creates a frame.
*/
private void createFrame() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
// OK. The default will be used.
logger.error(e.getMessage(), e);
}
JFrame.setDefaultLookAndFeelDecorated(false);
this.frame = new JFrame();
// Adjust the size
XBayaConfiguration config = this.engine.getConfiguration();
int width = config.getWidth();
int height = config.getHeight();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
final int inset = 50;
this.frame.setLocation(inset, inset);
Dimension size = new Dimension(screenSize.width - inset * 2, screenSize.height - inset * 2);
if (width != 0) {
size.width = width;
}
if (height != 0) {
size.height = height;
}
// This controls the size when you open in a huge screen
if (size.width > 1280 && size.height > 800) {
size.width = 1280;
size.height = 800;
}
this.frame.setPreferredSize(size);
this.frame.setTitle(XBayaConstants.APPLICATION_NAME);
this.frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
this.frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent event) {
int result = JOptionPane.showConfirmDialog(frame, "Are you sure you want to exit?", "Exit XBaya", JOptionPane.YES_NO_OPTION);
if (result == JOptionPane.NO_OPTION || (!closeAllGraphCanvas())) {
return;
}
logger.debug(event.toString());
XBayaGUI.this.frame.setVisible(false);
try {
XBayaGUI.this.engine.dispose();
} catch (WorkflowException e) {
// Ignore the error.
logger.error(e.getMessage(), e);
} catch (RuntimeException e) {
// Ignore the error.
logger.error(e.getMessage(), e);
}
if (XBayaGUI.this.engine.getConfiguration().isCloseOnExit()) {
System.exit(0);
}
}
@Override
public void windowClosed(WindowEvent e) {
logger.debug(e.toString());
try {
XBayaGUI.this.engine.getMonitor().stop();
} catch (MonitorException e1) {
logger.error(e1.getMessage(), e1);
}
// Dispose only when it can be disposed to prevent infinite loop
if (XBayaGUI.this.frame.isDisplayable()) {
XBayaGUI.this.frame.dispose();
}
}
});
this.frame.setIconImage(SwingUtil.createImage("airavata-2.png"));
}
use of org.apache.airavata.xbaya.messaging.MonitorException 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.xbaya.messaging.MonitorException in project airavata by apache.
the class WorkflowModifier method getOutput.
private String getOutput(String nodeID, String messageName, String parameterName) throws MonitorException {
List<EventData> events = this.eventData.getEvents();
for (EventData event : events) {
// String value = parameter.requiredText();
return event.getMessage();
}
// TODO
String message = "Couldn't find a notification of the output from the service with nodeID, " + nodeID;
throw new MonitorException(message);
}
use of org.apache.airavata.xbaya.messaging.MonitorException in project airavata by apache.
the class WorkflowModifier method getWorkflowInput.
private String getWorkflowInput(String nodeID) throws MonitorException {
logger.debug("Node:" + nodeID);
List<EventData> events = this.eventData.getEvents();
for (EventData event : events) {
// String value = parameter.requiredText();
return event.getMessage();
}
// TODO
String message = "Couldn't find a notification of about the input with nodeID, " + nodeID;
throw new MonitorException(message);
}
Aggregations