You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ad...@apache.org on 2017/05/09 16:41:00 UTC

[4/7] airavata git commit: Adding worker constants to common for other modules

Adding worker constants to common for other modules


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

Branch: refs/heads/feature-workload-mgmt
Commit: 4bb22001cb7d3d83b32c195bfad5f5e145390595
Parents: 089ef37
Author: Ajinkya Dhamnaskar <ad...@apache.org>
Authored: Tue May 9 12:38:23 2017 -0400
Committer: Ajinkya Dhamnaskar <ad...@apache.org>
Committed: Tue May 9 12:38:23 2017 -0400

----------------------------------------------------------------------
 .../airavata/common/utils/WorkerConstants.java  | 58 ++++++++++++++++++++
 1 file changed, 58 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/4bb22001/modules/commons/src/main/java/org/apache/airavata/common/utils/WorkerConstants.java
----------------------------------------------------------------------
diff --git a/modules/commons/src/main/java/org/apache/airavata/common/utils/WorkerConstants.java b/modules/commons/src/main/java/org/apache/airavata/common/utils/WorkerConstants.java
new file mode 100644
index 0000000..5e59bf5
--- /dev/null
+++ b/modules/commons/src/main/java/org/apache/airavata/common/utils/WorkerConstants.java
@@ -0,0 +1,58 @@
+package org.apache.airavata.common.utils;
+
+import org.apache.airavata.model.dbevent.EntityType;
+import org.apache.airavata.model.task.TaskTypes;
+
+/**
+ * Created by Ajinkya on 5/2/17.
+ */
+public class WorkerConstants {
+
+    private final static String QUEUE_SUFFIX = ".queue";
+    public final static String WORKER_EVENT_EXCHANGE_NAME = "worker.event.exchange";
+    /**
+     * Get the queue-name for the task, given service-name as enum
+     * @param taskType
+     * @return
+     */
+    public static String getQueueName(TaskTypes taskType) {
+        return taskType.toString() + QUEUE_SUFFIX;
+    }
+
+    /**
+     * Get the queue-name for the task, given task-name as string
+     * @param taskType
+     * @return
+     */
+    public static String getQueueName(String taskType) {
+        return getQueueName(getTask(taskType));
+    }
+
+    /**
+     * Get serviceName from EntityType
+     * @param entityType
+     * @return
+     */
+    public static String getDbEventServiceName(EntityType entityType) {
+        for (DBEventService service : DBEventService.values()) {
+            if (service.name().equals(entityType.name())) {
+                return service.toString();
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Get the task as enum, given the task-name as string
+     * @param taskType
+     * @return
+     */
+    private static TaskTypes getTask(String taskType) {
+        for (TaskTypes task : TaskTypes.values()) {
+            if (task.toString().equals(taskType)) {
+                return task;
+            }
+        }
+        return null;
+    }
+}