Return-Path: X-Original-To: apmail-airavata-commits-archive@www.apache.org Delivered-To: apmail-airavata-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7B8EFD29E for ; Wed, 22 May 2013 20:19:59 +0000 (UTC) Received: (qmail 97643 invoked by uid 500); 22 May 2013 20:19:59 -0000 Delivered-To: apmail-airavata-commits-archive@airavata.apache.org Received: (qmail 97605 invoked by uid 500); 22 May 2013 20:19:59 -0000 Mailing-List: contact commits-help@airavata.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airavata.apache.org Delivered-To: mailing list commits@airavata.apache.org Received: (qmail 97598 invoked by uid 99); 22 May 2013 20:19:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 May 2013 20:19:59 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 May 2013 20:19:56 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 505592388847; Wed, 22 May 2013 20:19:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@airavata.apache.org From: lahiru@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130522201935.505592388847@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 registeredHosts = new ArrayList(); + Map applicationDescriptors = api.getApplicationManager().getApplicationDescriptors(serviceName); + for (String hostDescName : applicationDescriptors.keySet()) { + registeredHosts.add(api.getApplicationManager().getHostDescription(hostDescName)); + } + return scheduleHost(registeredHosts); + } + + private static HostDescription scheduleHost(List 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");