airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1357788 - /incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/utils/GramRSLGenerator.java
Date Thu, 05 Jul 2012 18:24:01 GMT
Author: lahiru
Date: Thu Jul  5 18:24:00 2012
New Revision: 1357788

URL: http://svn.apache.org/viewvc?rev=1357788&view=rev
Log:
setting queue name from application description.

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

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/utils/GramRSLGenerator.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/utils/GramRSLGenerator.java?rev=1357788&r1=1357787&r2=1357788&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/utils/GramRSLGenerator.java
(original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/provider/utils/GramRSLGenerator.java
Thu Jul  5 18:24:00 2012
@@ -35,6 +35,7 @@ import org.apache.airavata.core.gfac.exc
 import org.apache.airavata.core.gfac.utils.GFacConstants;
 import org.apache.airavata.schemas.gfac.GramApplicationDeploymentType;
 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;
@@ -49,11 +50,12 @@ public class GramRSLGenerator {
 
     private enum JobType {
         SINGLE, MPI, MULTIPLE, CONDOR
-    };
+    }
+
+    ;
 
     public static GramAttributes configureRemoteJob(InvocationContext context) throws ToolsException
{
         GramApplicationDeploymentType app = (GramApplicationDeploymentType) context.getExecutionDescription().getApp().getType();
-
         GramAttributes jobAttr = new GramAttributes();
         jobAttr.setExecutable(app.getExecutableLocation());
         jobAttr.setDirectory(app.getStaticWorkingDirectory());
@@ -65,8 +67,8 @@ public class GramRSLGenerator {
          * and application description documents
          */
         NameValuePairType[] env = app.getApplicationEnvironmentArray();
-        if(env.length != 0){
-            Map<String, String> nv =new HashMap<String, String>();
+        if (env.length != 0) {
+            Map<String, String> nv = new HashMap<String, String>();
             for (int i = 0; i < env.length; i++) {
                 String key = env[i].getName();
                 String value = env[i].getValue();
@@ -95,99 +97,104 @@ public class GramRSLGenerator {
 
         if (app.getStandardInput() != null && !"".equals(app.getStandardInput()))
{
             jobAttr.setStdin(app.getStandardInput());
-		} else {
-			MessageContext<Object> input = context.getInput();
-			for (Iterator<String> iterator = input.getNames(); iterator.hasNext();) {
-				String paramName = iterator.next();
-				ActualParameter actualParameter = (ActualParameter) input.getValue(paramName);
-				if ("URIArray".equals(actualParameter.getType().getType().toString())) {
-					String[] values = ((URIArrayType) actualParameter.getType()).getValueArray();
-					for (String value : values) {
-						jobAttr.addArgument(value);
-					}
-				} else {
-					String paramValue = input.getStringValue(paramName);
-					jobAttr.addArgument(paramValue);
-				}
-			}
-		}
+        } else {
+            MessageContext<Object> input = context.getInput();
+            for (Iterator<String> iterator = input.getNames(); iterator.hasNext();
) {
+                String paramName = iterator.next();
+                ActualParameter actualParameter = (ActualParameter) input.getValue(paramName);
+                if ("URIArray".equals(actualParameter.getType().getType().toString())) {
+                    String[] values = ((URIArrayType) actualParameter.getType()).getValueArray();
+                    for (String value : values) {
+                        jobAttr.addArgument(value);
+                    }
+                } else {
+                    String paramValue = input.getStringValue(paramName);
+                    jobAttr.addArgument(paramValue);
+                }
+            }
+        }
         // Using the workflowContext Header values if user provided them in the request and
overwrite the default values in DD
-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();
-        app.setCpuCount(cpuCount);
-    } catch (NullPointerException e) {
-        log.info("No Value sent in WorkflowContextHeader for CPU 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 {
-        int nodeCount = currentContextHeader.getWorkflowSchedulingContext().getApplicationSchedulingContextArray()[0].getNodeCount();
-        app.setNodeCount(nodeCount);
-    } catch (NullPointerException e) {
-        log.info("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){
-            jobAttr.setQueue(queueName);
-        }else{
-            if (app.getQueue() != null) {
-                if (app.getQueue().getQueueName() != null) {
-                    System.out.println("Testing");
-                    log.info("Setting job queue to " + app.getQueue().getQueueName());
-                    jobAttr.setQueue(app.getQueue().getQueueName());
+        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();
+                    app.setCpuCount(cpuCount);
+                } catch (NullPointerException e) {
+                    log.info("No Value sent in WorkflowContextHeader for CPU 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 {
+                    int nodeCount = currentContextHeader.getWorkflowSchedulingContext().getApplicationSchedulingContextArray()[0].getNodeCount();
+                    app.setNodeCount(nodeCount);
+                } catch (NullPointerException e) {
+                    log.info("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.info("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");
                 }
             }
         }
-    } catch (NullPointerException e) {
-        log.info("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 (app.getNodeCount() > 0) {
-    jobAttr.set("hostCount", String.valueOf(app.getNodeCount()));
-}
-if (app.getCpuCount() > 0) {
-    log.info("Setting number of procs to " + app.getCpuCount());
-    jobAttr.setNumProcs(app.getCpuCount());
-}
-if (app.getMinMemory() > 0) {
-    log.info("Setting minimum memory to " + app.getMinMemory());
-    jobAttr.setMinMemory(app.getMinMemory());
-}
-if (app.getMaxMemory() > 0) {
-    log.info("Setting maximum memory to " + app.getMaxMemory());
-    jobAttr.setMaxMemory(app.getMaxMemory());
-}
-if (app.getProjectAccount() != null) {
-    if (app.getProjectAccount().getProjectAccountNumber() != null) {
-        log.info("Setting project to " + app.getProjectAccount().getProjectAccountNumber());
-        jobAttr.setProject(app.getProjectAccount().getProjectAccountNumber());
-    }
-}
-String jobType = JobType.SINGLE.toString();
-if (app.getJobType() != null) {
-    jobType = app.getJobType().toString();
-}
-if (jobType.equalsIgnoreCase(JobType.SINGLE.toString())) {
-    log.info("Setting job type to single");
-    jobAttr.setJobType(GramAttributes.JOBTYPE_SINGLE);
-} else if (jobType.equalsIgnoreCase(JobType.MPI.toString())) {
-    log.info("Setting job type to mpi");
-    jobAttr.setJobType(GramAttributes.JOBTYPE_MPI);
-} else if (jobType.equalsIgnoreCase(JobType.MULTIPLE.toString())) {
-    log.info("Setting job type to multiple");
-    jobAttr.setJobType(GramAttributes.JOBTYPE_MULTIPLE);
-} else if (jobType.equalsIgnoreCase(JobType.CONDOR.toString())) {
-    jobAttr.setJobType(GramAttributes.JOBTYPE_CONDOR);
-}
+        if (app.getNodeCount() > 0) {
+            jobAttr.set("hostCount", String.valueOf(app.getNodeCount()));
+            log.info("Setting number of Nodes to " + app.getCpuCount());
+        }
+        if (app.getCpuCount() > 0) {
+            log.info("Setting number of procs to " + app.getCpuCount());
+            jobAttr.setNumProcs(app.getCpuCount());
+        }
+        if (app.getMinMemory() > 0) {
+            log.info("Setting minimum memory to " + app.getMinMemory());
+            jobAttr.setMinMemory(app.getMinMemory());
+        }
+        if (app.getMaxMemory() > 0) {
+            log.info("Setting maximum memory to " + app.getMaxMemory());
+            jobAttr.setMaxMemory(app.getMaxMemory());
+        }
+        if (app.getProjectAccount() != null) {
+            if (app.getProjectAccount().getProjectAccountNumber() != null) {
+                log.info("Setting project to " + app.getProjectAccount().getProjectAccountNumber());
+                jobAttr.setProject(app.getProjectAccount().getProjectAccountNumber());
+            }
+        }
+        if (app.getQueue() != null) {
+            if (app.getQueue().getQueueName() != null) {
+                System.out.println("Testing");
+                log.info("Setting job queue to " + app.getQueue().getQueueName());
+                jobAttr.setQueue(app.getQueue().getQueueName());
+            }
+        }
+        String jobType = JobType.SINGLE.toString();
+        if (app.getJobType() != null) {
+            jobType = app.getJobType().toString();
+        }
+        if (jobType.equalsIgnoreCase(JobType.SINGLE.toString())) {
+            log.info("Setting job type to single");
+            jobAttr.setJobType(GramAttributes.JOBTYPE_SINGLE);
+        } else if (jobType.equalsIgnoreCase(JobType.MPI.toString())) {
+            log.info("Setting job type to mpi");
+            jobAttr.setJobType(GramAttributes.JOBTYPE_MPI);
+        } else if (jobType.equalsIgnoreCase(JobType.MULTIPLE.toString())) {
+            log.info("Setting job type to multiple");
+            jobAttr.setJobType(GramAttributes.JOBTYPE_MULTIPLE);
+        } else if (jobType.equalsIgnoreCase(JobType.CONDOR.toString())) {
+            jobAttr.setJobType(GramAttributes.JOBTYPE_CONDOR);
+        }
 
-return jobAttr;
-}
+        return jobAttr;
+    }
 }



Mime
View raw message