[Swift-commit] cog r3423
swift at ci.uchicago.edu
swift at ci.uchicago.edu
Wed Jun 13 11:55:03 CDT 2012
------------------------------------------------------------------------
r3423 | hategan | 2012-06-13 11:54:00 -0500 (Wed, 13 Jun 2012) | 1 line
fixed deadlock (some unnecessary sync) and re-added logging statements to log site scores (used by the TUI)
------------------------------------------------------------------------
Index: modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostSet.java
===================================================================
--- modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostSet.java (revision 3422)
+++ modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostSet.java (working copy)
@@ -61,6 +61,24 @@
checkOverloaded(wh);
}
}
+
+ public double factorScore(WeightedHost wh, double factor) {
+ synchronized (scores) {
+ scores.remove(wh);
+ sum -= wh.getTScore();
+ double newScore = factor(wh.getScore(), factor);
+ wh.setScore(newScore);
+ weightedHosts.put(wh.getHost(), wh);
+ scores.add(wh);
+ sum += wh.getTScore();
+ checkOverloaded(wh);
+ return newScore;
+ }
+ }
+
+ protected final double factor(double score, double factor) {
+ return score + factor;
+ }
public void changeLoad(WeightedHost wh, int dl) {
wh.changeLoad(dl);
Index: modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostScoreScheduler.java
===================================================================
--- modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostScoreScheduler.java (revision 3422)
+++ modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostScoreScheduler.java (working copy)
@@ -140,13 +140,12 @@
return sorted;
}
- protected synchronized void factorScore(WeightedHost wh, double factor) {
- double score = wh.getScore();
+ protected void factorScore(WeightedHost wh, double factor) {
if (logger.isDebugEnabled()) {
logger.debug("multiplyScore(" + wh + ", " + factor + ")");
}
- double ns = factor(score, factor);
- sorted.changeScore(wh, ns);
+ double score = wh.getScore();
+ double ns = sorted.factorScore(wh, factor);
if (logger.isDebugEnabled()) {
logger.debug("Old score: " + WeightedHost.D4.format(score) + ", new score: "
+ WeightedHost.D4.format(ns));
@@ -160,10 +159,6 @@
wh.setDelayedDelta(wh.getDelayedDelta() + factor);
}
- protected final double factor(double score, double factor) {
- return score + factor;
- }
-
protected synchronized BoundContact getNextContact(TaskConstraints t)
throws NoFreeResourceException {
checkGlobalLoadConditions();
@@ -204,14 +199,17 @@
throw new NoFreeResourceException();
}
else if (s.size() == 1) {
- selected = (WeightedHost) s.iterator().next();
+ selected = s.iterator().next();
+ if (logger.isInfoEnabled()) {
+ logger.info("Sorted: " + s);
+ }
}
else {
double sum = s.getSum();
if (policy == POLICY_WEIGHTED_RANDOM) {
double rand = Math.random() * sum;
- if (logger.isDebugEnabled() && !s.isEmpty()) {
- logger.debug("Sorted: " + s);
+ if (logger.isInfoEnabled() && !s.isEmpty()) {
+ logger.info("Sorted: " + s);
}
if (logger.isDebugEnabled()) {
logger.debug("Rand: " + rand + ", sum: " + sum);
More information about the Swift-commit
mailing list