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 2011/11/01 04:29:27 UTC

svn commit: r1195795 - in /incubator/airavata/trunk/modules: commons/registry-api/src/main/java/org/apache/airavata/registry/api/ commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/ gfac-core/src/main/java/org/apache/airavata/core...

Author: lahiru
Date: Tue Nov  1 03:29:27 2011
New Revision: 1195795

URL: http://svn.apache.org/viewvc?rev=1195795&view=rev
Log:
removing usage of getservicelocation function in Registry API from the scheduler

Modified:
    incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java
    incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java
    incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/impl/SchedulerImpl.java

Modified: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java?rev=1195795&r1=1195794&r2=1195795&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java (original)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/Registry.java Tue Nov  1 03:29:27 2011
@@ -145,6 +145,17 @@ public interface Registry {
             throws RegistryException;
 
     /**
+     * Search deployment description from a service name
+     * 
+     * @param serviceName
+     * @return the deployment descriptions with matched names
+     * @throws PathNotFoundException
+     * @throws DeploymentDescriptionRetrieveException
+     */
+    public Map<HostDescription, List<ApplicationDeploymentDescription>> searchDeploymentDescription(String serviceName)
+            throws RegistryException;
+    
+    /**
      * Search deployment description from a service and/or a hostname
      * 
      * @param serviceName

Modified: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java?rev=1195795&r1=1195794&r2=1195795&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java (original)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java Tue Nov  1 03:29:27 2011
@@ -541,7 +541,37 @@ public class JCRRegistry extends Observa
         }
         return result;
     }
-
+	
+	public Map<HostDescription,List<ApplicationDeploymentDescription>> searchDeploymentDescription(String serviceName)
+            throws RegistryException{
+		Session session = null;
+		Map<HostDescription,List<ApplicationDeploymentDescription>> result = new HashMap<HostDescription,List<ApplicationDeploymentDescription>>();
+		try {
+			session = getSession();
+			Node deploymentNode = getDeploymentNode(session);
+			Node serviceNode = deploymentNode.getNode(serviceName);
+			NodeIterator hostNodes = serviceNode.getNodes();
+			for(;hostNodes.hasNext();){
+				Node hostNode = hostNodes.nextNode();
+				HostDescription hostDescriptor = getHostDescription(hostNode.getName());
+				result.put(hostDescriptor, new ArrayList<ApplicationDeploymentDescription>());
+				NodeIterator nodes = hostNode.getNodes();
+				for (; nodes.hasNext();) {
+					Node app = nodes.nextNode();
+					Property prop = app.getProperty(XML_PROPERTY_NAME);
+					result.get(hostDescriptor).add(ApplicationDeploymentDescription.fromXML(prop.getString()));
+				}
+			}
+		}catch (PathNotFoundException e){
+            return result;
+        } catch (Exception e) {
+			throw new DeploymentDescriptionRetrieveException(e);
+		} finally {
+			closeSession(session);
+		}
+		return result;
+	}
+	
     public List<ApplicationDeploymentDescription> searchDeploymentDescription(String serviceName, String hostName)
             throws RegistryException {
         Session session = null;

Modified: incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/impl/SchedulerImpl.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/impl/SchedulerImpl.java?rev=1195795&r1=1195794&r2=1195795&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/impl/SchedulerImpl.java (original)
+++ incubator/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/core/gfac/scheduler/impl/SchedulerImpl.java Tue Nov  1 03:29:27 2011
@@ -22,8 +22,8 @@
 package org.apache.airavata.core.gfac.scheduler.impl;
 
 import java.net.UnknownHostException;
-import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.airavata.commons.gfac.type.ApplicationDeploymentDescription;
 import org.apache.airavata.commons.gfac.type.HostDescription;
@@ -119,18 +119,33 @@ public class SchedulerImpl implements Sc
     private HostDescription scheduleToHost(Registry regService, String serviceName) {
 
         log.info("Searching registry for some deployed application hosts");
-        List<HostDescription> hosts = regService.getServiceLocation(serviceName);
-        if (hosts != null && hosts.size() > 0) {
-            HostDescription result = null;
-            for (Iterator<HostDescription> iterator = hosts.iterator(); iterator.hasNext();) {
-                result = iterator.next();
-
-                log.info("Found service on: " + result.getType().getHostAddress());
-            }
-            return result;
-        } else {
-            log.warn("Applcation  " + serviceName + " not found in registry");
-            return null;
+        HostDescription result = null;
+        Map<HostDescription, List<ApplicationDeploymentDescription>> deploymentDescription = null;
+		try {
+			deploymentDescription = regService.searchDeploymentDescription(serviceName);
+	        for (HostDescription hostDesc : deploymentDescription.keySet()) {
+	        	result = hostDesc;
+	            log.info("Found service on: " + result.getType().getHostAddress());
+			}
+		} catch (RegistryException e) {
+			e.printStackTrace();
+		}
+        if (result==null){
+        	log.warn("Applcation  " + serviceName + " not found in registry");
         }
+        return result;
+//        List<HostDescription> hosts = regService.getServiceLocation(serviceName);
+//        if (hosts != null && hosts.size() > 0) {
+//            HostDescription result = null;
+//            for (Iterator<HostDescription> iterator = hosts.iterator(); iterator.hasNext();) {
+//                result = iterator.next();
+//
+//                log.info("Found service on: " + result.getType().getHostAddress());
+//            }
+//            return result;
+//        } else {
+//            log.warn("Applcation  " + serviceName + " not found in registry");
+//            return null;
+//        }
     }
 }