[Swift-commit] r7945 - in trunk/src/org/globus/swift: catalog/site catalog/types data

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Fri Jul 4 01:20:56 CDT 2014


Author: hategan
Date: 2014-07-04 01:20:56 -0500 (Fri, 04 Jul 2014)
New Revision: 7945

Added:
   trunk/src/org/globus/swift/catalog/site/Application.java
   trunk/src/org/globus/swift/catalog/site/SwiftContactSet.java
Modified:
   trunk/src/org/globus/swift/catalog/site/SwiftContact.java
   trunk/src/org/globus/swift/catalog/types/SysInfo.java
   trunk/src/org/globus/swift/data/Action.java
Log:
new sites spec

Added: trunk/src/org/globus/swift/catalog/site/Application.java
===================================================================
--- trunk/src/org/globus/swift/catalog/site/Application.java	                        (rev 0)
+++ trunk/src/org/globus/swift/catalog/site/Application.java	2014-07-04 06:20:56 UTC (rev 7945)
@@ -0,0 +1,73 @@
+//----------------------------------------------------------------------
+//This code is developed as part of the Java CoG Kit project
+//The terms of the license can be found at http://www.cogkit.org/license
+//This message may not be removed or altered.
+//----------------------------------------------------------------------
+
+/*
+ * Created on Jun 22, 2014
+ */
+package org.globus.swift.catalog.site;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+public class Application {
+    private String name, executable;
+    private Map<String, String> env;
+    private Map<String, Object> properties;
+    
+    
+    public String getName() {
+        return name;
+    }
+    
+    public void setName(String name) {
+        this.name = name;
+    
+    }
+    public String getExecutable() {
+        return executable;
+    }
+    
+    public void setExecutable(String executable) {
+        this.executable = executable;
+    }
+
+    public void setEnv(String name, String value) {
+        if (env == null) {
+            env = new HashMap<String, String>();
+        }
+        env.put(name, value);
+    }
+
+    public void addProperty(String name, String value) {
+        if (properties == null) {
+            properties = new HashMap<String, Object>();
+        }
+        properties.put(name, value);
+    }
+    
+    public Map<String, String> getEnv() {
+        if (env == null) {
+            return Collections.emptyMap();
+        }
+        else {
+            return env;
+        }
+    }
+
+    public Map<String, Object> getProperties() {
+        if (properties == null) {
+            return Collections.emptyMap();
+        }
+        else {
+            return properties;
+        }
+    }
+
+    public boolean executableIsWildcard() {
+        return "*".equals(executable);
+    }
+}

Modified: trunk/src/org/globus/swift/catalog/site/SwiftContact.java
===================================================================
--- trunk/src/org/globus/swift/catalog/site/SwiftContact.java	2014-07-04 06:13:22 UTC (rev 7944)
+++ trunk/src/org/globus/swift/catalog/site/SwiftContact.java	2014-07-04 06:20:56 UTC (rev 7945)
@@ -9,28 +9,72 @@
  */
 package org.globus.swift.catalog.site;
 
+import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
 import org.globus.cog.karajan.util.BoundContact;
