airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject [1/2] git commit: adding a result object for validation
Date Wed, 14 May 2014 16:12:34 GMT
Repository: airavata
Updated Branches:
  refs/heads/master 71477800f -> d76c9d57f


adding a result object for validation


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

Branch: refs/heads/master
Commit: f05dd0fb7305aae98c47e427a9926f85e3c3e882
Parents: a5e6967
Author: lahiru <lahiru@apache.org>
Authored: Wed May 14 12:11:42 2014 -0400
Committer: lahiru <lahiru@apache.org>
Committed: Wed May 14 12:11:42 2014 -0400

----------------------------------------------------------------------
 .../main/resources/airavata-server.properties   |  2 +-
 .../apache/airavata/gfac/core/cpi/GFacImpl.java |  3 +-
 .../SingleAppIntegrationTestBase.java           |  2 +
 .../src/test/resources/orchestrator.properties  |  2 +-
 .../core/utils/OrchestratorConstants.java       |  2 +-
 .../core/validator/JobMetadataValidator.java    |  2 +-
 .../core/validator/ValidatorResult.java         | 54 ++++++++++++++++++++
 .../validator/impl/SimpleAppDataValidator.java  |  5 +-
 .../cpi/impl/SimpleOrchestratorImpl.java        | 23 +++++++--
 .../orchestrator/core/ValidatorTest.java        |  3 +-
 .../orchestrator/core/util/SecondValidator.java |  7 +--
 .../orchestrator/core/util/TestValidator.java   |  9 ++--
 12 files changed, 94 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/f05dd0fb/modules/configuration/server/src/main/resources/airavata-server.properties
----------------------------------------------------------------------
diff --git a/modules/configuration/server/src/main/resources/airavata-server.properties b/modules/configuration/server/src/main/resources/airavata-server.properties
index 8165f93..fb49955 100644
--- a/modules/configuration/server/src/main/resources/airavata-server.properties
+++ b/modules/configuration/server/src/main/resources/airavata-server.properties
@@ -266,7 +266,7 @@ activity.listeners=org.apache.airavata.gfac.core.monitor.AiravataJobStatusUpdato
 
 ###---------------------------Orchestrator module Configurations---------------------------###
 job.submitter=org.apache.airavata.orchestrator.core.impl.EmbeddedGFACJobSubmitter
-job.validator=org.apache.airavata.orchestrator.core.validator.impl.SimpleAppDataValidator
+job.validators=org.apache.airavata.orchestrator.core.validator.impl.SimpleAppDataValidator
 submitter.interval=10000
 threadpool.size=10
 start.submitter=true

http://git-wip-us.apache.org/repos/asf/airavata/blob/f05dd0fb/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/GFacImpl.java
----------------------------------------------------------------------
diff --git a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/GFacImpl.java
b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/GFacImpl.java
index ef988b0..ddcf775 100644
--- a/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/GFacImpl.java
+++ b/modules/gfac/gfac-core/src/main/java/org/apache/airavata/gfac/core/cpi/GFacImpl.java
@@ -115,7 +115,8 @@ public class GFacImpl implements GFac {
                 Class<? extends AbstractActivityListener> aClass = Class.forName(listenerClass).asSubclass(AbstractActivityListener.class);
                 AbstractActivityListener abstractActivityListener = aClass.newInstance();
                 activityListeners.add(abstractActivityListener);
-                abstractActivityListener.setup(getMonitorPublisher(),registry);
+                abstractActivityListener.setup(getMonitorPublisher(), registry);
+                log.info("Registering listener: " + listenerClass);
                 getMonitorPublisher().registerListener(abstractActivityListener);
             }
         }catch (ClassNotFoundException e) {

http://git-wip-us.apache.org/repos/asf/airavata/blob/f05dd0fb/modules/integration-tests/src/test/java/org/apache/airavata/integration/SingleAppIntegrationTestBase.java
----------------------------------------------------------------------
diff --git a/modules/integration-tests/src/test/java/org/apache/airavata/integration/SingleAppIntegrationTestBase.java
b/modules/integration-tests/src/test/java/org/apache/airavata/integration/SingleAppIntegrationTestBase.java
index b5f8057..76e8e96 100644
--- a/modules/integration-tests/src/test/java/org/apache/airavata/integration/SingleAppIntegrationTestBase.java
+++ b/modules/integration-tests/src/test/java/org/apache/airavata/integration/SingleAppIntegrationTestBase.java
@@ -29,6 +29,7 @@ import org.apache.airavata.model.workspace.experiment.Experiment;
 import org.apache.airavata.model.workspace.experiment.ExperimentState;
 import org.apache.airavata.model.workspace.experiment.ExperimentStatus;
 import org.apache.thrift.TException;
+import org.junit.Assert;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -66,6 +67,7 @@ public class SingleAppIntegrationTestBase extends AbstractIntegrationTest
{
                         log.error("Thread interrupted", e.getMessage());
                     }
                     System.out.println(experimentStatus.getExperimentState().toString());
+                    Assert.assertFalse(experimentStatus.getExperimentState().equals(ExperimentState.FAILED));
                 }while(!experimentStatus.getExperimentState().equals(ExperimentState.COMPLETED));
             }
         });

