airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1447777 - in /airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac: context/JobExecutionContext.java utils/GramRSLGenerator.java
Date Tue, 19 Feb 2013 16:02:07 GMT
Author: lahiru
Date: Tue Feb 19 16:02:07 2013
New Revision: 1447777

URL: http://svn.apache.org/r1447777
Log:
adding workflow context header support.

Modified:
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/JobExecutionContext.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/utils/GramRSLGenerator.java

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/JobExecutionContext.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/JobExecutionContext.java?rev=1447777&r1=1447776&r2=1447777&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/JobExecutionContext.java
(original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/JobExecutionContext.java
Tue Feb 19 16:02:07 2013
@@ -24,6 +24,7 @@ package org.apache.airavata.gfac.context
 import org.apache.airavata.gfac.GFacConfiguration;
 import org.apache.airavata.gfac.notification.GFacNotifier;
 import org.apache.airavata.gfac.provider.GFacProvider;
+import org.apache.airavata.schemas.wec.ContextHeaderDocument;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -41,6 +42,9 @@ public class JobExecutionContext extends
     private GFacNotifier notifier;
 
     private SecurityContext securityContext;
+
+    private ContextHeaderDocument.ContextHeader contextHeader;
+
     // Keep track of the current path of the message. Before hitting provider its in-path.
     // After provider its out-path.
     private boolean inPath = true;
@@ -165,4 +169,12 @@ public class JobExecutionContext extends
     public void setSecurityContext(SecurityContext securityContext) {
         this.securityContext = securityContext;
     }
+
+    public ContextHeaderDocument.ContextHeader getContextHeader() {
+        return contextHeader;
+    }
+
+    public void setContextHeader(ContextHeaderDocument.ContextHeader contextHeader) {
+        this.contextHeader = contextHeader;
+    }
 }

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/utils/GramRSLGenerator.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/utils/GramRSLGenerator.java?rev=1447777&r1=1447776&r2=1447777&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/utils/GramRSLGenerator.java
(original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/utils/GramRSLGenerator.java
Tue Feb 19 16:02:07 2013
@@ -26,9 +26,12 @@ import org.apache.airavata.gfac.Constant
 import org.apache.airavata.gfac.ToolsException;
 import org.apache.airavata.gfac.context.JobExecutionContext;
 import org.apache.airavata.gfac.context.MessageContext;
+import org.apache.airavata.gfac.provider.GFacProviderException;
 import org.apache.airavata.schemas.gfac.HpcApplicationDeploymentType;
 import org.apache.airavata.schemas.gfac.NameValuePairType;
+import org.apache.airavata.schemas.gfac.QueueType;
 import org.apache.airavata.schemas.gfac.URIArrayType;
+import org.apache.airavata.schemas.wec.ContextHeaderDocument;
 import org.globus.gram.GramAttributes;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -108,49 +111,51 @@ public class GramRSLGenerator {
         }
         // Using the workflowContext Header values if user provided them in the request and
overwrite the default values in DD
         //todo finish the scheduling based on workflow execution context
-//        ContextHeaderDocument.ContextHeader currentContextHeader = WorkflowContextHeaderBuilder.getCurrentContextHeader();
-//        if (currentContextHeader.getWorkflowSchedulingContext() != null) {
-//            if (currentContextHeader != null &&
-//                    currentContextHeader.getWorkflowSchedulingContext().getApplicationSchedulingContextArray()
!= null &&
-//                    currentContextHeader.getWorkflowSchedulingContext().getApplicationSchedulingContextArray().length
> 0) {
-//                try {
-//                    int cpuCount = currentContextHeader.getWorkflowSchedulingContext().getApplicationSchedulingContextArray()[0].getCpuCount();
-//                    if(cpuCount>0){
-//                        app.setCpuCount(cpuCount);
-//                    }
-//                } catch (NullPointerException e) {
-//                    log.debug("No Value sent in WorkflowContextHeader for CPU Count, value
in the Deployment Descriptor will be used");
-//                    context.getNotifier().publish(new ExecutionFailEvent(context, e, "No
Value sent in WorkflowContextHeader for Node Count, value in the Deployment Descriptor will
be used");
-//                }
-//                try {
-//                    int nodeCount = currentContextHeader.getWorkflowSchedulingContext().getApplicationSchedulingContextArray()[0].getNodeCount();
-//                    if(nodeCount>0){
-//                        app.setNodeCount(nodeCount);
-//                    }
-//                } catch (NullPointerException e) {
-//                    log.debug("No Value sent in WorkflowContextHeader for Node Count, value
in the Deployment Descriptor will be used");
-//                    context.getExecutionContext().getNotifier().executionFail(context,
e, "No Value sent in WorkflowContextHeader for Node Count, value in the Deployment Descriptor
will be used");
-//                }
-//                try {
-//                    String queueName = currentContextHeader.getWorkflowSchedulingContext().getApplicationSchedulingContextArray()[0].getQueueName();
-//                    if (queueName != null) {
-//                        if(app.getQueue() == null){
-//                            QueueType queueType = app.addNewQueue();
-//                            queueType.setQueueName(queueName);
-//                        }else{
-//                            app.getQueue().setQueueName(queueName);
-//                        }
-//                    }
-//                } catch (NullPointerException e) {
-//                    log.debug("No Value sent in WorkflowContextHeader for Node Count, value
in the Deployment Descriptor will be used");
-//                    context.getExecutionContext().getNotifier().executionFail(context,
e, "No Value sent in WorkflowContextHeader for Node Count, value in the Deployment Descriptor
will be used");
-//                }
-//            }
-//        }
-//        if(currentContextHeader.getWorkflowOutputDataHandling() != null){
-//            if(currentContextHeader.getWorkflowOutputDataHandling().getApplicationOutputDataHandlingArray().length
!= 0)
-//            app.setOutputDataDirectory(currentContextHeader.getWorkflowOutputDataHandling().getApplicationOutputDataHandlingArray()[0].getOutputDataDirectory());
-//        }
+        ContextHeaderDocument.ContextHeader currentContextHeader = context.getContextHeader();
+        if(currentContextHeader != null){
+        if (currentContextHeader.getWorkflowSchedulingContext() != null) {
+            if (currentContextHeader != null &&
+                    currentContextHeader.getWorkflowSchedulingContext().getApplicationSchedulingContextArray()
!= null &&
+                    currentContextHeader.getWorkflowSchedulingContext().getApplicationSchedulingContextArray().length
> 0) {
+                try {
+                    int cpuCount = currentContextHeader.getWorkflowSchedulingContext().getApplicationSchedulingContextArray()[0].getCpuCount();
+                    if(cpuCount>0){
+                        app.setCpuCount(cpuCount);
+                    }
+                } catch (NullPointerException e) {
+                    log.debug("No Value sent in WorkflowContextHeader for CPU Count, value
in the Deployment Descriptor will be used");
+                    new GFacProviderException("No Value sent in WorkflowContextHeader for
Node Count, value in the Deployment Descriptor will be used",e);
+                }
+                try {
+                    int nodeCount = currentContextHeader.getWorkflowSchedulingContext().getApplicationSchedulingContextArray()[0].getNodeCount();
+                    if(nodeCount>0){
+                        app.setNodeCount(nodeCount);
+                    }
+                } catch (NullPointerException e) {
+                    log.debug("No Value sent in WorkflowContextHeader for Node Count, value
in the Deployment Descriptor will be used");
+                     new GFacProviderException("No Value sent in WorkflowContextHeader for
Node Count, value in the Deployment Descriptor will be used",e);
+                }
+                try {
+                    String queueName = currentContextHeader.getWorkflowSchedulingContext().getApplicationSchedulingContextArray()[0].getQueueName();
+                    if (queueName != null) {
+                        if(app.getQueue() == null){
+                            QueueType queueType = app.addNewQueue();
+                            queueType.setQueueName(queueName);
+                        }else{
+                            app.getQueue().setQueueName(queueName);
+                        }
+                    }
+                } catch (NullPointerException e) {
+                    log.debug("No Value sent in WorkflowContextHeader for Node Count, value
in the Deployment Descriptor will be used");
+                     new GFacProviderException("No Value sent in WorkflowContextHeader for
Node Count, value in the Deployment Descriptor will be used",e);
+                }
+            }
+        }
+        if(currentContextHeader.getWorkflowOutputDataHandling() != null){
+            if(currentContextHeader.getWorkflowOutputDataHandling().getApplicationOutputDataHandlingArray().length
!= 0)
+            app.setOutputDataDirectory(currentContextHeader.getWorkflowOutputDataHandling().getApplicationOutputDataHandlingArray()[0].getOutputDataDirectory());
+        }
+        }
         if (app.getNodeCount() > 0) {
             jobAttr.set("hostCount", String.valueOf(app.getNodeCount()));
             log.debug("Setting number of Nodes to " + app.getCpuCount());



Mime
View raw message