airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shame...@apache.org
Subject [1/2] airavata git commit: Check output or input value is valid before do actual file staging
Date Wed, 16 Sep 2015 19:43:31 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 719d1a7eb -> e2132b680


Check output or input value is valid before do actual file staging


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/270ff237
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/270ff237
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/270ff237

Branch: refs/heads/master
Commit: 270ff23782dae07ddb9e417de0d1e33653ebf155
Parents: 3d0dd11
Author: Shameera Rathanyaka <shameerainfo@gmail.com>
Authored: Wed Sep 16 15:41:07 2015 -0400
Committer: Shameera Rathanyaka <shameerainfo@gmail.com>
Committed: Wed Sep 16 15:41:07 2015 -0400

----------------------------------------------------------------------
 .../impl/task/AdvancedSCPDataStageTask.java     | 54 +++++++++++++++-----
 1 file changed, 40 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/270ff237/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 3640455..f94a8ed 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
@@ -42,6 +42,7 @@ import org.apache.airavata.gfac.core.task.Task;
 import org.apache.airavata.gfac.core.task.TaskException;
 import org.apache.airavata.gfac.impl.Factory;
 import org.apache.airavata.gfac.impl.SSHUtils;
+import org.apache.airavata.model.application.io.InputDataObjectType;
 import org.apache.airavata.model.application.io.OutputDataObjectType;
 import org.apache.airavata.model.commons.ErrorModel;
 import org.apache.airavata.model.status.ProcessState;
@@ -63,6 +64,10 @@ import java.net.URISyntaxException;
 import java.util.List;
 import java.util.Map;
 
+/**
+ * This will be used for both Input file staging and output file staging, hence if you do
any changes to a part of logic
+ * in this class please consider that will works with both input and output cases.
+ */
 public class AdvancedSCPDataStageTask implements Task{
 	private static final Logger log = LoggerFactory.getLogger(AdvancedSCPDataStageTask.class);
 	private static final int DEFAULT_SSH_PORT = 22;
@@ -86,15 +91,41 @@ public class AdvancedSCPDataStageTask implements Task{
         TaskStatus status = new TaskStatus(TaskState.CREATED);
         AuthenticationInfo authenticationInfo = null;
         DataStagingTaskModel subTaskModel = null;
-
-		OutputDataObjectType processOutput = taskContext.getProcessOutput();
-		if (processOutput != null && processOutput.getValue() == null) {
-				log.error("expId: {}, processId:{} :- Couldn't stage file {} , file name shouldn't be
null",
-						taskContext.getExperimentId(), taskContext.getProcessId(), processOutput.getName ());
-			status = new TaskStatus(TaskState.FAILED);
-			status.setReason("File name is null");
-			return status;
+		ProcessState processState = taskContext.getParentProcessContext().getProcessState();
+		if (processState == ProcessState.OUTPUT_DATA_STAGING) {
+			OutputDataObjectType processOutput = taskContext.getProcessOutput();
+			if (processOutput != null && processOutput.getValue() == null) {
+				log.error("expId: {}, processId:{}, taskId: {}:- Couldn't stage file {} , file name shouldn't
be null",
+						taskContext.getExperimentId(), taskContext.getProcessId(), taskContext.getTaskId(),
+						processOutput.getName());
+				status = new TaskStatus(TaskState.FAILED);
+				if (processOutput.isIsRequired()) {
+					status.setReason("File name is null, but this output's isRequired bit is not set");
+				} else {
+					status.setReason("File name is null");
+				}
+				return status;
+			}
+		} else if (processState == ProcessState.INPUT_DATA_STAGING) {
+			InputDataObjectType processInput = taskContext.getProcessInput();
+			if (processInput != null && processInput.getValue() == null) {
+				log.error("expId: {}, processId:{}, taskId: {}:- Couldn't stage file {} , file name shouldn't
be null",
+						taskContext.getExperimentId(), taskContext.getProcessId(), taskContext.getTaskId(),
+						processInput.getName());
+				status = new TaskStatus(TaskState.FAILED);
+				if (processInput.isIsRequired()) {
+					status.setReason("File name is null, but this input's isRequired bit is not set");
+				} else {
+					status.setReason("File name is null");
+				}
+				return status;
+			}
+		} else {
+			status.setState(TaskState.FAILED);
+			status.setReason("Invalid task invocation, Support " + ProcessState.INPUT_DATA_STAGING.name()
+ " and " +
+					"" + ProcessState.OUTPUT_DATA_STAGING.name() + " process phases. found " + processState.name());
 		}
+
 		try {
             String tokenId = taskContext.getParentProcessContext().getTokenId();
             CredentialReader credentialReader = GFacUtils.getCredentialReader();
@@ -137,7 +168,6 @@ public class AdvancedSCPDataStageTask implements Task{
 
             ServerInfo serverInfo = new ServerInfo(userName, hostName, DEFAULT_SSH_PORT);
             Session sshSession = Factory.getSSHSession(authenticationInfo, serverInfo);
-            ProcessState processState = taskContext.getParentProcessContext().getProcessState();
 	        URI destinationURI = null;
 	        if (processState == ProcessState.INPUT_DATA_STAGING) {
 		        destinationURI = new URI(subTaskModel.getDestination());
@@ -153,11 +183,7 @@ public class AdvancedSCPDataStageTask implements Task{
 		        // TODO - save updated subtask model with new destination
 		        outputDataStaging(taskContext, sshSession, sourceURI, destinationURI, filePath);
 		        status.setReason("Successfully staged output data");
-	        } else {
-                status.setState(TaskState.FAILED);
-                status.setReason("Invalid task invocation, Support " + ProcessState.INPUT_DATA_STAGING.name()
+ " and " +
-                        "" + ProcessState.OUTPUT_DATA_STAGING.name() + " process phases.
found " + processState.name());
-            }
+	        }
         }  catch (TException e) {
 			String msg = "Couldn't create subTask model thrift model";
 			log.error(msg, e);


Mime
View raw message