[Swift-commit] r2249 - provider-wonky/src/org/globus/cog/abstraction/impl/execution/wonky

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Tue Sep 23 14:29:17 CDT 2008


Author: benc
Date: 2008-09-23 14:29:16 -0500 (Tue, 23 Sep 2008)
New Revision: 2249

Modified:
   provider-wonky/src/org/globus/cog/abstraction/impl/execution/wonky/JobSubmissionTaskHandler.java
Log:
fail-first jobs mode

Modified: provider-wonky/src/org/globus/cog/abstraction/impl/execution/wonky/JobSubmissionTaskHandler.java
===================================================================
--- provider-wonky/src/org/globus/cog/abstraction/impl/execution/wonky/JobSubmissionTaskHandler.java	2008-09-23 19:25:21 UTC (rev 2248)
+++ provider-wonky/src/org/globus/cog/abstraction/impl/execution/wonky/JobSubmissionTaskHandler.java	2008-09-23 19:29:16 UTC (rev 2249)
@@ -17,8 +17,10 @@
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Random;
 
 import org.apache.log4j.Logger;
@@ -45,6 +47,7 @@
 static Random r = new Random();
 
 static List firstJobList = Collections.synchronizedList(new ArrayList());
+static Map siteStates = Collections.synchronizedMap(new HashMap());
 
 static int globalJobNumber = 0;
 int jobNumber = globalJobNumber++; // racy?
@@ -383,6 +386,27 @@
     boolean failDelay(String name) {
         double failRate = getWonkyParam(name+"fail");
         double delayTime = getWonkyParam(name+"delay");
+        double failFirstCount = getWonkyParam(name+"failfirstcount");
+
+        if(failFirstCount > 0) {
+            System.out.println("State "+name+" will fail first "+failFirstCount+" times");
+            String key = getSiteName() + ":" + name + "failfirstcountsofar";
+            Integer iObj = (Integer)siteStates.get(key);
+            if(iObj == null) {
+                iObj = new Integer(0);
+                siteStates.put(key,iObj);
+                
+            } 
+            int i = iObj.intValue();
+            i++;
+            siteStates.put(key,new Integer(i));
+            System.out.println("new value is "+i);
+            if(i<=failFirstCount) {  // not failed enough
+                System.out.println("Failing because early job");
+                return false; 
+            }
+        }
+
         System.out.print("State "+name+" with probability of failure "+failRate+": ");
         if(Math.random()<failRate) {
             System.out.println("Fail.");
@@ -411,4 +435,10 @@
         }
         return 0;
     }
+
+    String getSiteName() {
+        String siteName = (String) siteOptions.get(0);
+        System.out.println("Site name is "+siteName);
+        return siteName;
+    }
 }




More information about the Swift-commit mailing list