[Swift-commit] r6661 - in trunk/src/org/griphyn/vdl/karajan: . lib

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Thu Jul 18 21:22:37 CDT 2013


Author: hategan
Date: 2013-07-18 21:22:37 -0500 (Thu, 18 Jul 2013)
New Revision: 6661

Modified:
   trunk/src/org/griphyn/vdl/karajan/TCCache.java
   trunk/src/org/griphyn/vdl/karajan/VDSTaskTransformer.java
   trunk/src/org/griphyn/vdl/karajan/lib/Executable.java
Log:
implemented wildcards in tc.data (bug 1018)

Modified: trunk/src/org/griphyn/vdl/karajan/TCCache.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/TCCache.java	2013-07-18 19:48:48 UTC (rev 6660)
+++ trunk/src/org/griphyn/vdl/karajan/TCCache.java	2013-07-19 02:22:37 UTC (rev 6661)
@@ -39,18 +39,48 @@
 		cache = new HashMap<Entry, List<TCEntry>>();
 		entry = new Entry();
 	}
+	
+	public static final FQN ANY_APP = new FQN("*");
 
 	public synchronized List<TCEntry> getTCEntries(FQN tr, String host, TCType tctype) throws Exception {
+		List<TCEntry> l;
+		// try exact entry
 		entry.set(tr, host, tctype);
-		List<TCEntry> l = cache.get(entry);
-		if (l == null && !cache.containsKey(entry)) {
-			l = tc.getTCEntries(tr.getNamespace(), tr.getName(), tr.getVersion(), host, tctype);
-			cache.put(new Entry(tr, host, tctype), l);
+		l = getTCEntries_(entry);
+		if (l != null) {
+			return l;
 		}
+		
+		// try host app wildcard on this host
+		entry.set(ANY_APP, host, tctype);
+		l = getTCEntries_(entry);
+		if (l != null) {
+			return l;
+		}
+		// try this app on wildcard host
+		entry.set(tr, "*", tctype);
+		l = getTCEntries_(entry);
+		if (l != null) {
+			return l;
+		}
+		
+		// finally try app wildcard on wildcard host
+		entry.set(ANY_APP, "*", tctype);
+		l = getTCEntries_(entry);
 		return l;
 	}
 
-	private class Entry {
+	private List<TCEntry> getTCEntries_(Entry e) throws Exception {
+		List<TCEntry> l = cache.get(e);
+        if (l == null && !cache.containsKey(e)) {
+            l = tc.getTCEntries(e.tr.getNamespace(), e.tr.getName(), e.tr.getVersion(), e.host, e.tctype);
+            cache.put(new Entry(e), l);
+        }
+        
+        return l;
+    }
+
+    private class Entry {
 		public FQN tr;
 		public String host;
 		public TCType tctype;
@@ -61,6 +91,10 @@
 		public Entry(FQN tr, String host, TCType tctype) {
 			set(tr, host, tctype);
 		}
+		
+		public Entry(Entry e) {
+            set(e.tr, e.host, e.tctype);
+        }
 
 		public void set(FQN tr, String host, TCType tctype) {
 			this.tr = tr;

Modified: trunk/src/org/griphyn/vdl/karajan/VDSTaskTransformer.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/VDSTaskTransformer.java	2013-07-18 19:48:48 UTC (rev 6660)
+++ trunk/src/org/griphyn/vdl/karajan/VDSTaskTransformer.java	2013-07-19 02:22:37 UTC (rev 6661)
@@ -22,7 +22,6 @@
 
 import java.io.IOException;
 import java.util.HashSet;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
 
@@ -35,9 +34,6 @@
 import org.globus.cog.karajan.scheduler.TaskTransformer;
 import org.globus.cog.karajan.util.BoundContact;
 import org.globus.cog.karajan.util.Contact;
-import org.globus.swift.catalog.TCEntry;
-import org.globus.swift.catalog.types.TCType;
-import org.griphyn.vdl.util.FQN;
 import org.griphyn.vdl.util.VDL2Config;
 
 public class VDSTaskTransformer implements TaskTransformer {
@@ -68,9 +64,9 @@
 			}
 		}
 
-		private static Set opsWithDirInFirstArg = new HashSet();
+		private static Set<String> opsWithDirInFirstArg = new HashSet<String>();
 		static {
-			Set s = opsWithDirInFirstArg;
+			Set<String> s = opsWithDirInFirstArg;
 			s.add(FileOperationSpecification.LS);
 			s.add(FileOperationSpecification.MKDIR);
 			s.add(FileOperationSpecification.MKDIRS);
@@ -142,19 +138,22 @@
 					}
 				}
 			}
-			List l =   spec.getArgumentsAsList();
-			// perhaps should check for /bin/bash in the executable, or some other way of detecting we need to do a substitution here... or equally could assume that the second parameter always needs to undergo this substitution...
-			String executable = (String)l.get(0);
+			List<String> l =   spec.getArgumentsAsList();
+			// perhaps should check for /bin/bash in the executable, or some 
+			// other way of detecting we need to do a substitution here... 
+			// or equally could assume that the second parameter always needs to 
+			// undergo this substitution...
+			String executable = l.get(0);
 
 			try {
 				VDL2Config config = VDL2Config.getConfig();
 
-				if(config.getProperty("wrapper.invocation.mode", bc).equals("absolute")
-			 	 &&(executable.endsWith("shared/_swiftwrap")
-			   	  || executable.endsWith("shared/_swiftseq"))) {
+				if (config.getProperty("wrapper.invocation.mode", bc).equals("absolute")
+				        && (executable.endsWith("shared/_swiftwrap")
+				        || executable.endsWith("shared/_swiftseq"))) {
 
-				String s  = spec.getDirectory()+"/"+executable;
-				l.set(0,s);
+				    String s  = spec.getDirectory() + "/" + executable;
+				    l.set(0, s);
 				}
 			} 
 			catch(IOException ioe) {
@@ -167,42 +166,16 @@
 
 	public static class TCTransformer extends AbstractTransformer {
 		private TCCache tc;
-		private Set warnset = new HashSet();
 
 		public TCTransformer(TCCache tc) {
 			this.tc = tc;
 		}
 
 		protected void applyTCEntry(Task task, Contact[] contacts) {
-			JobSpecification spec = (JobSpecification) task.getSpecification();
-			BoundContact bc = (BoundContact) contacts[0];
-
-			FQN fqn = new FQN(spec.getExecutable());
-			List l;
-			try {
-				l = tc.getTCEntries(fqn, bc.getHost(), TCType.INSTALLED);
-			}
-			catch (Exception e) {
-				throw new RuntimeException(e);
-			}
-			if (l == null || l.isEmpty()) {
-				return;
-			}
-			if (l.size() > 1) {
-				synchronized (warnset) {
-					LinkedList wl = new LinkedList();
-					wl.add(fqn);
-					wl.add(bc);
-					if (!warnset.contains(wl)) {
-						logger.warn("Multiple entries found for " + fqn + " on " + bc
-								+ ". Using the first one");
-						warnset.add(wl);
-					}
-				}
-			}
-
-			TCEntry tce = (TCEntry) l.get(0);
-			spec.setExecutable(tce.getPhysicalTransformation());
+			// this method used to filter the task executable through
+		    // tc.data, but the task executable at this point was
+		    // always set to /bin/bash (or whatever the wrapper interpreter was).
+		    // That was useless.
 		}
 	}
 }

Modified: trunk/src/org/griphyn/vdl/karajan/lib/Executable.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/Executable.java	2013-07-18 19:48:48 UTC (rev 6660)
+++ trunk/src/org/griphyn/vdl/karajan/lib/Executable.java	2013-07-19 02:22:37 UTC (rev 6661)
@@ -50,7 +50,13 @@
 			return tr;
 		}
 		else {
-			return tce.getPhysicalTransformation();
+			String pt = tce.getPhysicalTransformation();
+			if ("*".equals(pt)) {
+			    return tr;
+			}
+			else {
+			    return pt;
+			}
 		}
 	}
 }




More information about the Swift-commit mailing list