You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sh...@apache.org on 2015/03/26 18:08:22 UTC
[23/50] [abbrv] airavata git commit: Fixed AIRAVATA-1612,
Enable to plug different workflow parser implementation through
airavata-server.properties file.
Fixed AIRAVATA-1612, Enable to plug different workflow parser implementation through airavata-server.properties file.
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/ad44956f
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/ad44956f
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/ad44956f
Branch: refs/heads/master
Commit: ad44956fc29a6e7328e93fc182d9c35fb7b8775b
Parents: 8b2a6b0
Author: shamrath <sh...@gmail.com>
Authored: Mon Mar 2 16:03:03 2015 -0500
Committer: shamrath <sh...@gmail.com>
Committed: Mon Mar 2 16:03:03 2015 -0500
----------------------------------------------------------------------
.../airavata/common/utils/ServerSettings.java | 5 ++++
.../main/resources/airavata-server.properties | 3 +++
.../main/resources/airavata-server.properties | 3 +++
.../engine/SimpleWorkflowInterpreter.java | 9 +++----
.../simple/workflow/engine/WorkflowFactory.java | 2 +-
.../workflow/engine/WorkflowFactoryImpl.java | 28 ++++++++++++++------
6 files changed, 36 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/airavata/blob/ad44956f/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
----------------------------------------------------------------------
diff --git a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
index 5073949..1c338d4 100644
--- a/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
+++ b/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
@@ -64,6 +64,7 @@ public class ServerSettings extends ApplicationSettings {
// Workflow Enactment Service component configuration.
private static final String ENACTMENT_THREAD_POOL_SIZE = "enactment.thread.pool.size";
private static final int DEFAULT_ENACTMENT_THREAD_POOL_SIZE = 10;
+ private static final String WORKFLOW_PARSER = "workflow.parser";
private static boolean stopAllThreads = false;
@@ -202,4 +203,8 @@ public class ServerSettings extends ApplicationSettings {
}
return Integer.valueOf(threadPoolSize);
}
+
+ public static String getWorkflowParser() throws ApplicationSettingsException {
+ return getSetting(WORKFLOW_PARSER);
+ }
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/ad44956f/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 12566ec..475017b 100644
--- a/modules/configuration/server/src/main/resources/airavata-server.properties
+++ b/modules/configuration/server/src/main/resources/airavata-server.properties
@@ -162,6 +162,9 @@ gfac.passive=false
#workflowserver=org.apache.airavata.api.server.WorkflowServer
enactment.thread.pool.size=10
+#to define custom workflow parser user following property
+#workflow.parser=org.apache.airavata.simple.workflow.engine.parser.AiravataWorkflowParser
+
###########################################################################
# API Server module Configuration
http://git-wip-us.apache.org/repos/asf/airavata/blob/ad44956f/modules/credential-store-service/credential-store-webapp/src/main/resources/airavata-server.properties
----------------------------------------------------------------------
diff --git a/modules/credential-store-service/credential-store-webapp/src/main/resources/airavata-server.properties b/modules/credential-store-service/credential-store-webapp/src/main/resources/airavata-server.properties
index 3cd3cdb..7c72dd5 100644
--- a/modules/credential-store-service/credential-store-webapp/src/main/resources/airavata-server.properties
+++ b/modules/credential-store-service/credential-store-webapp/src/main/resources/airavata-server.properties
@@ -146,6 +146,9 @@ trusted.cert.location=/Users/lahirugunathilake/Downloads/certificates
#workflowserver=org.apache.airavata.api.server.WorkflowServer
enactment.thread.pool.size=10
+#to define custom workflow parser user following property
+#workflow.parser=org.apache.airavata.simple.workflow.engine.parser.AiravataWorkflowParser
+
###########################################################################
# API Server module Configuration
http://git-wip-us.apache.org/repos/asf/airavata/blob/ad44956f/modules/simple-workflow/src/main/java/org/apache/airavata/simple/workflow/engine/SimpleWorkflowInterpreter.java
----------------------------------------------------------------------
diff --git a/modules/simple-workflow/src/main/java/org/apache/airavata/simple/workflow/engine/SimpleWorkflowInterpreter.java b/modules/simple-workflow/src/main/java/org/apache/airavata/simple/workflow/engine/SimpleWorkflowInterpreter.java
index edfa306..8eb5d5e 100644
--- a/modules/simple-workflow/src/main/java/org/apache/airavata/simple/workflow/engine/SimpleWorkflowInterpreter.java
+++ b/modules/simple-workflow/src/main/java/org/apache/airavata/simple/workflow/engine/SimpleWorkflowInterpreter.java
@@ -104,13 +104,12 @@ public class SimpleWorkflowInterpreter implements Runnable{
public void launchWorkflow() throws Exception {
- // process workflow input nodes
-// WorkflowFactoryImpl wfFactory = WorkflowFactoryImpl.getInstance();
-// WorkflowParser workflowParser = wfFactory.getWorkflowParser(experiment.getExperimentID(), credentialToken);
- WorkflowParser workflowParser = new AiravataWorkflowParser(experiment, credentialToken);
+ WorkflowFactoryImpl wfFactory = WorkflowFactoryImpl.getInstance();
+ WorkflowParser workflowParser = wfFactory.getWorkflowParser(experiment.getExperimentID(), credentialToken);
log.debug("Initialized workflow parser");
setWorkflowInputNodes(workflowParser.parse());
log.debug("Parsed the workflow and got the workflow input nodes");
+ // process workflow input nodes
processWorkflowInputNodes(getWorkflowInputNodes());
@@ -295,7 +294,7 @@ public class SimpleWorkflowInterpreter implements Runnable{
statusConsumer.stopListen(consumerId);
log.info("Successfully un-bind status consumer for experiment " + getExperiment().getExperimentID());
} catch (Exception e) {
- //TODO - handle this.
+ log.error("Error launching workflow", e);
}
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/ad44956f/modules/simple-workflow/src/main/java/org/apache/airavata/simple/workflow/engine/WorkflowFactory.java
----------------------------------------------------------------------
diff --git a/modules/simple-workflow/src/main/java/org/apache/airavata/simple/workflow/engine/WorkflowFactory.java b/modules/simple-workflow/src/main/java/org/apache/airavata/simple/workflow/engine/WorkflowFactory.java
index 3de90f2..9631768 100644
--- a/modules/simple-workflow/src/main/java/org/apache/airavata/simple/workflow/engine/WorkflowFactory.java
+++ b/modules/simple-workflow/src/main/java/org/apache/airavata/simple/workflow/engine/WorkflowFactory.java
@@ -26,6 +26,6 @@ package org.apache.airavata.simple.workflow.engine;
*/
public interface WorkflowFactory {
- public WorkflowParser getWorkflowParser(String experimentId, String credentialToken);
+ public WorkflowParser getWorkflowParser(String experimentId, String credentialToken) throws Exception;
}
http://git-wip-us.apache.org/repos/asf/airavata/blob/ad44956f/modules/simple-workflow/src/main/java/org/apache/airavata/simple/workflow/engine/WorkflowFactoryImpl.java
----------------------------------------------------------------------
diff --git a/modules/simple-workflow/src/main/java/org/apache/airavata/simple/workflow/engine/WorkflowFactoryImpl.java b/modules/simple-workflow/src/main/java/org/apache/airavata/simple/workflow/engine/WorkflowFactoryImpl.java
index e8674f2..23fc4c2 100644
--- a/modules/simple-workflow/src/main/java/org/apache/airavata/simple/workflow/engine/WorkflowFactoryImpl.java
+++ b/modules/simple-workflow/src/main/java/org/apache/airavata/simple/workflow/engine/WorkflowFactoryImpl.java
@@ -21,17 +21,24 @@
package org.apache.airavata.simple.workflow.engine;
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.ServerSettings;
import org.apache.airavata.registry.cpi.RegistryException;
import org.apache.airavata.simple.workflow.engine.parser.AiravataWorkflowParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
/**
* Singleton class, only one instance can exist in runtime.
*/
public class WorkflowFactoryImpl implements WorkflowFactory {
- private static WorkflowFactoryImpl workflowFactoryImpl;
+ private static final Logger log = LoggerFactory.getLogger(WorkflowFactoryImpl.class);
- private WorkflowParser workflowParser;
+ private static WorkflowFactoryImpl workflowFactoryImpl;
private WorkflowFactoryImpl(){
@@ -50,13 +57,18 @@ public class WorkflowFactoryImpl implements WorkflowFactory {
@Override
- public WorkflowParser getWorkflowParser(String experimentId, String credentialToken) {
+ public WorkflowParser getWorkflowParser(String experimentId, String credentialToken) throws Exception {
+ WorkflowParser workflowParser = null;
+ try {
+ String wfParserClassName = ServerSettings.getWorkflowParser();
+ Class<?> aClass = Class.forName(wfParserClassName);
+ Constructor<?> constructor = aClass.getConstructor(String.class, String.class);
+ workflowParser = (WorkflowParser) constructor.newInstance(experimentId, credentialToken);
+ } catch (ApplicationSettingsException e) {
+ log.info("A custom workflow parser is not defined, Use default Airavata workflow parser");
+ }
if (workflowParser == null) {
- try {
- workflowParser = new AiravataWorkflowParser(experimentId, credentialToken);
- } catch (RegistryException e) {
- // TODO : handle this scenario
- }
+ workflowParser = new AiravataWorkflowParser(experimentId, credentialToken);
}
return workflowParser;
}