Improving exception handling of SCPDataStageTask
@@ -59,6 +59,7 @@ import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
/**
* This will be used for both Input file staging and output file staging, hence if you do any changes to a part of logic
@@ -129,7 +130,10 @@ public class SCPDataStageTask implements Task {
} else {
throw new GFacException("Storage Resource is null");
}
- String inputPath = processContext.getStorageFileSystemRootLocation();
+
+ String inputPath = Optional.ofNullable(processContext.getStorageFileSystemRootLocation())
+ .orElseThrow(() -> new GFacException("Input path can not be null"));
+
inputPath = (inputPath.endsWith(File.separator) ? inputPath : inputPath + File.separator);
// use rsync instead of scp if source and destination host and user name is same.
@@ -290,6 +294,15 @@ public class SCPDataStageTask implements Task {
errorModel.setActualErrorMessage(e.getMessage());
errorModel.setUserFriendlyMessage(msg);
taskContext.getTaskModel().setTaskErrors(Arrays.asList(errorModel));
+ } catch (Exception e) {
+ String msg = "Unknown exception occurred while data staging";
+ log.error(msg, e);
+ status.setState(TaskState.FAILED);
+ status.setReason(msg);
+ ErrorModel errorModel = new ErrorModel();
+ errorModel.setActualErrorMessage(e.getMessage());
+ errorModel.setUserFriendlyMessage(msg);
+ taskContext.getTaskModel().setTaskErrors(Arrays.asList(errorModel));
}finally {
if (registryClient != null) {
ThriftUtils.close(registryClient);
@@ -322,8 +335,12 @@ public class SCPDataStageTask implements Task {
*/
//Wildcard file path has not been resolved and cannot be handled. Hence ignoring
if(!destinationURI.toString().contains("*")){
+ log.info("SCP " + taskContext.getTaskId() + " step31");
+
taskContext.getParentProcessContext().getDataMovementRemoteCluster().scpThirdParty(sourceURI.getPath(), srcSession,
destinationURI.getPath(), destSession, RemoteCluster.DIRECTION.TO, true);
+ log.info("SCP " + taskContext.getTaskId() + " step32");
+
// update output locations
GFacUtils.saveExperimentOutput(taskContext.getParentProcessContext(), registryClient, taskContext.getProcessOutput().getName(), destinationURI.toString());
GFacUtils.saveProcessOutput(taskContext.getParentProcessContext(), registryClient, taskContext.getProcessOutput().getName(), destinationURI.toString());
