You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2013/05/28 22:26:15 UTC

svn commit: r1487100 - in /airavata/trunk/modules: commons/utils/src/main/java/org/apache/airavata/common/utils/ distribution/airavata-server/src/main/resources/conf/ gfac-core/src/main/java/org/apache/airavata/gfac/scheduler/ gfac-core/src/main/java/o...

Author: lahiru
Date: Tue May 28 20:26:15 2013
New Revision: 1487100

URL: http://svn.apache.org/r1487100
Log:
fixing https://issues.apache.org/jira/browse/AIRAVATA-862.

Added:
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/scheduler/
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/scheduler/HostScheduler.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/scheduler/impl/
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/scheduler/impl/SimpleHostScheduler.java
Modified:
    airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
    airavata/trunk/modules/distribution/airavata-server/src/main/resources/conf/airavata-server.properties
    airavata/trunk/modules/rest/webapp/src/main/resources/airavata-server.properties
    airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/EmbeddedGFacInvoker.java

Modified: airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java?rev=1487100&r1=1487099&r2=1487100&view=diff
==============================================================================
--- airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java (original)
+++ airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/ServerSettings.java Tue May 28 20:26:15 2013
@@ -56,6 +56,7 @@ public class ServerSettings extends Appl
     private static final String REGISTRY_DB_PASSWORD ="registry.jdbc.password";
     private static final String REGISTRY_DB_DRIVER ="registry.jdbc.driver";
     private static final String ENABLE_HTTPS = "enable.https";
+    private static final String HOST_SCHEDULER = "host.scheduler";
 
     public static String getDefaultGatewayId()throws ApplicationSettingsException{
     	return getSetting(DEFAULT_GATEWAY_ID);
@@ -171,4 +172,8 @@ public class ServerSettings extends Appl
 		}
 		return tomcatPort;
     }
+
+    public static String getHostScheduler() throws ApplicationSettingsException {
+        return getSetting(HOST_SCHEDULER);
+    }
 }

Modified: airavata/trunk/modules/distribution/airavata-server/src/main/resources/conf/airavata-server.properties
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/distribution/airavata-server/src/main/resources/conf/airavata-server.properties?rev=1487100&r1=1487099&r2=1487100&view=diff
==============================================================================
--- airavata/trunk/modules/distribution/airavata-server/src/main/resources/conf/airavata-server.properties (original)
+++ airavata/trunk/modules/distribution/airavata-server/src/main/resources/conf/airavata-server.properties Tue May 28 20:26:15 2013
@@ -143,9 +143,9 @@ msgBox.jdbc.url=jdbc:derby:wsmg;create=t
 #server.context-root=axis2
 
 #
-# Class which implemented Scheduler interface. It will be used to determine a Provider
+# Class which implemented HostScheduler interface. It will determine the which host to submit the request
 #
-scheduler.class= org.apache.airavata.core.gfac.scheduler.impl.SchedulerImpl
+host.scheduler=org.apache.airavata.gfac.scheduler.impl.SimpleHostScheduler
 
 #
 # Data Service Plugins classes

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/scheduler/HostScheduler.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/scheduler/HostScheduler.java?rev=1487100&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/scheduler/HostScheduler.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/scheduler/HostScheduler.java Tue May 28 20:26:15 2013
@@ -0,0 +1,35 @@
+/*
+ *
+ * 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.gfac.scheduler;
+
+import org.apache.airavata.commons.gfac.type.HostDescription;
+
+import java.util.List;
+
+public  interface HostScheduler {
+    /**
+     * This method will pick a host among set of hosts based on the algorithm users wants to implement, For a single instance
+     * of Airavata users can pick one Scheduler.
+     * @param registeredHosts
+     * @return
+     */
+     public HostDescription schedule(List<HostDescription> registeredHosts);
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/scheduler/impl/SimpleHostScheduler.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/scheduler/impl/SimpleHostScheduler.java?rev=1487100&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/scheduler/impl/SimpleHostScheduler.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/scheduler/impl/SimpleHostScheduler.java Tue May 28 20:26:15 2013
@@ -0,0 +1,33 @@
+/*
+ *
+ * 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.gfac.scheduler.impl;
+
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.gfac.scheduler.HostScheduler;
+
+import java.util.List;
+
+public class SimpleHostScheduler implements HostScheduler{
+    public HostDescription schedule(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/rest/webapp/src/main/resources/airavata-server.properties
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/rest/webapp/src/main/resources/airavata-server.properties?rev=1487100&r1=1487099&r2=1487100&view=diff
==============================================================================
--- airavata/trunk/modules/rest/webapp/src/main/resources/airavata-server.properties (original)
+++ airavata/trunk/modules/rest/webapp/src/main/resources/airavata-server.properties Tue May 28 20:26:15 2013
@@ -141,10 +141,12 @@ msgBox.jdbc.url=jdbc:derby:wsmg;create=t
 #Update the server context root path if airavata server is deployed under a different context root other than axis2
 #server.context-root=axis2
 
+
 #
-# Class which implemented Scheduler interface. It will be used to determine a Provider
+# Class which implemented HostScheduler interface. It will determine the which host to submit the request
 #
-scheduler.class= org.apache.airavata.core.gfac.scheduler.impl.SchedulerImpl
+host.scheduler=org.apache.airavata.gfac.scheduler.impl.SimpleHostScheduler
+
 
 #
 # Data Service Plugins classes

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=1487100&r1=1487099&r2=1487100&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 Tue May 28 20:26:15 2013
@@ -54,6 +54,7 @@ import org.apache.airavata.gfac.context.
 import org.apache.airavata.gfac.context.security.AmazonSecurityContext;
 import org.apache.airavata.gfac.context.security.GSISecurityContext;
 import org.apache.airavata.gfac.context.security.SSHSecurityContext;
+import org.apache.airavata.gfac.scheduler.HostScheduler;
 import org.apache.airavata.gfac.utils.GFacUtils;
 import org.apache.airavata.registry.api.exception.RegistryException;
 import org.apache.airavata.schemas.gfac.BooleanArrayType;
@@ -293,12 +294,19 @@ public class EmbeddedGFacInvoker impleme
                  hostName = contextHeader.getWorkflowSchedulingContext().getApplicationSchedulingContextArray(0).getHostName();
                  }
              }
-        	//todo This is the basic scheduling, have to do proper scheduling implementation
+        	//todo This is the basic scheduling, have to do proper scheduling implementation by implementing HostScheduler interface
             ServiceDescription serviceDescription = airavataAPI.getApplicationManager().getServiceDescription(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) {
+                List<HostDescription> registeredHosts = new ArrayList<HostDescription>();
+                Map<String, ApplicationDescription> applicationDescriptors = airavataAPI.getApplicationManager().getApplicationDescriptors(serviceName);
+                for (String hostDescName : applicationDescriptors.keySet()) {
+                    registeredHosts.add(airavataAPI.getApplicationManager().getHostDescription(hostDescName));
+                }
+                Class<? extends HostScheduler> aClass = Class.forName(ServerSettings.getHostScheduler()).asSubclass(HostScheduler.class);
+                HostScheduler hostScheduler = aClass.newInstance();
+                registeredHost = hostScheduler.schedule(registeredHosts);
+            } 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
                 registeredHost = airavataAPI.getApplicationManager().getHostDescription(hostName);
             }
             ApplicationDescription applicationDescription =