[Swift-commit] r2182 - trunk/src/org/griphyn/vdl/karajan/lib/replication

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Thu Aug 7 14:33:30 CDT 2008


Author: hategan
Date: 2008-08-07 14:33:29 -0500 (Thu, 07 Aug 2008)
New Revision: 2182

Modified:
   trunk/src/org/griphyn/vdl/karajan/lib/replication/ReplicationManager.java
Log:
added initial queuing time estimate to prevent the no-replication-of-first-batch-of-jobs problem

Modified: trunk/src/org/griphyn/vdl/karajan/lib/replication/ReplicationManager.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/replication/ReplicationManager.java	2008-08-07 13:34:45 UTC (rev 2181)
+++ trunk/src/org/griphyn/vdl/karajan/lib/replication/ReplicationManager.java	2008-08-07 19:33:29 UTC (rev 2182)
@@ -17,6 +17,8 @@
 	public static final Logger logger = Logger.getLogger(ReplicationManager.class);
 
 	public static final int STATUS_NEEDS_REPLICATION = 100;
+	
+	public static final int INITIAL_QUEUE_TIME_ESTIMATE = 30; //seconds
 
 	private int n;
 	private long s;
@@ -83,17 +85,24 @@
 	}
 
 	public synchronized double getMean() {
-		return s / n;
+		if (n == 0) {
+			return INITIAL_QUEUE_TIME_ESTIMATE; 
+		}
+		else {
+			return s / n;
+		}
 	}
 
 	public synchronized double getStandardDeviation() {
-		return Math.sqrt((s2 - s * s / n) / n);
+		if (n == 0) {
+			return 0;
+		}
+		else {
+			return Math.sqrt((s2 - s * s / n) / n);
+		}
 	}
 
 	public void checkTasks() {
-		if (n == 0) {
-			return;
-		}
 		Map m;
 		synchronized (queued) {
 			m = new HashMap(queued);
@@ -115,7 +124,7 @@
 			return false;
 		}
 		long inTheQueue = (System.currentTimeMillis() - d.getTime()) / 1000;
-		if (n > 0 && inTheQueue > minQueueTime && inTheQueue > 3 * getMean()
+		if (inTheQueue > minQueueTime && inTheQueue > 3 * getMean()
 				&& replicationGroups.getRequestedCount(t) < limit) {
 			return true;
 		}




More information about the Swift-commit mailing list