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 2016/12/19 17:00:12 UTC
[2/2] airavata git commit: resolved storage resource precedency
inside the process context- fixed AIRAVATA-2252,
use credential token part of session caching key- fixes AIRAVATA-2284
resolved storage resource precedency inside the process context- fixed AIRAVATA-2252, use credential token part of session caching key- fixes AIRAVATA-2284
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/445e1495
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/445e1495
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/445e1495
Branch: refs/heads/develop
Commit: 445e1495006563bb9710f35a134e406b1bd9ee95
Parents: 2cb5ebc
Author: Shameera Rathnayaka <sh...@gmail.com>
Authored: Mon Dec 19 12:00:01 2016 -0500
Committer: Shameera Rathnayaka <sh...@gmail.com>
Committed: Mon Dec 19 12:00:01 2016 -0500
----------------------------------------------------------------------
.../core/cluster/AbstractRemoteCluster.java | 6 +-
.../gfac/core/cluster/OutputParser.java | 9 +-
.../gfac/core/cluster/RemoteCluster.java | 31 +--
.../airavata/gfac/core/cluster/ServerInfo.java | 26 +--
.../gfac/core/context/JobExecutionContext.java | 2 +-
.../gfac/core/context/ProcessContext.java | 217 ++++++++++++++++---
.../airavata/gfac/impl/BESRemoteCluster.java | 27 +--
.../org/apache/airavata/gfac/impl/Factory.java | 114 ++++++----
.../airavata/gfac/impl/GFacEngineImpl.java | 98 ++++-----
.../airavata/gfac/impl/HPCRemoteCluster.java | 90 ++++----
.../airavata/gfac/impl/LocalRemoteCluster.java | 49 +++--
.../org/apache/airavata/gfac/impl/SSHUtils.java | 11 +-
.../gfac/impl/job/ForkOutputParser.java | 9 +-
.../airavata/gfac/impl/job/LSFOutputParser.java | 11 +-
.../airavata/gfac/impl/job/PBSOutputParser.java | 3 +-
.../gfac/impl/job/SlurmOutputParser.java | 9 +-
.../airavata/gfac/impl/job/UGEOutputParser.java | 3 +-
.../airavata/gfac/impl/task/ArchiveTask.java | 24 +-
.../gfac/impl/task/BESJobSubmissionTask.java | 20 +-
.../airavata/gfac/impl/task/DataStageTask.java | 3 +-
.../gfac/impl/task/DataStreamingTask.java | 3 +-
.../impl/task/DefaultJobSubmissionTask.java | 11 +-
.../gfac/impl/task/EnvironmentSetupTask.java | 3 +-
.../gfac/impl/task/ForkJobSubmissionTask.java | 9 -
.../gfac/impl/task/LocalJobSubmissionTask.java | 2 +-
.../gfac/impl/task/SCPDataStageTask.java | 30 ++-
.../airavata/gfac/impl/task/TaskUtils.java | 2 +-
.../gfac/impl/task/utils/StreamData.java | 13 +-
.../task/utils/bes/UNICORESecurityContext.java | 12 +-
29 files changed, 504 insertions(+), 343 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/445e1495/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/AbstractRemoteCluster.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/AbstractRemoteCluster.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/AbstractRemoteCluster.java
index 51867ec..64ca5d4 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/AbstractRemoteCluster.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/AbstractRemoteCluster.java
@@ -31,8 +31,10 @@ public abstract class AbstractRemoteCluster implements RemoteCluster {
protected final ServerInfo serverInfo;
protected final JobManagerConfiguration jobManagerConfiguration;
- public AbstractRemoteCluster(ServerInfo serverInfo, JobManagerConfiguration jobManagerConfiguration, AuthenticationInfo
- authenticationInfo) {
+ public AbstractRemoteCluster(ServerInfo serverInfo,
+ JobManagerConfiguration jobManagerConfiguration,
+ AuthenticationInfo authenticationInfo) {
+
this.serverInfo = serverInfo;
this.jobManagerConfiguration = jobManagerConfiguration;
this.authenticationInfo = authenticationInfo;
http://git-wip-us.apache.org/repos/asf/airavata/blob/445e1495/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/OutputParser.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/OutputParser.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/OutputParser.java
index d90ae1d..abe1805 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/OutputParser.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/OutputParser.java
@@ -19,6 +19,7 @@
*/
package org.apache.airavata.gfac.core.cluster;
+import org.apache.airavata.gfac.core.GFacException;
import org.apache.airavata.gfac.core.SSHApiException;
import org.apache.airavata.model.status.JobStatus;
@@ -31,7 +32,7 @@ public interface OutputParser {
* @param rawOutput
* @return
*/
- public String parseJobSubmission(String rawOutput)throws SSHApiException;
+ public String parseJobSubmission(String rawOutput)throws GFacException;
/**
@@ -47,14 +48,14 @@ public interface OutputParser {
* @param jobID
* @param rawOutput
*/
- public JobStatus parseJobStatus(String jobID, String rawOutput)throws SSHApiException;
+ public JobStatus parseJobStatus(String jobID, String rawOutput)throws GFacException;
/**
* This can be used to parseSingleJob a big output and get multipleJob statuses
* @param statusMap list of status map will return and key will be the job ID
* @param rawOutput
*/
- public void parseJobStatuses(String userName, Map<String, JobStatus> statusMap, String rawOutput)throws SSHApiException;
+ public void parseJobStatuses(String userName, Map<String, JobStatus> statusMap, String rawOutput)throws GFacException;
/**
* filter the jobId value of given JobName from rawOutput
@@ -63,5 +64,5 @@ public interface OutputParser {
* @return
* @throws SSHApiException
*/
- public String parseJobId(String jobName, String rawOutput) throws SSHApiException;
+ public String parseJobId(String jobName, String rawOutput) throws GFacException;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/445e1495/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/RemoteCluster.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/RemoteCluster.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/RemoteCluster.java
index 3916573..9a5c757 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/RemoteCluster.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/RemoteCluster.java
@@ -20,6 +20,7 @@
package org.apache.airavata.gfac.core.cluster;
import com.jcraft.jsch.Session;
+import org.apache.airavata.gfac.core.GFacException;
import org.apache.airavata.gfac.core.SSHApiException;
import org.apache.airavata.gfac.core.authentication.AuthenticationInfo;
import org.apache.airavata.gfac.core.authentication.SSHKeyAuthentication;
@@ -43,7 +44,7 @@ public interface RemoteCluster { // FIXME: replace SSHApiException with suitable
* @return jobId after successful job submission
* @throws SSHApiException throws exception during error
*/
- public JobSubmissionOutput submitBatchJob(String jobScriptFilePath, String workingDirectory) throws SSHApiException;
+ public JobSubmissionOutput submitBatchJob(String jobScriptFilePath, String workingDirectory) throws GFacException;
/**
* This will copy the localFile to remoteFile location in configured cluster
@@ -52,7 +53,7 @@ public interface RemoteCluster { // FIXME: replace SSHApiException with suitable
* @param remoteFile remote file location, this can be a directory too
* @throws SSHApiException throws exception during error
*/
- public void copyTo(String localFile, String remoteFile) throws SSHApiException;
+ public void copyTo(String localFile, String remoteFile) throws GFacException;
/**
* This will copy a remote file in path rFile to local file lFile
@@ -60,7 +61,7 @@ public interface RemoteCluster { // FIXME: replace SSHApiException with suitable
* @param remoteFile remote file path, this has to be a full qualified path
* @param localFile This is the local file to copy, this can be a directory too
*/
- public void copyFrom(String remoteFile, String localFile) throws SSHApiException;
+ public void copyFrom(String remoteFile, String localFile) throws GFacException;
/**
* This wil copy source remote file to target remote file.
@@ -71,7 +72,11 @@ public interface RemoteCluster { // FIXME: replace SSHApiException with suitable
* @param inOrOut direction to file transfer , to the remote cluster(DIRECTION.IN) or from the remote cluster(DIRECTION.OUT)
*
*/
- public void scpThirdParty(String sourceFile, String destinationFile ,Session session , DIRECTION inOrOut, boolean ignoreEmptyFile) throws SSHApiException;
+ public void scpThirdParty(String sourceFile,
+ String destinationFile ,
+ Session session ,
+ DIRECTION inOrOut,
+ boolean ignoreEmptyFile) throws GFacException;
/**
* This will create directories in computing resources
@@ -79,7 +84,7 @@ public interface RemoteCluster { // FIXME: replace SSHApiException with suitable
* @param directoryPath the full qualified path for the directory user wants to create
* @throws SSHApiException throws during error
*/
- public void makeDirectory(String directoryPath) throws SSHApiException;
+ public void makeDirectory(String directoryPath) throws GFacException;
/**
* This will delete the given job from the queue
@@ -88,7 +93,7 @@ public interface RemoteCluster { // FIXME: replace SSHApiException with suitable
* @return return the description of the deleted job
* @throws SSHApiException throws exception during error
*/
- public JobStatus cancelJob(String jobID) throws SSHApiException;
+ public JobStatus cancelJob(String jobID) throws GFacException;
/**
* This will get the job status of the the job associated with this jobId
@@ -97,7 +102,7 @@ public interface RemoteCluster { // FIXME: replace SSHApiException with suitable
* @return job status of the given jobID
* @throws SSHApiException throws exception during error
*/
- public JobStatus getJobStatus(String jobID) throws SSHApiException;
+ public JobStatus getJobStatus(String jobID) throws GFacException;
/**
* This will get the job status of the the job associated with this jobId
@@ -106,7 +111,7 @@ public interface RemoteCluster { // FIXME: replace SSHApiException with suitable
* @return jobId of the given jobName
* @throws SSHApiException throws exception during error
*/
- public String getJobIdByJobName(String jobName, String userName) throws SSHApiException;
+ public String getJobIdByJobName(String jobName, String userName) throws GFacException;
/**
* This method can be used to poll the jobstatuses based on the given
@@ -117,7 +122,7 @@ public interface RemoteCluster { // FIXME: replace SSHApiException with suitable
* @param userName userName of the jobs which required to get the status
* @param jobIDs precises set of jobIDs
*/
- public void getJobStatuses(String userName, Map<String, JobStatus> jobIDs) throws SSHApiException;
+ public void getJobStatuses(String userName, Map<String, JobStatus> jobIDs) throws GFacException;
/**
* This will list directories in computing resources
@@ -125,7 +130,7 @@ public interface RemoteCluster { // FIXME: replace SSHApiException with suitable
* @param directoryPath the full qualified path for the directory user wants to create
* @throws SSHApiException throws during error
*/
- public List<String> listDirectory(String directoryPath) throws SSHApiException;
+ public List<String> listDirectory(String directoryPath) throws GFacException;
/**
* This method can use to execute custom command on remote compute resource.
@@ -133,19 +138,19 @@ public interface RemoteCluster { // FIXME: replace SSHApiException with suitable
* @return <code>true</code> if command successfully executed, <code>false</code> otherwise.
* @throws SSHApiException
*/
- public boolean execute(CommandInfo commandInfo) throws SSHApiException;
+ public boolean execute(CommandInfo commandInfo) throws GFacException;
/**
* This method can be used to get created ssh session
* to reuse the created session.
*/
- public Session getSession() throws SSHApiException;
+ public Session getSession() throws GFacException;
/**
* This method can be used to close the connections initialized
* to handle graceful shutdown of the system
*/
- public void disconnect() throws SSHApiException;
+ public void disconnect() throws GFacException;
/**
* This gives the server Info
http://git-wip-us.apache.org/repos/asf/airavata/blob/445e1495/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/ServerInfo.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/ServerInfo.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/ServerInfo.java
index a606da6..099b63e 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/ServerInfo.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cluster/ServerInfo.java
@@ -23,43 +23,37 @@ package org.apache.airavata.gfac.core.cluster;
* Encapsulate server information.
*/
public class ServerInfo {
-
+ private static int DEFAULT_PORT = 22;
private String host;
private String userName;
- private int port = 22;
+ private int port;
+ private String credentialToken;
- public ServerInfo(String userName, String host) {
- this.userName = userName;
- this.host = host;
+ public ServerInfo(String userName, String host, String credentialToken) {
+ this(userName, host, credentialToken, DEFAULT_PORT);
}
- public ServerInfo(String userName,String host, int port) {
+ public ServerInfo(String userName, String host, String credentialToken, int port) {
this.host = host;
this.userName = userName;
this.port = port;
+ this.credentialToken = credentialToken;
}
public String getHost() {
return host;
}
- public void setHost(String host) {
- this.host = host;
- }
-
public String getUserName() {
return userName;
}
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
public int getPort() {
return port;
}
- public void setPort(int port) {
- this.port = port;
+ public String getCredentialToken() {
+ return credentialToken;
}
+
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/445e1495/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/context/JobExecutionContext.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/context/JobExecutionContext.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/context/JobExecutionContext.java
index c6e4c78..13cb3e3 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/context/JobExecutionContext.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/context/JobExecutionContext.java
@@ -474,7 +474,7 @@
//
//
//
-// public String getLoginUserName() {
+// public String getComputeResourceLoginUserName() {
// return loginUserName;
// }
//
http://git-wip-us.apache.org/repos/asf/airavata/blob/445e1495/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/context/ProcessContext.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/context/ProcessContext.java b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/context/ProcessContext.java
index f875437..97c954e 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/context/ProcessContext.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/context/ProcessContext.java
@@ -20,6 +20,7 @@
package org.apache.airavata.gfac.core.context;
import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.gfac.core.GFacException;
import org.apache.airavata.gfac.core.authentication.SSHKeyAuthentication;
import org.apache.airavata.gfac.core.cluster.RemoteCluster;
import org.apache.airavata.gfac.core.cluster.ServerInfo;
@@ -36,9 +37,11 @@ import org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference;
import org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription;
import org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference;
import org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile;
+import org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference;
import org.apache.airavata.model.data.movement.DataMovementProtocol;
import org.apache.airavata.model.job.JobModel;
import org.apache.airavata.model.process.ProcessModel;
+import org.apache.airavata.model.scheduling.ComputationalResourceSchedulingModel;
import org.apache.airavata.model.status.ProcessState;
import org.apache.airavata.model.status.ProcessStatus;
import org.apache.airavata.model.task.TaskModel;
@@ -73,8 +76,10 @@ public class ProcessContext {
private String localWorkingDir;
private GatewayResourceProfile gatewayResourceProfile;
private ComputeResourcePreference gatewayComputeResourcePreference;
+ private StoragePreference gatewayStorageResourcePreference;
private UserResourceProfile userResourceProfile;
private UserComputeResourcePreference userComputeResourcePreference;
+ private UserStoragePreference userStoragePreference;
private ComputeResourceDescription computeResourceDescription;
private ApplicationDeploymentDescription applicationDeploymentDescription;
private ApplicationInterfaceDescription applicationInterfaceDescription;
@@ -86,7 +91,6 @@ public class ProcessContext {
private JobSubmissionProtocol jobSubmissionProtocol;
private DataMovementProtocol dataMovementProtocol;
private JobModel jobModel;
- private StoragePreference storagePreference;
private StorageResourceDescription storageResource;
private MonitorMode monitorMode;
private ResourceJobManager resourceJobManager;
@@ -109,7 +113,7 @@ public class ProcessContext {
* Note: process context property use lazy loading approach. In runtime you will see some properties as null
* unless you have access it previously. Once that property access using the api,it will be set to correct value.
*/
- public ProcessContext(String processId, String gatewayId, String tokenId) {
+ private ProcessContext(String processId, String gatewayId, String tokenId) {
this.processId = processId;
this.gatewayId = gatewayId;
this.tokenId = tokenId;
@@ -221,6 +225,22 @@ public class ProcessContext {
this.userComputeResourcePreference = userComputeResourcePreference;
}
+ public UserStoragePreference getUserStoragePreference() {
+ return userStoragePreference;
+ }
+
+ public void setUserStoragePreference(UserStoragePreference userStoragePreference) {
+ this.userStoragePreference = userStoragePreference;
+ }
+
+ public StoragePreference getGatewayStorageResourcePreference() {
+ return gatewayStorageResourcePreference;
+ }
+
+ public void setGatewayStorageResourcePreference(StoragePreference gatewayStorageResourcePreference) {
+ this.gatewayStorageResourcePreference = gatewayStorageResourcePreference;
+ }
+
public RemoteCluster getJobSubmissionRemoteCluster() {
return jobSubmissionRemoteCluster;
}
@@ -422,7 +442,7 @@ public class ProcessContext {
}
}
- public String getCredentialToken(){
+ public String getComputeResourceCredentialToken(){
if (isUseUserCRPref() && isValid(userComputeResourcePreference.getResourceSpecificCredentialStoreToken())) {
return userComputeResourcePreference.getResourceSpecificCredentialStoreToken();
} else if (isValid(gatewayComputeResourcePreference.getResourceSpecificCredentialStoreToken())) {
@@ -432,6 +452,14 @@ public class ProcessContext {
}
}
+ public String getStorageResourceCredentialToken(){
+ if (isUseUserCRPref() && isValid(userStoragePreference.getResourceSpecificCredentialStoreToken())) {
+ return userStoragePreference.getResourceSpecificCredentialStoreToken();
+ }else {
+ return gatewayStorageResourcePreference.getResourceSpecificCredentialStoreToken();
+ }
+ }
+
public JobSubmissionProtocol getPreferredJobSubmissionProtocol(){
return gatewayComputeResourcePreference.getPreferredJobSubmissionProtocol();
}
@@ -488,14 +516,6 @@ public class ProcessContext {
return this.cancel || this.handOver;
}
- public void setServerInfo(ServerInfo serverInfo) {
- this.serverInfo = serverInfo;
- }
-
- public ServerInfo getServerInfo() {
- return serverInfo;
- }
-
public String getCurrentExecutingTaskId() {
if (currentExecutingTaskModel != null) {
return currentExecutingTaskModel.getTaskId();
@@ -535,14 +555,6 @@ public class ProcessContext {
this.currentExecutingTaskModel = currentExecutingTaskModel;
}
- public StoragePreference getStoragePreference() {
- return storagePreference;
- }
-
- public void setStoragePreference(StoragePreference storagePreference) {
- this.storagePreference = storagePreference;
- }
-
public StorageResourceDescription getStorageResource() {
return storageResource;
}
@@ -559,14 +571,6 @@ public class ProcessContext {
return acknowledge;
}
- public SSHKeyAuthentication getSshKeyAuthentication() {
- return sshKeyAuthentication;
- }
-
- public void setSshKeyAuthentication(SSHKeyAuthentication sshKeyAuthentication) {
- this.sshKeyAuthentication = sshKeyAuthentication;
- }
-
public boolean isRecoveryWithCancel() {
return recoveryWithCancel;
}
@@ -579,9 +583,9 @@ public class ProcessContext {
return getProcessModel().isUseUserCRPref();
}
- public String getLoginUserName(){
+ public String getComputeResourceLoginUserName(){
if (isUseUserCRPref() && isValid(userComputeResourcePreference.getLoginUserName())) {
- return userComputeResourcePreference.getLoginUserName();
+ return userStoragePreference.getLoginUserName();
} else if (isValid(processModel.getProcessResourceSchedule().getOverrideLoginUserName())) {
return processModel.getProcessResourceSchedule().getOverrideLoginUserName();
} else {
@@ -589,6 +593,50 @@ public class ProcessContext {
}
}
+ public String getStorageResourceLoginUserName(){
+ if (isUseUserCRPref() && isValid(userStoragePreference.getLoginUserName())) {
+ return userStoragePreference.getLoginUserName();
+ } else {
+ return gatewayStorageResourcePreference.getLoginUserName();
+ }
+ }
+
+ public String getStorageFileSystemRootLocation(){
+ if (userStoragePreference != null && isValid(userStoragePreference.getFileSystemRootLocation())) {
+ return userStoragePreference.getFileSystemRootLocation();
+ } else {
+ return gatewayStorageResourcePreference.getFileSystemRootLocation();
+ }
+ }
+
+ public String getStorageResourceId() {
+ if (userStoragePreference != null && isValid(userStoragePreference.getStorageResourceId())) {
+ return userStoragePreference.getStorageResourceId();
+ } else {
+ return gatewayStorageResourcePreference.getStorageResourceId();
+ }
+ }
+
+ private ComputationalResourceSchedulingModel getProcessCRSchedule() {
+ if (getProcessModel() != null) {
+ return getProcessModel().getProcessResourceSchedule();
+ } else {
+ return null;
+ }
+ }
+
+ public ServerInfo getComputeResourceServerInfo(){
+ return new ServerInfo(getComputeResourceLoginUserName(),
+ getComputeResourceDescription().getHostName(),
+ getComputeResourceCredentialToken());
+ }
+
+ public ServerInfo getStorageResourceServerInfo() {
+ return new ServerInfo(getStorageResourceLoginUserName(),
+ getStorageResource().getHostName(),
+ getStorageResourceCredentialToken());
+ }
+
private boolean isValid(String str) {
return str != null && !str.trim().isEmpty();
}
@@ -642,5 +690,116 @@ public class ProcessContext {
return gatewayComputeResourcePreference.getPreferredBatchQueue();
}
}
+
+ public static class ProcessContextBuilder{
+ private final String processId;
+ private final String gatewayId;
+ private final String tokenId;
+ private ExperimentCatalog experimentCatalog;
+ private AppCatalog appCatalog;
+ private CuratorFramework curatorClient;
+ private Publisher statusPublisher;
+ private GatewayResourceProfile gatewayResourceProfile;
+ private ComputeResourcePreference gatewayComputeResourcePreference;
+ private StoragePreference gatewayStorageResourcePreference;
+ private ProcessModel processModel;
+
+ public ProcessContextBuilder(String processId, String gatewayId, String tokenId) throws GFacException {
+ if (notValid(processId) || notValid(gatewayId) || notValid(tokenId)) {
+ throwError("Process Id, Gateway Id and tokenId must be not null");
+ }
+ this.processId = processId;
+ this.gatewayId = gatewayId;
+ this.tokenId = tokenId;
+ }
+
+ public ProcessContextBuilder setGatewayResourceProfile(GatewayResourceProfile gatewayResourceProfile) {
+ this.gatewayResourceProfile = gatewayResourceProfile;
+ return this;
+ }
+
+ public ProcessContextBuilder setGatewayComputeResourcePreference(ComputeResourcePreference gatewayComputeResourcePreference) {
+ this.gatewayComputeResourcePreference = gatewayComputeResourcePreference;
+ return this;
+ }
+
+ public ProcessContextBuilder setGatewayStorageResourcePreference(StoragePreference gatewayStorageResourcePreference) {
+ this.gatewayStorageResourcePreference = gatewayStorageResourcePreference;
+ return this;
+ }
+
+ public ProcessContextBuilder setProcessModel(ProcessModel processModel) {
+ this.processModel = processModel;
+ return this;
+ }
+
+ public ProcessContextBuilder setExperimentCatalog(ExperimentCatalog experimentCatalog) {
+ this.experimentCatalog = experimentCatalog;
+ return this;
+ }
+
+ public ProcessContextBuilder setAppCatalog(AppCatalog appCatalog) {
+ this.appCatalog = appCatalog;
+ return this;
+ }
+
+ public ProcessContextBuilder setCuratorClient(CuratorFramework curatorClient) {
+ this.curatorClient = curatorClient;
+ return this;
+ }
+
+ public ProcessContextBuilder setStatusPublisher(Publisher statusPublisher) {
+ this.statusPublisher = statusPublisher;
+ return this;
+ }
+
+ public ProcessContext build() throws GFacException {
+ if (notValid(gatewayResourceProfile)) {
+ throwError("Invalid GatewayResourceProfile");
+ }
+ if (notValid(gatewayComputeResourcePreference)) {
+ throwError("Invalid Gateway ComputeResourcePreference");
+ }
+ if (notValid(gatewayStorageResourcePreference)) {
+ throwError("Invalid Gateway StoragePreference");
+ }
+ if (notValid(processModel)) {
+ throwError("Invalid Process Model");
+ }
+ if (notValid(appCatalog)) {
+ throwError("Invalid AppCatalog");
+ }
+ if (notValid(experimentCatalog)) {
+ throwError("Invalid Experiment catalog");
+ }
+ if (notValid(curatorClient)) {
+ throwError("Invalid Curator Client");
+ }
+ if (notValid(statusPublisher)) {
+ throwError("Invalid Status Publisher");
+ }
+
+ ProcessContext pc = new ProcessContext(processId, gatewayId, tokenId);
+ pc.setAppCatalog(appCatalog);
+ pc.setExperimentCatalog(experimentCatalog);
+ pc.setCuratorClient(curatorClient);
+ pc.setStatusPublisher(statusPublisher);
+ pc.setProcessModel(processModel);
+ pc.setGatewayResourceProfile(gatewayResourceProfile);
+ pc.setGatewayComputeResourcePreference(gatewayComputeResourcePreference);
+ pc.setGatewayStorageResourcePreference(gatewayStorageResourcePreference);
+
+ return pc;
+ }
+
+ private boolean notValid(Object value) {
+ return value == null;
+ }
+
+ private void throwError(String msg) throws GFacException {
+ throw new GFacException(msg);
+ }
+
+ }
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/445e1495/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/BESRemoteCluster.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/BESRemoteCluster.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/BESRemoteCluster.java
index 3586ee8..7b46b14 100644
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/BESRemoteCluster.java
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/BESRemoteCluster.java
@@ -22,6 +22,7 @@
package org.apache.airavata.gfac.impl;
import com.jcraft.jsch.Session;
+import org.apache.airavata.gfac.core.GFacException;
import org.apache.airavata.gfac.core.JobManagerConfiguration;
import org.apache.airavata.gfac.core.SSHApiException;
import org.apache.airavata.gfac.core.authentication.AuthenticationInfo;
@@ -38,67 +39,67 @@ public class BESRemoteCluster extends AbstractRemoteCluster{
}
@Override
- public JobSubmissionOutput submitBatchJob(String jobScriptFilePath, String workingDirectory) throws SSHApiException {
+ public JobSubmissionOutput submitBatchJob(String jobScriptFilePath, String workingDirectory) throws GFacException {
return null;
}
@Override
- public void copyTo(String localFile, String remoteFile) throws SSHApiException {
+ public void copyTo(String localFile, String remoteFile) throws GFacException {
}
@Override
- public void copyFrom(String remoteFile, String localFile) throws SSHApiException {
+ public void copyFrom(String remoteFile, String localFile) throws GFacException {
}
@Override
- public void scpThirdParty(String sourceFile, String destinationFile, Session session, DIRECTION inOrOut, boolean ignoreEmptyFile) throws SSHApiException {
+ public void scpThirdParty(String sourceFile, String destinationFile, Session session, DIRECTION inOrOut, boolean ignoreEmptyFile) throws GFacException {
}
@Override
- public void makeDirectory(String directoryPath) throws SSHApiException {
+ public void makeDirectory(String directoryPath) throws GFacException {
}
@Override
- public JobStatus cancelJob(String jobID) throws SSHApiException {
+ public JobStatus cancelJob(String jobID) throws GFacException {
return null;
}
@Override
- public JobStatus getJobStatus(String jobID) throws SSHApiException {
+ public JobStatus getJobStatus(String jobID) throws GFacException {
return null;
}
@Override
- public String getJobIdByJobName(String jobName, String userName) throws SSHApiException {
+ public String getJobIdByJobName(String jobName, String userName) throws GFacException {
return null;
}
@Override
- public void getJobStatuses(String userName, Map<String, JobStatus> jobIDs) throws SSHApiException {
+ public void getJobStatuses(String userName, Map<String, JobStatus> jobIDs) throws GFacException {
}
@Override
- public List<String> listDirectory(String directoryPath) throws SSHApiException {
+ public List<String> listDirectory(String directoryPath) throws GFacException {
return null;
}
@Override
- public boolean execute(CommandInfo commandInfo) throws SSHApiException {
+ public boolean execute(CommandInfo commandInfo) throws GFacException {
return false;
}
@Override
- public Session getSession() throws SSHApiException {
+ public Session getSession() throws GFacException {
return null;
}
@Override
- public void disconnect() throws SSHApiException {
+ public void disconnect() throws GFacException {
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/445e1495/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/Factory.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/Factory.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/Factory.java
index 46e220a..11de368 100644
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/Factory.java
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/Factory.java
@@ -33,6 +33,7 @@ import org.apache.airavata.credential.store.credential.Credential;
import org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential;
import org.apache.airavata.credential.store.store.CredentialReader;
import org.apache.airavata.credential.store.store.CredentialStoreException;
+import org.apache.airavata.gfac.core.GFac;
import org.apache.airavata.gfac.core.GFacEngine;
import org.apache.airavata.gfac.core.GFacException;
import org.apache.airavata.gfac.core.GFacUtils;
@@ -66,7 +67,6 @@ import org.apache.airavata.model.appcatalog.computeresource.JobSubmissionProtoco
import org.apache.airavata.model.appcatalog.computeresource.MonitorMode;
import org.apache.airavata.model.appcatalog.computeresource.ResourceJobManager;
import org.apache.airavata.model.appcatalog.computeresource.ResourceJobManagerType;
-import org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference;
import org.apache.airavata.model.data.movement.DataMovementProtocol;
import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory;
import org.apache.airavata.registry.cpi.AppCatalog;
@@ -228,24 +228,30 @@ public abstract class Factory {
String computeResourceId = processContext.getComputeResourceId();
JobSubmissionProtocol jobSubmissionProtocol = processContext.getJobSubmissionProtocol();
- String key = new StringBuilder(processContext.getLoginUserName())
+ String key = new StringBuilder(processContext.getComputeResourceLoginUserName())
.append(':')
.append(jobSubmissionProtocol.name())
.append(':')
- .append(computeResourceId).toString();
+ .append(computeResourceId)
+ .append(':')
+ .append(processContext.getComputeResourceCredentialToken())
+ .toString();
RemoteCluster remoteCluster = remoteClusterMap.get(key);
if (remoteCluster == null) {
JobManagerConfiguration jobManagerConfiguration = getJobManagerConfiguration(processContext.getResourceJobManager());
if (jobSubmissionProtocol == JobSubmissionProtocol.LOCAL ||
jobSubmissionProtocol == JobSubmissionProtocol.LOCAL_FORK) {
- remoteCluster = new LocalRemoteCluster(processContext.getServerInfo(), jobManagerConfiguration, null);
- } else if (jobSubmissionProtocol == JobSubmissionProtocol.SSH ||
+ remoteCluster = new LocalRemoteCluster(processContext.getComputeResourceServerInfo(),
+ jobManagerConfiguration,
+ null);
+ } else if (jobSubmissionProtocol == JobSubmissionProtocol.SSH ||
jobSubmissionProtocol == JobSubmissionProtocol.SSH_FORK
|| jobSubmissionProtocol == JobSubmissionProtocol.CLOUD) {
- remoteCluster = new HPCRemoteCluster(processContext.getServerInfo(), jobManagerConfiguration,
- processContext.getSshKeyAuthentication());
- }else {
+ remoteCluster = new HPCRemoteCluster(processContext.getComputeResourceServerInfo(),
+ jobManagerConfiguration,
+ Factory.getComputerResourceSSHKeyAuthentication(processContext));
+ }else {
throw new GFacException("No remote cluster implementation map to job submission protocol "
+ jobSubmissionProtocol.name());
}
@@ -254,14 +260,15 @@ public abstract class Factory {
AuthenticationInfo authentication = remoteCluster.getAuthentication();
if (authentication instanceof SSHKeyAuthentication){
SSHKeyAuthentication sshKeyAuthentication = (SSHKeyAuthentication)authentication;
- if (!sshKeyAuthentication.getUserName().equals(processContext.getLoginUserName())){
+ if (!sshKeyAuthentication.getUserName().equals(processContext.getComputeResourceLoginUserName())){
JobManagerConfiguration jobManagerConfiguration =
getJobManagerConfiguration(processContext.getResourceJobManager());
if (jobSubmissionProtocol == JobSubmissionProtocol.SSH ||
jobSubmissionProtocol == JobSubmissionProtocol.SSH_FORK) {
- remoteCluster = new HPCRemoteCluster(processContext.getServerInfo(), jobManagerConfiguration,
- processContext.getSshKeyAuthentication());
- }
+ remoteCluster = new HPCRemoteCluster(processContext.getComputeResourceServerInfo(),
+ jobManagerConfiguration,
+ Factory.getComputerResourceSSHKeyAuthentication(processContext));
+ }
}
}
@@ -272,23 +279,28 @@ public abstract class Factory {
public static RemoteCluster getDataMovementRemoteCluster(ProcessContext processContext)
throws GFacException, AiravataException {
- String computeResourceId = processContext.getComputeResourceId();
+ String storageResourceId = processContext.getStorageResourceId();
DataMovementProtocol dataMovementProtocol = processContext.getDataMovementProtocol();
- String key = new StringBuilder(processContext.getLoginUserName())
+ String key = new StringBuilder(processContext.getComputeResourceLoginUserName())
.append(':')
.append(dataMovementProtocol.name())
.append(':')
- .append(computeResourceId).toString();
-
+ .append(storageResourceId)
+ .append(":")
+ .append(processContext.getStorageResourceCredentialToken())
+ .toString();
RemoteCluster remoteCluster = remoteClusterMap.get(key);
if (remoteCluster == null) {
JobManagerConfiguration jobManagerConfiguration = getJobManagerConfiguration(processContext.getResourceJobManager());
if (dataMovementProtocol == DataMovementProtocol.LOCAL) {
- remoteCluster = new LocalRemoteCluster(processContext.getServerInfo(), jobManagerConfiguration, null);
- } else if (dataMovementProtocol == DataMovementProtocol.SCP) {
- remoteCluster = new HPCRemoteCluster(processContext.getServerInfo(), jobManagerConfiguration,
- processContext.getSshKeyAuthentication());
- }else {
+ remoteCluster = new LocalRemoteCluster(processContext.getStorageResourceServerInfo(),
+ jobManagerConfiguration,
+ null);
+ } else if (dataMovementProtocol == DataMovementProtocol.SCP) {
+ remoteCluster = new HPCRemoteCluster(processContext.getStorageResourceServerInfo(),
+ jobManagerConfiguration,
+ Factory.getStorageSSHKeyAuthentication(processContext));
+ }else {
throw new GFacException("No remote cluster implementation map to job data movement protocol "
+ dataMovementProtocol.name());
}
@@ -298,14 +310,15 @@ public abstract class Factory {
AuthenticationInfo authentication = remoteCluster.getAuthentication();
if (authentication instanceof SSHKeyAuthentication){
SSHKeyAuthentication sshKeyAuthentication = (SSHKeyAuthentication)authentication;
- if (!sshKeyAuthentication.getUserName().equals(processContext.getLoginUserName())){
+ if (!sshKeyAuthentication.getUserName().equals(processContext.getStorageResourceLoginUserName())){
JobManagerConfiguration jobManagerConfiguration =
getJobManagerConfiguration(processContext.getResourceJobManager());
dataMovementProtocol = processContext.getDataMovementProtocol();
if (dataMovementProtocol == DataMovementProtocol.SCP) {
- remoteCluster = new HPCRemoteCluster(processContext.getServerInfo(), jobManagerConfiguration,
- processContext.getSshKeyAuthentication());
- }
+ remoteCluster = new HPCRemoteCluster(processContext.getStorageResourceServerInfo(),
+ jobManagerConfiguration,
+ Factory.getStorageSSHKeyAuthentication(processContext));
+ }
}
}
@@ -315,21 +328,19 @@ public abstract class Factory {
public static SSHKeyAuthentication getComputerResourceSSHKeyAuthentication(ProcessContext pc) throws GFacException {
try {
- return getSshKeyAuthentication(pc.getGatewayId(),pc.getLoginUserName(), pc.getCredentialToken());
- } catch (ApplicationSettingsException | IllegalAccessException | InstantiationException | CredentialStoreException e) {
+ return getSshKeyAuthentication(pc.getGatewayId(),
+ pc.getComputeResourceLoginUserName(),
+ pc.getComputeResourceCredentialToken());
+ } catch (ApplicationSettingsException | IllegalAccessException | InstantiationException | CredentialStoreException e) {
throw new GFacException("Couldn't build ssh authentication object", e);
}
}
public static SSHKeyAuthentication getStorageSSHKeyAuthentication(ProcessContext pc) throws GFacException {
try {
- StoragePreference storagePreference = pc.getStoragePreference();
- String loginUserName = storagePreference.getLoginUserName();
- String credentialStoreToken = storagePreference.getResourceSpecificCredentialStoreToken();
- if (credentialStoreToken == null || credentialStoreToken.isEmpty()) {
- credentialStoreToken = pc.getGatewayResourceProfile().getCredentialStoreToken();
- }
- return getSshKeyAuthentication(pc.getGatewayId(), loginUserName, credentialStoreToken);
+ return getSshKeyAuthentication(pc.getGatewayId(),
+ pc.getStorageResourceLoginUserName(),
+ pc.getStorageResourceCredentialToken());
} catch (ApplicationSettingsException | IllegalAccessException | InstantiationException | CredentialStoreException e) {
throw new GFacException("Couldn't build ssh authentication object", e);
}
@@ -452,9 +463,20 @@ public abstract class Factory {
return new CancelRequestWatcherImpl(experimentId, processId);
}
- public static synchronized Session getSSHSession(AuthenticationInfo authenticationInfo, ServerInfo serverInfo) throws AiravataException {
- SSHKeyAuthentication authentication = null;
- String key = serverInfo.getUserName() + "_" + serverInfo.getHost() + "_" + serverInfo.getPort();
+ public static synchronized Session getSSHSession(AuthenticationInfo authenticationInfo,
+ ServerInfo serverInfo) throws GFacException {
+ if (authenticationInfo == null
+ || serverInfo == null) {
+
+ throw new IllegalArgumentException("Can't create ssh session, argument should be valid (not null)");
+ }
+ SSHKeyAuthentication authentication;
+ if (authenticationInfo instanceof SSHKeyAuthentication) {
+ authentication = (SSHKeyAuthentication) authenticationInfo;
+ } else {
+ throw new GFacException("Support ssh key authentication only");
+ }
+ String key = buildKey(serverInfo);
Session session = sessionMap.get(key);
boolean valid = isValidSession(session);
// FIXME - move following info logs to debug
@@ -477,11 +499,7 @@ public abstract class Factory {
log.info("Initialize a new SSH session for :" + key);
}
try {
- if (authenticationInfo instanceof SSHKeyAuthentication) {
- authentication = (SSHKeyAuthentication) authenticationInfo;
- } else {
- throw new AiravataException("Support ssh key authentication only");
- }
+
JSch jSch = new JSch();
jSch.addIdentity(UUID.randomUUID().toString(), authentication.getPrivateKey(), authentication.getPublicKey(),
authentication.getPassphrase().getBytes());
@@ -496,7 +514,7 @@ public abstract class Factory {
session.connect(); // 0 connection timeout
sessionMap.put(key, session);
} catch (JSchException e) {
- throw new AiravataException("JSch initialization error ", e);
+ throw new GFacException("JSch initialization error ", e);
}
} else {
// FIXME - move following info log to debug
@@ -506,6 +524,16 @@ public abstract class Factory {
}
+ private static String buildKey(ServerInfo serverInfo) {
+ return serverInfo.getUserName() +
+ "_" +
+ serverInfo.getHost() +
+ "_" +
+ serverInfo.getPort() +
+ "_" +
+ serverInfo.getCredentialToken();
+ }
+
public static void disconnectSSHSession(ServerInfo serverInfo) {
// TODO - remove session from map and call disconnect
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/445e1495/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacEngineImpl.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacEngineImpl.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacEngineImpl.java
index d94580c..e49d81b 100644
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacEngineImpl.java
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/GFacEngineImpl.java
@@ -43,7 +43,6 @@ import org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDes
import org.apache.airavata.model.appcatalog.computeresource.*;
import org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference;
import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile;
-import org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference;
import org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription;
import org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference;
import org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile;
@@ -84,38 +83,38 @@ public class GFacEngineImpl implements GFacEngine {
tokenId) throws GFacException {
// NOTE: Process context gives precedence to data come with process Computer resources;
- ProcessContext processContext = new ProcessContext(processId, gatewayId, tokenId);
+ ProcessContext processContext = null;
+ ProcessContext.ProcessContextBuilder builder = new ProcessContext.ProcessContextBuilder(processId, gatewayId, tokenId);
try {
AppCatalog appCatalog = Factory.getDefaultAppCatalog();
- processContext.setAppCatalog(appCatalog);
ExperimentCatalog expCatalog = Factory.getDefaultExpCatalog();
- processContext.setExperimentCatalog(expCatalog);
- processContext.setCuratorClient(Factory.getCuratorClient());
- processContext.setStatusPublisher(Factory.getStatusPublisher());
-
ProcessModel processModel = (ProcessModel) expCatalog.get(ExperimentCatalogModelType.PROCESS, processId);
- processContext.setProcessModel(processModel);
-
- try {
- checkRecoveryWithCancel(processContext);
- } catch (Exception e) {
- log.error("expId: {}, processId: {}, Error while checking process cancel data in zookeeper",
- processContext.getExperimentId(), processContext.getProcessId());
- }
+ builder.setAppCatalog(appCatalog)
+ .setExperimentCatalog(expCatalog)
+ .setCuratorClient(Factory.getCuratorClient())
+ .setStatusPublisher(Factory.getStatusPublisher())
+ .setProcessModel(processModel)
+ .setGatewayResourceProfile(appCatalog.getGatewayProfile().getGatewayProfile(gatewayId))
+ .setGatewayComputeResourcePreference(
+ appCatalog.getGatewayProfile()
+ .getComputeResourcePreference(gatewayId, processModel.getComputeResourceId()))
+ .setGatewayStorageResourcePreference(
+ appCatalog.getGatewayProfile()
+ .getStoragePreference(gatewayId, processModel.getStorageResourceId()));
+
+ processContext = builder.build();
+ /* check point */
+ checkpoint(processContext);
- setGatewayResourceProfile(gatewayId, processContext);
- setGatewayComputeResourcePreference(gatewayId, processContext);
if (processModel.isUseUserCRPref()) {
setUserResourceProfile(gatewayId, processContext);
setUserComputeResourcePreference(gatewayId, processContext);
}
- //FIXME: Temporary revert, this needs a proper fix.
-// String scratchLocation = Factory.getScratchLocation(processContext);
String scratchLocation = processContext.getScratchLocation();
- scratchLocation = scratchLocation + File.separator + processId + File.separator;
- StoragePreference storagePreference = appCatalog.getGatewayProfile().getStoragePreference(gatewayId, processModel.getStorageResourceId());
- StorageResourceDescription storageResource = appCatalog.getStorageResource().getStorageResource(processModel.getStorageResourceId());
+ String workingDirectory = scratchLocation + File.separator + processId + File.separator;
+ StorageResourceDescription storageResource = appCatalog.getStorageResource()
+ .getStorageResource(processModel.getStorageResourceId());
if (storageResource != null){
processContext.setStorageResource(storageResource);
}else {
@@ -125,17 +124,6 @@ public class GFacEngineImpl implements GFacEngine {
throw new GFacException("expId: " + processModel.getExperimentId() + ", processId: " + processId +
":- Couldn't find storage resource for storage resource id :" + processModel.getStorageResourceId());
}
- if (storagePreference != null) {
- processContext.setStoragePreference(storagePreference);
- } else {
- // we need to fail the process which will fail the experiment
- processContext.setProcessStatus(new ProcessStatus(ProcessState.FAILED));
- GFacUtils.saveAndPublishProcessStatus(processContext);
- throw new GFacException("expId: " + processModel.getExperimentId() + ", processId: " + processId +
- ":- Couldn't find storage preference for storage resource id :" + processModel.getStorageResourceId());
-
- }
-
/* StorageResourceDescription storageResource = appCatalog.getStorageResource().getStorageResource(processModel.getStorageResourceId());
if (storageResource != null){
@@ -148,24 +136,20 @@ public class GFacEngineImpl implements GFacEngine {
ApplicationInterfaceDescription applicationInterface = appCatalog.getApplicationInterface()
.getApplicationInterface(processModel.getApplicationInterfaceId());
processContext.setApplicationInterfaceDescription(applicationInterface);
- String computeResourceId = processContext.getComputeResourceDescription().getComputeResourceId();
- String hostName = Factory.getDefaultAppCatalog().getComputeResource().getComputeResource(computeResourceId).getHostName();
- ServerInfo serverInfo = new ServerInfo(processContext.getLoginUserName(), hostName);
- processContext.setServerInfo(serverInfo);
List<OutputDataObjectType> applicationOutputs = applicationInterface.getApplicationOutputs();
if (applicationOutputs != null && !applicationOutputs.isEmpty()) {
for (OutputDataObjectType outputDataObjectType : applicationOutputs) {
if (outputDataObjectType.getType().equals(DataType.STDOUT)) {
if (outputDataObjectType.getValue() == null || outputDataObjectType.getValue().equals("")) {
- outputDataObjectType.setValue(scratchLocation + applicationInterface.getApplicationName() + ".stdout");
- processContext.setStdoutLocation(scratchLocation + applicationInterface.getApplicationName() + ".stdout");
+ outputDataObjectType.setValue(workingDirectory + applicationInterface.getApplicationName() + ".stdout");
+ processContext.setStdoutLocation(workingDirectory + applicationInterface.getApplicationName() + ".stdout");
} else {
processContext.setStdoutLocation(outputDataObjectType.getValue());
}
}
if (outputDataObjectType.getType().equals(DataType.STDERR)) {
if (outputDataObjectType.getValue() == null || outputDataObjectType.getValue().equals("")) {
- String stderrLocation = scratchLocation + applicationInterface.getApplicationName() + ".stderr";
+ String stderrLocation = workingDirectory + applicationInterface.getApplicationName() + ".stderr";
outputDataObjectType.setValue(stderrLocation);
processContext.setStderrLocation(stderrLocation);
} else {
@@ -177,7 +161,6 @@ public class GFacEngineImpl implements GFacEngine {
expCatalog.update(ExperimentCatalogModelType.PROCESS, processModel, processId);
processModel.setProcessOutputs(applicationOutputs);
- processContext.setSshKeyAuthentication(Factory.getComputerResourceSSHKeyAuthentication(processContext));
if (processContext.getJobSubmissionProtocol() == JobSubmissionProtocol.UNICORE) {
// process monitor mode set in getResourceJobManager method, but unicore doesn't have resource job manager.
// hence we set process monitor mode here.
@@ -224,18 +207,13 @@ public class GFacEngineImpl implements GFacEngine {
}
- private void setGatewayComputeResourcePreference(String gatewayId, ProcessContext processContext) throws AppCatalogException {
- AppCatalog appCatalog = processContext.getAppCatalog();
- ProcessModel processModel = processContext.getProcessModel();
- ComputeResourcePreference computeResourcePreference =
- appCatalog.getGatewayProfile().getComputeResourcePreference(gatewayId, processModel.getComputeResourceId());
- processContext.setGatewayComputeResourcePreference(computeResourcePreference);
- }
-
- private void setGatewayResourceProfile(String gatewayId, ProcessContext processContext) throws AppCatalogException {
- AppCatalog appCatalog = processContext.getAppCatalog();
- GatewayResourceProfile gatewayProfile = appCatalog.getGatewayProfile().getGatewayProfile(gatewayId);
- processContext.setGatewayResourceProfile(gatewayProfile);
+ private void checkpoint(ProcessContext processContext) {
+ try {
+ checkRecoveryWithCancel(processContext);
+ } catch (Exception e) {
+ log.error("expId: {}, processId: {}, Error while checking process cancel data in zookeeper",
+ processContext.getExperimentId(), processContext.getProcessId());
+ }
}
private void setUserResourceProfile(String gatewayId, ProcessContext processContext) throws AppCatalogException {
@@ -404,7 +382,7 @@ public class GFacEngineImpl implements GFacEngine {
submodel.setType(DataStageType.OUPUT);
submodel.setProcessOutput(output);
URI source = new URI(processContext.getDataMovementProtocol().name(),
- processContext.getLoginUserName(),
+ processContext.getComputeResourceLoginUserName(),
processContext.getComputeResourceDescription().getHostName(),
22,
processContext.getWorkingDir() + output.getValue(), null, null);
@@ -863,7 +841,7 @@ public class GFacEngineImpl implements GFacEngine {
String remoteOutputDir = processContext.getOutputDir();
remoteOutputDir = remoteOutputDir.endsWith("/") ? remoteOutputDir : remoteOutputDir + "/";
DataStagingTaskModel submodel = new DataStagingTaskModel();
- ServerInfo serverInfo = processContext.getServerInfo();
+ ServerInfo serverInfo = processContext.getComputeResourceServerInfo();
URI source = null;
try {
source = new URI(processContext.getDataMovementProtocol().name(), serverInfo.getHost(),
@@ -913,7 +891,10 @@ public class GFacEngineImpl implements GFacEngine {
});
}
- private void updateProcessFailure(ProcessContext pc, String reason){
+ private void updateProcessFailure(ProcessContext pc, String reason) throws GFacException {
+ if (pc == null) {
+ throw new GFacException("Can't update process failure, process context is null");
+ }
ProcessStatus status = new ProcessStatus(ProcessState.FAILED);
status.setReason(reason);
pc.setProcessStatus(status);
@@ -924,7 +905,10 @@ public class GFacEngineImpl implements GFacEngine {
}
}
- private void saveErrorModel(ProcessContext pc, Exception e, String userFriendlyMsg){
+ private void saveErrorModel(ProcessContext pc, Exception e, String userFriendlyMsg) throws GFacException {
+ if(pc == null){
+ throw new GFacException("Can't save error process context is null", e);
+ }
StringWriter errors = new StringWriter();
e.printStackTrace(new PrintWriter(errors));
ErrorModel errorModel = new ErrorModel();
http://git-wip-us.apache.org/repos/asf/airavata/blob/445e1495/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/HPCRemoteCluster.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/HPCRemoteCluster.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/HPCRemoteCluster.java
index 725b6d0..875b229 100644
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/HPCRemoteCluster.java
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/HPCRemoteCluster.java
@@ -26,11 +26,16 @@ import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import com.jcraft.jsch.UserInfo;
import org.apache.airavata.common.exception.AiravataException;
+import org.apache.airavata.gfac.core.GFacException;
import org.apache.airavata.gfac.core.JobManagerConfiguration;
-import org.apache.airavata.gfac.core.SSHApiException;
import org.apache.airavata.gfac.core.authentication.AuthenticationInfo;
import org.apache.airavata.gfac.core.authentication.SSHKeyAuthentication;
-import org.apache.airavata.gfac.core.cluster.*;
+import org.apache.airavata.gfac.core.cluster.AbstractRemoteCluster;
+import org.apache.airavata.gfac.core.cluster.CommandInfo;
+import org.apache.airavata.gfac.core.cluster.CommandOutput;
+import org.apache.airavata.gfac.core.cluster.JobSubmissionOutput;
+import org.apache.airavata.gfac.core.cluster.RawCommandInfo;
+import org.apache.airavata.gfac.core.cluster.ServerInfo;
import org.apache.airavata.model.status.JobStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,7 +58,7 @@ public class HPCRemoteCluster extends AbstractRemoteCluster{
private Session session;
public HPCRemoteCluster(ServerInfo serverInfo, JobManagerConfiguration jobManagerConfiguration, AuthenticationInfo
- authenticationInfo) throws AiravataException {
+ authenticationInfo) throws AiravataException, GFacException {
super(serverInfo, jobManagerConfiguration, authenticationInfo);
try {
if (authenticationInfo instanceof SSHKeyAuthentication) {
@@ -83,7 +88,7 @@ public class HPCRemoteCluster extends AbstractRemoteCluster{
}
@Override
- public JobSubmissionOutput submitBatchJob(String jobScriptFilePath, String workingDirectory) throws SSHApiException {
+ public JobSubmissionOutput submitBatchJob(String jobScriptFilePath, String workingDirectory) throws GFacException {
JobSubmissionOutput jsoutput = new JobSubmissionOutput();
copyTo(jobScriptFilePath, workingDirectory); // scp script file to working directory
RawCommandInfo submitCommand = jobManagerConfiguration.getSubmitCommand(workingDirectory, jobScriptFilePath);
@@ -111,7 +116,7 @@ public class HPCRemoteCluster extends AbstractRemoteCluster{
}
@Override
- public void copyTo(String localFile, String remoteFile) throws SSHApiException {
+ public void copyTo(String localFile, String remoteFile) throws GFacException {
int retry = 3;
while (retry > 0) {
try {
@@ -121,13 +126,9 @@ public class HPCRemoteCluster extends AbstractRemoteCluster{
retry = 0;
} catch (Exception e) {
retry--;
- try {
- session = Factory.getSSHSession(authenticationInfo, serverInfo);
- } catch (AiravataException e1) {
- throw new SSHApiException("JSch Session connection failed", e1);
- }
+ session = Factory.getSSHSession(authenticationInfo, serverInfo);
if (retry == 0) {
- throw new SSHApiException("Failed to scp localhost:" + localFile + " to " + serverInfo.getHost() +
+ throw new GFacException("Failed to scp localhost:" + localFile + " to " + serverInfo.getHost() +
":" + remoteFile, e);
} else {
log.info("Retry transfer localhost:" + localFile + " to " + serverInfo.getHost() + ":" +
@@ -138,7 +139,7 @@ public class HPCRemoteCluster extends AbstractRemoteCluster{
}
@Override
- public void copyFrom(String remoteFile, String localFile) throws SSHApiException {
+ public void copyFrom(String remoteFile, String localFile) throws GFacException {
int retry = 3;
while(retry>0) {
try {
@@ -148,13 +149,9 @@ public class HPCRemoteCluster extends AbstractRemoteCluster{
retry=0;
} catch (Exception e) {
retry--;
- try {
- session = Factory.getSSHSession(authenticationInfo, serverInfo);
- } catch (AiravataException e1) {
- throw new SSHApiException("JSch Session connection failed", e1);
- }
+ session = Factory.getSSHSession(authenticationInfo, serverInfo);
if (retry == 0) {
- throw new SSHApiException("Failed to scp " + serverInfo.getHost() + ":" + remoteFile + " to " +
+ throw new GFacException("Failed to scp " + serverInfo.getHost() + ":" + remoteFile + " to " +
"localhost:" + localFile, e);
} else {
log.info("Retry transfer " + serverInfo.getHost() + ":" + remoteFile + " to localhost:" + localFile);
@@ -164,7 +161,11 @@ public class HPCRemoteCluster extends AbstractRemoteCluster{
}
@Override
- public void scpThirdParty(String sourceFile, String destinationFile, Session clientSession, DIRECTION direction, boolean ignoreEmptyFile) throws SSHApiException {
+ public void scpThirdParty(String sourceFile,
+ String destinationFile,
+ Session clientSession,
+ DIRECTION direction,
+ boolean ignoreEmptyFile) throws GFacException {
int retryCount= 0;
try {
while (retryCount < MAX_RETRY_COUNT) {
@@ -187,14 +188,14 @@ public class HPCRemoteCluster extends AbstractRemoteCluster{
log.error("Issue with jsch, Retry transferring from:" + sourceFile + " To: " + destinationFile, e);
}
}
- } catch (IOException | AiravataException| JSchException e) {
- throw new SSHApiException("Failed scp file:" + sourceFile + " to remote file "
+ } catch (IOException | JSchException e) {
+ throw new GFacException("Failed scp file:" + sourceFile + " to remote file "
+destinationFile , e);
}
}
@Override
- public void makeDirectory(String directoryPath) throws SSHApiException {
+ public void makeDirectory(String directoryPath) throws GFacException {
int retryCount = 0;
try {
while (retryCount < MAX_RETRY_COUNT) {
@@ -214,13 +215,13 @@ public class HPCRemoteCluster extends AbstractRemoteCluster{
log.error("Issue with jsch, Retry creating directory: " + serverInfo.getHost() + ":" + directoryPath);
}
}
- } catch (JSchException | AiravataException | IOException e) {
- throw new SSHApiException("Failed to create directory " + serverInfo.getHost() + ":" + directoryPath, e);
+ } catch (JSchException | IOException e) {
+ throw new GFacException("Failed to create directory " + serverInfo.getHost() + ":" + directoryPath, e);
}
}
@Override
- public JobStatus cancelJob(String jobId) throws SSHApiException {
+ public JobStatus cancelJob(String jobId) throws GFacException {
JobStatus oldStatus = getJobStatus(jobId);
RawCommandInfo cancelCommand = jobManagerConfiguration.getCancelCommand(jobId);
StandardOutReader reader = new StandardOutReader();
@@ -230,7 +231,7 @@ public class HPCRemoteCluster extends AbstractRemoteCluster{
}
@Override
- public JobStatus getJobStatus(String jobId) throws SSHApiException {
+ public JobStatus getJobStatus(String jobId) throws GFacException {
RawCommandInfo monitorCommand = jobManagerConfiguration.getMonitorCommand(jobId);
StandardOutReader reader = new StandardOutReader();
executeCommand(monitorCommand, reader);
@@ -239,7 +240,7 @@ public class HPCRemoteCluster extends AbstractRemoteCluster{
}
@Override
- public String getJobIdByJobName(String jobName, String userName) throws SSHApiException {
+ public String getJobIdByJobName(String jobName, String userName) throws GFacException {
RawCommandInfo jobIdMonitorCommand = jobManagerConfiguration.getJobIdMonitorCommand(jobName, userName);
StandardOutReader reader = new StandardOutReader();
executeCommand(jobIdMonitorCommand, reader);
@@ -248,7 +249,7 @@ public class HPCRemoteCluster extends AbstractRemoteCluster{
}
@Override
- public void getJobStatuses(String userName, Map<String, JobStatus> jobStatusMap) throws SSHApiException {
+ public void getJobStatuses(String userName, Map<String, JobStatus> jobStatusMap) throws GFacException {
RawCommandInfo userBasedMonitorCommand = jobManagerConfiguration.getUserBasedMonitorCommand(userName);
StandardOutReader reader = new StandardOutReader();
executeCommand(userBasedMonitorCommand, reader);
@@ -257,58 +258,55 @@ public class HPCRemoteCluster extends AbstractRemoteCluster{
}
@Override
- public List<String> listDirectory(String directoryPath) throws SSHApiException {
+ public List<String> listDirectory(String directoryPath) throws GFacException {
try {
session = Factory.getSSHSession(authenticationInfo, serverInfo);
log.info("Creating directory: " + serverInfo.getHost() + ":" + directoryPath);
return SSHUtils.listDirectory(directoryPath, session);
- } catch (JSchException | AiravataException | IOException e) {
- throw new SSHApiException("Failed to list directory " + serverInfo.getHost() + ":" + directoryPath, e);
+ } catch (JSchException | IOException e) {
+ throw new GFacException("Failed to list directory " + serverInfo.getHost() + ":" + directoryPath, e);
}
}
@Override
- public boolean execute(CommandInfo commandInfo) throws SSHApiException {
+ public boolean execute(CommandInfo commandInfo) throws GFacException {
StandardOutReader reader = new StandardOutReader();
executeCommand(commandInfo, reader);
return true;
}
@Override
- public Session getSession() throws SSHApiException {
- try {
- return Factory.getSSHSession(authenticationInfo, serverInfo);
- } catch (AiravataException e) {
- throw new SSHApiException("Error!",e);
- }
+ public Session getSession() throws GFacException {
+ return Factory.getSSHSession(authenticationInfo, serverInfo);
}
@Override
- public void disconnect() throws SSHApiException {
+ public void disconnect() throws GFacException {
Factory.disconnectSSHSession(serverInfo);
}
/**
* This method return <code>true</code> if there is an error in standard output. If not return <code>false</code>
- * @param reader - command output reader
+ *
+ * @param reader - command output reader
* @param submitCommand - command which executed in remote machine.
* @return command has return error or not.
*/
- private void throwExceptionOnError(StandardOutReader reader, RawCommandInfo submitCommand) throws SSHApiException{
+ private void throwExceptionOnError(StandardOutReader reader, RawCommandInfo submitCommand) throws GFacException {
String stdErrorString = reader.getStdErrorString();
String command = submitCommand.getCommand().substring(submitCommand.getCommand().lastIndexOf(File.separator)
+ 1);
if (stdErrorString == null) {
// noting to do
- }else if ((stdErrorString.contains(command.trim()) && !stdErrorString.contains("Warning")) || stdErrorString
+ } else if ((stdErrorString.contains(command.trim()) && !stdErrorString.contains("Warning")) || stdErrorString
.contains("error")) {
log.error("Command {} , Standard Error output {}", command, stdErrorString);
- throw new SSHApiException("Error running command " + command + " on remote cluster. StandardError: " +
+ throw new GFacException("Error running command " + command + " on remote cluster. StandardError: " +
stdErrorString);
}
}
- private void executeCommand(CommandInfo commandInfo, CommandOutput commandOutput) throws SSHApiException {
+ private void executeCommand(CommandInfo commandInfo, CommandOutput commandOutput) throws GFacException {
String command = commandInfo.getCommand();
int retryCount = 0;
ChannelExec channelExec = null;
@@ -333,8 +331,8 @@ public class HPCRemoteCluster extends AbstractRemoteCluster{
log.error("Issue with jsch, Retry executing command : " + command, e);
}
}
- } catch (JSchException | AiravataException e) {
- throw new SSHApiException("Unable to execute command - " + command, e);
+ } catch (JSchException e) {
+ throw new GFacException("Unable to execute command - " + command, e);
} finally {
//Only disconnecting the channel, session can be reused
if (channelExec != null) {
http://git-wip-us.apache.org/repos/asf/airavata/blob/445e1495/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/LocalRemoteCluster.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/LocalRemoteCluster.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/LocalRemoteCluster.java
index 9294470..4bf88eb 100644
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/LocalRemoteCluster.java
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/LocalRemoteCluster.java
@@ -23,6 +23,7 @@ package org.apache.airavata.gfac.impl;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import org.apache.airavata.common.exception.AiravataException;
+import org.apache.airavata.gfac.core.GFacException;
import org.apache.airavata.gfac.core.JobManagerConfiguration;
import org.apache.airavata.gfac.core.SSHApiException;
import org.apache.airavata.gfac.core.authentication.AuthenticationInfo;
@@ -56,7 +57,7 @@ public class LocalRemoteCluster extends AbstractRemoteCluster {
}
@Override
- public JobSubmissionOutput submitBatchJob(String jobScriptFilePath, String workingDirectory) throws SSHApiException {
+ public JobSubmissionOutput submitBatchJob(String jobScriptFilePath, String workingDirectory) throws GFacException {
try {
JobSubmissionOutput jsoutput = new JobSubmissionOutput();
copyTo(jobScriptFilePath, workingDirectory + File.separator + new File(jobScriptFilePath).getName()); // scp script file to working directory
@@ -70,36 +71,40 @@ public class LocalRemoteCluster extends AbstractRemoteCluster {
jsoutput.setStdErr(localCommandOutput.getStandardErrorString());
return jsoutput;
} catch (IOException e) {
- throw new SSHApiException("Error while submitting local batch job", e);
+ throw new GFacException("Error while submitting local batch job", e);
}
}
@Override
- public void copyTo(String localFile, String remoteFile) throws SSHApiException {
+ public void copyTo(String localFile, String remoteFile) throws GFacException {
Path sourcePath = Paths.get(localFile);
Path targetPath = Paths.get(remoteFile);
try {
Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
- throw new SSHApiException("Error while copying sourceFile: " + sourcePath.toString()
+ throw new GFacException("Error while copying sourceFile: " + sourcePath.toString()
+ ", to destinationFile: " + targetPath.toString(), e);
}
}
@Override
- public void copyFrom(String remoteFile, String localFile) throws SSHApiException {
+ public void copyFrom(String remoteFile, String localFile) throws GFacException {
Path sourcePath = Paths.get(remoteFile);
Path targetPath = Paths.get(localFile);
try {
Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
- throw new SSHApiException("Error while copying sourceFile: " + sourcePath.toString()
+ throw new GFacException("Error while copying sourceFile: " + sourcePath.toString()
+ ", to destinationFile: " + targetPath.toString(), e);
}
}
@Override
- public void scpThirdParty(String sourceFile, String destinationFile, Session session, DIRECTION inOrOut, boolean ignoreEmptyFile) throws SSHApiException {
+ public void scpThirdParty(String sourceFile,
+ String destinationFile,
+ Session session,
+ DIRECTION inOrOut,
+ boolean ignoreEmptyFile) throws GFacException {
int retryCount= 0;
try {
while (retryCount < MAX_RETRY_COUNT) {
@@ -122,13 +127,13 @@ public class LocalRemoteCluster extends AbstractRemoteCluster {
}
}
} catch (IOException | JSchException e) {
- throw new SSHApiException("Failed scp file:" + sourceFile + " to remote file "
+ throw new GFacException("Failed scp file:" + sourceFile + " to remote file "
+destinationFile , e);
}
}
@Override
- public void makeDirectory(String directoryPath) throws SSHApiException {
+ public void makeDirectory(String directoryPath) throws GFacException {
Path dirPath = Paths.get(directoryPath);
Set<PosixFilePermission> perms = new HashSet<>();
// add permission as rwxr--r-- 744
@@ -141,13 +146,13 @@ public class LocalRemoteCluster extends AbstractRemoteCluster {
try {
Files.createDirectory(dirPath, fileAttributes);
} catch (IOException e) {
- throw new SSHApiException("Error making directory", e);
+ throw new GFacException("Error making directory", e);
}
}
@Override
- public JobStatus cancelJob(String jobID) throws SSHApiException {
+ public JobStatus cancelJob(String jobID) throws GFacException {
JobStatus oldStatus = getJobStatus(jobID);
RawCommandInfo cancelCommand = jobManagerConfiguration.getCancelCommand(jobID);
execute(cancelCommand);
@@ -156,43 +161,43 @@ public class LocalRemoteCluster extends AbstractRemoteCluster {
@Override
- public JobStatus getJobStatus(String jobID) throws SSHApiException {
+ public JobStatus getJobStatus(String jobID) throws GFacException {
RawCommandInfo monitorCommand = jobManagerConfiguration.getMonitorCommand(jobID);
LocalCommandOutput localCommandOutput = new LocalCommandOutput();
try {
executeCommand(monitorCommand, localCommandOutput);
return outputParser.parseJobStatus(jobID, localCommandOutput.getStandardErrorString());
} catch (IOException e) {
- throw new SSHApiException("Error while getting jobStatus", e);
+ throw new GFacException("Error while getting jobStatus", e);
}
}
@Override
- public String getJobIdByJobName(String jobName, String userName) throws SSHApiException {
+ public String getJobIdByJobName(String jobName, String userName) throws GFacException {
try {
RawCommandInfo jobIdMonitorCommand = jobManagerConfiguration.getJobIdMonitorCommand(jobName, userName);
LocalCommandOutput localCommandOutput = new LocalCommandOutput();
executeCommand(jobIdMonitorCommand, localCommandOutput);
return outputParser.parseJobId(jobName, localCommandOutput.getStandardOut());
} catch (IOException e) {
- throw new SSHApiException("Error while getting jobId using JobName", e);
+ throw new GFacException("Error while getting jobId using JobName", e);
}
}
@Override
- public void getJobStatuses(String userName, Map<String, JobStatus> jobStatusMap) throws SSHApiException {
+ public void getJobStatuses(String userName, Map<String, JobStatus> jobStatusMap) throws GFacException {
try {
RawCommandInfo userBasedMonitorCommand = jobManagerConfiguration.getUserBasedMonitorCommand(userName);
LocalCommandOutput localCommandOutput = new LocalCommandOutput();
executeCommand(userBasedMonitorCommand, localCommandOutput);
outputParser.parseJobStatuses(userName, jobStatusMap, localCommandOutput.getStandardOut());
} catch (IOException e) {
- throw new SSHApiException("Error while getting job statuses", e);
+ throw new GFacException("Error while getting job statuses", e);
}
}
@Override
- public List<String> listDirectory(String directoryPath) throws SSHApiException {
+ public List<String> listDirectory(String directoryPath) throws GFacException {
File directory = new File(directoryPath);
List<String> results = new ArrayList<>();
File[] files = directory.listFiles();
@@ -203,12 +208,12 @@ public class LocalRemoteCluster extends AbstractRemoteCluster {
}
@Override
- public boolean execute(CommandInfo commandInfo) throws SSHApiException {
+ public boolean execute(CommandInfo commandInfo) throws GFacException {
LocalCommandOutput localCommandOutput = new LocalCommandOutput();
try {
executeCommand(commandInfo, localCommandOutput);
} catch (IOException e) {
- throw new SSHApiException("Error while executing command " + commandInfo.getCommand(), e);
+ throw new GFacException("Error while executing command " + commandInfo.getCommand(), e);
}
return true;
}
@@ -219,12 +224,12 @@ public class LocalRemoteCluster extends AbstractRemoteCluster {
}
@Override
- public Session getSession() throws SSHApiException {
+ public Session getSession() throws GFacException {
return null;
}
@Override
- public void disconnect() throws SSHApiException {
+ public void disconnect() throws GFacException {
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/445e1495/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/SSHUtils.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/SSHUtils.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/SSHUtils.java
index cd5651e..ace8e1b 100644
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/SSHUtils.java
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/SSHUtils.java
@@ -24,6 +24,7 @@ import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
+import org.apache.airavata.gfac.core.GFacException;
import org.apache.airavata.gfac.core.SSHApiException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -426,7 +427,7 @@ public class SSHUtils {
}
}
- public static void makeDirectory(String path, Session session) throws IOException, JSchException, SSHApiException {
+ public static void makeDirectory(String path, Session session) throws IOException, JSchException, GFacException {
// exec 'scp -t rfile' remotely
String command = "mkdir -p " + path;
@@ -451,14 +452,14 @@ public class SSHUtils {
}
stdOutReader.onOutput(channel);
if (stdOutReader.getStdErrorString().contains("mkdir:")) {
- throw new SSHApiException(stdOutReader.getStdErrorString());
+ throw new GFacException(stdOutReader.getStdErrorString());
}
channel.disconnect();
}
public static List<String> listDirectory(String path, Session session) throws IOException, JSchException,
- SSHApiException {
+ GFacException {
// exec 'scp -t rfile' remotely
String command = "ls " + path;
@@ -476,7 +477,7 @@ public class SSHUtils {
channel.disconnect();
// session.disconnect();
- throw new SSHApiException("Unable to retrieve command output. Command - " + command +
+ throw new GFacException("Unable to retrieve command output. Command - " + command +
" on server - " + session.getHost() + ":" + session.getPort() +
" connecting user name - "
+ session.getUserName(), e);
@@ -484,7 +485,7 @@ public class SSHUtils {
stdOutReader.onOutput(channel);
stdOutReader.getStdOutputString();
if (stdOutReader.getStdErrorString().contains("ls:")) {
- throw new SSHApiException(stdOutReader.getStdErrorString());
+ throw new GFacException(stdOutReader.getStdErrorString());
}
channel.disconnect();
return Arrays.asList(stdOutReader.getStdOutputString().split("\n"));
http://git-wip-us.apache.org/repos/asf/airavata/blob/445e1495/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/ForkOutputParser.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/ForkOutputParser.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/ForkOutputParser.java
index 076bdba..4088c9c 100644
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/ForkOutputParser.java
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/ForkOutputParser.java
@@ -22,6 +22,7 @@
package org.apache.airavata.gfac.impl.job;
import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.gfac.core.GFacException;
import org.apache.airavata.gfac.core.SSHApiException;
import org.apache.airavata.gfac.core.cluster.OutputParser;
import org.apache.airavata.model.status.JobStatus;
@@ -34,7 +35,7 @@ public class ForkOutputParser implements OutputParser {
private static final Logger log = LoggerFactory.getLogger(ForkOutputParser.class);
@Override
- public String parseJobSubmission(String rawOutput) throws SSHApiException {
+ public String parseJobSubmission(String rawOutput) throws GFacException {
return AiravataUtils.getId("JOB_ID_");
}
@@ -44,17 +45,17 @@ public class ForkOutputParser implements OutputParser {
}
@Override
- public JobStatus parseJobStatus(String jobID, String rawOutput) throws SSHApiException {
+ public JobStatus parseJobStatus(String jobID, String rawOutput) throws GFacException {
return null;
}
@Override
- public void parseJobStatuses(String userName, Map<String, JobStatus> statusMap, String rawOutput) throws SSHApiException {
+ public void parseJobStatuses(String userName, Map<String, JobStatus> statusMap, String rawOutput) throws GFacException {
}
@Override
- public String parseJobId(String jobName, String rawOutput) throws SSHApiException {
+ public String parseJobId(String jobName, String rawOutput) throws GFacException {
// For fork jobs there is no job ID, hence airavata generates a job ID
return AiravataUtils.getId(jobName);
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/445e1495/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/LSFOutputParser.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/LSFOutputParser.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/LSFOutputParser.java
index 7c86ffc..66de84e 100644
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/LSFOutputParser.java
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/job/LSFOutputParser.java
@@ -20,6 +20,7 @@
*/
package org.apache.airavata.gfac.impl.job;
+import org.apache.airavata.gfac.core.GFacException;
import org.apache.airavata.gfac.core.SSHApiException;
import org.apache.airavata.gfac.core.cluster.OutputParser;
import org.apache.airavata.model.status.JobState;
@@ -38,7 +39,7 @@ public class LSFOutputParser implements OutputParser {
private final static Logger logger = LoggerFactory.getLogger(LSFOutputParser.class);
@Override
- public String parseJobSubmission(String rawOutput) throws SSHApiException {
+ public String parseJobSubmission(String rawOutput) throws GFacException {
logger.debug(rawOutput);
return rawOutput.substring(rawOutput.indexOf("<")+1,rawOutput.indexOf(">"));
}
@@ -49,7 +50,7 @@ public class LSFOutputParser implements OutputParser {
}
@Override
- public JobStatus parseJobStatus(String jobID, String rawOutput) throws SSHApiException {
+ public JobStatus parseJobStatus(String jobID, String rawOutput) throws GFacException {
boolean jobFount = false;
logger.debug(rawOutput);
//todo this is not used anymore
@@ -57,7 +58,7 @@ public class LSFOutputParser implements OutputParser {
}
@Override
- public void parseJobStatuses(String userName, Map<String, JobStatus> statusMap, String rawOutput) throws SSHApiException {
+ public void parseJobStatuses(String userName, Map<String, JobStatus> statusMap, String rawOutput) throws GFacException {
logger.debug(rawOutput);
String[] info = rawOutput.split("\n");
@@ -93,7 +94,7 @@ public class LSFOutputParser implements OutputParser {
}
@Override
- public String parseJobId(String jobName, String rawOutput) throws SSHApiException {
+ public String parseJobId(String jobName, String rawOutput) throws GFacException {
String regJobId = "jobId";
Pattern pattern = Pattern.compile("(?=(?<" + regJobId + ">\\d+)\\s+\\w+\\s+" + jobName + ")"); // regex - look ahead and match
if (rawOutput != null) {
@@ -121,7 +122,7 @@ public class LSFOutputParser implements OutputParser {
LSFOutputParser lsfOutputParser = new LSFOutputParser();
try {
lsfOutputParser.parseJobStatuses("cjh", statusMap, test1);
- } catch (SSHApiException e) {
+ } catch (GFacException e) {
logger.error(e.getMessage(), e);
}
System.out.println(statusMap.get("2477983,2134490944"));