|
From: <ha...@us...> - 2006-12-28 20:37:03
|
Revision: 1495
http://svn.sourceforge.net/cogkit/?rev=1495&view=rev
Author: hategan
Date: 2006-12-28 12:37:00 -0800 (Thu, 28 Dec 2006)
Log Message:
-----------
clean constraints; distinguish between no resources because of unsatisfiable contraints or load conditions
Modified Paths:
--------------
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/AbstractScheduler.java
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/DefaultScheduler.java
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/LateBindingScheduler.java
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostScoreScheduler.java
Added Paths:
-----------
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/NoSuchResourceException.java
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/AbstractScheduler.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/AbstractScheduler.java 2006-12-28 20:35:59 UTC (rev 1494)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/AbstractScheduler.java 2006-12-28 20:37:00 UTC (rev 1495)
@@ -211,6 +211,12 @@
return constraints.get(task);
}
}
+
+ protected void removeConstraints(Task task) {
+ synchronized(constraints) {
+ constraints.remove(task);
+ }
+ }
public void addTaskTransformer(TaskTransformer taskTransformer) {
this.taskTransformers.add(taskTransformer);
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/DefaultScheduler.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/DefaultScheduler.java 2006-12-28 20:35:59 UTC (rev 1494)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/DefaultScheduler.java 2006-12-28 20:37:00 UTC (rev 1495)
@@ -65,21 +65,29 @@
checkGlobalLoadConditions();
int initial = contactCursor;
ContactSet resources = getResources();
- while (!checkLoad(resources.get(contactCursor))
- || !checkConstraints(resources.get(contactCursor), t)) {
+ boolean incompatibleConstraints = true;
+ while (true) {
+ if (checkConstraints(resources.get(contactCursor), t)) {
+ incompatibleConstraints = false;
+ if (checkLoad(resources.get(contactCursor))) {
+ break;
+ }
+ }
incContactCursor();
if (contactCursor == initial) {
- logger.debug("No free resources");
- throw new NoFreeResourceException("No free hosts available");
+ if (incompatibleConstraints) {
+ throw new NoSuchResourceException();
+ }
+ else {
+ throw new NoFreeResourceException("No free hosts available");
+ }
}
}
- if (initial == contactCursor) {
- incContactCursor();
- }
BoundContact contact = getResources().get(contactCursor);
if (logger.isDebugEnabled()) {
logger.debug("Contact: " + contact);
}
+ incContactCursor();
return contact;
}
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/LateBindingScheduler.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/LateBindingScheduler.java 2006-12-28 20:35:59 UTC (rev 1494)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/LateBindingScheduler.java 2006-12-28 20:37:00 UTC (rev 1495)
@@ -235,22 +235,26 @@
break;
}
Task t = (Task) getJobQueue().get(index);
+ boolean remove = true;
try {
submitUnbound(t);
- synchronized (this) {
- getJobQueue().remove(index);
- }
success = true;
}
- catch (NoFreeResourceException e) {
- if (running == 0) {
- failUnsubmittedTask(t, "Could not find any valid host for task \"" + t
+ catch (NoSuchResourceException e) {
+ failTask(t, "Could not find any valid host for task \"" + t
+ "\" with constraints " + getTaskConstraints(t), e);
- }
}
+ catch (NoFreeResourceException e) {
+ remove = false;
+ }
catch (Exception e) {
failTask(t, "The scheduler could not execute the task", e);
}
+ if (remove) {
+ synchronized (this) {
+ getJobQueue().remove(index);
+ }
+ }
index++;
}
}
@@ -277,14 +281,6 @@
s.setMessage(message);
s.setException(e);
t.setStatus(s);
- }
-
- protected void failUnsubmittedTask(Task t, String message, Exception e) {
- Status s = new StatusImpl();
- s.setStatusCode(Status.FAILED);
- s.setMessage(message);
- s.setException(e);
- t.setStatus(s);
fireJobStatusChangeEvent(t, s);
}
@@ -327,7 +323,7 @@
services[i] = resolveService((BoundContact) contacts[i], t.getType());
}
if (services[i] == null) {
- failUnsubmittedTask(t, "Could not find a suitable service/provider for host "
+ failTask(t, "Could not find a suitable service/provider for host "
+ contacts[i], null);
return;
}
@@ -348,11 +344,10 @@
throw e;
}
catch (Exception e) {
- if (e instanceof NullPointerException) {
- e.printStackTrace();
- }
- logger.debug("Scheduler exception: job =" + t.getIdentity().getValue() + ", status = "
+ if (logger.isDebugEnabled()) {
+ logger.debug("Scheduler exception: job =" + t.getIdentity().getValue() + ", status = "
+ t.getStatus(), e);
+ }
Status status = t.getStatus();
status.setPrevStatusCode(status.getStatusCode());
status.setStatusCode(Status.FAILED);
@@ -556,6 +551,7 @@
synchronized (taskContacts) {
taskContacts.remove(task);
}
+ removeConstraints(task);
for (int i = 0; i < contacts.length; i++) {
BoundContact c = (BoundContact) contacts[i];
Added: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/NoSuchResourceException.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/NoSuchResourceException.java (rev 0)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/NoSuchResourceException.java 2006-12-28 20:37:00 UTC (rev 1495)
@@ -0,0 +1,30 @@
+// ----------------------------------------------------------------------
+//This code is developed as part of the Java CoG Kit project
+//The terms of the license can be found at http://www.cogkit.org/license
+//This message may not be removed or altered.
+//----------------------------------------------------------------------
+
+/*
+ * Created on Sep 2, 2004
+ */
+package org.globus.cog.karajan.scheduler;
+
+public class NoSuchResourceException extends NoFreeResourceException {
+ private static final long serialVersionUID = 4757539377378613461L;
+
+ public NoSuchResourceException() {
+ super();
+ }
+
+ public NoSuchResourceException(String message) {
+ super(message);
+ }
+
+ public NoSuchResourceException(Throwable cause) {
+ super(cause);
+ }
+
+ public NoSuchResourceException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
\ No newline at end of file
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 2006-12-28 20:35:59 UTC (rev 1494)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostScoreScheduler.java 2006-12-28 20:37:00 UTC (rev 1495)
@@ -112,6 +112,16 @@
WeightedHost selected = null;
s = constrain(s, getConstraintChecker(), t);
+
+ if (s.isEmpty()) {
+ throw new NoSuchResourceException();
+ }
+
+ removeOverloaded(s);
+
+ if (s.isEmpty()) {
+ throw new NoFreeResourceException();
+ }
double sum = s.getSum();
if (policy == POLICY_WEIGHTED_RANDOM) {
@@ -134,12 +144,7 @@
}
}
if (selected == null) {
- if (s.isEmpty()) {
- throw new NoFreeResourceException();
- }
- else {
- selected = s.last();
- }
+ selected = s.last();
}
}
else if (policy == POLICY_BEST_SCORE) {
@@ -181,18 +186,28 @@
Iterator i = s.iterator();
while (i.hasNext()) {
WeightedHost wh = (WeightedHost) i.next();
- if (rcc.checkConstraints(wh.getHost(), tc) && notOverloaded(wh)) {
+ if (rcc.checkConstraints(wh.getHost(), tc)) {
ns.add(wh);
}
}
return ns;
}
}
+
+ protected void removeOverloaded(WeightedHostSet s) {
+ Iterator i = s.iterator();
+ while (i.hasNext()) {
+ WeightedHost wh = (WeightedHost) i.next();
+ if (overloaded(wh)) {
+ i.remove();
+ }
+ }
+ }
- protected boolean notOverloaded(WeightedHost wh) {
+ protected boolean overloaded(WeightedHost wh) {
double score = wh.getTScore();
int load = wh.getLoad();
- return load < jobThrottle * score + 2;
+ return !(load < jobThrottle * score + 2);
}
private static String[] propertyNames;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|