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 2015/06/16 21:37:46 UTC
[7/7] airavata git commit: Removed gsi related code
Removed gsi related code
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/d9b2df03
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/d9b2df03
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/d9b2df03
Branch: refs/heads/master
Commit: d9b2df0336199e7641e1af5da5e0d2b4908bf4ac
Parents: 9226453
Author: Shameera Rathanyaka <sh...@gmail.com>
Authored: Tue Jun 16 15:37:32 2015 -0400
Committer: Shameera Rathanyaka <sh...@gmail.com>
Committed: Tue Jun 16 15:37:32 2015 -0400
----------------------------------------------------------------------
.../core/monitor/GfacInternalStatusUpdator.java | 103 ---
.../airavata/gfac/core/monitor/JobMonitor.java | 39 +
.../airavata/gfac/gsi/ssh/GSSContextX509.java | 210 -----
.../gfac/gsi/ssh/api/CommandExecutor.java | 295 -------
.../gsi/ssh/api/job/LSFJobConfiguration.java | 124 ---
.../gfac/gsi/ssh/api/job/LSFOutputParser.java | 132 ----
.../gsi/ssh/api/job/PBSJobConfiguration.java | 121 ---
.../gfac/gsi/ssh/api/job/PBSOutputParser.java | 218 ------
.../gsi/ssh/api/job/SlurmJobConfiguration.java | 119 ---
.../gfac/gsi/ssh/api/job/SlurmOutputParser.java | 192 -----
.../gsi/ssh/api/job/UGEJobConfiguration.java | 121 ---
.../gfac/gsi/ssh/api/job/UGEOutputParser.java | 190 -----
.../gfac/gsi/ssh/config/ConfigReader.java | 76 --
.../ssh/impl/DefaultJobSubmissionListener.java | 43 -
.../gsi/ssh/impl/GSISSHAbstractCluster.java | 777 -------------------
.../gfac/gsi/ssh/impl/HPCRemoteCluster.java | 333 --------
.../airavata/gfac/gsi/ssh/impl/SSHUserInfo.java | 63 --
.../gfac/gsi/ssh/impl/StandardOutReader.java | 79 --
.../gfac/gsi/ssh/impl/SystemCommandOutput.java | 78 --
.../DefaultPasswordAuthenticationInfo.java | 48 --
.../DefaultPublicKeyAuthentication.java | 68 --
.../DefaultPublicKeyFileAuthentication.java | 70 --
.../MyProxyAuthenticationInfo.java | 108 ---
.../gfac/gsi/ssh/jsch/ExtendedJSch.java | 64 --
.../gsi/ssh/listener/JobSubmissionListener.java | 81 --
.../airavata/gfac/gsi/ssh/util/CommonUtils.java | 83 --
.../ssh/util/SSHAPIUIKeyboardInteractive.java | 73 --
.../gsi/ssh/util/SSHKeyPasswordHandler.java | 68 --
.../airavata/gfac/gsi/ssh/util/SSHUtils.java | 760 ------------------
.../handler/GSISSHDirectorySetupHandler.java | 118 ---
.../gfac/gsissh/handler/GSISSHInputHandler.java | 213 -----
.../gsissh/handler/GSISSHOutputHandler.java | 323 --------
.../gsissh/handler/NewGSISSHOutputHandler.java | 83 --
.../gsissh/provider/impl/GSISSHProvider.java | 344 --------
.../gsissh/security/GSISecurityContext.java | 67 --
.../security/TokenizedMyProxyAuthInfo.java | 304 --------
.../gfac/gsissh/util/GFACGSISSHUtils.java | 367 ---------
.../org/apache/airavata/gfac/impl/Factory.java | 53 ++
.../airavata/gfac/impl/HPCRemoteCluster.java | 332 ++++++++
.../org/apache/airavata/gfac/impl/SSHUtils.java | 1 -
.../airavata/gfac/impl/StandardOutReader.java | 79 ++
.../gfac/impl/job/LSFJobConfiguration.java | 123 +++
.../airavata/gfac/impl/job/LSFOutputParser.java | 133 ++++
.../gfac/impl/job/PBSJobConfiguration.java | 121 +++
.../airavata/gfac/impl/job/PBSOutputParser.java | 219 ++++++
.../gfac/impl/job/SlurmJobConfiguration.java | 119 +++
.../gfac/impl/job/SlurmOutputParser.java | 193 +++++
.../gfac/impl/job/UGEJobConfiguration.java | 121 +++
.../airavata/gfac/impl/job/UGEOutputParser.java | 191 +++++
.../airavata/gfac/monitor/HPCMonitorID.java | 107 ---
.../airavata/gfac/monitor/HostMonitorData.java | 88 ---
.../airavata/gfac/monitor/UserMonitorData.java | 76 --
.../command/ExperimentCancelRequest.java | 38 -
.../gfac/monitor/command/TaskCancelRequest.java | 52 --
.../monitor/core/AiravataAbstractMonitor.java | 37 -
.../gfac/monitor/core/MessageParser.java | 43 -
.../airavata/gfac/monitor/core/Monitor.java | 30 -
.../airavata/gfac/monitor/core/PullMonitor.java | 64 --
.../airavata/gfac/monitor/core/PushMonitor.java | 60 --
.../gfac/monitor/email/EmailBasedMonitor.java | 18 +-
.../gfac/monitor/email/EmailMonitorFactory.java | 47 --
.../handlers/GridPullMonitorHandler.java | 139 ----
.../handlers/GridPushMonitorHandler.java | 107 ---
.../monitor/impl/pull/qstat/HPCPullMonitor.java | 471 -----------
.../impl/pull/qstat/ResourceConnection.java | 154 ----
.../monitor/impl/push/amqp/AMQPMonitor.java | 280 -------
.../monitor/impl/push/amqp/BasicConsumer.java | 87 ---
.../impl/push/amqp/ComputingActivity.java | 19 -
.../impl/push/amqp/JSONMessageParser.java | 77 --
.../impl/push/amqp/SimpleJobFinishConsumer.java | 86 --
.../impl/push/amqp/UnRegisterWorker.java | 67 --
.../gfac/monitor/util/AMQPConnectionUtil.java | 80 --
.../airavata/gfac/monitor/util/CommonUtils.java | 280 -------
.../airavata/gfac/monitor/util/X509Helper.java | 164 ----
.../gfac/ssh/provider/impl/SSHProvider.java | 2 +-
.../airavata/gfac/ssh/util/GFACSSHUtils.java | 2 +-
.../impl/DefaultSSHApiTestWithMyProxyAuth.java | 2 +-
.../gfac/ssh/impl/VanilaTestWithSSHAuth.java | 2 +-
.../apache/airavata/job/AMQPMonitorTest.java | 2 +-
79 files changed, 1744 insertions(+), 9177 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/monitor/GfacInternalStatusUpdator.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/monitor/GfacInternalStatusUpdator.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/monitor/GfacInternalStatusUpdator.java
deleted file mode 100644
index 84d72fa..0000000
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/monitor/GfacInternalStatusUpdator.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- *
- * 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.gfac.core.monitor;
-
-import com.google.common.eventbus.Subscribe;
-import org.apache.airavata.common.utils.AiravataZKUtils;
-import org.apache.airavata.common.utils.Constants;
-import org.apache.airavata.common.utils.ServerSettings;
-import org.apache.airavata.common.utils.listener.AbstractActivityListener;
-import org.apache.airavata.gfac.core.monitor.state.GfacExperimentStateChangeRequest;
-import org.apache.airavata.gfac.core.states.GfacExperimentState;
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.ZooDefs;
-import org.apache.zookeeper.data.Stat;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-
-public class GfacInternalStatusUpdator implements AbstractActivityListener, Watcher {
- private final static Logger logger = LoggerFactory.getLogger(GfacInternalStatusUpdator.class);
-
- private CuratorFramework curatorClient;
-
- private static Integer mutex = -1;
-
- @Subscribe
- public void updateZK(GfacExperimentStateChangeRequest statusChangeRequest) throws Exception {
- logger.info("Gfac internal state changed to: " + statusChangeRequest.getState().toString());
- MonitorID monitorID = statusChangeRequest.getMonitorID();
- String experimentNode = ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_EXPERIMENT_NODE, "/gfac-experiments");
- String experimentPath = experimentNode + File.separator + ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_SERVER_NAME)
- + File.separator + statusChangeRequest.getMonitorID().getExperimentID();
- Stat exists = null;
- if(!(GfacExperimentState.COMPLETED.equals(statusChangeRequest.getState()) || GfacExperimentState.FAILED.equals(statusChangeRequest.getState()))) {
- exists = curatorClient.checkExists().forPath(experimentPath);
- if (exists == null) {
- logger.error("ZK path: " + experimentPath + " does not exists !!");
- return;
- }
- Stat state = curatorClient.checkExists().forPath(experimentPath + File.separator + AiravataZKUtils.ZK_EXPERIMENT_STATE_NODE);
- if (state == null) {
- // state znode has to be created
- curatorClient.create().withMode(CreateMode.PERSISTENT).withACL(ZooDefs.Ids.OPEN_ACL_UNSAFE).
- forPath(experimentPath + File.separator + AiravataZKUtils.ZK_EXPERIMENT_STATE_NODE,
- String.valueOf(statusChangeRequest.getState().getValue()).getBytes());
- } else {
- curatorClient.setData().withVersion(state.getVersion()).forPath(experimentPath + File.separator + AiravataZKUtils.ZK_EXPERIMENT_STATE_NODE,
- String.valueOf(statusChangeRequest.getState().getValue()).getBytes());
- }
- }
- switch (statusChangeRequest.getState()) {
- case COMPLETED:
- logger.info("Experiment Completed, So removing the ZK entry for the experiment" + monitorID.getExperimentID());
- logger.info("Zookeeper experiment Path: " + experimentPath);
- break;
- case FAILED:
- logger.info("Experiment Failed, So removing the ZK entry for the experiment" + monitorID.getExperimentID());
- logger.info("Zookeeper experiment Path: " + experimentPath);
- break;
- default:
- }
- }
-
- public void setup(Object... configurations) {
- for (Object configuration : configurations) {
- if (configuration instanceof CuratorFramework) {
- this.curatorClient = (CuratorFramework) configuration;
- }
- }
- }
-
- public void process(WatchedEvent watchedEvent) {
- logger.info(watchedEvent.getPath());
- synchronized (mutex) {
- Event.KeeperState state = watchedEvent.getState();
- if (state == Event.KeeperState.SyncConnected) {
- mutex.notify();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/monitor/JobMonitor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/monitor/JobMonitor.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/monitor/JobMonitor.java
new file mode 100644
index 0000000..64a9838
--- /dev/null
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/monitor/JobMonitor.java
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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.gfac.core.monitor;
+
+import org.apache.airavata.gfac.core.context.ProcessContext;
+
+public interface JobMonitor {
+
+ /**
+ * Start monitor jobId on remote computer resource.
+ * @param jobId
+ * @param processContext
+ */
+ public void monitor(String jobId, ProcessContext processContext);
+
+ /**
+ * Stop monitoring for given jobId
+ * @param jobId
+ */
+ public void stopMonitor(String jobId);
+}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/GSSContextX509.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/GSSContextX509.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/GSSContextX509.java
deleted file mode 100644
index a6eea6f..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/GSSContextX509.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- *
- * 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.gfac.gsi.ssh;
-
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-import org.globus.common.CoGProperties;
-import org.globus.gsi.gssapi.auth.HostAuthorization;
-import org.gridforum.jgss.ExtendedGSSCredential;
-import org.gridforum.jgss.ExtendedGSSManager;
-import org.ietf.jgss.GSSContext;
-import org.ietf.jgss.GSSCredential;
-import org.ietf.jgss.GSSException;
-import org.ietf.jgss.GSSName;
-import org.ietf.jgss.MessageProp;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.jcraft.jsch.JSchException;
-
-/**
- * This class is based on GSSContextKrb5; it substitutes the globus
- * ExtendedGSSManager and uses the SecurityUtils method to get the credential if
- * one is not passed in from memory.
- *
- */
-public class GSSContextX509 implements com.jcraft.jsch.GSSContext {
-
- private GSSContext context = null;
- private GSSCredential credential;
- private static final Logger logger = LoggerFactory.getLogger(GSSContextX509.class);
-
- public void create(String user, String host) throws JSchException {
- try {
-// ExtendedGSSManager manager = (ExtendedGSSManager) ExtendedGSSManager.getInstance();
-
- if (credential == null) {
- try {
- credential = getCredential();
- } catch (SecurityException t) {
- System.out.printf("Could not get proxy: %s: %s\n", t.getClass().getSimpleName(), t.getMessage());
- throw new JSchException(t.toString());
- }
- }
-
- String cname = host;
-
- try {
- cname = InetAddress.getByName(cname).getCanonicalHostName();
- } catch (UnknownHostException e) {
- }
-
- GSSName name = HostAuthorization.getInstance().getExpectedName(credential, cname);
-
-// context = manager.createContext(name, null, credential, GSSContext.DEFAULT_LIFETIME);
-//
-// // RFC4462 3.4. GSS-API Session
-// //
-// // When calling GSS_Init_sec_context(), the client MUST set
-// // integ_req_flag to "true" to request that per-message integrity
-// // protection be supported for this context. In addition,
-// // deleg_req_flag MAY be set to "true" to request access delegation,
-// // if
-// // requested by the user.
-// //
-// // Since the user authentication process by its nature authenticates
-// // only the client, the setting of mutual_req_flag is not needed for
-// // this process. This flag SHOULD be set to "false".
-//
-// // TODO: OpenSSH's sshd does accept 'false' for mutual_req_flag
-// // context.requestMutualAuth(false);
-// context.requestMutualAuth(true);
-// context.requestConf(true);
-// context.requestInteg(true); // for MIC
-// context.requestCredDeleg(true);
-// context.requestAnonymity(false);
-
-// context = new BCGSSContextImpl(name, (GlobusGSSCredentialImpl) credential);
-// context.requestLifetime(GSSCredential.DEFAULT_LIFETIME);
-// context.requestCredDeleg(true);
-// context.requestMutualAuth(true);
-// context.requestReplayDet(true);
-// context.requestSequenceDet(true);
-// context.requestConf(false);
-// context.requestInteg(true);
-// ((ExtendedGSSContext)context).setOption(GSSConstants.DELEGATION_TYPE, GSIConstants.DELEGATION_TYPE_FULL);
-
- return;
- } catch (GSSException ex) {
- throw new JSchException(ex.toString());
- }
- }
-
- private static GSSCredential getProxy() {
- return getProxy(null, GSSCredential.DEFAULT_LIFETIME);
- }
-
- /**
- * @param x509_USER_PROXY
- * path to the proxy.
- * @param credentialLifetime
- * in seconds.
- * @return valid credential.
- * if proxy task throws exception (or if proxy cannot be found).
- */
- private static GSSCredential getProxy(String x509_USER_PROXY, int credentialLifetime) throws SecurityException {
- if (x509_USER_PROXY == null)
- x509_USER_PROXY = System.getProperty("x509.user.proxy");
-
-// if (x509_USER_PROXY == null) {
-// SystemUtils.envToProperties();
-// x509_USER_PROXY = System.getProperty("x509.user.proxy");
-// }
-
- if (x509_USER_PROXY == null || "".equals(x509_USER_PROXY))
- x509_USER_PROXY = CoGProperties.getDefault().getProxyFile();
-
- if (x509_USER_PROXY == null)
- throw new SecurityException("could not get credential; no location defined");
-
- ExtendedGSSManager manager = (ExtendedGSSManager) ExtendedGSSManager.getInstance();
-
- // file...load file into a buffer
- try {
- File f = new File(x509_USER_PROXY);
- byte[] data = new byte[(int) f.length()];
- FileInputStream in = new FileInputStream(f);
- // read in the credential data
- in.read(data);
- in.close();
- return manager.createCredential(data, ExtendedGSSCredential.IMPEXP_OPAQUE, credentialLifetime, null, // use
- // default
- // mechanism
- // -
- // GSI
- GSSCredential.INITIATE_AND_ACCEPT);
- } catch (Throwable t) {
- throw new SecurityException("could not get credential from " + x509_USER_PROXY, t);
- }
- }
-
- public boolean isEstablished() {
- // this must check to see if the call returned GSS_S_COMPLETE
- if (context != null){
- return context.isEstablished();
- }
- return false;
- }
-
- public byte[] init(byte[] token, int s, int l) throws JSchException {
- try {
- if (context != null){
- return context.initSecContext(token, s, l);
- }else {
- throw new JSchException("Context is null..");
- }
- } catch (GSSException ex) {
- throw new JSchException(ex.toString());
- }
- }
-
- public byte[] getMIC(byte[] message, int s, int l) {
- try {
- MessageProp prop = new MessageProp(0, false);
- return context.getMIC(message, s, l, prop);
- } catch (GSSException ex) {
- logger.error(ex.getMessage(), ex);
- return null;
- }
- }
-
- public void dispose() {
- try {
- context.dispose();
- } catch (GSSException ex) {
- }
- }
-
- public void setCredential(GSSCredential credential) {
- this.credential = credential;
- }
-
- public GSSCredential getCredential() {
- return credential;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandExecutor.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandExecutor.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandExecutor.java
deleted file mode 100644
index bf306ef..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/CommandExecutor.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- *
- * 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.gfac.gsi.ssh.api;
-
-import com.jcraft.jsch.Channel;
-import com.jcraft.jsch.ChannelExec;
-import com.jcraft.jsch.ExtendedSession;
-import com.jcraft.jsch.GSISSHIdentityFile;
-import com.jcraft.jsch.GSISSHIdentityRepository;
-import com.jcraft.jsch.Identity;
-import com.jcraft.jsch.JSch;
-import com.jcraft.jsch.JSchException;
-import com.jcraft.jsch.Session;
-import org.apache.airavata.gfac.core.SSHApiException;
-import org.apache.airavata.gfac.core.authentication.AuthenticationInfo;
-import org.apache.airavata.gfac.core.authentication.GSIAuthenticationInfo;
-import org.apache.airavata.gfac.core.authentication.SSHKeyAuthentication;
-import org.apache.airavata.gfac.core.authentication.SSHPublicKeyAuthentication;
-import org.apache.airavata.gfac.core.authentication.SSHPublicKeyFileAuthentication;
-import org.apache.airavata.gfac.core.cluster.CommandInfo;
-import org.apache.airavata.gfac.core.cluster.CommandOutput;
-import org.apache.airavata.gfac.core.authentication.SSHPasswordAuthentication;
-import org.apache.airavata.gfac.core.cluster.ServerInfo;
-import org.apache.airavata.gfac.gsi.ssh.config.ConfigReader;
-import org.apache.airavata.gfac.gsi.ssh.jsch.ExtendedJSch;
-import org.apache.airavata.gfac.gsi.ssh.util.SSHAPIUIKeyboardInteractive;
-import org.apache.airavata.gfac.gsi.ssh.util.SSHKeyPasswordHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This is a generic class which take care of command execution
- * in a shell, this is used through out the other places of the API.
- */
-public class CommandExecutor {
- static {
- JSch.setConfig("gssapi-with-mic.x509", "org.apache.airavata.gfac.ssh.GSSContextX509");
- JSch.setConfig("userauth.gssapi-with-mic", "com.jcraft.jsch.UserAuthGSSAPIWithMICGSSCredentials");
- JSch jSch = new JSch();
- }
-
- private static final Logger log = LoggerFactory.getLogger(CommandExecutor.class);
- public static final String X509_CERT_DIR = "X509_CERT_DIR";
-
- /**
- * This will execute the given command with given session and session is not closed at the end.
- *
- * @param commandInfo
- * @param session
- * @param commandOutput
- * @throws SSHApiException
- */
- public static Session executeCommand(CommandInfo commandInfo, Session session,
- CommandOutput commandOutput) throws SSHApiException {
-
- String command = commandInfo.getCommand();
-
- Channel channel = null;
- try {
- if (!session.isConnected()) {
- session.connect();
- }
- channel = session.openChannel("exec");
- ((ChannelExec) channel).setCommand(command);
- } catch (JSchException e) {
-// session.disconnect();
-
- throw new SSHApiException("Unable to execute command - ", e);
- }
-
- channel.setInputStream(null);
- ((ChannelExec) channel).setErrStream(commandOutput.getStandardError());
- try {
- channel.connect();
- } catch (JSchException e) {
-
- channel.disconnect();
-// session.disconnect();
- throw new SSHApiException("Unable to retrieve command output. Command - " + command, e);
- }
-
-
- commandOutput.onOutput(channel);
- //Only disconnecting the channel, session can be reused
- channel.disconnect();
- return session;
- }
-
- /**
- * This will not reuse any session, it will create the session and close it at the end
- *
- * @param commandInfo Encapsulated information about command. E.g :- executable name
- * parameters etc ...
- * @param serverInfo The SSHing server information.
- * @param authenticationInfo Security data needs to be communicated with remote server.
- * @param commandOutput The output of the command.
- * @param configReader configuration required for ssh/gshissh connection
- * @throws SSHApiException throw exception when error occurs
- */
- public static void executeCommand(CommandInfo commandInfo, ServerInfo serverInfo,
- AuthenticationInfo authenticationInfo,
- CommandOutput commandOutput, ConfigReader configReader) throws SSHApiException {
-
- if (authenticationInfo instanceof GSIAuthenticationInfo) {
- System.setProperty(X509_CERT_DIR, (String) ((GSIAuthenticationInfo)authenticationInfo).getProperties().
- get("X509_CERT_DIR"));
- }
-
-
- JSch jsch = new ExtendedJSch();
-
- log.debug("Connecting to server - " + serverInfo.getHost() + ":" + serverInfo.getPort() + " with user name - "
- + serverInfo.getUserName());
-
- Session session;
-
- try {
- session = jsch.getSession(serverInfo.getUserName(), serverInfo.getHost(), serverInfo.getPort());
- } catch (JSchException e) {
- throw new SSHApiException("An exception occurred while creating SSH session." +
- "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
- " connecting user name - "
- + serverInfo.getUserName(), e);
- }
-
- java.util.Properties config = configReader.getProperties();
- session.setConfig(config);
-
- //=============================================================
- // Handling vanilla SSH pieces
- //=============================================================
- if (authenticationInfo instanceof SSHPasswordAuthentication) {
- String password = ((SSHPasswordAuthentication) authenticationInfo).
- getPassword(serverInfo.getUserName(), serverInfo.getHost());
-
- session.setUserInfo(new SSHAPIUIKeyboardInteractive(password));
-
- // TODO figure out why we need to set password to session
- session.setPassword(password);
-
- } else if (authenticationInfo instanceof SSHPublicKeyFileAuthentication) {
- SSHPublicKeyFileAuthentication sshPublicKeyFileAuthentication
- = (SSHPublicKeyFileAuthentication)authenticationInfo;
-
- String privateKeyFile = sshPublicKeyFileAuthentication.
- getPrivateKeyFile(serverInfo.getUserName(), serverInfo.getHost());
-
- logDebug("The private key file for vanilla SSH " + privateKeyFile);
-
- String publicKeyFile = sshPublicKeyFileAuthentication.
- getPrivateKeyFile(serverInfo.getUserName(), serverInfo.getHost());
-
- logDebug("The public key file for vanilla SSH " + publicKeyFile);
-
- Identity identityFile;
-
- try {
- identityFile = GSISSHIdentityFile.newInstance(privateKeyFile, null, jsch);
- } catch (JSchException e) {
- throw new SSHApiException("An exception occurred while initializing keys using files. " +
- "(private key and public key)." +
- "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
- " connecting user name - "
- + serverInfo.getUserName() + " private key file - " + privateKeyFile + ", public key file - " +
- publicKeyFile, e);
- }
-
- // Add identity to identity repository
- GSISSHIdentityRepository identityRepository = new GSISSHIdentityRepository(jsch);
- identityRepository.add(identityFile);
-
- // Set repository to session
- session.setIdentityRepository(identityRepository);
-
- // Set the user info
- SSHKeyPasswordHandler sshKeyPasswordHandler
- = new SSHKeyPasswordHandler((SSHKeyAuthentication)authenticationInfo);
-
- session.setUserInfo(sshKeyPasswordHandler);
-
- } else if (authenticationInfo instanceof SSHPublicKeyAuthentication) {
-
- SSHPublicKeyAuthentication sshPublicKeyAuthentication
- = (SSHPublicKeyAuthentication)authenticationInfo;
-
- Identity identityFile;
-
- try {
- String name = serverInfo.getUserName() + "_" + serverInfo.getHost();
- identityFile = GSISSHIdentityFile.newInstance(name,
- sshPublicKeyAuthentication.getPrivateKey(serverInfo.getUserName(), serverInfo.getHost()),
- sshPublicKeyAuthentication.getPublicKey(serverInfo.getUserName(), serverInfo.getHost()), jsch);
- } catch (JSchException e) {
- throw new SSHApiException("An exception occurred while initializing keys using byte arrays. " +
- "(private key and public key)." +
- "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
- " connecting user name - "
- + serverInfo.getUserName(), e);
- }
-
- // Add identity to identity repository
- GSISSHIdentityRepository identityRepository = new GSISSHIdentityRepository(jsch);
- identityRepository.add(identityFile);
-
- // Set repository to session
- session.setIdentityRepository(identityRepository);
-
- // Set the user info
- SSHKeyPasswordHandler sshKeyPasswordHandler
- = new SSHKeyPasswordHandler((SSHKeyAuthentication)authenticationInfo);
-
- session.setUserInfo(sshKeyPasswordHandler);
-
- }
-
- // Not a good way, but we dont have any choice
- if (session instanceof ExtendedSession) {
- if (authenticationInfo instanceof GSIAuthenticationInfo) {
- ((ExtendedSession) session).setAuthenticationInfo((GSIAuthenticationInfo)authenticationInfo);
- }
- }
-
- try {
- session.connect();
- } catch (JSchException e) {
- throw new SSHApiException("An exception occurred while connecting to server." +
- "Connecting server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
- " connecting user name - "
- + serverInfo.getUserName(), e);
- }
-
- String command = commandInfo.getCommand();
-
- Channel channel;
- try {
- channel = session.openChannel("exec");
- ((ChannelExec) channel).setCommand(command);
- } catch (JSchException e) {
-// session.disconnect();
-
- throw new SSHApiException("Unable to execute command - " + command +
- " on server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
- " connecting user name - "
- + serverInfo.getUserName(), e);
- }
-
-
- channel.setInputStream(null);
- ((ChannelExec) channel).setErrStream(commandOutput.getStandardError());
-
- try {
- channel.connect();
- } catch (JSchException e) {
-
- channel.disconnect();
-// session.disconnect();
-
- throw new SSHApiException("Unable to retrieve command output. Command - " + command +
- " on server - " + serverInfo.getHost() + ":" + serverInfo.getPort() +
- " connecting user name - "
- + serverInfo.getUserName(), e);
- }
-
- commandOutput.onOutput(channel);
-
- channel.disconnect();
-// session.disconnect();
- }
-
- private static void logDebug(String message) {
- if (log.isDebugEnabled()) {
- log.debug(message);
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/LSFJobConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/LSFJobConfiguration.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/LSFJobConfiguration.java
deleted file mode 100644
index 9e2a913..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/LSFJobConfiguration.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- *
- * 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.gfac.gsi.ssh.api.job;
-
-import org.apache.airavata.gfac.core.AbstractJobManagerConfiguration;
-import org.apache.airavata.gfac.core.JobManagerConfiguration;
-import org.apache.airavata.gfac.core.cluster.OutputParser;
-import org.apache.airavata.gfac.core.cluster.RawCommandInfo;
-import org.apache.commons.io.FilenameUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-
-public class LSFJobConfiguration implements JobManagerConfiguration {
- private final static Logger logger = LoggerFactory.getLogger(LSFJobConfiguration.class);
-
- private String jobDescriptionTemplateName;
-
- private String scriptExtension;
-
- private String installedPath;
-
- private OutputParser parser;
-
- public LSFJobConfiguration(){
- // this can be used to construct and use setter methods to set all the params in order
- }
- public LSFJobConfiguration(String jobDescriptionTemplateName,
- String scriptExtension,String installedPath,OutputParser parser) {
- this.jobDescriptionTemplateName = jobDescriptionTemplateName;
- this.scriptExtension = scriptExtension;
- this.parser = parser;
- if (installedPath.endsWith("/") || installedPath.isEmpty()) {
- this.installedPath = installedPath;
- } else {
- this.installedPath = installedPath + "/";
- }
- }
-
- @Override
- public RawCommandInfo getCancelCommand(String jobID) {
- return new RawCommandInfo(this.installedPath + "bkill " + jobID);
- }
-
- @Override
- public String getJobDescriptionTemplateName() {
- return jobDescriptionTemplateName;
- }
-
- @Override
- public RawCommandInfo getMonitorCommand(String jobID) {
- return new RawCommandInfo(this.installedPath + "bjobs " + jobID);
- }
-
- @Override
- public RawCommandInfo getUserBasedMonitorCommand(String userName) {
- return new RawCommandInfo(this.installedPath + "bjobs -u " + userName);
- }
-
- @Override
- public RawCommandInfo getJobIdMonitorCommand(String jobName, String userName) {
- return new RawCommandInfo(this.installedPath + "bjobs -J " + jobName);
- }
-
- @Override
- public String getScriptExtension() {
- return scriptExtension;
- }
-
- @Override
- public RawCommandInfo getSubmitCommand(String workingDirectory, String pbsFilePath) {
- return new RawCommandInfo(this.installedPath + "bsub < " +
- workingDirectory + File.separator + FilenameUtils.getName(pbsFilePath));
- }
-
- @Override
- public OutputParser getParser() {
- return parser;
- }
-
- public void setParser(OutputParser parser) {
- this.parser = parser;
- }
-
- @Override
- public String getInstalledPath() {
- return installedPath;
- }
-
-
- @Override
- public String getBaseCancelCommand() {
- return "bkill";
- }
-
- @Override
- public String getBaseMonitorCommand() {
- return "bjobs";
- }
-
- @Override
- public String getBaseSubmitCommand() {
- return "bsub";
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/LSFOutputParser.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/LSFOutputParser.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/LSFOutputParser.java
deleted file mode 100644
index 76012d6..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/LSFOutputParser.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- *
- * 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.gfac.gsi.ssh.api.job;
-
-import org.apache.airavata.gfac.core.JobDescriptor;
-import org.apache.airavata.gfac.core.cluster.JobStatus;
-import org.apache.airavata.gfac.core.cluster.OutputParser;
-import org.apache.airavata.gfac.core.SSHApiException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class LSFOutputParser implements OutputParser {
- private final static Logger logger = LoggerFactory.getLogger(LSFOutputParser.class);
-
- @Override
- public void parseSingleJob(JobDescriptor jobDescriptor, String rawOutput) throws SSHApiException {
- logger.debug(rawOutput);
- //todo we need to implement this but we are not using it airavata runtime
- // if someone is using the gsissh as a tool this will be useful to get a descriptive information about a single job
- }
-
- @Override
- public String parseJobSubmission(String rawOutput) throws SSHApiException {
- logger.debug(rawOutput);
- return rawOutput.substring(rawOutput.indexOf("<")+1,rawOutput.indexOf(">"));
- }
-
- @Override
- public JobStatus parseJobStatus(String jobID, String rawOutput) throws SSHApiException {
- boolean jobFount = false;
- logger.debug(rawOutput);
- //todo this is not used anymore
- return JobStatus.C;
- }
-
- @Override
- public void parseJobStatuses(String userName, Map<String, JobStatus> statusMap, String rawOutput) throws SSHApiException {
- logger.debug(rawOutput);
-
- String[] info = rawOutput.split("\n");
-// int lastStop = 0;
- for (String jobID : statusMap.keySet()) {
- String jobName = jobID.split(",")[1];
- boolean found = false;
- for (int i = 0; i < info.length; i++) {
- if (info[i].contains(jobName.substring(0,8))) {
- // now starts processing this line
- logger.info(info[i]);
- String correctLine = info[i];
- String[] columns = correctLine.split(" ");
- List<String> columnList = new ArrayList<String>();
- for (String s : columns) {
- if (!"".equals(s)) {
- columnList.add(s);
- }
- }
-// lastStop = i + 1;
- try {
- statusMap.put(jobID, JobStatus.valueOf(columnList.get(2)));
- }catch(IndexOutOfBoundsException e){
- statusMap.put(jobID, JobStatus.valueOf("U"));
- }
- found = true;
- break;
- }
- }
- if(!found)
- logger.error("Couldn't find the status of the Job with JobName: " + jobName + "Job Id: " + jobID.split(",")[0]);
- }
- }
-
- @Override
- public String parseJobId(String jobName, String rawOutput) throws SSHApiException {
- String regJobId = "jobId";
- Pattern pattern = Pattern.compile("(?=(?<" + regJobId + ">\\d+)\\s+\\w+\\s+" + jobName + ")"); // regex - look ahead and match
- if (rawOutput != null) {
- Matcher matcher = pattern.matcher(rawOutput);
- if (matcher.find()) {
- return matcher.group(regJobId);
- } else {
- logger.error("No match is found for JobName");
- return null;
- }
- } else {
- logger.error("Error: RawOutput shouldn't be null");
- return null;
- }
- }
-
- public static void main(String[] args) {
- String test = "Job <2477982> is submitted to queue <short>.";
- System.out.println(test.substring(test.indexOf("<")+1, test.indexOf(">")));
- String test1 = "JOBID USER STAT QUEUE FROM_HOST EXEC_HOST JOB_NAME SUBMIT_TIME\n" +
- "2636607 lg11w RUN long ghpcc06 c11b02 *069656647 Mar 7 00:58\n" +
- "2636582 lg11w RUN long ghpcc06 c02b01 2134490944 Mar 7 00:48";
- Map<String, JobStatus> statusMap = new HashMap<String, JobStatus>();
- statusMap.put("2477983,2134490944", JobStatus.U);
- LSFOutputParser lsfOutputParser = new LSFOutputParser();
- try {
- lsfOutputParser.parseJobStatuses("cjh", statusMap, test1);
- } catch (SSHApiException e) {
- logger.error(e.getMessage(), e);
- }
- System.out.println(statusMap.get("2477983,2134490944"));
-
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/PBSJobConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/PBSJobConfiguration.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/PBSJobConfiguration.java
deleted file mode 100644
index c5be412..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/PBSJobConfiguration.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- *
- * 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.gfac.gsi.ssh.api.job;
-
-import org.apache.airavata.gfac.core.JobManagerConfiguration;
-import org.apache.airavata.gfac.core.cluster.OutputParser;
-import org.apache.airavata.gfac.core.cluster.RawCommandInfo;
-import org.apache.commons.io.FilenameUtils;
-
-import java.io.File;
-
-public class PBSJobConfiguration implements JobManagerConfiguration {
-
- private String jobDescriptionTemplateName;
-
- private String scriptExtension;
-
- private String installedPath;
-
- private OutputParser parser;
-
- public PBSJobConfiguration() {
- // this can be used to construct and use setter methods to set all the params in order
- }
-
- public PBSJobConfiguration(String jobDescriptionTemplateName,
- String scriptExtension, String installedPath, OutputParser parser) {
- this.jobDescriptionTemplateName = jobDescriptionTemplateName;
- this.scriptExtension = scriptExtension;
- this.parser = parser;
- if (installedPath.endsWith("/")) {
- this.installedPath = installedPath;
- } else {
- this.installedPath = installedPath + "/";
- }
- }
-
- public RawCommandInfo getCancelCommand(String jobID) {
- return new RawCommandInfo(this.installedPath + "qdel " + jobID);
- }
-
- public String getJobDescriptionTemplateName() {
- return jobDescriptionTemplateName;
- }
-
- public void setJobDescriptionTemplateName(String jobDescriptionTemplateName) {
- this.jobDescriptionTemplateName = jobDescriptionTemplateName;
- }
-
- public RawCommandInfo getMonitorCommand(String jobID) {
- return new RawCommandInfo(this.installedPath + "qstat -f " + jobID);
- }
-
- public String getScriptExtension() {
- return scriptExtension;
- }
-
- public RawCommandInfo getSubmitCommand(String workingDirectory, String pbsFilePath) {
- return new RawCommandInfo(this.installedPath + "qsub " +
- workingDirectory + File.separator + FilenameUtils.getName(pbsFilePath));
- }
-
- public String getInstalledPath() {
- return installedPath;
- }
-
- public void setInstalledPath(String installedPath) {
- this.installedPath = installedPath;
- }
-
- public OutputParser getParser() {
- return parser;
- }
-
- public void setParser(OutputParser parser) {
- this.parser = parser;
- }
-
- public RawCommandInfo getUserBasedMonitorCommand(String userName) {
- return new RawCommandInfo(this.installedPath + "qstat -u " + userName);
- }
-
- @Override
- public RawCommandInfo getJobIdMonitorCommand(String jobName, String userName) {
- // For PBS there is no option to get jobDetails by JobName, so we search with userName
- return new RawCommandInfo(this.installedPath + "qstat -u " + userName + " -f | grep \"Job_Name = " + jobName + "\" -B1");
- }
-
- @Override
- public String getBaseCancelCommand() {
- return "qdel";
- }
-
- @Override
- public String getBaseMonitorCommand() {
- return "qstat";
- }
-
- @Override
- public String getBaseSubmitCommand() {
- return "qsub ";
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/PBSOutputParser.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/PBSOutputParser.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/PBSOutputParser.java
deleted file mode 100644
index 15e2405..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/PBSOutputParser.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- *
- * 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.gfac.gsi.ssh.api.job;
-
-import org.apache.airavata.gfac.core.JobDescriptor;
-import org.apache.airavata.gfac.core.cluster.JobStatus;
-import org.apache.airavata.gfac.core.cluster.OutputParser;
-import org.apache.airavata.gfac.core.SSHApiException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class PBSOutputParser implements OutputParser {
- private static final Logger log = LoggerFactory.getLogger(PBSOutputParser.class);
-
- public void parseSingleJob(JobDescriptor jobDescriptor, String rawOutput) {
- log.debug(rawOutput);
- String[] info = rawOutput.split("\n");
- String[] line;
- for (int i = 0; i < info.length; i++) {
- if (info[i].contains("=")) {
- line = info[i].split("=", 2);
- } else {
- line = info[i].split(":", 2);
- }
- if (line.length >= 2) {
- String header = line[0].trim();
- log.debug("Header = " + header);
- String value = line[1].trim();
- log.debug("value = " + value);
-
- if (header.equals("Variable_List")) {
- while (info[i + 1].startsWith("\t")) {
- value += info[i + 1];
- i++;
- }
- value = value.replaceAll("\t", "");
- jobDescriptor.setVariableList(value);
- } else if ("Job Id".equals(header)) {
- jobDescriptor.setJobID(value);
- } else if ("Job_Name".equals(header)) {
- jobDescriptor.setJobName(value);
- } else if ("Account_Name".equals(header)) {
- jobDescriptor.setAcountString(value);
- } else if ("job_state".equals(header)) {
- jobDescriptor.setStatus(value);
- } else if ("Job_Owner".equals(header)) {
- jobDescriptor.setOwner(value);
- } else if ("resources_used.cput".equals(header)) {
- jobDescriptor.setUsedCPUTime(value);
- } else if ("resources_used.mem".equals(header)) {
- jobDescriptor.setUsedMemory(value);
- } else if ("resources_used.walltime".equals(header)) {
- jobDescriptor.setEllapsedTime(value);
- } else if ("job_state".equals(header)) {
- jobDescriptor.setStatus(value);
- } else if ("queue".equals(header))
- jobDescriptor.setQueueName(value);
- else if ("ctime".equals(header)) {
- jobDescriptor.setCTime(value);
- } else if ("qtime".equals(header)) {
- jobDescriptor.setQTime(value);
- } else if ("mtime".equals(header)) {
- jobDescriptor.setMTime(value);
- } else if ("start_time".equals(header)) {
- jobDescriptor.setSTime(value);
- } else if ("comp_time".equals(header)) {
- jobDescriptor.setCompTime(value);
- } else if ("exec_host".equals(header)) {
- jobDescriptor.setExecuteNode(value);
- } else if ("Output_Path".equals(header)) {
- if (info[i + 1].contains("=") || info[i + 1].contains(":"))
- jobDescriptor.setStandardOutFile(value);
- else {
- jobDescriptor.setStandardOutFile(value + info[i + 1].trim());
- i++;
- }
- } else if ("Error_Path".equals(header)) {
- if (info[i + 1].contains("=") || info[i + 1].contains(":"))
- jobDescriptor.setStandardErrorFile(value);
- else {
- String st = info[i + 1].trim();
- jobDescriptor.setStandardErrorFile(value + st);
- i++;
- }
-
- } else if ("submit_args".equals(header)) {
- while (i + 1 < info.length) {
- if (info[i + 1].startsWith("\t")) {
- value += info[i + 1];
- i++;
- } else
- break;
- }
- value = value.replaceAll("\t", "");
- jobDescriptor.setSubmitArgs(value);
- }
- }
- }
- }
-
- public String parseJobSubmission(String rawOutput) {
- log.debug(rawOutput);
- return rawOutput; //In PBS stdout is going to be directly the jobID
- }
-
- public JobStatus parseJobStatus(String jobID, String rawOutput) {
- boolean jobFount = false;
- log.debug(rawOutput);
- String[] info = rawOutput.split("\n");
- String[] line = null;
- int index = 0;
- for (String anInfo : info) {
- index++;
- if (anInfo.contains("Job Id:")) {
- if (anInfo.contains(jobID)) {
- jobFount = true;
- break;
- }
- }
- }
- if (jobFount) {
- for (int i=index;i<info.length;i++) {
- String anInfo = info[i];
- if (anInfo.contains("=")) {
- line = anInfo.split("=", 2);
- if (line.length != 0) {
- if (line[0].contains("job_state")) {
- return JobStatus.valueOf(line[1].replaceAll(" ", ""));
- }
- }
- }
- }
- }
- return null;
- }
-
- public void parseJobStatuses(String userName, Map<String, JobStatus> statusMap, String rawOutput) {
- log.debug(rawOutput);
- String[] info = rawOutput.split("\n");
-// int lastStop = 0;
- for (String jobID : statusMap.keySet()) {
- String jobName = jobID.split(",")[1];
- boolean found = false;
- for (int i = 0; i < info.length; i++) {
- if (info[i].contains(jobName.substring(0,8))) {
- // now starts processing this line
- log.info(info[i]);
- String correctLine = info[i];
- String[] columns = correctLine.split(" ");
- List<String> columnList = new ArrayList<String>();
- for (String s : columns) {
- if (!"".equals(s)) {
- columnList.add(s);
- }
- }
-// lastStop = i + 1;
- try {
- statusMap.put(jobID, JobStatus.valueOf(columnList.get(9)));
- }catch(IndexOutOfBoundsException e){
- statusMap.put(jobID, JobStatus.valueOf("U"));
- }
- found = true;
- break;
- }
- }
- if(!found)
- log.error("Couldn't find the status of the Job with JobName: " + jobName + "Job Id: " + jobID.split(",")[0]);
- }
- }
-
- @Override
- public String parseJobId(String jobName, String rawOutput) throws SSHApiException {
- /* output will look like
- Job Id: 2080802.gordon-fe2.local
- Job_Name = A312402627
- */
- String regJobId = "jobId";
- Pattern pattern = Pattern.compile("(?<" + regJobId + ">[^\\s]*)\\s*.* " + jobName);
- if (rawOutput != null) {
- Matcher matcher = pattern.matcher(rawOutput);
- if (matcher.find()) {
- return matcher.group(regJobId);
- } else {
- log.error("No match is found for JobName");
- return null;
- }
- } else {
- log.error("Error: RawOutput shouldn't be null");
- return null;
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/SlurmJobConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/SlurmJobConfiguration.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/SlurmJobConfiguration.java
deleted file mode 100644
index 48ba48e..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/SlurmJobConfiguration.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- *
- * 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.gfac.gsi.ssh.api.job;
-
-import org.apache.airavata.gfac.core.JobManagerConfiguration;
-import org.apache.airavata.gfac.core.cluster.OutputParser;
-import org.apache.airavata.gfac.core.cluster.RawCommandInfo;
-import org.apache.commons.io.FilenameUtils;
-
-import java.io.File;
-
-public class SlurmJobConfiguration implements JobManagerConfiguration {
-
- private String jobDescriptionTemplateName;
-
- private String scriptExtension;
-
- private String installedPath;
-
- private OutputParser parser;
-
- public SlurmJobConfiguration(){
- // this can be used to construct and use setter methods to set all the params in order
- }
- public SlurmJobConfiguration(String jobDescriptionTemplateName,
- String scriptExtension,String installedPath,OutputParser parser) {
- this.jobDescriptionTemplateName = jobDescriptionTemplateName;
- this.scriptExtension = scriptExtension;
- this.parser = parser;
- if (installedPath.endsWith("/")) {
- this.installedPath = installedPath;
- } else {
- this.installedPath = installedPath + "/";
- }
- }
-
- public RawCommandInfo getCancelCommand(String jobID) {
- return new RawCommandInfo(this.installedPath + "scancel " + jobID);
- }
-
- public String getJobDescriptionTemplateName() {
- return jobDescriptionTemplateName;
- }
-
- public void setJobDescriptionTemplateName(String jobDescriptionTemplateName) {
- this.jobDescriptionTemplateName = jobDescriptionTemplateName;
- }
-
- public RawCommandInfo getMonitorCommand(String jobID) {
- return new RawCommandInfo(this.installedPath + "squeue -j " + jobID);
- }
-
- public String getScriptExtension() {
- return scriptExtension;
- }
-
- public RawCommandInfo getSubmitCommand(String workingDirectory,String pbsFilePath) {
- return new RawCommandInfo(this.installedPath + "sbatch " +
- workingDirectory + File.separator + FilenameUtils.getName(pbsFilePath));
- }
-
- public String getInstalledPath() {
- return installedPath;
- }
-
- public void setInstalledPath(String installedPath) {
- this.installedPath = installedPath;
- }
-
- public OutputParser getParser() {
- return parser;
- }
-
- public void setParser(OutputParser parser) {
- this.parser = parser;
- }
-
- public RawCommandInfo getUserBasedMonitorCommand(String userName) {
- return new RawCommandInfo(this.installedPath + "squeue -u " + userName);
- }
-
- @Override
- public RawCommandInfo getJobIdMonitorCommand(String jobName, String userName) {
- return new RawCommandInfo(this.installedPath + "squeue -n " + jobName + " -u " + userName);
- }
-
- @Override
- public String getBaseCancelCommand() {
- return "scancel";
- }
-
- @Override
- public String getBaseMonitorCommand() {
- return "squeue";
- }
-
- @Override
- public String getBaseSubmitCommand() {
- return "sbatch";
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/SlurmOutputParser.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/SlurmOutputParser.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/SlurmOutputParser.java
deleted file mode 100644
index 3d2dc48..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/SlurmOutputParser.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- *
- * 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.gfac.gsi.ssh.api.job;
-
-import org.apache.airavata.gfac.core.JobDescriptor;
-import org.apache.airavata.gfac.core.cluster.JobStatus;
-import org.apache.airavata.gfac.core.cluster.OutputParser;
-import org.apache.airavata.gfac.core.SSHApiException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class SlurmOutputParser implements OutputParser {
- private static final Logger log = LoggerFactory.getLogger(SlurmOutputParser.class);
- public static final int JOB_NAME_OUTPUT_LENGTH = 8;
- public static final String STATUS = "status";
-
- public void parseSingleJob(JobDescriptor descriptor, String rawOutput) throws SSHApiException {
- log.info(rawOutput);
- String[] info = rawOutput.split("\n");
- String lastString = info[info.length - 1];
- if (lastString.contains("JOB ID")) {
- // because there's no state
- descriptor.setStatus("U");
- } else {
- int column = 0;
- System.out.println(lastString);
- for (String each : lastString.split(" ")) {
- if (each.trim().isEmpty()) {
- continue;
- } else {
- switch (column) {
- case 0:
- descriptor.setJobID(each);
- column++;
- break;
- case 1:
- descriptor.setPartition(each);
- column++;
- break;
- case 2:
- descriptor.setJobName(each);
- column++;
- break;
- case 3:
- descriptor.setUserName(each);
- column++;
- break;
- case 4:
- descriptor.setStatus(each);
- column++;
- break;
- case 5:
- descriptor.setUsedCPUTime(each);
- column++;
- break;
- case 6:
- try {
- int nodes = Integer.parseInt(each);
- descriptor.setNodes(nodes);
- }catch (Exception e){
- log.error("Node count read from command output is not an integer !!!");
- }
- column++;
- break;
- case 7:
- descriptor.setNodeList(each);
- column++;
- break;
- }
- }
- }
- }
-
- }
-
- /**
- * This can be used to parseSingleJob the outpu of sbatch and extrac the jobID from the content
- *
- * @param rawOutput
- * @return
- */
- public String parseJobSubmission(String rawOutput) throws SSHApiException {
- // FIXME : use regex to match correct jobId;
- log.info(rawOutput);
- String[] info = rawOutput.split("\n");
- for (String anInfo : info) {
- if (anInfo.contains("Submitted batch job")) {
- String[] split = anInfo.split("Submitted batch job");
- return split[1].trim();
- }
- }
- return "";
-// throw new SSHApiException(rawOutput); //todo//To change body of implemented methods use File | Settings | File Templates.
- }
-
- public JobStatus parseJobStatus(String jobID, String rawOutput) throws SSHApiException {
- log.info(rawOutput);
- Pattern pattern = Pattern.compile(jobID + "(?=\\s+\\S+\\s+\\S+\\s+\\S+\\s+(?<" + STATUS + ">\\w+))");
- Matcher matcher = pattern.matcher(rawOutput);
- if (matcher.find()) {
- return JobStatus.valueOf(matcher.group(STATUS));
- }
- return null;
- }
-
- public void parseJobStatuses(String userName, Map<String, JobStatus> statusMap, String rawOutput) throws SSHApiException {
- log.debug(rawOutput);
- String[] info = rawOutput.split("\n");
- String lastString = info[info.length - 1];
- if (lastString.contains("JOBID") || lastString.contains("PARTITION")) {
- log.info("There are no jobs with this username ... ");
- return;
- }
-// int lastStop = 0;
- for (String jobID : statusMap.keySet()) {
- String jobId = jobID.split(",")[0];
- String jobName = jobID.split(",")[1];
- boolean found = false;
- for (int i = 0; i < info.length; i++) {
- if (info[i].contains(jobName.substring(0, 8))) {
- // now starts processing this line
- log.info(info[i]);
- String correctLine = info[i];
- String[] columns = correctLine.split(" ");
- List<String> columnList = new ArrayList<String>();
- for (String s : columns) {
- if (!"".equals(s)) {
- columnList.add(s);
- }
- }
- try {
- statusMap.put(jobID, JobStatus.valueOf(columnList.get(4)));
- } catch (IndexOutOfBoundsException e) {
- statusMap.put(jobID, JobStatus.valueOf("U"));
- }
- found = true;
- break;
- }
- }
- if (!found) {
- log.error("Couldn't find the status of the Job with JobName: " + jobName + "Job Id: " + jobId);
- }
- }
- }
-
- @Override
- public String parseJobId(String jobName, String rawOutput) throws SSHApiException {
- String regJobId = "jobId";
- if (jobName == null) {
- return null;
- } else if(jobName.length() > JOB_NAME_OUTPUT_LENGTH) {
- jobName = jobName.substring(0, JOB_NAME_OUTPUT_LENGTH);
- }
- Pattern pattern = Pattern.compile("(?=(?<" + regJobId + ">\\d+)\\s+\\w+\\s+" + jobName + ")"); // regex - look ahead and match
- if (rawOutput != null) {
- Matcher matcher = pattern.matcher(rawOutput);
- if (matcher.find()) {
- return matcher.group(regJobId);
- } else {
- log.error("No match is found for JobName");
- return null;
- }
- } else {
- log.error("Error: RawOutput shouldn't be null");
- return null;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/UGEJobConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/UGEJobConfiguration.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/UGEJobConfiguration.java
deleted file mode 100644
index fddf210..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/UGEJobConfiguration.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- *
- * 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.gfac.gsi.ssh.api.job;
-
-import org.apache.airavata.gfac.core.JobManagerConfiguration;
-import org.apache.airavata.gfac.core.cluster.OutputParser;
-import org.apache.airavata.gfac.core.cluster.RawCommandInfo;
-import org.apache.commons.io.FilenameUtils;
-
-import java.io.File;
-
-public class UGEJobConfiguration implements JobManagerConfiguration {
-
- private String jobDescriptionTemplateName;
-
- private String scriptExtension;
-
- private String installedPath;
-
- private OutputParser parser;
-
- public UGEJobConfiguration() {
- // this can be used to construct and use setter methods to set all the params in order
- }
-
- public UGEJobConfiguration(String jobDescriptionTemplateName,
- String scriptExtension, String installedPath, OutputParser parser) {
- this.jobDescriptionTemplateName = jobDescriptionTemplateName;
- this.scriptExtension = scriptExtension;
- this.parser = parser;
- if (installedPath.endsWith("/")) {
- this.installedPath = installedPath;
- } else {
- this.installedPath = installedPath + "/";
- }
- }
-
- public RawCommandInfo getCancelCommand(String jobID) {
- return new RawCommandInfo(this.installedPath + "qdel " + jobID);
- }
-
- public String getJobDescriptionTemplateName() {
- return jobDescriptionTemplateName;
- }
-
- public void setJobDescriptionTemplateName(String jobDescriptionTemplateName) {
- this.jobDescriptionTemplateName = jobDescriptionTemplateName;
- }
-
- public RawCommandInfo getMonitorCommand(String jobID) {
- return new RawCommandInfo(this.installedPath + "qstat -j " + jobID);
- }
-
- public String getScriptExtension() {
- return scriptExtension;
- }
-
- public RawCommandInfo getSubmitCommand(String workingDirectory, String pbsFilePath) {
- return new RawCommandInfo(this.installedPath + "qsub " +
- workingDirectory + File.separator + FilenameUtils.getName(pbsFilePath));
- }
-
- public String getInstalledPath() {
- return installedPath;
- }
-
- public void setInstalledPath(String installedPath) {
- this.installedPath = installedPath;
- }
-
- public OutputParser getParser() {
- return parser;
- }
-
- public void setParser(OutputParser parser) {
- this.parser = parser;
- }
-
- public RawCommandInfo getUserBasedMonitorCommand(String userName) {
- return new RawCommandInfo(this.installedPath + "qstat -u " + userName);
- }
-
- @Override
- public RawCommandInfo getJobIdMonitorCommand(String jobName, String userName) {
- // For PBS there is no option to get jobDetails by JobName, so we search with userName
- return new RawCommandInfo(this.installedPath + "qstat -u " + userName);
- }
-
- @Override
- public String getBaseCancelCommand() {
- return "qdel";
- }
-
- @Override
- public String getBaseMonitorCommand() {
- return "qstat";
- }
-
- @Override
- public String getBaseSubmitCommand() {
- return "qsub ";
- }
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/UGEOutputParser.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/UGEOutputParser.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/UGEOutputParser.java
deleted file mode 100644
index 3419b3a..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/api/job/UGEOutputParser.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- *
- * 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.gfac.gsi.ssh.api.job;
-
-import org.apache.airavata.gfac.core.JobDescriptor;
-import org.apache.airavata.gfac.core.cluster.JobStatus;
-import org.apache.airavata.gfac.core.cluster.OutputParser;
-import org.apache.airavata.gfac.core.SSHApiException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class UGEOutputParser implements OutputParser {
- private static final Logger log = LoggerFactory.getLogger(PBSOutputParser.class);
- public static final String JOB_ID = "jobId";
-
- public void parseSingleJob(JobDescriptor jobDescriptor, String rawOutput) {
- log.debug(rawOutput);
- String[] info = rawOutput.split("\n");
- String[] line;
- for (int i = 0; i < info.length; i++) {
- if (info[i].contains("=")) {
- line = info[i].split("=", 2);
- } else {
- line = info[i].split(":", 2);
- }
- if (line.length >= 2) {
- String header = line[0].trim();
- log.debug("Header = " + header);
- String value = line[1].trim();
- log.debug("value = " + value);
-
- if (header.equals("Variable_List")) {
- while (info[i + 1].startsWith("\t")) {
- value += info[i + 1];
- i++;
- }
- value = value.replaceAll("\t", "");
- jobDescriptor.setVariableList(value);
- } else if ("Job Id".equals(header)) {
- jobDescriptor.setJobID(value);
- } else if ("Job_Name".equals(header)) {
- jobDescriptor.setJobName(value);
- } else if ("Account_Name".equals(header)) {
- jobDescriptor.setAcountString(value);
- } else if ("job_state".equals(header)) {
- jobDescriptor.setStatus(value);
- } else if ("Job_Owner".equals(header)) {
- jobDescriptor.setOwner(value);
- } else if ("resources_used.cput".equals(header)) {
- jobDescriptor.setUsedCPUTime(value);
- } else if ("resources_used.mem".equals(header)) {
- jobDescriptor.setUsedMemory(value);
- } else if ("resources_used.walltime".equals(header)) {
- jobDescriptor.setEllapsedTime(value);
- } else if ("job_state".equals(header)) {
- jobDescriptor.setStatus(value);
- } else if ("queue".equals(header))
- jobDescriptor.setQueueName(value);
- else if ("ctime".equals(header)) {
- jobDescriptor.setCTime(value);
- } else if ("qtime".equals(header)) {
- jobDescriptor.setQTime(value);
- } else if ("mtime".equals(header)) {
- jobDescriptor.setMTime(value);
- } else if ("start_time".equals(header)) {
- jobDescriptor.setSTime(value);
- } else if ("comp_time".equals(header)) {
- jobDescriptor.setCompTime(value);
- } else if ("exec_host".equals(header)) {
- jobDescriptor.setExecuteNode(value);
- } else if ("Output_Path".equals(header)) {
- if (info[i + 1].contains("=") || info[i + 1].contains(":"))
- jobDescriptor.setStandardOutFile(value);
- else {
- jobDescriptor.setStandardOutFile(value + info[i + 1].trim());
- i++;
- }
- } else if ("Error_Path".equals(header)) {
- if (info[i + 1].contains("=") || info[i + 1].contains(":"))
- jobDescriptor.setStandardErrorFile(value);
- else {
- String st = info[i + 1].trim();
- jobDescriptor.setStandardErrorFile(value + st);
- i++;
- }
-
- } else if ("submit_args".equals(header)) {
- while (i + 1 < info.length) {
- if (info[i + 1].startsWith("\t")) {
- value += info[i + 1];
- i++;
- } else
- break;
- }
- value = value.replaceAll("\t", "");
- jobDescriptor.setSubmitArgs(value);
- }
- }
- }
- }
-
- public String parseJobSubmission(String rawOutput) {
- log.debug(rawOutput);
- if (rawOutput != null && !rawOutput.isEmpty()) {
- String[] info = rawOutput.split("\n");
- String lastLine = info[info.length - 1];
- return lastLine.split(" ")[2]; // In PBS stdout is going to be directly the jobID
- } else {
- return "";
- }
- }
-
- public JobStatus parseJobStatus(String jobID, String rawOutput) {
- Pattern pattern = Pattern.compile("job_number:[\\s]+" + jobID);
- Matcher matcher = pattern.matcher(rawOutput);
- if (matcher.find()) {
- return JobStatus.Q; // fixme; return correct status.
- }
- return JobStatus.U;
- }
-
- public void parseJobStatuses(String userName, Map<String, JobStatus> statusMap, String rawOutput) {
- log.debug(rawOutput);
- String[] info = rawOutput.split("\n");
- int lastStop = 0;
- for (String jobID : statusMap.keySet()) {
- for(int i=lastStop;i<info.length;i++){
- if(jobID.split(",")[0].contains(info[i].split(" ")[0]) && !"".equals(info[i].split(" ")[0])){
- // now starts processing this line
- log.info(info[i]);
- String correctLine = info[i];
- String[] columns = correctLine.split(" ");
- List<String> columnList = new ArrayList<String>();
- for (String s : columns) {
- if (!"".equals(s)) {
- columnList.add(s);
- }
- }
- lastStop = i+1;
- if ("E".equals(columnList.get(4))) {
- // There is another status with the same letter E other than error status
- // to avoid that we make a small tweek to the job status
- columnList.set(4, "Er");
- }
- statusMap.put(jobID, JobStatus.valueOf(columnList.get(4)));
- break;
- }
- }
- }
- }
-
- @Override
- public String parseJobId(String jobName, String rawOutput) throws SSHApiException {
- if (jobName.length() > 10) {
- jobName = jobName.substring(0, 10);
- }
- Pattern pattern = Pattern.compile("(?<" + JOB_ID + ">\\S+)\\s+\\S+\\s+(" + jobName + ")");
- Matcher matcher = pattern.matcher(rawOutput);
- if (matcher.find()) {
- return matcher.group(JOB_ID);
- }
- return null;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/airavata/blob/d9b2df03/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/config/ConfigReader.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/config/ConfigReader.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/config/ConfigReader.java
deleted file mode 100644
index c40059e..0000000
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/gsi/ssh/config/ConfigReader.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- *
- * 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.gfac.gsi.ssh.config;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-/**
- * Reads basic configurations.
- */
-public class ConfigReader {
-
- private static final String CONFIGURATION_FILE = "gsissh.properties";
-
-
- private Properties properties;
-
- /**
- * Reads configurations from the class path configuration file.
- * @throws IOException If an error occurred while reading configurations.
- */
- public ConfigReader() throws IOException {
- this.properties = getPropertiesFromClasspath(CONFIGURATION_FILE);
- }
-
- private Properties getPropertiesFromClasspath(String propFileName) throws IOException {
- Properties props = new Properties();
- InputStream inputStream = this.getClass().getClassLoader()
- .getResourceAsStream(propFileName);
-
- if (inputStream == null) {
- throw new FileNotFoundException("System configuration file '" + propFileName
- + "' not found in the classpath");
- }
-
- props.load(inputStream);
-
- return props;
- }
-
- public String getConfiguration(String key) {
- return this.properties.getProperty(key);
- }
-
-
- /**
- * Gets all the SSH related properties used by JSch.
- * @return All properties.
- */
- public Properties getProperties() {
- return this.properties;
- }
-
-
-}