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/10/05 21:33:28 UTC
airavata git commit: Local data copy if both source and destination
are same and username aslso the same
Repository: airavata
Updated Branches:
refs/heads/master 0665ee421 -> 9fcd441f1
Local data copy if both source and destination are same and username aslso the same
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/9fcd441f
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/9fcd441f
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/9fcd441f
Branch: refs/heads/master
Commit: 9fcd441f1df055fbe363ef9a172fd01003f45ddc
Parents: 0665ee4
Author: Shameera Rathnayaka <sh...@gmail.com>
Authored: Mon Oct 5 15:33:19 2015 -0400
Committer: Shameera Rathnayaka <sh...@gmail.com>
Committed: Mon Oct 5 15:33:19 2015 -0400
----------------------------------------------------------------------
.../gfac/core/cluster/RemoteCluster.java | 8 +++++++
.../airavata/gfac/impl/HPCRemoteCluster.java | 7 ++++++
.../impl/task/AdvancedSCPDataStageTask.java | 25 +++++++++++++++++---
3 files changed, 37 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/9fcd441f/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 3a03a6a..ad407f9 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
@@ -124,6 +124,14 @@ public interface RemoteCluster { // FIXME: replace SSHApiException with suitable
public List<String> listDirectory(String directoryPath) throws SSHApiException;
/**
+ * This method can use to execute custom command on remote compute resource.
+ * @param commandInfo
+ * @return <code>true</code> if command successfully executed, <code>false</code> otherwise.
+ * @throws SSHApiException
+ */
+ public boolean execute(CommandInfo commandInfo) throws SSHApiException;
+
+ /**
* This method can be used to get created ssh session
* to reuse the created session.
*/
http://git-wip-us.apache.org/repos/asf/airavata/blob/9fcd441f/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 2664d3f..c6274cb 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
@@ -240,6 +240,13 @@ public class HPCRemoteCluster extends AbstractRemoteCluster{
}
@Override
+ public boolean execute(CommandInfo commandInfo) throws SSHApiException {
+ StandardOutReader reader = new StandardOutReader();
+ executeCommand(commandInfo, reader);
+ return true;
+ }
+
+ @Override
public Session getSession() throws SSHApiException {
return session;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/9fcd441f/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/task/AdvancedSCPDataStageTask.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/task/AdvancedSCPDataStageTask.java b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/task/AdvancedSCPDataStageTask.java
index 3220c86..1c72fab 100644
--- a/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/task/AdvancedSCPDataStageTask.java
+++ b/modules/gfac/gfac-impl/src/main/java/org/apache/airavata/gfac/impl/task/AdvancedSCPDataStageTask.java
@@ -36,6 +36,8 @@ 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.authentication.SSHPasswordAuthentication;
+import org.apache.airavata.gfac.core.cluster.CommandInfo;
+import org.apache.airavata.gfac.core.cluster.RawCommandInfo;
import org.apache.airavata.gfac.core.cluster.ServerInfo;
import org.apache.airavata.gfac.core.context.TaskContext;
import org.apache.airavata.gfac.core.task.Task;
@@ -127,6 +129,19 @@ public class AdvancedSCPDataStageTask implements Task{
}
try {
+ // use cp instead of scp if source and destination host and user name is same.
+ URI sourceURI = new URI(subTaskModel.getSource());
+ URI destinationURI = new URI(subTaskModel.getDestination());
+
+ if (sourceURI.getHost().equalsIgnoreCase(destinationURI.getHost())
+ && sourceURI.getUserInfo().equalsIgnoreCase(destinationURI.getUserInfo())) {
+ localDataCopy(taskContext, sourceURI, destinationURI);
+ status.setState(TaskState.COMPLETED);
+ status.setReason("Locally copied file using 'cp' command ");
+ return status;
+ }
+
+
String tokenId = taskContext.getParentProcessContext().getTokenId();
CredentialReader credentialReader = GFacUtils.getCredentialReader();
Credential credential = credentialReader.getCredential(taskContext.getParentProcessContext().getGatewayId(), tokenId);
@@ -153,7 +168,6 @@ public class AdvancedSCPDataStageTask implements Task{
status = new TaskStatus(TaskState.COMPLETED);
subTaskModel = (DataStagingTaskModel) ThriftUtils.getSubTaskModel
(taskContext.getTaskModel());
- URI sourceURI = new URI(subTaskModel.getSource());
File templocalDataDir = GFacUtils.getLocalDataDir(taskContext);
if (!templocalDataDir.exists()) {
@@ -168,9 +182,7 @@ public class AdvancedSCPDataStageTask implements Task{
ServerInfo serverInfo = new ServerInfo(userName, hostName, DEFAULT_SSH_PORT);
Session sshSession = Factory.getSSHSession(authenticationInfo, serverInfo);
- URI destinationURI = null;
if (processState == ProcessState.INPUT_DATA_STAGING) {
- destinationURI = new URI(subTaskModel.getDestination());
inputDataStaging(taskContext, sshSession, sourceURI, destinationURI, filePath);
status.setReason("Successfully staged input data");
}else if (processState == ProcessState.OUTPUT_DATA_STAGING) {
@@ -253,6 +265,13 @@ public class AdvancedSCPDataStageTask implements Task{
return status;
}
+ private void localDataCopy(TaskContext taskContext, URI sourceURI, URI destinationURI) throws SSHApiException {
+ StringBuilder sb = new StringBuilder("rsync -cr ");
+ sb.append(sourceURI.getPath()).append(" ").append(destinationURI.getPath());
+ CommandInfo commandInfo = new RawCommandInfo(sb.toString());
+ taskContext.getParentProcessContext().getRemoteCluster().execute(commandInfo);
+ }
+
private void inputDataStaging(TaskContext taskContext, Session sshSession, URI sourceURI, URI
destinationURI, String filePath) throws SSHApiException, IOException, JSchException {
/**