You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sh...@apache.org on 2014/09/09 22:39:07 UTC
[1/4] git commit: Updated Xbaya to enable execution of a single
application through thrift api
Repository: airavata
Updated Branches:
refs/heads/master ea5da3399 -> 6b9d3c59b
Updated Xbaya to enable execution of a single application through thrift api
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/6b519e2a
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/6b519e2a
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/6b519e2a
Branch: refs/heads/master
Commit: 6b519e2a5f485af5499212bc2eee324be8ca93a1
Parents: bb8e448
Author: Nadeem Anjum <na...@gmail.com>
Authored: Sun Aug 17 06:38:17 2014 +0530
Committer: Nadeem Anjum <na...@gmail.com>
Committed: Sun Aug 17 06:38:17 2014 +0530
----------------------------------------------------------------------
.../ui/experiment/LaunchApplicationWindow.java | 400 +++++++++++++++++++
.../airavata/xbaya/ui/menues/RunMenuItem.java | 9 +-
2 files changed, 406 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/6b519e2a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/LaunchApplicationWindow.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/LaunchApplicationWindow.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/LaunchApplicationWindow.java
new file mode 100644
index 0000000..18daea0
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/LaunchApplicationWindow.java
@@ -0,0 +1,400 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.ui.experiment;
+
+import java.awt.event.ActionEvent;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.swing.AbstractAction;
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.border.EtchedBorder;
+import javax.xml.namespace.QName;
+
+import org.apache.airavata.api.Airavata.Client;
+import org.apache.airavata.common.utils.XMLUtil;
+import org.apache.airavata.model.error.AiravataClientConnectException;
+import org.apache.airavata.model.error.AiravataClientException;
+import org.apache.airavata.model.error.AiravataSystemException;
+import org.apache.airavata.model.error.InvalidRequestException;
+import org.apache.airavata.model.workspace.Project;
+import org.apache.airavata.model.workspace.experiment.ComputationalResourceScheduling;
+import org.apache.airavata.model.workspace.experiment.DataObjectType;
+import org.apache.airavata.model.workspace.experiment.DataType;
+import org.apache.airavata.model.workspace.experiment.Experiment;
+import org.apache.airavata.model.workspace.experiment.UserConfigurationData;
+import org.apache.airavata.workflow.model.graph.impl.NodeImpl;
+import org.apache.airavata.workflow.model.graph.system.InputNode;
+import org.apache.airavata.workflow.model.graph.system.OutputNode;
+import org.apache.airavata.workflow.model.graph.util.GraphUtil;
+import org.apache.airavata.workflow.model.wf.Workflow;
+import org.apache.airavata.ws.monitor.MonitorConfiguration;
+import org.apache.airavata.xbaya.ThriftClientData;
+import org.apache.airavata.xbaya.ThriftServiceType;
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.ui.dialogs.XBayaDialog;
+import org.apache.airavata.xbaya.ui.utils.ErrorMessages;
+import org.apache.airavata.xbaya.ui.widgets.GridPanel;
+import org.apache.airavata.xbaya.ui.widgets.XBayaLabel;
+import org.apache.airavata.xbaya.ui.widgets.XBayaTextField;
+import org.apache.airavata.xbaya.util.XBayaUtil;
+import org.apache.thrift.TException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xmlpull.infoset.XmlElement;
+
+public class LaunchApplicationWindow {
+
+ private static final Logger logger = LoggerFactory.getLogger(LaunchApplicationWindow.class);
+
+ private XBayaEngine engine;
+
+ private Workflow workflow;
+
+ private XBayaDialog dialog;
+
+ private GridPanel parameterPanel;
+
+ private ThriftClientData thriftClientData;
+
+ private Client airavataClient;
+
+ private List<XBayaTextField> parameterTextFields = new ArrayList<XBayaTextField>();
+
+
+ private XBayaTextField instanceNameTextField;
+
+ private JComboBox host;
+
+ private Map<String,String> hostNames;
+
+
+ /**
+ * Constructs a LaunchApplicationWindow.
+ *
+ * @param engine
+ *
+ */
+ public LaunchApplicationWindow(XBayaEngine engine) {
+ this.engine = engine;
+ thriftClientData = engine.getConfiguration().getThriftClientData(ThriftServiceType.API_SERVICE);
+ try {
+ airavataClient = XBayaUtil.getAiravataClient(thriftClientData);
+ } catch (AiravataClientConnectException e) {
+ e.printStackTrace();
+ }
+ initGUI();
+ }
+
+ /**
+ * Shows the dialog.
+ */
+ public void show() {
+ this.workflow = this.engine.getGUI().getWorkflow();
+
+ MonitorConfiguration notifConfig = this.engine.getMonitor().getConfiguration();
+ if (notifConfig.getBrokerURL() == null) {
+ this.engine.getGUI().getErrorWindow().error(ErrorMessages.BROKER_URL_NOT_SET_ERROR);
+ return;
+ }
+
+ // Create input fields
+ Collection<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph());
+ for (InputNode node : inputNodes) {
+ String id = node.getID();
+ QName parameterType = node.getParameterType();
+ JLabel nameLabel = new JLabel(id);
+ JLabel typeField = new JLabel(parameterType.getLocalPart());
+ XBayaTextField paramField = new XBayaTextField();
+ Object value = node.getDefaultValue();
+
+ String valueString;
+ if (value == null) {
+ valueString = "";
+ } else {
+ if (value instanceof XmlElement) {
+ XmlElement valueElement = (XmlElement) value;
+ valueString = XMLUtil.xmlElementToString(valueElement);
+ } else {
+ // Only string comes here for now.
+ valueString = value.toString();
+ }
+ }
+ paramField.setText(valueString);
+ this.parameterPanel.add(nameLabel);
+ this.parameterPanel.add(typeField);
+ this.parameterPanel.add(paramField);
+ this.parameterTextFields.add(paramField);
+ }
+
+ Map<String, String> hosts = null;
+
+ try {
+ hosts = airavataClient.getAllComputeResourceNames();
+ } catch (InvalidRequestException e2) {
+ // TODO Auto-generated catch block
+ e2.printStackTrace();
+ } catch (AiravataClientException e2) {
+ // TODO Auto-generated catch block
+ e2.printStackTrace();
+ } catch (AiravataSystemException e2) {
+ // TODO Auto-generated catch block
+ e2.printStackTrace();
+ } catch (TException e2) {
+ // TODO Auto-generated catch block
+ e2.printStackTrace();
+ }
+
+
+ hostNames= new HashMap<String,String>();
+
+ Iterator it=hosts.entrySet().iterator();
+ while(it.hasNext()){
+ Map.Entry pairs=(Map.Entry)it.next();
+ String key = (String) pairs.getKey();
+ String value = (String) pairs.getValue();
+ if(!hostNames.containsKey(value)){
+ hostNames.put(value, key);
+ }
+ }
+ host = new JComboBox();
+ it=hostNames.entrySet().iterator();
+ while(it.hasNext()){
+ Map.Entry pairs=(Map.Entry)it.next();
+ String key = (String) pairs.getKey();
+ host.addItem(key);
+ }
+ host.setSelectedIndex(1);
+
+ XBayaLabel hostLabel = new XBayaLabel("Host", this.host);
+ this.parameterPanel.add(hostLabel);
+ this.parameterPanel.add(host);
+ // this.parameterPanel.layout(inputNodes.size()+1, 2, GridPanel.WEIGHT_NONE, 2);
+ this.dialog.show();
+ }
+
+ /**
+ * Hides the dialog.
+ */
+ public void hide() {
+ this.dialog.hide();
+
+ this.parameterPanel.getContentPanel().removeAll();
+ this.parameterTextFields.clear();
+ }
+
+ private void initGUI() {
+ this.parameterPanel = new GridPanel(true);
+
+ this.instanceNameTextField = new XBayaTextField();
+ XBayaLabel instanceNameLabel = new XBayaLabel("Experiment name", this.instanceNameTextField);
+ GridPanel infoPanel = new GridPanel();
+ infoPanel.add(instanceNameLabel);
+ infoPanel.add(this.instanceNameTextField);
+ infoPanel.layout(1, 2, GridPanel.WEIGHT_NONE, 1);
+
+ GridPanel mainPanel = new GridPanel();
+ mainPanel.getContentPanel().setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
+ mainPanel.add(infoPanel);
+ mainPanel.add(this.parameterPanel);
+ mainPanel.layout(2, 1, 0, 0);
+
+ JButton okButton = new JButton("Run");
+ okButton.addActionListener(new AbstractAction() {
+ public void actionPerformed(ActionEvent e) {
+ try {
+ execute();
+ } catch (AiravataClientConnectException e1) {
+ e1.printStackTrace();
+ } catch (InvalidRequestException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (AiravataClientException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (AiravataSystemException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (TException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ }
+ });
+
+ JButton cancelButton = new JButton("Cancel");
+ cancelButton.addActionListener(new AbstractAction() {
+ public void actionPerformed(ActionEvent e) {
+ hide();
+ }
+ });
+
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.add(okButton);
+ buttonPanel.add(cancelButton);
+ buttonPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
+ this.dialog = new XBayaDialog(this.engine.getGUI(), "Launch workflow", mainPanel, buttonPanel);
+ this.dialog.setDefaultButton(okButton);
+ }
+
+ private void execute() throws AiravataClientConnectException, InvalidRequestException, AiravataClientException, AiravataSystemException, TException {
+ List<NodeImpl> nodes = workflow.getGraph().getNodes();
+ String appId = null;
+ for(int i=0; i<nodes.size(); i++){
+ NodeImpl 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(project));
+ final List<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph());
+ 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 < inputNodes.size(); i++) {
+ InputNode inputNode = inputNodes.get(i);
+ XBayaTextField parameterTextField = this.parameterTextFields.get(i);
+ inputNode.getID();
+ String value = parameterTextField.getText();
+ DataObjectType elem = new DataObjectType();
+ elem.setKey(inputNode.getID());
+ elem.setType(DataType.STRING);
+ elem.setValue(value);
+ experiment.addToExperimentInputs(elem );
+ }
+ final List<OutputNode> outputNodes = GraphUtil.getOutputNodes(this.workflow.getGraph());
+
+ for (int i = 0; i < outputNodes.size(); i++) {
+ OutputNode outputNode = outputNodes.get(i);
+ DataObjectType elem = new DataObjectType();
+ elem.setKey(outputNode.getID());
+ elem.setType(DataType.STRING);
+ elem.setValue("");
+ experiment.addToExperimentOutputs(elem );
+ }
+
+ experiment.setExperimentID(airavataClient.createExperiment(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) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ String output = "";
+ while(output.equals("")){
+ String fullOutput = "Experiment Completed Successfully. Output(s) are shown below:\n";
+ if(status.equals("COMPLETED")){
+ List<DataObjectType> outputs = airavataClient.getExperimentOutputs(experiment.getExperimentID());
+ for(int i1=0; i1<outputs.size(); i1++){
+ output = outputs.get(i1).getValue();
+ fullOutput+= outputs.get(i1).getKey()+": "+output+"\n";
+
+ }
+ JOptionPane.showMessageDialog(null, fullOutput);
+ }
+ else{
+ JOptionPane.showMessageDialog(null, "Experiment Failed");
+ return;
+ }
+ }
+
+
+ new Thread() {
+ @Override
+ public void run() {
+
+ }
+ }.start();
+
+ hide();
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/6b519e2a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/RunMenuItem.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/RunMenuItem.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/RunMenuItem.java
index 0b43f04..6cfde9f 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/RunMenuItem.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/RunMenuItem.java
@@ -45,7 +45,8 @@ import org.apache.airavata.xbaya.XBayaConfiguration.XBayaExecutionMode;
import org.apache.airavata.xbaya.XBayaEngine;
import org.apache.airavata.xbaya.core.ide.XBayaExecutionModeListener;
import org.apache.airavata.xbaya.ui.dialogs.monitor.MonitorConfigurationWindow;
-import org.apache.airavata.xbaya.ui.experiment.WorkflowInterpreterLaunchWindow;
+import org.apache.airavata.xbaya.ui.experiment.LaunchApplicationWindow;
+//import org.apache.airavata.xbaya.ui.experiment.WorkflowInterpreterLaunchWindow;
import org.apache.airavata.xbaya.ui.monitor.MonitorStarter;
import org.apache.airavata.xbaya.ui.utils.ErrorMessages;
import org.apache.airavata.xbaya.ui.widgets.ToolbarButton;
@@ -267,7 +268,8 @@ public class RunMenuItem implements EventListener, XBayaExecutionModeListener{
private void createLaunchXBayaInterpreterItem() {
this.launchXBayaInterpreterItem = new JMenuItem("Run on Interpreter Server...", MenuIcons.RUN_ICON);
AbstractAction action = new AbstractAction() {
- private WorkflowInterpreterLaunchWindow window;
+ //private WorkflowInterpreterLaunchWindow window;
+ private LaunchApplicationWindow window;
public void actionPerformed(ActionEvent e) {
if(!engine.getMonitor().hasCurrentExecutionTerminatedNotificationReceived() && engine.getMonitor().isMonitoring()){
if (JOptionPane.showConfirmDialog(null,
@@ -277,7 +279,8 @@ public class RunMenuItem implements EventListener, XBayaExecutionModeListener{
}
}
// if (this.window == null) {
- this.window = new WorkflowInterpreterLaunchWindow(engine);
+ //this.window = new WorkflowInterpreterLaunchWindow(engine);
+ this.window = new LaunchApplicationWindow(engine);
// }
try {
this.window.show();
[3/4] git commit: Merged pull request send by Nadeem for fix
AIRAVATA-1389
Posted by sh...@apache.org.
Merged pull request send by Nadeem for fix AIRAVATA-1389
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/39798cb5
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/39798cb5
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/39798cb5
Branch: refs/heads/master
Commit: 39798cb51f5d9c4c0a1d5ace69b8ce6d1501990e
Parents: 93e37db 4056bb9
Author: shamrath <sh...@gmail.com>
Authored: Tue Sep 9 16:37:09 2014 -0400
Committer: shamrath <sh...@gmail.com>
Committed: Tue Sep 9 16:37:09 2014 -0400
----------------------------------------------------------------------
.../ui/experiment/LaunchApplicationWindow.java | 177 +++++++++++++------
.../xbaya/ui/menues/ApplicationMenuItem.java | 59 +++++++
.../airavata/xbaya/ui/menues/XBayaMenu.java | 5 +-
3 files changed, 188 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/39798cb5/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/LaunchApplicationWindow.java
----------------------------------------------------------------------
diff --cc modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/LaunchApplicationWindow.java
index 18daea0,e99a6f3..0e3127f
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/LaunchApplicationWindow.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/LaunchApplicationWindow.java
@@@ -127,33 -128,30 +128,51 @@@ public class LaunchApplicationWindow
}
// Create input fields
- Collection<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph());
- for (InputNode node : inputNodes) {
- String id = node.getID();
- QName parameterType = node.getParameterType();
- JLabel nameLabel = new JLabel(id);
++// Collection<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph());
++// for (InputNode node : inputNodes) {
++// String id = node.getID();
++// QName parameterType = node.getParameterType();
++// JLabel nameLabel = new JLabel(id);
++// JLabel typeField = new JLabel(parameterType.getLocalPart());
++// XBayaTextField paramField = new XBayaTextField();
++// Object value = node.getDefaultValue();
++//
++// String valueString;
++// if (value == null) {
++// valueString = "";
++// } else {
++// if (value instanceof XmlElement) {
++// XmlElement valueElement = (XmlElement) value;
++// valueString = XMLUtil.xmlElementToString(valueElement);
++// } else {
++// // Only string comes here for now.
++// valueString = value.toString();
++// }
++// }
++// paramField.setText(valueString);
+ List<NodeImpl> nodes = workflow.getGraph().getNodes();
+ 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")){
+ break;
+ }
+ }
+ List<DataPort> inputPorts = node.getInputPorts();
+ for(DataPort port : inputPorts){
+ String id = port.getName();
+ QName parameterType = port.getType();
+ JLabel nameLabel = new JLabel(id);
JLabel typeField = new JLabel(parameterType.getLocalPart());
- XBayaTextField paramField = new XBayaTextField();
- Object value = node.getDefaultValue();
-
- String valueString;
- if (value == null) {
- valueString = "";
- } else {
- if (value instanceof XmlElement) {
- XmlElement valueElement = (XmlElement) value;
- valueString = XMLUtil.xmlElementToString(valueElement);
- } else {
- // Only string comes here for now.
- valueString = value.toString();
- }
- }
- paramField.setText(valueString);
+ XBayaTextField paramField = new XBayaTextField();
+ paramField.setText("");
this.parameterPanel.add(nameLabel);
this.parameterPanel.add(typeField);
this.parameterPanel.add(paramField);
this.parameterTextFields.add(paramField);
- }
+ }
-
Map<String, String> hosts = null;
@@@ -301,7 -300,7 +321,8 @@@
if(owner.equals(""))owner="NotKnown";
project.setOwner(owner);
project.setProjectID(airavataClient.createProject(project));
- final List<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph());
++// 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();
@@@ -325,14 -324,30 +346,50 @@@
experiment.setName(instanceName);
experiment.setProjectID(project.getProjectID());
experiment.setUserName(thriftClientData.getUsername());
- for (int i = 0; i < inputNodes.size(); i++) {
- InputNode inputNode = inputNodes.get(i);
- XBayaTextField parameterTextField = this.parameterTextFields.get(i);
- inputNode.getID();
++
++// 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();
++// DataObjectType elem = new DataObjectType();
++// elem.setKey(inputNode.getID());
++// elem.setType(DataType.STRING);
++// elem.setValue(value);
++// experiment.addToExperimentInputs(elem );
++// }
++// final List<OutputNode> outputNodes = GraphUtil.getOutputNodes(this.workflow.getGraph());
++//
++// for (int i = 0; i < outputNodes.size(); i++) {
++// OutputNode outputNode = outputNodes.get(i);
++// DataObjectType elem = new DataObjectType();
++// elem.setKey(outputNode.getID());
++// elem.setType(DataType.STRING);
++
+ for (int i = 0; i < inputPorts.size(); i++) {
+ DataPort inputPort = inputPorts.get(i);
+ XBayaTextField parameterTextField = this.parameterTextFields.get(i);
String value = parameterTextField.getText();
DataObjectType elem = new DataObjectType();
- elem.setKey(inputNode.getID());
- elem.setType(DataType.STRING);
+ elem.setKey(inputPort.getName());
+ String type = inputPort.getType().getLocalPart().trim();
+ DataType inpType = DataType.STRING;
+ if(type.equalsIgnoreCase("string")){
+ inpType=DataType.STRING;
+ }
+ else if(type.equalsIgnoreCase("integer")){
+ inpType=DataType.INTEGER;
+ }
+ else if(type.equalsIgnoreCase("uri")){
+ inpType=DataType.URI;
+ }
+ else if(type.equalsIgnoreCase("stdour")){
+ inpType=DataType.STDOUT;
+ }
+ else if(type.equalsIgnoreCase("stderr")){
+ inpType=DataType.STDERR;
+ }
+ elem.setType(inpType);
elem.setValue(value);
experiment.addToExperimentInputs(elem );
}
@@@ -376,17 -411,15 +453,14 @@@
for(int i1=0; i1<outputs.size(); i1++){
output = outputs.get(i1).getValue();
fullOutput+= outputs.get(i1).getKey()+": "+output+"\n";
--
- }
- JOptionPane.showMessageDialog(null, fullOutput);
- }
- else{
- JOptionPane.showMessageDialog(null, "Experiment Failed");
- return;
- }
+ }
+ }
+ JOptionPane.showMessageDialog(null, fullOutput);
+ }
+ else{
+ JOptionPane.showMessageDialog(null, "Experiment Failed");
+ return;
}
-
-
new Thread() {
@Override
public void run() {
@@@ -395,6 -428,5 +469,5 @@@
}.start();
hide();
- }
-
- }
++ }
}
[4/4] git commit: Merge branch 'Fix_AIRAVATA-1389'
Posted by sh...@apache.org.
Merge branch 'Fix_AIRAVATA-1389'
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/6b9d3c59
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/6b9d3c59
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/6b9d3c59
Branch: refs/heads/master
Commit: 6b9d3c59b07c5f20fcffc5125a908956959c884f
Parents: ea5da33 39798cb
Author: shamrath <sh...@gmail.com>
Authored: Tue Sep 9 16:38:49 2014 -0400
Committer: shamrath <sh...@gmail.com>
Committed: Tue Sep 9 16:38:49 2014 -0400
----------------------------------------------------------------------
.../ui/experiment/LaunchApplicationWindow.java | 177 +++++++++++++------
.../xbaya/ui/menues/ApplicationMenuItem.java | 59 +++++++
.../airavata/xbaya/ui/menues/XBayaMenu.java | 5 +-
3 files changed, 188 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
[2/4] git commit: Added a menu item for executing applications,
restored previous workflow launching menu action,
made composing workflows for executing single applciations optional
Posted by sh...@apache.org.
Added a menu item for executing applications, restored previous workflow launching menu action, made composing workflows for executing single applciations optional
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/4056bb91
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/4056bb91
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/4056bb91
Branch: refs/heads/master
Commit: 4056bb916e4de9acafbf3a8740c28152ea9b5ef4
Parents: 6b519e2
Author: Nadeem Anjum <na...@gmail.com>
Authored: Wed Aug 20 02:57:48 2014 +0530
Committer: Nadeem Anjum <na...@gmail.com>
Committed: Wed Aug 20 02:57:48 2014 +0530
----------------------------------------------------------------------
.../ui/experiment/LaunchApplicationWindow.java | 136 ++++++++++++-------
.../xbaya/ui/menues/ApplicationMenuItem.java | 59 ++++++++
.../airavata/xbaya/ui/menues/RunMenuItem.java | 9 +-
.../airavata/xbaya/ui/menues/XBayaMenu.java | 5 +-
4 files changed, 150 insertions(+), 59 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/4056bb91/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/LaunchApplicationWindow.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/LaunchApplicationWindow.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/LaunchApplicationWindow.java
index 18daea0..e99a6f3 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/LaunchApplicationWindow.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/experiment/LaunchApplicationWindow.java
@@ -51,6 +51,7 @@ import org.apache.airavata.model.workspace.experiment.DataObjectType;
import org.apache.airavata.model.workspace.experiment.DataType;
import org.apache.airavata.model.workspace.experiment.Experiment;
import org.apache.airavata.model.workspace.experiment.UserConfigurationData;
+import org.apache.airavata.workflow.model.graph.DataPort;
import org.apache.airavata.workflow.model.graph.impl.NodeImpl;
import org.apache.airavata.workflow.model.graph.system.InputNode;
import org.apache.airavata.workflow.model.graph.system.OutputNode;
@@ -127,33 +128,30 @@ public class LaunchApplicationWindow {
}
// Create input fields
- Collection<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph());
- for (InputNode node : inputNodes) {
- String id = node.getID();
- QName parameterType = node.getParameterType();
- JLabel nameLabel = new JLabel(id);
+ List<NodeImpl> nodes = workflow.getGraph().getNodes();
+ 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")){
+ break;
+ }
+ }
+ List<DataPort> inputPorts = node.getInputPorts();
+ for(DataPort port : inputPorts){
+ String id = port.getName();
+ QName parameterType = port.getType();
+ JLabel nameLabel = new JLabel(id);
JLabel typeField = new JLabel(parameterType.getLocalPart());
- XBayaTextField paramField = new XBayaTextField();
- Object value = node.getDefaultValue();
-
- String valueString;
- if (value == null) {
- valueString = "";
- } else {
- if (value instanceof XmlElement) {
- XmlElement valueElement = (XmlElement) value;
- valueString = XMLUtil.xmlElementToString(valueElement);
- } else {
- // Only string comes here for now.
- valueString = value.toString();
- }
- }
- paramField.setText(valueString);
+ XBayaTextField paramField = new XBayaTextField();
+ paramField.setText("");
this.parameterPanel.add(nameLabel);
this.parameterPanel.add(typeField);
this.parameterPanel.add(paramField);
this.parameterTextFields.add(paramField);
- }
+ }
+
Map<String, String> hosts = null;
@@ -268,13 +266,14 @@ public class LaunchApplicationWindow {
private void execute() throws AiravataClientConnectException, InvalidRequestException, AiravataClientException, AiravataSystemException, TException {
List<NodeImpl> nodes = workflow.getGraph().getNodes();
String appId = null;
+ NodeImpl node = null;
for(int i=0; i<nodes.size(); i++){
- NodeImpl node = nodes.get(i);
- String html = node.getComponent().toHTML();
+ 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;
+ break;
}
}
@@ -301,7 +300,7 @@ public class LaunchApplicationWindow {
if(owner.equals(""))owner="NotKnown";
project.setOwner(owner);
project.setProjectID(airavataClient.createProject(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();
@@ -325,24 +324,57 @@ public class LaunchApplicationWindow {
experiment.setName(instanceName);
experiment.setProjectID(project.getProjectID());
experiment.setUserName(thriftClientData.getUsername());
- for (int i = 0; i < inputNodes.size(); i++) {
- InputNode inputNode = inputNodes.get(i);
- XBayaTextField parameterTextField = this.parameterTextFields.get(i);
- inputNode.getID();
+ for (int i = 0; i < inputPorts.size(); i++) {
+ DataPort inputPort = inputPorts.get(i);
+ XBayaTextField parameterTextField = this.parameterTextFields.get(i);
String value = parameterTextField.getText();
DataObjectType elem = new DataObjectType();
- elem.setKey(inputNode.getID());
- elem.setType(DataType.STRING);
+ elem.setKey(inputPort.getName());
+ String type = inputPort.getType().getLocalPart().trim();
+ DataType inpType = DataType.STRING;
+ if(type.equalsIgnoreCase("string")){
+ inpType=DataType.STRING;
+ }
+ else if(type.equalsIgnoreCase("integer")){
+ inpType=DataType.INTEGER;
+ }
+ else if(type.equalsIgnoreCase("uri")){
+ inpType=DataType.URI;
+ }
+ else if(type.equalsIgnoreCase("stdour")){
+ inpType=DataType.STDOUT;
+ }
+ else if(type.equalsIgnoreCase("stderr")){
+ inpType=DataType.STDERR;
+ }
+ elem.setType(inpType);
elem.setValue(value);
experiment.addToExperimentInputs(elem );
}
- final List<OutputNode> outputNodes = GraphUtil.getOutputNodes(this.workflow.getGraph());
+ final List<DataPort> outputPorts = node.getOutputPorts();
- for (int i = 0; i < outputNodes.size(); i++) {
- OutputNode outputNode = outputNodes.get(i);
+ for (int i = 0; i < outputPorts.size(); i++) {
+ DataPort outputPort = outputPorts.get(i);
DataObjectType elem = new DataObjectType();
- elem.setKey(outputNode.getID());
- elem.setType(DataType.STRING);
+ elem.setKey(outputPort.getName());
+ String type = outputPort.getType().getLocalPart().trim();
+ DataType outType = DataType.STRING;
+ if(type.equalsIgnoreCase("string")){
+ outType=DataType.STRING;
+ }
+ else if(type.equalsIgnoreCase("integer")){
+ outType=DataType.INTEGER;
+ }
+ else if(type.equalsIgnoreCase("uri")){
+ outType=DataType.URI;
+ }
+ else if(type.equalsIgnoreCase("stdour")){
+ outType=DataType.STDOUT;
+ }
+ else if(type.equalsIgnoreCase("stderr")){
+ outType=DataType.STDERR;
+ }
+ elem.setType(outType);
elem.setValue("");
experiment.addToExperimentOutputs(elem );
}
@@ -368,25 +400,26 @@ public class LaunchApplicationWindow {
// TODO Auto-generated catch block
e.printStackTrace();
}
- String output = "";
- while(output.equals("")){
- String fullOutput = "Experiment Completed Successfully. Output(s) are shown below:\n";
- if(status.equals("COMPLETED")){
+
+ if(status.equals("COMPLETED")){
+ String output="";;
+ String fullOutput="";
+ while(output.equals("")){
+ output = "";
+ fullOutput = "Experiment Completed Successfully. Output(s) are shown below:\n";
List<DataObjectType> outputs = airavataClient.getExperimentOutputs(experiment.getExperimentID());
for(int i1=0; i1<outputs.size(); i1++){
output = outputs.get(i1).getValue();
fullOutput+= outputs.get(i1).getKey()+": "+output+"\n";
- }
- JOptionPane.showMessageDialog(null, fullOutput);
- }
- else{
- JOptionPane.showMessageDialog(null, "Experiment Failed");
- return;
- }
+ }
+ }
+ JOptionPane.showMessageDialog(null, fullOutput);
+ }
+ else{
+ JOptionPane.showMessageDialog(null, "Experiment Failed");
+ return;
}
-
-
new Thread() {
@Override
public void run() {
@@ -395,6 +428,5 @@ public class LaunchApplicationWindow {
}.start();
hide();
- }
-
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/airavata/blob/4056bb91/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/ApplicationMenuItem.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/ApplicationMenuItem.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/ApplicationMenuItem.java
new file mode 100644
index 0000000..1787c06
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/ApplicationMenuItem.java
@@ -0,0 +1,59 @@
+package org.apache.airavata.xbaya.ui.menues;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+
+import org.apache.airavata.xbaya.XBayaEngine;
+import org.apache.airavata.xbaya.ui.experiment.LaunchApplicationWindow;
+
+public class ApplicationMenuItem {
+
+ private JMenu applicationMenu;
+
+ private JMenuItem executeApplicationItem;
+
+ private XBayaEngine engine;
+
+ public ApplicationMenuItem(XBayaEngine engine) {
+ this.engine = engine;
+
+ createApplicationMenu();
+ }
+
+ private void createApplicationMenu() {
+ createExecuteApplicationItem();
+ this.applicationMenu = new JMenu("Run Applications");
+ this.applicationMenu.add(this.executeApplicationItem);
+ this.applicationMenu.addSeparator();
+ }
+
+ private void createExecuteApplicationItem() {
+ this.executeApplicationItem = new JMenuItem("Execute Application");
+ this.executeApplicationItem.addActionListener(new AbstractAction() {
+ private LaunchApplicationWindow window;
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (this.window == null) {
+ this.window = new LaunchApplicationWindow(ApplicationMenuItem.this.engine);
+ }
+ try {
+ this.window.show();
+ } catch (Exception e1) {
+ ApplicationMenuItem.this.engine.getGUI().getErrorWindow().error(e1);
+ }
+ }
+ });
+
+ }
+
+ public JMenu getMenu() {
+ return this.applicationMenu;
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/4056bb91/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/RunMenuItem.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/RunMenuItem.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/RunMenuItem.java
index 6cfde9f..0320e06 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/RunMenuItem.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/RunMenuItem.java
@@ -45,8 +45,7 @@ import org.apache.airavata.xbaya.XBayaConfiguration.XBayaExecutionMode;
import org.apache.airavata.xbaya.XBayaEngine;
import org.apache.airavata.xbaya.core.ide.XBayaExecutionModeListener;
import org.apache.airavata.xbaya.ui.dialogs.monitor.MonitorConfigurationWindow;
-import org.apache.airavata.xbaya.ui.experiment.LaunchApplicationWindow;
-//import org.apache.airavata.xbaya.ui.experiment.WorkflowInterpreterLaunchWindow;
+import org.apache.airavata.xbaya.ui.experiment.WorkflowInterpreterLaunchWindow;
import org.apache.airavata.xbaya.ui.monitor.MonitorStarter;
import org.apache.airavata.xbaya.ui.utils.ErrorMessages;
import org.apache.airavata.xbaya.ui.widgets.ToolbarButton;
@@ -268,8 +267,7 @@ public class RunMenuItem implements EventListener, XBayaExecutionModeListener{
private void createLaunchXBayaInterpreterItem() {
this.launchXBayaInterpreterItem = new JMenuItem("Run on Interpreter Server...", MenuIcons.RUN_ICON);
AbstractAction action = new AbstractAction() {
- //private WorkflowInterpreterLaunchWindow window;
- private LaunchApplicationWindow window;
+ private WorkflowInterpreterLaunchWindow window;
public void actionPerformed(ActionEvent e) {
if(!engine.getMonitor().hasCurrentExecutionTerminatedNotificationReceived() && engine.getMonitor().isMonitoring()){
if (JOptionPane.showConfirmDialog(null,
@@ -279,8 +277,7 @@ public class RunMenuItem implements EventListener, XBayaExecutionModeListener{
}
}
// if (this.window == null) {
- //this.window = new WorkflowInterpreterLaunchWindow(engine);
- this.window = new LaunchApplicationWindow(engine);
+ this.window = new WorkflowInterpreterLaunchWindow(engine);
// }
try {
this.window.show();
http://git-wip-us.apache.org/repos/asf/airavata/blob/4056bb91/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/XBayaMenu.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/XBayaMenu.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/XBayaMenu.java
index 5b472ed..3eb385a 100644
--- a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/XBayaMenu.java
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/menues/XBayaMenu.java
@@ -53,6 +53,8 @@ public class XBayaMenu implements XBayaComponent,XBayaExecutionModeListener{
private RegistryMenuItem registryMenuItem;
private AmazonEC2MenuItem amazonEC2MenuItem;
+
+ private ApplicationMenuItem applicationMenuItem;
// private ToolsMenuItem toolsMenuItem;
@@ -80,7 +82,7 @@ public class XBayaMenu implements XBayaComponent,XBayaExecutionModeListener{
runMenuItem = new RunMenuItem(getEngine(), getToolBar());
registryMenuItem = new RegistryMenuItem(getEngine(),getToolBar());
// toolsMenuItem = new ToolsMenuItem(getEngine());
-
+ applicationMenuItem = new ApplicationMenuItem(getEngine());
createMenuBar();
executionModeChanged(getEngine().getConfiguration());
}
@@ -106,6 +108,7 @@ public class XBayaMenu implements XBayaComponent,XBayaExecutionModeListener{
// menuBar.add(toolsMenuItem.getMenu());
menuBar.add(registryMenuItem.getMenu());
menuBar.add(amazonEC2MenuItem.getMenu());
+ menuBar.add(applicationMenuItem.getMenu());
// Space before Help
this.menuBar.add(Box.createHorizontalGlue());