Updated Branches: refs/heads/master 5dd40195f -> 11191ef46
Fixing test case with orchestrator job - AIRAVATA-1011 Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/c4f80abb Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/c4f80abb Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/c4f80abb Branch: refs/heads/master Commit: c4f80abbd83da9217646adf637a7acdc145c4ed7 Parents: 41da886 Author: lahiru <[email protected]> Authored: Thu Feb 13 10:24:25 2014 -0500 Committer: lahiru <[email protected]> Committed: Thu Feb 13 10:24:25 2014 -0500 ---------------------------------------------------------------------- .../core/utils/OrchestratorConstants.java | 1 + .../core/utils/OrchestratorUtils.java | 5 ++-- .../cpi/impl/SimpleOrchestratorImpl.java | 24 +++++++++++++------- .../orchestrator/core/NewOrchestratorTest.java | 2 ++ 4 files changed, 22 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/c4f80abb/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorConstants.java ---------------------------------------------------------------------- diff --git a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorConstants.java b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorConstants.java index bb242aa..ae22ae5 100644 --- a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorConstants.java +++ b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/utils/OrchestratorConstants.java @@ -35,4 +35,5 @@ public class OrchestratorConstants { public static final String START_SUBMITTER = "start.submitter"; public static final String EMBEDDED_MODE = "embedded.mode"; public static final String ENABLE_VALIDATION = "enable.validation"; + public static final String JOB_VALIDATOR = "job.validator"; } http://git-wip-us.apache.org/repos/asf/airavata/blob/c4f80abb/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 c65f1f4..7ff07e0 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 @@ -56,9 +56,10 @@ public class OrchestratorUtils { orchestratorConfiguration.setStartSubmitter(Boolean.valueOf(orchestratorProps.getProperty(OrchestratorConstants.START_SUBMITTER))); orchestratorConfiguration.setEmbeddedMode(Boolean.valueOf(orchestratorProps.getProperty(OrchestratorConstants.EMBEDDED_MODE))); orchestratorConfiguration.setEnableValidation(Boolean.valueOf(orchestratorProps.getProperty(OrchestratorConstants.ENABLE_VALIDATION))); + if(orchestratorConfiguration.isEnableValidation()){ + orchestratorConfiguration.setValidatorClass((String) orchestratorProps.get(OrchestratorConstants.JOB_VALIDATOR)); + } return orchestratorConfiguration; } - - } http://git-wip-us.apache.org/repos/asf/airavata/blob/c4f80abb/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 5f1aaa0..dbc3c28 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 @@ -26,6 +26,7 @@ import java.util.concurrent.Executors; import org.apache.airavata.common.utils.AiravataJobState; import org.apache.airavata.orchestrator.core.exception.OrchestratorException; import org.apache.airavata.orchestrator.core.job.JobSubmitter; +import org.apache.airavata.orchestrator.core.utils.OrchestratorUtils; import org.apache.airavata.orchestrator.core.validator.JobMetadataValidator; import org.apache.airavata.registry.api.exception.RegistryException; import org.slf4j.Logger; @@ -44,15 +45,20 @@ public class SimpleOrchestratorImpl extends AbstractOrchestrator { public SimpleOrchestratorImpl() throws OrchestratorException { try { - try { + try { String submitterClass = this.orchestratorContext.getOrchestratorConfiguration().getNewJobSubmitterClass(); Class<? extends JobSubmitter> aClass = Class.forName(submitterClass.trim()).asSubclass(JobSubmitter.class); jobSubmitter = aClass.newInstance(); jobSubmitter.initialize(this.orchestratorContext); String validatorClzz = this.orchestratorContext.getOrchestratorConfiguration().getValidatorClass(); - Class<? extends JobMetadataValidator> vClass = Class.forName(validatorClzz.trim()).asSubclass(JobMetadataValidator.class); - jobMetadataValidator = vClass.newInstance(); + if (this.orchestratorConfiguration.isEnableValidation()) { + if (validatorClzz == null) { + logger.error("Job validation class is not properly set, so Validation will be turned off !"); + } + Class<? extends JobMetadataValidator> vClass = Class.forName(validatorClzz.trim()).asSubclass(JobMetadataValidator.class); + jobMetadataValidator = vClass.newInstance(); + } } catch (Exception e) { String error = "Error creating JobSubmitter in non threaded mode "; logger.error(error); @@ -66,17 +72,19 @@ public class SimpleOrchestratorImpl extends AbstractOrchestrator { public boolean launchExperiment(String experimentID) throws OrchestratorException { // we give higher priority to userExperimentID - if (experimentID == null) { - logger.error("Invalid Experiment ID given: " + experimentID); - return false; + if (this.orchestratorConfiguration.isEnableValidation()) { + if(jobMetadataValidator.validate(experimentID)){ + logger.info("validation Successful for the experiment: " + experimentID); + }else { + throw new OrchestratorException("Validation Failed, so Job will not be submitted to GFAC"); + } } try { airavataRegistry.changeStatus(experimentID, AiravataJobState.State.ACCEPTED); if (orchestratorContext.getOrchestratorConfiguration().getThreadPoolSize() == 0) { jobSubmitter.directJobSubmit(experimentID); } - } catch (RegistryException e) - { + } catch (RegistryException e) { //todo put more meaningful error message logger.error("Failed to create experiment for the request from " + experimentID); return false; http://git-wip-us.apache.org/repos/asf/airavata/blob/c4f80abb/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/NewOrchestratorTest.java ---------------------------------------------------------------------- diff --git a/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/NewOrchestratorTest.java b/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/NewOrchestratorTest.java index 8be0059..0bed552 100644 --- a/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/NewOrchestratorTest.java +++ b/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/NewOrchestratorTest.java @@ -34,6 +34,8 @@ import org.apache.airavata.model.experiment.*; import org.apache.airavata.orchestrator.cpi.Orchestrator; import org.apache.airavata.orchestrator.cpi.impl.SimpleOrchestratorImpl; import org.apache.airavata.persistance.registry.jpa.impl.RegistryImpl; +import org.apache.airavata.registry.cpi.ChildDataType; +import org.apache.airavata.registry.cpi.ParentDataType; import org.apache.airavata.registry.cpi.Registry; import org.apache.airavata.schemas.gfac.*; import org.slf4j.Logger;
