Return-Path: X-Original-To: apmail-airavata-commits-archive@www.apache.org Delivered-To: apmail-airavata-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 30B2310A6B for ; Thu, 13 Feb 2014 16:01:44 +0000 (UTC) Received: (qmail 81195 invoked by uid 500); 13 Feb 2014 16:01:43 -0000 Delivered-To: apmail-airavata-commits-archive@airavata.apache.org Received: (qmail 81086 invoked by uid 500); 13 Feb 2014 16:01:41 -0000 Mailing-List: contact commits-help@airavata.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airavata.apache.org Delivered-To: mailing list commits@airavata.apache.org Received: (qmail 81048 invoked by uid 99); 13 Feb 2014 16:01:37 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Feb 2014 16:01:37 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id DA1B3925CA2; Thu, 13 Feb 2014 16:01:36 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: lahiru@apache.org To: commits@airavata.apache.org Date: Thu, 13 Feb 2014 16:01:36 -0000 Message-Id: <3fe836604349408382964a1c4fc7cf5a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/3] git commit: Fixing test case with orchestrator job - AIRAVATA-1011 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 Authored: Thu Feb 13 10:24:25 2014 -0500 Committer: lahiru 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 aClass = Class.forName(submitterClass.trim()).asSubclass(JobSubmitter.class); jobSubmitter = aClass.newInstance(); jobSubmitter.initialize(this.orchestratorContext); String validatorClzz = this.orchestratorContext.getOrchestratorConfiguration().getValidatorClass(); - Class 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 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;