airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adham...@apache.org
Subject airavata git commit: Loading task implementations in worker factory
Date Tue, 09 May 2017 16:58:47 GMT
Repository: airavata
Updated Branches:
  refs/heads/feature-workload-mgmt bdb8b974b -> 0504c58f1


Loading task implementations in worker factory


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

Branch: refs/heads/feature-workload-mgmt
Commit: 0504c58f16a680118864e27177ea32e47c10e9c9
Parents: bdb8b97
Author: Ajinkya Dhamnaskar <adhamnas@apache.org>
Authored: Tue May 9 12:58:36 2017 -0400
Committer: Ajinkya Dhamnaskar <adhamnas@apache.org>
Committed: Tue May 9 12:58:36 2017 -0400

----------------------------------------------------------------------
 .../airavata/worker/core/utils/WorkerFactory.java  | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/0504c58f/modules/worker/worker-core/src/main/java/org/apache/airavata/worker/core/utils/WorkerFactory.java
----------------------------------------------------------------------
diff --git a/modules/worker/worker-core/src/main/java/org/apache/airavata/worker/core/utils/WorkerFactory.java
b/modules/worker/worker-core/src/main/java/org/apache/airavata/worker/core/utils/WorkerFactory.java
index b5ce833..4a0a02f 100644
--- a/modules/worker/worker-core/src/main/java/org/apache/airavata/worker/core/utils/WorkerFactory.java
+++ b/modules/worker/worker-core/src/main/java/org/apache/airavata/worker/core/utils/WorkerFactory.java
@@ -29,18 +29,22 @@ import org.apache.airavata.common.utils.ServerSettings;
 import org.apache.airavata.credential.store.credential.Credential;
 import org.apache.airavata.credential.store.store.CredentialReader;
 import org.apache.airavata.credential.store.store.CredentialStoreException;
+import org.apache.airavata.model.appcatalog.computeresource.JobSubmissionProtocol;
 import org.apache.airavata.model.appcatalog.computeresource.ResourceJobManagerType;
 import org.apache.airavata.credential.store.credential.impl.ssh.SSHCredential;
 import org.apache.airavata.worker.core.authentication.AuthenticationInfo;
 import org.apache.airavata.worker.core.authentication.SSHKeyAuthentication;
 import org.apache.airavata.worker.core.cluster.ServerInfo;
 import org.apache.airavata.worker.core.config.ResourceConfig;
+import org.apache.airavata.worker.core.config.TaskImplementationConfig;
 import org.apache.airavata.worker.core.config.WorkerYamlConfigruation;
 import org.apache.airavata.worker.core.context.ProcessContext;
 import org.apache.airavata.worker.core.exceptions.WorkerException;
+import org.apache.airavata.worker.core.task.Task;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.lang.reflect.Constructor;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
@@ -55,6 +59,7 @@ public class WorkerFactory {
     private static boolean isWorkerConfigurationLoaded = false;
     private static Map<ResourceJobManagerType, ResourceConfig> resources = new HashMap<>();
     private static Cache<String,Session> sessionCache;
+    private static Map<String, Task> taskImplementations = new HashMap<>();
 
     public static void loadConfiguration() throws WorkerException {
         if (!isWorkerConfigurationLoaded) {
@@ -63,10 +68,20 @@ public class WorkerFactory {
                 for (ResourceConfig resourceConfig : config.getResourceConfiguration()) {
                     resources.put(resourceConfig.getJobManagerType(), resourceConfig);
                 }
-            } catch (Exception e) {
+
+                for (TaskImplementationConfig taskImplementationConfig : config.getTaskImplementations())
{
+                    String taskClass = taskImplementationConfig.getImplementationClass();
+                    Class<?> aClass = Class.forName(taskClass);
+                    Constructor<?> constructor = aClass.getConstructor();
+                    Task task = (Task) constructor.newInstance();
+                    taskImplementations.put(taskImplementationConfig.getTaskType(), task);
+                }
+            }catch (Exception e) {
                 throw new WorkerException("Worker config issue", e);
             }
 
+
+
             sessionCache = CacheBuilder.newBuilder()
                     .expireAfterAccess(ServerSettings.getSessionCacheAccessTimeout(), TimeUnit.MINUTES)
                     .removalListener((RemovalListener<String, Session>) removalNotification
-> {


Mime
View raw message