You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sa...@apache.org on 2013/10/09 01:32:17 UTC

svn commit: r1530460 - in /airavata/trunk/modules: commons/utils/src/main/java/org/apache/airavata/common/utils/ xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/descriptors/

Author: samindaw
Date: Tue Oct  8 23:32:17 2013
New Revision: 1530460

URL: http://svn.apache.org/r1530460
Log:
updating xbaya to suppose gsissh and ssh

Modified:
    airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/StringUtil.java
    airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/descriptors/ApplicationDescriptionDialog.java
    airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/descriptors/ApplicationDescriptionHostAdvancedOptionDialog.java
    airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/descriptors/HostDescriptionDialog.java

Modified: airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/StringUtil.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/StringUtil.java?rev=1530460&r1=1530459&r2=1530460&view=diff
==============================================================================
--- airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/StringUtil.java (original)
+++ airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/StringUtil.java Tue Oct  8 23:32:17 2013
@@ -101,14 +101,14 @@ public class StringUtil {
 	 * @param s
 	 * @return
 	 */
-	public static String[] getElementsFromString(String s) {
+	public static String[] getElementsFromString(String s, String delimeter, String quote) {
 		List<String> list=new ArrayList<String>();
 		String currentItem="";
 		String previousChar=null;
 		boolean insideQuote=false;
 		for(int i=0;i<s.length();i++){
 			String c=s.substring(i,i+1);
-			if (c.equals(DELIMETER)){
+			if (c.equals(delimeter)){
 				//if not inside a quoted string ignore the delimiter character
 				if (insideQuote) {
 					currentItem+=c;
@@ -116,10 +116,10 @@ public class StringUtil {
 					list.add(currentItem);
 					currentItem = "";
 				}
-			}else if (c.equals(QUOTE)){
-				if (QUOTE.equals(previousChar)){
+			}else if (c.equals(quote)){
+				if (quote.equals(previousChar)){
 					//which means previousChar was an escape character, not a quote for the string
-					currentItem+=QUOTE;
+					currentItem+=quote;
 					if (insideQuote){
 						//mistakenly thought previous char was opening quote char, thus need to make this false
 						insideQuote=false;
@@ -144,6 +144,15 @@ public class StringUtil {
 		list.add(currentItem);
 		return list.toArray(new String[]{});
 	}
+	
+	/**
+	 * Parse the delimitered string and return elements as a string array 
+	 * @param s
+	 * @return
+	 */
+	public static String[] getElementsFromString(String s) {
+		return getElementsFromString(s, DELIMETER, QUOTE);
+	}
 
     /**
      * Converts object to String without worrying about null check.

Modified: airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/descriptors/ApplicationDescriptionDialog.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/descriptors/ApplicationDescriptionDialog.java?rev=1530460&r1=1530459&r2=1530460&view=diff
==============================================================================
--- airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/descriptors/ApplicationDescriptionDialog.java (original)
+++ airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/descriptors/ApplicationDescriptionDialog.java Tue Oct  8 23:32:17 2013
@@ -56,7 +56,9 @@ import org.apache.airavata.commons.gfac.
 import org.apache.airavata.commons.gfac.type.ServiceDescription;
 import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
 import org.apache.airavata.schemas.gfac.GlobusHostType;
+import org.apache.airavata.schemas.gfac.GsisshHostType;
 import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
+import org.apache.airavata.schemas.gfac.SSHHostType;
 import org.apache.airavata.xbaya.XBayaEngine;
 import org.apache.airavata.xbaya.ui.menues.MenuIcons;
 import org.apache.airavata.xbaya.ui.widgets.GridPanel;
@@ -707,11 +709,17 @@ public class ApplicationDescriptionDialo
 				if (hostDescription.getType() instanceof GlobusHostType) {
 					getShellApplicationDescription().getType().changeType(
 					        HpcApplicationDeploymentType.type);
+				} else if (hostDescription.getType() instanceof GsisshHostType) {
+						getShellApplicationDescription().getType().changeType(
+						        HpcApplicationDeploymentType.type);
+				} else if (hostDescription.getType() instanceof SSHHostType && ((SSHHostType)hostDescription.getType()).getHpcResource()) {
+					getShellApplicationDescription().getType().changeType(
+					        HpcApplicationDeploymentType.type);
 				} else {
 					getShellApplicationDescription().getType().changeType(
 							ApplicationDeploymentDescriptionType.type);
 				}
-				btnHostAdvanceOptions.setVisible(hostDescription.getType() instanceof GlobusHostType);
+				btnHostAdvanceOptions.setVisible(getShellApplicationDescription().getType() instanceof HpcApplicationDeploymentType);
 				String hostAddress = hostDescription.getType().getHostAddress();
 				boolean isLocal = isLocalAddress(hostAddress);
 				btnExecBrowse.setVisible(isLocal);

Modified: airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/descriptors/ApplicationDescriptionHostAdvancedOptionDialog.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/descriptors/ApplicationDescriptionHostAdvancedOptionDialog.java?rev=1530460&r1=1530459&r2=1530460&view=diff
==============================================================================
--- airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/descriptors/ApplicationDescriptionHostAdvancedOptionDialog.java (original)
+++ airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/descriptors/ApplicationDescriptionHostAdvancedOptionDialog.java Tue Oct  8 23:32:17 2013
@@ -66,6 +66,8 @@ public class ApplicationDescriptionHostA
 	private XBayaLabel lblCpuCount;
 	private XBayaLabel lblProcessorPerNode;
     private XBayaLabel lbNodeCount;
+	private XBayaTextField txtjobSubmitterCommand;
+	private XBayaTextField txtinstalledParentPath;
 
     /**
      * Create the dialog.
@@ -132,6 +134,9 @@ public class ApplicationDescriptionHostA
         txtCpuCount = new XBayaTextField();
         txtProcessorsPerNode = new XBayaTextField();
         txtNodeCount = new XBayaTextField();
+        txtjobSubmitterCommand = new XBayaTextField();
+        txtinstalledParentPath = new XBayaTextField();
+        
 
         DefaultComboBoxModel cmbModelJobType = new DefaultComboBoxModel(getJobTypesAsStrings());
 		cmbJobType = new XBayaComboBox(cmbModelJobType);
@@ -158,7 +163,9 @@ public class ApplicationDescriptionHostA
 		XBayaLabel lblMinMemory = new XBayaLabel("Min Memory",txtMinMemory);
 		XBayaLabel lblMaxMemory = new XBayaLabel("Max Memory",txtMaxMemory);
         lbNodeCount = new XBayaLabel("Node Count", txtNodeCount);
-
+        XBayaLabel lbljobSubmitterCommand = new XBayaLabel("Job Submitter Command",txtjobSubmitterCommand);
+        XBayaLabel lblinstalledParentPath = new XBayaLabel("Installed Parent Path",txtinstalledParentPath);
+        
 		panel.add(lbljobType);
 		panel.add(cmbJobType);
 		panel.add(lblProjectAccountNumber);
@@ -179,10 +186,14 @@ public class ApplicationDescriptionHostA
 		panel.add(txtMinMemory);
         panel.add(lblMaxMemory);
         panel.add(txtMaxMemory);
+        panel.add(lbljobSubmitterCommand);
+        panel.add(txtjobSubmitterCommand);
+        panel.add(lblinstalledParentPath);
+        panel.add(txtinstalledParentPath);
 		panel.getSwingComponent().setBorder(BorderFactory.createEtchedBorder());
         buttonPane.getSwingComponent().setBorder(BorderFactory.createEtchedBorder());
 
-        SwingUtil.layoutToGrid(panel.getSwingComponent(), 10, 2, SwingUtil.WEIGHT_NONE, 1);
+        SwingUtil.layoutToGrid(panel.getSwingComponent(), 12, 2, SwingUtil.WEIGHT_NONE, 1);
         
         buttonPane.add(okButton);
         buttonPane.add(cancelButton);
@@ -302,6 +313,28 @@ public class ApplicationDescriptionHostA
 			showError("Maximum memory must be a number", "Invalid value");
 			return false;
 		}
+	    try {
+			if (isValueNotEmpty(txtjobSubmitterCommand.getText())) {
+			    getHPCApplicationDescriptionType().setJobSubmitterCommand(
+		                txtjobSubmitterCommand.getText());
+		    }else{
+		    	getHPCApplicationDescriptionType().setJobSubmitterCommand(null);
+		    }
+		} catch (NumberFormatException e) {
+			showError("Maximum memory must be a number", "Invalid value");
+			return false;
+		}
+	    try {
+			if (isValueNotEmpty(txtinstalledParentPath.getText())) {
+			    getHPCApplicationDescriptionType().setInstalledParentPath(
+			    		txtinstalledParentPath.getText());
+		    }else{
+		    	getHPCApplicationDescriptionType().setInstalledParentPath(null);
+		    }
+		} catch (NumberFormatException e) {
+			showError("Maximum memory must be a number", "Invalid value");
+			return false;
+		}	    
 		ProjectAccountType projectAccount = getProjectAccountType();
 		if (isValueNotEmpty(txtProjectAccountNumber.getText())) {
 			projectAccount.setProjectAccountNumber(txtProjectAccountNumber
@@ -354,6 +387,8 @@ public class ApplicationDescriptionHostA
         txtMinMemory.setText(getPropValue(hpcAppType.getMinMemory()));
         txtMaxMemory.setText(getPropValue(hpcAppType.getMaxMemory()));
         txtNodeCount.setText(getPropValue(hpcAppType.getNodeCount()));
+        txtjobSubmitterCommand.setText(hpcAppType.getJobSubmitterCommand()==null?"":hpcAppType.getJobSubmitterCommand());
+        txtinstalledParentPath.setText(hpcAppType.getInstalledParentPath()==null?"":hpcAppType.getInstalledParentPath());
 		ProjectAccountType projectAccount = getProjectAccountType();
 
 		txtProjectAccountNumber.setText(projectAccount.getProjectAccountNumber()==null? "":projectAccount.getProjectAccountNumber());

Modified: airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/descriptors/HostDescriptionDialog.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/descriptors/HostDescriptionDialog.java?rev=1530460&r1=1530459&r2=1530460&view=diff
==============================================================================
--- airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/descriptors/HostDescriptionDialog.java (original)
+++ airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/ui/dialogs/descriptors/HostDescriptionDialog.java Tue Oct  8 23:32:17 2013
@@ -29,9 +29,12 @@ import java.awt.event.KeyAdapter;
 import java.awt.event.KeyEvent;
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.swing.BorderFactory;
 import javax.swing.JButton;
+import javax.swing.JCheckBox;
 import javax.swing.JComboBox;
 import javax.swing.JDialog;
 import javax.swing.JFrame;
@@ -45,7 +48,10 @@ import org.apache.airavata.common.utils.
 import org.apache.airavata.common.utils.SwingUtil;
 import org.apache.airavata.commons.gfac.type.HostDescription;
 import org.apache.airavata.schemas.gfac.Ec2HostType;
+import org.apache.airavata.schemas.gfac.ExportProperties;
+import org.apache.airavata.schemas.gfac.ExportProperties.Name;
 import org.apache.airavata.schemas.gfac.GlobusHostType;
+import org.apache.airavata.schemas.gfac.GsisshHostType;
 import org.apache.airavata.schemas.gfac.HostDescriptionType;
 import org.apache.airavata.schemas.gfac.SSHHostType;
 import org.apache.airavata.schemas.gfac.UnicoreHostType;
@@ -91,12 +97,31 @@ public class HostDescriptionDialog exten
 
 	private GridPanel infoPanel2;
 
+	private XBayaTextField exportsTextField;
+
+	private XBayaTextField preJobCommandsTextField;
+
+	private XBayaTextField postJobCommandsTextField;
+
+	private XBayaLabel postJobCommandsTextFieldLabel;
+
+	private XBayaLabel preJobCommandsLabel;
+
+	private XBayaLabel exportsLabel;
+
+	private XBayaTextField fileEndPointPrefixTextField;
+
+	private XBayaLabel fileEndPointPrefixLabel;
+
+	private JCheckBox hpcResourceCheckBoxField;
+
 	private static final String REMOTE_PROTOCOL_STR_LOCAL="Local";
 	private static final String REMOTE_PROTOCOL_STR_SSH="SSH";
 	private static final String REMOTE_PROTOCOL_STR_GLOBUS="Globus";
 	private static final String REMOTE_PROTOCOL_STR_UNICORE="Unicore";
 	private static final String REMOTE_PROTOCOL_STR_AMAZON_EC2="Amazon EC2";
 	private static final String REMOTE_PROTOCOL_STR_HADOOP="Hadoop";
+	private static final String REMOTE_PROTOCOL_GSI_SSH="GSI-SSH";
 
 
     public HostDescriptionDialog(AiravataAPI registry, JFrame parent) {
@@ -162,6 +187,30 @@ public class HostDescriptionDialog exten
         }else if (host instanceof UnicoreHostType){
         	((UnicoreHostType)hostDescription.getType()).addUnicoreBESEndPoint(this.gateKeeperTextField.getText());
             ((UnicoreHostType)hostDescription.getType()).addGridFTPEndPoint(this.gridFTPTextField.getText());
+        }else if (host instanceof SSHHostType){
+        	while(((SSHHostType)hostDescription.getType()).getFileEndPointPrefixArray().length>0){
+        		((SSHHostType)hostDescription.getType()).removeFileEndPointPrefix(0);
+        	}
+        	String[] prefixes = StringUtil.getElementsFromString(this.fileEndPointPrefixTextField.getText());
+        	for (String prefix : prefixes) {
+        		((SSHHostType)hostDescription.getType()).addNewFileEndPointPrefix().setStringValue(prefix);
+			}
+            ((SSHHostType)hostDescription.getType()).setHpcResource(hpcResourceCheckBoxField.isSelected());
+        }else if (host instanceof GsisshHostType){
+        	String[] exports = StringUtil.getElementsFromString(exportsTextField.getText());
+        	ExportProperties exportsElement = ((GsisshHostType)hostDescription.getType()).addNewExports();
+        	for (String export : exports) {
+        		String[] nameVal = StringUtil.getElementsFromString(export,"=",StringUtil.QUOTE);
+        		if (nameVal.length>0){
+            		Name name = exportsElement.addNewName();
+        			name.setStringValue(nameVal[0]);
+        			if (nameVal.length>1){
+        				name.setValue(nameVal[1]);
+        			}
+        		}
+			}
+            ((GsisshHostType)hostDescription.getType()).addNewPreJobCommands().setCommandArray(StringUtil.getElementsFromString(this.preJobCommandsTextField.getText()));
+            ((GsisshHostType)hostDescription.getType()).addNewPostJobCommands().setCommandArray(StringUtil.getElementsFromString(this.postJobCommandsTextField.getText()));
         }
         saveHostDescription();
         close();
@@ -193,7 +242,7 @@ public class HostDescriptionDialog exten
 
         XBayaLabel hostIdLabel = new XBayaLabel("Host ID", this.hostIdTextField);
         XBayaLabel hostAddressLabel = new XBayaLabel("Host Address", this.hostAddressTextField);
-        cmbResourceProtocol = new JComboBox(new String[]{REMOTE_PROTOCOL_STR_LOCAL,REMOTE_PROTOCOL_STR_SSH,REMOTE_PROTOCOL_STR_GLOBUS,REMOTE_PROTOCOL_STR_UNICORE,REMOTE_PROTOCOL_STR_AMAZON_EC2, REMOTE_PROTOCOL_STR_HADOOP});
+        cmbResourceProtocol = new JComboBox(new String[]{REMOTE_PROTOCOL_STR_LOCAL,REMOTE_PROTOCOL_STR_SSH,REMOTE_PROTOCOL_STR_GLOBUS,REMOTE_PROTOCOL_STR_UNICORE,REMOTE_PROTOCOL_STR_AMAZON_EC2, REMOTE_PROTOCOL_STR_HADOOP, REMOTE_PROTOCOL_GSI_SSH});
         JLabel lblResourceProtocol = new JLabel("Resource Protocol");
         GridPanel pnlResourceProtocolSelection=new GridPanel();
         pnlResourceProtocolSelection.add(lblResourceProtocol);
@@ -295,6 +344,40 @@ public class HostDescriptionDialog exten
         SwingUtil.layoutToGrid(globusPanel.getSwingComponent(), 2, 2, SwingUtil.WEIGHT_NONE, 1);
         return globusPanel;
 	}
+	
+	private GridPanel createSSHRemoteProtocolPanel() {
+		GridPanel globusPanel = new GridPanel();
+        if (exportsTextField==null) {
+			this.fileEndPointPrefixTextField = new XBayaTextField();
+			this.hpcResourceCheckBoxField = new JCheckBox("HPC Resource");
+			fileEndPointPrefixLabel = new XBayaLabel("File Endpoint Prefix", this.exportsTextField);
+		}
+        globusPanel.add(fileEndPointPrefixLabel);
+        globusPanel.add(fileEndPointPrefixTextField);
+        globusPanel.add(hpcResourceCheckBoxField);
+        SwingUtil.layoutToGrid(globusPanel.getSwingComponent(), 2, 2, SwingUtil.WEIGHT_NONE, 1);
+        return globusPanel;
+	}
+	
+	private GridPanel createGSISSHRemoteProtocolPanel() {
+		GridPanel globusPanel = new GridPanel();
+        if (exportsTextField==null) {
+			this.exportsTextField = new XBayaTextField();
+			this.preJobCommandsTextField = new XBayaTextField();
+			this.postJobCommandsTextField = new XBayaTextField();
+			exportsLabel = new XBayaLabel("Exports", this.exportsTextField);
+			preJobCommandsLabel = new XBayaLabel("Pre-job Commands", this.preJobCommandsTextField);
+			postJobCommandsTextFieldLabel = new XBayaLabel("Post-job Commands", this.postJobCommandsTextField);
+		}
+        globusPanel.add(exportsLabel);
+        globusPanel.add(exportsTextField);
+        globusPanel.add(preJobCommandsLabel);
+        globusPanel.add(preJobCommandsTextField);
+        globusPanel.add(postJobCommandsTextFieldLabel);
+        globusPanel.add(postJobCommandsTextField);
+        SwingUtil.layoutToGrid(globusPanel.getSwingComponent(), 3, 2, SwingUtil.WEIGHT_NONE, 1);
+        return globusPanel;
+	}
 
 	private GridPanel createUnicoreRemoteProtocolPanel() {
 		GridPanel globusPanel = new GridPanel();
@@ -321,12 +404,24 @@ public class HostDescriptionDialog exten
 			gridFTPTextField.setText(StringUtil.createDelimiteredString(((GlobusHostType) t).getGridFTPEndPointArray()));
 		}else if (t instanceof SSHHostType){
 			cmbResourceProtocol.setSelectedItem(REMOTE_PROTOCOL_STR_SSH);
+			fileEndPointPrefixTextField.setText(StringUtil.createDelimiteredString(((SSHHostType)t).getFileEndPointPrefixArray()));
+			hpcResourceCheckBoxField.setSelected(((SSHHostType)t).getHpcResource());
 		}else if (t instanceof UnicoreHostType){
 			cmbResourceProtocol.setSelectedItem(REMOTE_PROTOCOL_STR_UNICORE);
 			gateKeeperTextField.setText(StringUtil.createDelimiteredString(((UnicoreHostType) t).getUnicoreBESEndPointArray()));
 			gridFTPTextField.setText(StringUtil.createDelimiteredString(((UnicoreHostType) t).getGridFTPEndPointArray()));
 		}else if (t instanceof Ec2HostType){
 			cmbResourceProtocol.setSelectedItem(REMOTE_PROTOCOL_STR_AMAZON_EC2);
+		}else if (t instanceof GsisshHostType){
+			cmbResourceProtocol.setSelectedItem(REMOTE_PROTOCOL_GSI_SSH);
+			Name[] nameArray = ((GsisshHostType) t).getExports().getNameArray();
+			List<String> arr=new ArrayList<String>();
+			for (Name name : nameArray) {
+				arr.add(name.getStringValue()+"="+StringUtil.quoteString(name.getValue(),"="));
+			}
+			exportsTextField.setText(StringUtil.createDelimiteredString(arr.toArray(new String[]{})));
+			preJobCommandsTextField.setText(StringUtil.createDelimiteredString(((GsisshHostType) t).getPreJobCommands().getCommandArray()));
+			postJobCommandsTextField.setText(StringUtil.createDelimiteredString(((GsisshHostType) t).getPostJobCommands().getCommandArray()));
 		}
 		hostIdTextField.setEditable(isNewHost());
 		updateRemoteProtocolTypeAndControls();
@@ -441,7 +536,7 @@ public class HostDescriptionDialog exten
 				infoPanel2.add(createPanelWithMessage("No configurations needed."));
 			}else if (selectedProtocol.equals(REMOTE_PROTOCOL_STR_SSH)){
 				getHostDescription().getType().changeType(SSHHostType.type);
-				infoPanel2.add(createPanelWithMessage("No configurations needed."));
+				infoPanel2.add(createSSHRemoteProtocolPanel());
 			}else if (selectedProtocol.equals(REMOTE_PROTOCOL_STR_GLOBUS)){
 				getHostDescription().getType().changeType(GlobusHostType.type);
 				infoPanel2.add(createGlobusRemoteProtocolPanel());
@@ -451,6 +546,9 @@ public class HostDescriptionDialog exten
 			}else if (selectedProtocol.equals(REMOTE_PROTOCOL_STR_AMAZON_EC2)){
 				getHostDescription().getType().changeType(Ec2HostType.type);
 				infoPanel2.add(createPanelWithMessage("No configurations needed."));
+			}else if (selectedProtocol.equals(REMOTE_PROTOCOL_GSI_SSH)){
+				getHostDescription().getType().changeType(GsisshHostType.type);
+				infoPanel2.add(createGSISSHRemoteProtocolPanel());
 			}else{
 				infoPanel2.add(createPanelWithMessage("Not supported."));
 			}