[Swift-commit] r6251 - in branches/faster/src/org/griphyn/vdl/karajan: . lib

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Fri Feb 8 23:28:44 CST 2013


Author: hategan
Date: 2013-02-08 23:28:44 -0600 (Fri, 08 Feb 2013)
New Revision: 6251

Modified:
   branches/faster/src/org/griphyn/vdl/karajan/VDSAdaptiveScheduler.java
   branches/faster/src/org/griphyn/vdl/karajan/lib/SiteCatalog.java
Log:
abort if site catalog has errors or has no resources

Modified: branches/faster/src/org/griphyn/vdl/karajan/VDSAdaptiveScheduler.java
===================================================================
--- branches/faster/src/org/griphyn/vdl/karajan/VDSAdaptiveScheduler.java	2013-02-09 05:27:53 UTC (rev 6250)
+++ branches/faster/src/org/griphyn/vdl/karajan/VDSAdaptiveScheduler.java	2013-02-09 05:28:44 UTC (rev 6251)
@@ -457,6 +457,9 @@
 	
 	@Override
     public void setResources(ContactSet cs) {
+	    if (cs == null || cs.getContacts() == null) {
+	        throw new IllegalArgumentException("No sites specified");
+	    }
         super.setResources(cs);
         for (BoundContact bc : cs.getContacts()) {
             if ("passive".equals(bc.getProperty("globus:workerManager")) 

Modified: branches/faster/src/org/griphyn/vdl/karajan/lib/SiteCatalog.java
===================================================================
--- branches/faster/src/org/griphyn/vdl/karajan/lib/SiteCatalog.java	2013-02-09 05:27:53 UTC (rev 6250)
+++ branches/faster/src/org/griphyn/vdl/karajan/lib/SiteCatalog.java	2013-02-09 05:28:44 UTC (rev 6251)
@@ -63,7 +63,7 @@
                 }
             }
             catch (Exception e) {
-                System.err.println("Invalid pool entry '" + attr(pools.item(i), "name") + "': " + e.getMessage());
+                throw new ExecutionException(this, "Invalid pool entry '" + attr(pools.item(i), "handle") + "': ", e);
             }
         }
         return cs;
@@ -76,7 +76,7 @@
         String name = attr(n, "handle");
         BoundContact bc = new BoundContact(name);
         
-        String sysinfo = attr(n, "sysinfo");
+        String sysinfo = attr(n, "sysinfo", null);
         if (sysinfo != null) {
             bc.addProperty("sysinfo", sysinfo);
         }
@@ -160,23 +160,35 @@
 
     private Service execution(Node n) throws InvalidProviderException, ProviderMethodException {
         String provider = attr(n, "provider");
-        String url = attr(n, "url");
-        String jobManager = attr(n, "jobManager");
+        String url = attr(n, "url", null);
+        String jobManager = attr(n, "jobManager", null);
         ServiceContact contact = null;
         if (url != null) {
             contact = new ServiceContactImpl(url);
         }
+        else if (provider.equals("local")) {
+            contact = new ServiceContactImpl("localhost");
+        }
+        else {
+            throw new IllegalArgumentException("Missing URL");
+        }
         return new ExecutionServiceImpl(provider, contact, 
             AbstractionFactory.newSecurityContext(provider, contact), jobManager);
     }
 
     private Service filesystem(Node n) throws InvalidProviderException, ProviderMethodException {
         String provider = attr(n, "provider");
-        String url = attr(n, "url");
+        String url = attr(n, "url", null);
         ServiceContact contact = null;
         if (url != null) {
             contact = new ServiceContactImpl(url);
         }
+        else if (provider.equals("local")) {
+            contact = new ServiceContactImpl("localhost");
+        }
+        else {
+            throw new IllegalArgumentException("Missing URL");
+        }
         return new ServiceImpl(provider, Service.FILE_OPERATION, 
             contact, AbstractionFactory.newSecurityContext(provider, contact));
     }
@@ -210,14 +222,30 @@
         if (attrs != null) {
             Node attr = attrs.getNamedItem(name);
             if (attr == null) {
-                return null;
+                throw new IllegalArgumentException("Missing " + name);
             }
             else {
                 return attr.getNodeValue();
             }
         }
         else {
-            return null;
+            throw new IllegalArgumentException("Missing " + name);
         }
     }
+    
+    private String attr(Node n, String name, String defVal) {
+        NamedNodeMap attrs = n.getAttributes();
+        if (attrs != null) {
+            Node attr = attrs.getNamedItem(name);
+            if (attr == null) {
+                return defVal;
+            }
+            else {
+                return attr.getNodeValue();
+            }
+        }
+        else {
+            return defVal;
+        }
+    }
 }




More information about the Swift-commit mailing list