adding scratch location override - AIRAVATA-1945
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/9b52485f Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/9b52485f Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/9b52485f Branch: refs/heads/master Commit: 9b52485f7261c2241eeeee9e2b740ae95244f4aa Parents: e5ae01e Author: Suresh Marru <[email protected]> Authored: Fri Apr 1 05:30:40 2016 -0400 Committer: Suresh Marru <[email protected]> Committed: Fri Apr 1 05:30:40 2016 -0400 ---------------------------------------------------------------------- .../gfac/core/context/ProcessContext.java | 8 ++++++- .../org/apache/airavata/gfac/impl/Factory.java | 19 +++++++++++++++- .../airavata/gfac/impl/GFacEngineImpl.java | 2 +- .../core/utils/OrchestratorUtils.java | 23 +++++++++++++++++--- .../cpi/impl/SimpleOrchestratorImpl.java | 6 ++--- 5 files changed, 49 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/9b52485f/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 e503bfb..3951216 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 @@ -167,7 +167,13 @@ public class ProcessContext { if (processModel.getResourceSchedule().getStaticWorkingDir() != null){ workingDir = processModel.getResourceSchedule().getStaticWorkingDir(); }else { - String scratchLocation = computeResourcePreference.getScratchLocation(); + String scratchLocation = null; + String overrideScratchLocation = processModel.getResourceSchedule().getOverrideScratchLocation(); + if (overrideScratchLocation != null || !overrideScratchLocation.equals("")) { + scratchLocation = overrideScratchLocation; + } else { + scratchLocation = computeResourcePreference.getScratchLocation(); + } workingDir = (scratchLocation.endsWith("/") ? scratchLocation + processId : scratchLocation + "/" + processId); } http://git-wip-us.apache.org/repos/asf/airavata/blob/9b52485f/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 723eb37..b446e85 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 @@ -319,7 +319,7 @@ public abstract class Factory { ProcessModel processModel = processContext.getProcessModel(); String loginUserName = null; String overrideLoginUserName = processModel.getResourceSchedule().getOverrideLoginUserName(); - if (overrideLoginUserName != null) { + if (overrideLoginUserName != null || !overrideLoginUserName.equals("")) { loginUserName = overrideLoginUserName; } else { loginUserName = processContext.getComputeResourcePreference().getLoginUserName(); @@ -331,6 +331,23 @@ public abstract class Factory { } } + public static String getScratchLocation(ProcessContext processContext) throws GFacException { + try { + ProcessModel processModel = processContext.getProcessModel(); + String scratchLocation = null; + String overrideScratchLocation = processModel.getResourceSchedule().getOverrideScratchLocation(); + if (overrideScratchLocation != null || !overrideScratchLocation.equals("")) { + scratchLocation = overrideScratchLocation; + } else { + scratchLocation = processContext.getComputeResourcePreference().getScratchLocation(); + } + + return scratchLocation; + } catch (Exception e) { + throw new GFacException("Couldn't fetch scratchLocation", e); + } + } + private static SSHKeyAuthentication getSshKeyAuthentication(String gatewayId, String loginUserName, String credentialStoreToken) http://git-wip-us.apache.org/repos/asf/airavata/blob/9b52485f/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 129103b..c588f76 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 @@ -111,7 +111,7 @@ public class GFacEngineImpl implements GFacEngine { processContext.setGatewayResourceProfile(gatewayProfile); ComputeResourcePreference computeResourcePreference = appCatalog.getGatewayProfile().getComputeResourcePreference (gatewayId, processModel.getComputeResourceId()); - String scratchLocation = computeResourcePreference.getScratchLocation(); + String scratchLocation = Factory.getScratchLocation(processContext); scratchLocation = scratchLocation + File.separator + processId + File.separator; processContext.setComputeResourcePreference(computeResourcePreference); StoragePreference storagePreference = appCatalog.getGatewayProfile().getStoragePreference(gatewayId, processModel.getStorageResourceId()); http://git-wip-us.apache.org/repos/asf/airavata/blob/9b52485f/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java ---------------------------------------------------------------------- diff --git a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java index d38a860..be27eb5 100644 --- a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java +++ b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorUtils.java @@ -125,7 +125,7 @@ public class OrchestratorUtils { try { String loginUserName = null; String overrideLoginUserName = processModel.getResourceSchedule().getOverrideLoginUserName(); - if (overrideLoginUserName != null) { + if (overrideLoginUserName != null || !overrideLoginUserName.equals("")) { loginUserName = overrideLoginUserName; } else { GwyResourceProfile gatewayProfile = context.getRegistry().getAppCatalog().getGatewayProfile(); @@ -133,8 +133,25 @@ public class OrchestratorUtils { } return loginUserName; } catch (AppCatalogException e) { - logger.error("Error occurred while initializing app catalog", e); - throw new RegistryException("Error occurred while initializing app catalog", e); + logger.error("Error occurred while initializing app catalog to fetch login username", e); + throw new RegistryException("Error occurred while initializing app catalog to fetch login username", e); + } + } + + public static String getScratchLocation(OrchestratorContext context, ProcessModel processModel, String gatewayId) throws RegistryException { + try { + String scratchLocation = null; + String overrideScratchLocation = processModel.getResourceSchedule().getOverrideScratchLocation(); + if (overrideScratchLocation != null || !overrideScratchLocation.equals("")) { + scratchLocation = overrideScratchLocation; + } else { + GwyResourceProfile gatewayProfile = context.getRegistry().getAppCatalog().getGatewayProfile(); + scratchLocation = gatewayProfile.getComputeResourcePreference(gatewayId, processModel.getComputeResourceId()).getScratchLocation(); + } + return scratchLocation; + } catch (AppCatalogException e) { + logger.error("Error occurred while initializing app catalog to fetch scratch location", e); + throw new RegistryException("Error occurred while initializing app catalog to fetch scratch location", e); } } http://git-wip-us.apache.org/repos/asf/airavata/blob/9b52485f/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/cpi/impl/SimpleOrchestratorImpl.java ---------------------------------------------------------------------- diff --git a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/cpi/impl/SimpleOrchestratorImpl.java b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/cpi/impl/SimpleOrchestratorImpl.java index 116b5f8..4489ef0 100644 --- a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/cpi/impl/SimpleOrchestratorImpl.java +++ b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/cpi/impl/SimpleOrchestratorImpl.java @@ -352,7 +352,7 @@ public class SimpleOrchestratorImpl extends AbstractOrchestrator{ EnvironmentSetupTaskModel envSetupSubModel = new EnvironmentSetupTaskModel(); envSetupSubModel.setProtocol(OrchestratorUtils.getSecurityProtocol(orchestratorContext, processModel, gatewayId)); ComputeResourcePreference computeResourcePreference = OrchestratorUtils.getComputeResourcePreference(orchestratorContext, processModel, gatewayId); - String scratchLocation = computeResourcePreference.getScratchLocation(); + String scratchLocation = OrchestratorUtils.getScratchLocation(orchestratorContext,processModel, gatewayId); String workingDir = scratchLocation + File.separator + processModel.getProcessId(); envSetupSubModel.setLocation(workingDir); byte[] envSetupSub = ThriftUtils.serializeThriftObject(envSetupSubModel); @@ -543,7 +543,7 @@ public class SimpleOrchestratorImpl extends AbstractOrchestrator{ DataStagingTaskModel submodel = new DataStagingTaskModel(); ComputeResourcePreference computeResourcePreference = OrchestratorUtils.getComputeResourcePreference(orchestratorContext, processModel, gatewayId); ComputeResourceDescription computeResource = orchestratorContext.getRegistry().getAppCatalog().getComputeResource().getComputeResource(processModel.getComputeResourceId()); - String remoteOutputDir = computeResourcePreference.getScratchLocation() + File.separator + processModel.getProcessId(); + String remoteOutputDir = OrchestratorUtils.getScratchLocation(orchestratorContext,processModel, gatewayId) + File.separator + processModel.getProcessId(); remoteOutputDir = remoteOutputDir.endsWith("/") ? remoteOutputDir : remoteOutputDir + "/"; URI destination = null; try { @@ -580,7 +580,7 @@ public class SimpleOrchestratorImpl extends AbstractOrchestrator{ ComputeResourcePreference computeResourcePreference = OrchestratorUtils.getComputeResourcePreference(orchestratorContext, processModel, gatewayId); ComputeResourceDescription computeResource = orchestratorContext.getRegistry().getAppCatalog().getComputeResource().getComputeResource(processModel.getComputeResourceId()); - String remoteOutputDir = computeResourcePreference.getScratchLocation() + File.separator + processModel.getProcessId(); + String remoteOutputDir = OrchestratorUtils.getScratchLocation(orchestratorContext,processModel, gatewayId) + File.separator + processModel.getProcessId(); remoteOutputDir = remoteOutputDir.endsWith("/") ? remoteOutputDir : remoteOutputDir + "/"; DataStagingTaskModel submodel = new DataStagingTaskModel(); DataMovementProtocol dataMovementProtocol = OrchestratorUtils.getPreferredDataMovementProtocol(orchestratorContext, processModel, gatewayId);