-import org.griphyn.vdl.util.FQN;
+import org.griphyn.vdl.engine.Warnings;
 
 public class SwiftContact extends BoundContact {
-    private Map<FQN, Object> profiles = new HashMap<FQN, Object>();
-
+    private Map<String, Application> apps;
+    private SwiftContactSet siteCatalog;
+    
     public SwiftContact() {
         super();
     }
 
-    public SwiftContact(String host) {
-        super(host);
+    public SwiftContact(String name) {
+        super(name);
     }
 
-    public void addProfile(FQN fqn, String value) {
-    	profiles.put(fqn, value);
+    public void addApplication(Application app) {
+        if (apps == null) {
+            apps = new HashMap<String, Application>();
+        }
+        if (apps.put(app.getName(), app) != null) {
+            Warnings.warn(Warnings.Type.SITE, "Multiple entries found for application '" + 
+                app.getName() + "' on site '" + this.getName()  + "'");
+        }
     }
 
-    public Map<FQN, Object> getProfiles() {
-        return profiles;
+    public Collection<Application> getApplications() {
+        if (apps == null) {
+            return Collections.emptyList();
+        }
+        else {
+            return apps.values();
+        }
     }
+
+    public SwiftContactSet getSiteCatalog() {
+        return siteCatalog;
+    }
+
+    public void setSiteCatalog(SwiftContactSet siteCatalog) {
+        this.siteCatalog = siteCatalog;
+    }
+
+    public Application findApplication(String tr) {
+        /*
+         * Find apps in the following order:
+         * host:tr
+         * host:*
+         * pool:tr
+         * pool:*
+         */
+        
+        Application app = null;
+        if (apps != null) {
+            app = apps.get(tr);
+            if (app == null) {
+                app = apps.get("*");
+            }
+        }
+        if (app == null) {
+            app = siteCatalog.findApplication(tr);
+        }
+        return app;
+    }
 }

Added: trunk/src/org/globus/swift/catalog/site/SwiftContactSet.java
===================================================================
--- trunk/src/org/globus/swift/catalog/site/SwiftContactSet.java	                        (rev 0)
+++ trunk/src/org/globus/swift/catalog/site/SwiftContactSet.java	2014-07-04 06:20:56 UTC (rev 7945)
@@ -0,0 +1,52 @@
+//----------------------------------------------------------------------
+//This code is developed as part of the Java CoG Kit project
+//The terms of the license can be found at http://www.cogkit.org/license
+//This message may not be removed or altered.
+//----------------------------------------------------------------------
+
+/*
+ * Created on Jun 22, 2014
+ */
+package org.globus.swift.catalog.site;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.globus.cog.karajan.util.BoundContact;
+import org.globus.cog.karajan.util.ContactSet;
+import org.griphyn.vdl.engine.Warnings;
+
+public class SwiftContactSet extends ContactSet {
+    private Map<String, Application> apps;
+
+    public void addApplication(Application app) {
+        if (apps == null) {
+            apps = new HashMap<String, Application>();
+        }
+        if (apps.put(app.getName(), app) != null) {
+            Warnings.warn(Warnings.Type.SITE, "Multiple entries found for application '" + 
+                app.getName() + "' on site pool");
+        }
+    }
+
+    @Override
+    public void addContact(BoundContact contact) {
+        throw new UnsupportedOperationException();
+    }
+
+    public void addContact(SwiftContact contact) {
+        super.addContact(contact);
+        contact.setSiteCatalog(this);
+    }
+
+    public Application findApplication(String tr) {
+        Application app = null;
+        if (apps != null) {
+            app = apps.get(tr);
+            if (app == null) {
+                app = apps.get("*");
+            }
+        }
+        return app;
+    }
+}

Modified: trunk/src/org/globus/swift/catalog/types/SysInfo.java
===================================================================
--- trunk/src/org/globus/swift/catalog/types/SysInfo.java	2014-07-04 06:13:22 UTC (rev 7944)
+++ trunk/src/org/globus/swift/catalog/types/SysInfo.java	2014-07-04 06:20:56 UTC (rev 7945)
@@ -227,4 +227,8 @@
         }
         return s.toString();
     }
+    
+    public static SysInfo fromString(String str) {
+    	return new SysInfo(str);
+    }
 }

Modified: trunk/src/org/globus/swift/data/Action.java
===================================================================
--- trunk/src/org/globus/swift/data/Action.java	2014-07-04 06:13:22 UTC (rev 7944)
+++ trunk/src/org/globus/swift/data/Action.java	2014-07-04 06:20:56 UTC (rev 7945)
@@ -91,7 +91,7 @@
             if (srcdir.length() == 0) {
                 srcdir = ".";
             }
-            String desthost = bc.getHost();
+            String desthost = bc.getName();
             String workdir = (String) bc.getProperty("workdir");
             
             if (workdir != null && !workdir.startsWith("/")) {




More information about the Swift-commit mailing list