|
From: <ha...@us...> - 2007-01-06 20:53:20
|
Revision: 1533
http://svn.sourceforge.net/cogkit/?rev=1533&view=rev
Author: hategan
Date: 2007-01-06 12:53:17 -0800 (Sat, 06 Jan 2007)
Log Message:
-----------
tweaked factors; added overload caching
Modified Paths:
--------------
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostScoreScheduler.java
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostScoreScheduler.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostScoreScheduler.java 2007-01-06 20:52:19 UTC (rev 1532)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostScoreScheduler.java 2007-01-06 20:53:17 UTC (rev 1533)
@@ -54,6 +54,11 @@
private int jobThrottle;
+ private boolean change;
+ private TaskConstraints cachedConstraints;
+ private boolean cachedLoadState;
+ private int hits;
+
public WeightedHostScoreScheduler() {
policy = POLICY_WEIGHTED_RANDOM;
setDefaultFactors();
@@ -65,8 +70,8 @@
jobSubmissionTaskLoadFactor = -0.2;
transferTaskLoadFactor = -0.2;
fileOperationTaskLoadFactor = -0.01;
- successFactor = 1;
- failureFactor = -0.1;
+ successFactor = 0.1;
+ failureFactor = -0.5;
scoreHighCap = 100;
jobThrottle = 2;
}
@@ -76,7 +81,7 @@
sorted = new WeightedHostSet(scoreHighCap);
Iterator i = grid.getContacts().iterator();
while (i.hasNext()) {
- addToSorted(new WeightedHost((BoundContact) i.next()));
+ addToSorted(new WeightedHost((BoundContact) i.next(), jobThrottle));
}
}
@@ -92,7 +97,8 @@
double ns = factor(score, factor);
sorted.changeScore(wh, ns);
if (logger.isDebugEnabled()) {
- logger.debug("Old score: " + score + ", new score: " + ns);
+ logger.debug("Old score: " + WeightedHost.D4.format(score) + ", new score: "
+ + WeightedHost.D4.format(ns));
}
}
@@ -107,16 +113,36 @@
protected synchronized BoundContact getNextContact(TaskConstraints t)
throws NoFreeResourceException {
checkGlobalLoadConditions();
+
+ if (!change && cachedLoadState && cachedConstraints.equals(t)) {
+ hits++;
+ throw new NoFreeResourceException();
+ }
+
BoundContact contact;
WeightedHostSet s = sorted;
WeightedHost selected = null;
+ if (s.allOverloaded()) {
+ throw new NoFreeResourceException();
+ }
+
s = constrain(s, getConstraintChecker(), t);
if (s.isEmpty()) {
throw new NoSuchResourceException();
}
+ else if (s.allOverloaded()) {
+ change = false;
+ cachedLoadState = true;
+ cachedConstraints = t;
+ hits = 0;
+ throw new NoFreeResourceException();
+ }
+ else {
+ cachedLoadState = false;
+ }
s = removeOverloaded(s);
@@ -157,7 +183,7 @@
if (logger.isDebugEnabled()) {
logger.debug("Next contact: " + selected.getHost());
}
- selected.changeLoad(1);
+ sorted.changeLoad(selected, 1);
selected.setDelayedDelta(successFactor);
return selected.getHost();
}
@@ -169,7 +195,8 @@
super.releaseContact(contact);
WeightedHost wh = sorted.findHost(contact);
if (wh != null) {
- wh.changeLoad(-1);
+ change = true;
+ sorted.changeLoad(wh, -1);
sorted.changeScore(wh, wh.getScore() + wh.getDelayedDelta());
}
else {
@@ -201,7 +228,7 @@
Iterator i = s.iterator();
while (i.hasNext()) {
WeightedHost wh = (WeightedHost) i.next();
- if (!overloaded(wh)) {
+ if (!wh.isOverloaded()) {
ns.add(wh);
}
}
@@ -211,7 +238,7 @@
Iterator i = s.iterator();
while (i.hasNext()) {
WeightedHost wh = (WeightedHost) i.next();
- if (overloaded(wh)) {
+ if (wh.isOverloaded()) {
i.remove();
}
}
@@ -219,12 +246,6 @@
}
}
- protected boolean overloaded(WeightedHost wh) {
- double score = wh.getTScore();
- int load = wh.getLoad();
- return !(load < jobThrottle * score + 2);
- }
-
private static String[] propertyNames;
private static final String[] myPropertyNames = new String[] { POLICY,
FACTOR_CONNECTION_REFUSED, FACTOR_CONNECTION_TIMEOUT, FACTOR_SUBMISSION_TASK_LOAD,
@@ -298,11 +319,11 @@
Task t = (Task) e.getSource();
int code = e.getStatus().getStatusCode();
Contact[] contacts = getContacts(t);
-
+
if (contacts == null) {
return;
}
-
+
if (code == Status.SUBMITTED) {
// this isn't reliable
// factorSubmission(t, contacts, 1);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|