airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From goshe...@apache.org
Subject airavata git commit: Add impl for AuroraJobSubmission
Date Mon, 01 May 2017 19:02:01 GMT
Repository: airavata
Updated Branches:
  refs/heads/feature-workload-mgmt 9efc26668 -> 702aa50ae


Add impl for AuroraJobSubmission


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

Branch: refs/heads/feature-workload-mgmt
Commit: 702aa50ae0d0f579bec833e0fa09bd55561e10c5
Parents: 9efc266
Author: Gourav Shenoy <goshenoy@apache.org>
Authored: Mon May 1 15:01:56 2017 -0400
Committer: Gourav Shenoy <goshenoy@apache.org>
Committed: Mon May 1 15:01:56 2017 -0400

----------------------------------------------------------------------
 modules/worker/task-jobsubmission/pom.xml       |  5 ++
 .../impl/AuroraJobSubmissionTask.java           | 51 ++++++++++----------
 .../task/jobsubmission/utils/AuroraUtils.java   | 30 ++++++++++++
 .../jobsubmission/utils/JobSubmissionUtils.java |  4 +-
 4 files changed, 63 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/702aa50a/modules/worker/task-jobsubmission/pom.xml
----------------------------------------------------------------------
diff --git a/modules/worker/task-jobsubmission/pom.xml b/modules/worker/task-jobsubmission/pom.xml
index 0d468da..7d9506e 100644
--- a/modules/worker/task-jobsubmission/pom.xml
+++ b/modules/worker/task-jobsubmission/pom.xml
@@ -36,6 +36,11 @@
             <artifactId>groovy-templates</artifactId>
             <version>${groovy.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>aurora-client</artifactId>
+            <version>${project.version}</version>
+        </dependency>
     </dependencies>
 
 </project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/702aa50a/modules/worker/task-jobsubmission/src/main/java/org/apache/airavata/worker/task/jobsubmission/impl/AuroraJobSubmissionTask.java
----------------------------------------------------------------------
diff --git a/modules/worker/task-jobsubmission/src/main/java/org/apache/airavata/worker/task/jobsubmission/impl/AuroraJobSubmissionTask.java
b/modules/worker/task-jobsubmission/src/main/java/org/apache/airavata/worker/task/jobsubmission/impl/AuroraJobSubmissionTask.java
index 1aaf991..0a150bb 100644
--- a/modules/worker/task-jobsubmission/src/main/java/org/apache/airavata/worker/task/jobsubmission/impl/AuroraJobSubmissionTask.java
+++ b/modules/worker/task-jobsubmission/src/main/java/org/apache/airavata/worker/task/jobsubmission/impl/AuroraJobSubmissionTask.java
@@ -24,15 +24,6 @@ import org.apache.airavata.cloud.aurora.client.AuroraThriftClient;
 import org.apache.airavata.cloud.aurora.client.bean.*;
 import org.apache.airavata.cloud.aurora.util.AuroraThriftClientUtil;
 import org.apache.airavata.common.utils.AiravataUtils;
-import org.apache.airavata.gfac.core.GFacException;
-import org.apache.airavata.gfac.core.GFacUtils;
-import org.apache.airavata.gfac.core.GroovyMap;
-import org.apache.airavata.gfac.core.Script;
-import org.apache.airavata.gfac.core.context.ProcessContext;
-import org.apache.airavata.gfac.core.context.TaskContext;
-import org.apache.airavata.gfac.core.task.JobSubmissionTask;
-import org.apache.airavata.gfac.core.task.TaskException;
-import org.apache.airavata.gfac.impl.AuroraUtils;
 import org.apache.airavata.model.appcatalog.computeresource.ResourceJobManagerType;
 import org.apache.airavata.model.commons.ErrorModel;
 import org.apache.airavata.model.job.JobModel;
@@ -41,6 +32,16 @@ import org.apache.airavata.model.status.JobStatus;
 import org.apache.airavata.model.status.TaskState;
 import org.apache.airavata.model.status.TaskStatus;
 import org.apache.airavata.model.task.TaskTypes;
+import org.apache.airavata.worker.core.context.ProcessContext;
+import org.apache.airavata.worker.core.context.TaskContext;
+import org.apache.airavata.worker.core.exceptions.WorkerException;
+import org.apache.airavata.worker.core.task.TaskException;
+import org.apache.airavata.worker.core.utils.WorkerUtils;
+import org.apache.airavata.worker.task.jobsubmission.JobSubmissionTask;
+import org.apache.airavata.worker.task.jobsubmission.utils.AuroraUtils;
+import org.apache.airavata.worker.task.jobsubmission.utils.GroovyMap;
+import org.apache.airavata.worker.task.jobsubmission.utils.JobSubmissionUtils;
+import org.apache.airavata.worker.task.jobsubmission.utils.Script;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,18 +50,11 @@ import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Set;
 
-public class AuroraJobSubmissionTask implements JobSubmissionTask{
+public class AuroraJobSubmissionTask implements JobSubmissionTask {
 
     private static final Logger log = LoggerFactory.getLogger(AuroraJobSubmissionTask.class);
 
     @Override
-    public JobStatus cancel(TaskContext taskcontext) throws TaskException {
-        JobStatus jobStatus = new JobStatus();
-        jobStatus.setJobState(JobState.ACTIVE);
-        return jobStatus;
-    }
-
-    @Override
     public void init(Map<String, String> propertyMap) throws TaskException {
 
     }
@@ -71,7 +65,7 @@ public class AuroraJobSubmissionTask implements JobSubmissionTask{
         ProcessContext processContext = taskContext.getParentProcessContext();
         JobModel jobModel = processContext.getJobModel();
         jobModel.setTaskId(taskContext.getTaskId());
-        String jobIdAndName = "A" + GFacUtils.generateJobName();
+        String jobIdAndName = "A" + JobSubmissionUtils.generateJobName();
         jobModel.setJobName(jobIdAndName);
         JobStatus jobStatus = new JobStatus();
         jobStatus.setJobState(JobState.SUBMITTED);
@@ -79,10 +73,10 @@ public class AuroraJobSubmissionTask implements JobSubmissionTask{
         try {
             JobKeyBean jobKey = new JobKeyBean(AuroraUtils.ENVIRONMENT, AuroraUtils.ROLE,
jobIdAndName);
             IdentityBean owner = new IdentityBean(AuroraUtils.ROLE);
-            GroovyMap groovyMap = GFacUtils.createGroovyMap(processContext, taskContext);
+            GroovyMap groovyMap = JobSubmissionUtils.createGroovyMap(processContext, taskContext);
             groovyMap.add(Script.JOB_SUBMITTER_COMMAND, "sh");
-            String templateFileName = GFacUtils.getTemplateFileName(ResourceJobManagerType.CLOUD);
-            String script = GFacUtils.generateScript(groovyMap, templateFileName);
+            String templateFileName = WorkerUtils.getTemplateFileName(ResourceJobManagerType.CLOUD);
+            String script = JobSubmissionUtils.generateScript(groovyMap, templateFileName);
             Set<ProcessBean> processes = new LinkedHashSet<>();
             ProcessBean process_1 = new ProcessBean("main_process", script, false);
             processes.add(process_1);
@@ -118,8 +112,8 @@ public class AuroraJobSubmissionTask implements JobSubmissionTask{
             jobStatus.setTimeOfStateChange(AiravataUtils.getCurrentTimestamp().getTime());
             taskContext.getParentProcessContext().setJobModel(jobModel);
 
-            GFacUtils.saveJobModel(processContext, jobModel);
-            GFacUtils.saveJobStatus(processContext, jobModel);
+            JobSubmissionUtils.saveJobModel(processContext, jobModel);
+            WorkerUtils.saveJobStatus(processContext, jobModel);
             taskStatus.setReason("Successfully submitted job to Aurora");
         } catch (Throwable e) {
             String msg = "Error occurred while submitting Aurora job";
@@ -135,8 +129,8 @@ public class AuroraJobSubmissionTask implements JobSubmissionTask{
 
         taskContext.setTaskStatus(taskStatus);
         try {
-            GFacUtils.saveAndPublishTaskStatus(taskContext);
-        } catch (GFacException e) {
+            WorkerUtils.saveAndPublishTaskStatus(taskContext);
+        } catch (WorkerException e) {
             log.error("Error while saving task status", e);
         }
         return taskStatus;
@@ -151,4 +145,11 @@ public class AuroraJobSubmissionTask implements JobSubmissionTask{
     public TaskTypes getType() {
         return TaskTypes.JOB_SUBMISSION;
     }
+
+    @Override
+    public JobStatus cancel(TaskContext taskcontext) throws TaskException {
+        JobStatus jobStatus = new JobStatus();
+        jobStatus.setJobState(JobState.ACTIVE);
+        return jobStatus;
+    }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/702aa50a/modules/worker/task-jobsubmission/src/main/java/org/apache/airavata/worker/task/jobsubmission/utils/AuroraUtils.java
----------------------------------------------------------------------
diff --git a/modules/worker/task-jobsubmission/src/main/java/org/apache/airavata/worker/task/jobsubmission/utils/AuroraUtils.java
b/modules/worker/task-jobsubmission/src/main/java/org/apache/airavata/worker/task/jobsubmission/utils/AuroraUtils.java
new file mode 100644
index 0000000..622c636
--- /dev/null
+++ b/modules/worker/task-jobsubmission/src/main/java/org/apache/airavata/worker/task/jobsubmission/utils/AuroraUtils.java
@@ -0,0 +1,30 @@
+/*
+ *
+ * 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.worker.task.jobsubmission.utils;
+
+public class AuroraUtils {
+
+    public static final String ENVIRONMENT = "devel";
+    public static final String ROLE = "centos";
+    public static final String AURORA_SCHEDULER_PROP_FILE = "aurora-scheduler.properties";
+    public static final String CLUSTER = "example";
+
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/702aa50a/modules/worker/task-jobsubmission/src/main/java/org/apache/airavata/worker/task/jobsubmission/utils/JobSubmissionUtils.java
----------------------------------------------------------------------
diff --git a/modules/worker/task-jobsubmission/src/main/java/org/apache/airavata/worker/task/jobsubmission/utils/JobSubmissionUtils.java
b/modules/worker/task-jobsubmission/src/main/java/org/apache/airavata/worker/task/jobsubmission/utils/JobSubmissionUtils.java
index 6841c68..68229d6 100644
--- a/modules/worker/task-jobsubmission/src/main/java/org/apache/airavata/worker/task/jobsubmission/utils/JobSubmissionUtils.java
+++ b/modules/worker/task-jobsubmission/src/main/java/org/apache/airavata/worker/task/jobsubmission/utils/JobSubmissionUtils.java
@@ -240,7 +240,7 @@ public class JobSubmissionUtils {
         }
     }
 
-    private static String generateScript(GroovyMap groovyMap, String templateName) throws
WorkerException {
+    public static String generateScript(GroovyMap groovyMap, String templateName) throws
WorkerException {
         URL templateUrl = ApplicationSettings.loadFile(templateName);
         if (templateUrl == null) {
             String error = "Template file '" + templateName + "' not found";
@@ -526,7 +526,7 @@ public class JobSubmissionUtils {
         return null;
     }
 
-    private static int generateJobName() {
+    public static int generateJobName() {
         Random random = new Random();
         int i = random.nextInt(Integer.MAX_VALUE);
         i = i + 99999999;


Mime
View raw message