http://git-wip-us.apache.org/repos/asf/airavata/blob/f05dd0fb/modules/orchestrator/airavata-orchestrator-service/src/test/resources/orchestrator.properties
----------------------------------------------------------------------
diff --git a/modules/orchestrator/airavata-orchestrator-service/src/test/resources/orchestrator.properties
b/modules/orchestrator/airavata-orchestrator-service/src/test/resources/orchestrator.properties
index a1c34e6..5ebfe4f 100644
--- a/modules/orchestrator/airavata-orchestrator-service/src/test/resources/orchestrator.properties
+++ b/modules/orchestrator/airavata-orchestrator-service/src/test/resources/orchestrator.properties
@@ -18,7 +18,7 @@
 # under the License.
 #
 job.submitter=org.apache.airavata.orchestrator.core.impl.EmbeddedGFACJobSubmitter
-job.validator=org.apache.airavata.orchestrator.core.validator.impl.SimpleAppDataValidator
+job.validators=org.apache.airavata.orchestrator.core.validator.impl.SimpleAppDataValidator
 submitter.interval=10000
 threadpool.size=0
 start.submitter=true

http://git-wip-us.apache.org/repos/asf/airavata/blob/f05dd0fb/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 ade141a..0e0e425 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
@@ -34,5 +34,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";
+    public static final String JOB_VALIDATOR = "job.validators";
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/f05dd0fb/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/validator/JobMetadataValidator.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/validator/JobMetadataValidator.java
b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/validator/JobMetadataValidator.java
index 1c4eaba..9f57885 100644
--- a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/validator/JobMetadataValidator.java
+++ b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/validator/JobMetadataValidator.java
@@ -27,5 +27,5 @@ import org.apache.airavata.orchestrator.core.exception.OrchestratorException;
 
 public interface JobMetadataValidator {
 
-    boolean validate(Experiment experiment, WorkflowNodeDetails workflowNodeDetail, TaskDetails
taskID) throws OrchestratorException;
+    ValidatorResult validate(Experiment experiment, WorkflowNodeDetails workflowNodeDetail,
TaskDetails taskID) throws OrchestratorException;
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/f05dd0fb/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/validator/ValidatorResult.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/validator/ValidatorResult.java
b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/validator/ValidatorResult.java
new file mode 100644
index 0000000..3202d75
--- /dev/null
+++ b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/validator/ValidatorResult.java
@@ -0,0 +1,54 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.orchestrator.core.validator;
+
+public class ValidatorResult {
+    private boolean isSuccessful;
+
+    private String validationMessage;
+
+
+    public ValidatorResult(boolean successful) {
+        isSuccessful = successful;
+    }
+
+    public ValidatorResult(boolean successful, String validationMessage) {
+        isSuccessful = successful;
+        this.validationMessage = validationMessage;
+    }
+
+    public boolean isSuccessful() {
+        return isSuccessful;
+    }
+
+    public void setValidationMessage(String validationMessage) {
+        this.validationMessage = validationMessage;
+    }
+
+    public String getValidationMessage() {
+
+        return validationMessage;
+    }
+
+    public void setSuccessful(boolean successful) {
+        isSuccessful = successful;
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/f05dd0fb/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/validator/impl/SimpleAppDataValidator.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/validator/impl/SimpleAppDataValidator.java
b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/validator/impl/SimpleAppDataValidator.java
index a756a0a..6fbbce7 100644
--- a/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/validator/impl/SimpleAppDataValidator.java
+++ b/modules/orchestrator/orchestrator-core/src/main/java/org/apache/airavata/orchestrator/core/validator/impl/SimpleAppDataValidator.java
@@ -25,6 +25,7 @@ import org.apache.airavata.model.workspace.experiment.TaskDetails;
 import org.apache.airavata.model.workspace.experiment.WorkflowNodeDetails;
 import org.apache.airavata.orchestrator.core.exception.OrchestratorException;
 import org.apache.airavata.orchestrator.core.validator.JobMetadataValidator;
+import org.apache.airavata.orchestrator.core.validator.ValidatorResult;
 import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory;
 import org.apache.airavata.registry.cpi.Registry;
 import org.slf4j.Logger;
@@ -39,11 +40,11 @@ public class SimpleAppDataValidator implements JobMetadataValidator {
         this.registry = RegistryFactory.getDefaultRegistry();
     }
 
-    public boolean validate(Experiment experiment, WorkflowNodeDetails workflowNodeDetail,
TaskDetails taskID) throws OrchestratorException {
+    public ValidatorResult validate(Experiment experiment, WorkflowNodeDetails workflowNodeDetail,
TaskDetails taskID) throws OrchestratorException {
         boolean result = false;
         if (experiment.getUserConfigurationData().isAiravataAutoSchedule()) {
             logger.error("We dont' support auto scheduling at this point, We will simply
use user data as it is");
         }
-        return true;
+        return new ValidatorResult(true);
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/f05dd0fb/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 08df639..9a6dc5d 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
@@ -33,6 +33,7 @@ import org.apache.airavata.model.workspace.experiment.WorkflowNodeDetails;
 import org.apache.airavata.orchestrator.core.exception.OrchestratorException;
 import org.apache.airavata.orchestrator.core.job.JobSubmitter;
 import org.apache.airavata.orchestrator.core.validator.JobMetadataValidator;
+import org.apache.airavata.orchestrator.core.validator.ValidatorResult;
 import org.apache.airavata.registry.cpi.ChildDataType;
 import org.apache.airavata.registry.cpi.RegistryModelType;
 import org.apache.airavata.registry.cpi.Registry;
@@ -116,27 +117,39 @@ public class SimpleOrchestratorImpl extends AbstractOrchestrator{
     public boolean validateExperiment(Experiment experiment, WorkflowNodeDetails workflowNodeDetail,
TaskDetails taskID) throws OrchestratorException {
         if (this.orchestratorConfiguration.isEnableValidation()) {
             List<String> validatorClzzez = this.orchestratorContext.getOrchestratorConfiguration().getValidatorClasses();
+            ValidatorResult[] resultArray = new ValidatorResult[validatorClzzez.size()];
+            int index = 0;
             for (String validator : validatorClzzez) {
                 try {
                     Class<? extends JobMetadataValidator> vClass = Class.forName(validator.trim()).asSubclass(JobMetadataValidator.class);
                     JobMetadataValidator jobMetadataValidator = vClass.newInstance();
-                    if(jobMetadataValidator.validate(experiment, workflowNodeDetail, taskID)){
+                    resultArray[index] = jobMetadataValidator.validate(experiment, workflowNodeDetail,
taskID);
+                    if(resultArray[index].isSuccessful()){
                         logger.info("Validation of " + validator + " is SUCCESSFUL");
                     }else {
-                        logger.error("Validation of " + validator + " is FAILED");
-                        return false;
+                        logger.error("Validation of " + validator + " is FAILED:[error]"
+ resultArray[index].getValidationMessage());
+                        //todo we need to store this message to registry
+                        // we do not return immediately after the first failure
                     }
                 } catch (ClassNotFoundException e) {
                     logger.error("Error loading the validation class: ", validator, e);
-                    return false;
+                    resultArray[index] = new ValidatorResult(false, "Error loading the validation
class: " + e.getMessage());
                 } catch (InstantiationException e) {
                    logger.error("Error loading the validation class: ", validator, e);
-                    return false;
+                   resultArray[index] = new ValidatorResult(false, "Error loading the validation
class: " + e.getMessage());
                 } catch (IllegalAccessException e) {
                    logger.error("Error loading the validation class: ", validator, e);
+                   resultArray[index] = new ValidatorResult(false, "Error loading the validation
class: " + e.getMessage());
+                }
+                index++;
+            }
+            // we check whether validation was successful or not
+            for(ValidatorResult result:resultArray){
+                if(!result.isSuccessful()){
                     return false;
                 }
             }
+
         }
         return true;
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/f05dd0fb/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/ValidatorTest.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/ValidatorTest.java
b/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/ValidatorTest.java
index d4b86b1..5124198 100644
--- a/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/ValidatorTest.java
+++ b/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/ValidatorTest.java
@@ -23,6 +23,7 @@ package org.apache.airavata.orchestrator.core;
 import org.apache.airavata.common.utils.AiravataUtils;
 import org.apache.airavata.model.util.ExperimentModelUtil;
 import org.apache.airavata.model.workspace.experiment.*;
+import org.apache.airavata.orchestrator.core.utils.OrchestratorConstants;
 import org.apache.airavata.orchestrator.cpi.Orchestrator;
 import org.apache.airavata.orchestrator.cpi.impl.SimpleOrchestratorImpl;
 import org.apache.airavata.persistance.registry.jpa.impl.RegistryFactory;
@@ -47,7 +48,7 @@ public class ValidatorTest extends BaseOrchestratorTest {
     public void setUp() throws Exception {
         AiravataUtils.setExecutionAsServer();
         super.setUp();
-        System.setProperty("job.validator","org.apache.airavata.orchestrator.core.util.TestValidator,org.apache.airavata.orchestrator.core.util.SecondValidator");
+        System.setProperty(OrchestratorConstants.JOB_VALIDATOR,"org.apache.airavata.orchestrator.core.util.TestValidator,org.apache.airavata.orchestrator.core.util.SecondValidator");
         System.setProperty("enable.validation", "true");
         orchestrator = new SimpleOrchestratorImpl();
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/f05dd0fb/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/util/SecondValidator.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/util/SecondValidator.java
b/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/util/SecondValidator.java
index 8e76c2e..2eb438b 100644
--- a/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/util/SecondValidator.java
+++ b/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/util/SecondValidator.java
@@ -25,12 +25,13 @@ import org.apache.airavata.model.workspace.experiment.TaskDetails;
 import org.apache.airavata.model.workspace.experiment.WorkflowNodeDetails;
 import org.apache.airavata.orchestrator.core.exception.OrchestratorException;
 import org.apache.airavata.orchestrator.core.validator.JobMetadataValidator;
+import org.apache.airavata.orchestrator.core.validator.ValidatorResult;
 
 public class SecondValidator implements JobMetadataValidator {
-    public boolean validate(Experiment experiment, WorkflowNodeDetails workflowNodeDetail,
TaskDetails taskID) throws OrchestratorException {
+    public ValidatorResult validate(Experiment experiment, WorkflowNodeDetails workflowNodeDetail,
TaskDetails taskID) throws OrchestratorException {
         if(taskID.getTaskID() == null){
-            return false;
+            return new ValidatorResult(false,"No taskID is set, so Validation failed");
         }
-        return true;
+        return new ValidatorResult(true);
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/f05dd0fb/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/util/TestValidator.java
----------------------------------------------------------------------
diff --git a/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/util/TestValidator.java
b/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/util/TestValidator.java
index b92538c..0928b2f 100644
--- a/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/util/TestValidator.java
+++ b/modules/orchestrator/orchestrator-core/src/test/java/org/apache/airavata/orchestrator/core/util/TestValidator.java
@@ -25,20 +25,21 @@ import org.apache.airavata.model.workspace.experiment.TaskDetails;
 import org.apache.airavata.model.workspace.experiment.WorkflowNodeDetails;
 import org.apache.airavata.orchestrator.core.exception.OrchestratorException;
 import org.apache.airavata.orchestrator.core.validator.JobMetadataValidator;
+import org.apache.airavata.orchestrator.core.validator.ValidatorResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class TestValidator implements JobMetadataValidator {
     private final static Logger logger = LoggerFactory.getLogger(TestValidator.class);
 
-    public boolean validate(Experiment experiment, WorkflowNodeDetails workflowNodeDetail,
TaskDetails taskID) throws OrchestratorException {
+    public ValidatorResult validate(Experiment experiment, WorkflowNodeDetails workflowNodeDetail,
TaskDetails taskID) throws OrchestratorException {
         if (experiment.getProjectID() == null) {
             logger.error("Project ID is not set");
-            return false;
+            return new ValidatorResult(false,"Project ID is not set");
         } else if (experiment.getExperimentID() == null) {
             logger.error("This experiment is wrong, no experimentID set");
-            return false;
+            return new ValidatorResult(false,"This experiment is wrong, no experimentID set");
         }
-        return true;
+        return new ValidatorResult(true);
     }
 }


Mime
View raw message