airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1485399 - in /airavata/trunk/modules: gfac-core/src/main/java/org/apache/airavata/gfac/Scheduler.java xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/EmbeddedGFacInvoker.java
Date Wed, 22 May 2013 20:19:35 GMT
Author: lahiru
Date: Wed May 22 20:19:34 2013
New Revision: 1485399

URL: http://svn.apache.org/r1485399
Log:
adding host Scheduling method.

Modified:
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/Scheduler.java
    airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/EmbeddedGFacInvoker.java

Modified: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/Scheduler.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/Scheduler.java?rev=1485399&r1=1485398&r2=1485399&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/Scheduler.java
(original)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/Scheduler.java
Wed May 22 20:19:34 2013
@@ -21,10 +21,15 @@
 
 package org.apache.airavata.gfac;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 import javax.xml.xpath.XPathExpressionException;
 
+import org.apache.airavata.client.api.AiravataAPI;
+import org.apache.airavata.client.api.AiravataAPIInvocationException;
+import org.apache.airavata.commons.gfac.type.ApplicationDescription;
 import org.apache.airavata.commons.gfac.type.HostDescription;
 import org.apache.airavata.gfac.context.JobExecutionContext;
 import org.apache.airavata.gfac.provider.GFacProvider;
@@ -109,4 +114,18 @@ public class Scheduler {
         }
         return provider;
     }
+
+    public static HostDescription pickaHost(AiravataAPI api, String serviceName) throws AiravataAPIInvocationException
{
+        List<HostDescription> registeredHosts = new ArrayList<HostDescription>();
+        Map<String, ApplicationDescription> applicationDescriptors = api.getApplicationManager().getApplicationDescriptors(serviceName);
+        for (String hostDescName : applicationDescriptors.keySet()) {
+            registeredHosts.add(api.getApplicationManager().getHostDescription(hostDescName));
+        }
+        return scheduleHost(registeredHosts);
+    }
+
+    private static HostDescription scheduleHost(List<HostDescription> registeredHosts)
{
+        //todo implement an algorithm to pick a host among different hosts, ideally this
could be configurable in an xml
+        return registeredHosts.get(0);
+    }
 }

Modified: airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/EmbeddedGFacInvoker.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/EmbeddedGFacInvoker.java?rev=1485399&r1=1485398&r2=1485399&view=diff
==============================================================================
--- airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/EmbeddedGFacInvoker.java
(original)
+++ airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/EmbeddedGFacInvoker.java
Wed May 22 20:19:34 2013
@@ -47,6 +47,7 @@ import org.apache.airavata.commons.gfac.
 import org.apache.airavata.gfac.Constants;
 import org.apache.airavata.gfac.GFacAPI;
 import org.apache.airavata.gfac.GFacConfiguration;
+import org.apache.airavata.gfac.Scheduler;
 import org.apache.airavata.gfac.context.ApplicationContext;
 import org.apache.airavata.gfac.context.JobExecutionContext;
 import org.apache.airavata.gfac.context.MessageContext;
@@ -281,21 +282,27 @@ public class EmbeddedGFacInvoker impleme
      */
     public synchronized boolean invoke() throws WorkflowException {
         try {
-        	 ContextHeaderDocument.ContextHeader contextHeader =  WorkflowContextHeaderBuilder.removeOtherSchedulingConfig(nodeID,this.configuration.getContextHeader());
+        	 ContextHeaderDocument.ContextHeader contextHeader =
+                     WorkflowContextHeaderBuilder.removeOtherSchedulingConfig(nodeID,this.configuration.getContextHeader());
              String hostName = null;
+            HostDescription registeredHost;
              if(contextHeader != null){
-            	 if(contextHeader.getWorkflowSchedulingContext() != null && contextHeader.getWorkflowSchedulingContext().getApplicationSchedulingContextArray().length
> 0 && contextHeader.getWorkflowSchedulingContext().getApplicationSchedulingContextArray(0).getHostName()
!= null){
+            	 if(contextHeader.getWorkflowSchedulingContext() != null &&
+                         contextHeader.getWorkflowSchedulingContext().getApplicationSchedulingContextArray().length
> 0 &&
+                         contextHeader.getWorkflowSchedulingContext().getApplicationSchedulingContextArray(0).getHostName()
!= null){
                  hostName = contextHeader.getWorkflowSchedulingContext().getApplicationSchedulingContextArray(0).getHostName();
                  }
              }
         	//todo This is the basic scheduling, have to do proper scheduling implementation
             ServiceDescription serviceDescription = airavataAPI.getApplicationManager().getServiceDescription(serviceName);
-            HostDescription registeredHost = getRegisteredHost(airavataAPI, this.serviceName);
+            if(hostName == null){
+                registeredHost = Scheduler.pickaHost(airavataAPI, this.serviceName);
+            }else{
             // if user specify a host, no matter what we pick that host for all the nodes,
todo: allow users to specifi node specific host
-            if(hostName != null) {
                 registeredHost = airavataAPI.getApplicationManager().getHostDescription(hostName);
             }
-            ApplicationDescription applicationDescription = airavataAPI.getApplicationManager().getApplicationDescription(serviceName,
registeredHost.getType().getHostName());
+            ApplicationDescription applicationDescription =
+                    airavataAPI.getApplicationManager().getApplicationDescription(serviceName,
registeredHost.getType().getHostName());
 
             // When we run getInParameters we set the actualParameter object, this has to
be fixed
             URL resource = EmbeddedGFacInvoker.class.getClassLoader().getResource("gfac-config.xml");



Mime
View raw message