throws SchedulingException,
ResourceRequestDeniedException {
if (!this.valid) {
throw new SchedulingException("scheduler was instantiated " +
"incorrectly"); // note for future IoC muckers
}
if (coschedid != null && !this.slotManager.canCoSchedule()) {
throw new ResourceRequestDeniedException("this " +
"scheduler can not coschedule, ensemble usage is not " +
"supported");
}
final int[] ids;
try {
ids = this.db.getNextTasktIds(numNodes);
} catch (WorkspaceDatabaseException e) {
throw new SchedulingException(e.getMessage(), e);
}
final String[] assocs;
if (this.slotManager.isNeededAssociationsSupported()) {
assocs = neededAssociations;
} else {
assocs = null;
}
// see CreationPending class comment
this.creationPending.pending(ids);
final NodeRequest req =
new NodeRequest(ids, memory, cores, duration, assocs, resourcePool, groupid, creatorDN);
try {
if (coschedid == null) {
return this.scheduleImpl(req, preemptable);
} else {
this.scheduleCoschedImpl(req, coschedid);
return new Reservation(ids, null);
}
} catch (WorkspaceDatabaseException e) {
this.creationPending.notpending(ids);
throw new SchedulingException(e.getMessage(), e);
} catch (ResourceRequestDeniedException e) {
this.creationPending.notpending(ids);
throw e;
} catch (Throwable t) {
this.creationPending.notpending(ids);
throw new SchedulingException(t.getMessage(), t);
}
}