public synchronized boolean schedule(JobSpec spec)
throws SchedulerException {
String queueName = spec.getJob().getQueueName();
int load = spec.getJob().getLoadValue().intValue();
ResourceNode node = nodeAvailable(spec);
if (node != null) {
try {
myMonitor.assignLoad(node, load);
queueManager.usedNode(queueName, node.getNodeId());
// assign via batch system
LOG.log(Level.INFO, "Assigning job: ["
+ spec.getJob().getName() + "] to node: ["
+ node.getNodeId() + "]");
try {
myBatchmgr.executeRemotely(spec, node);
} catch (JobExecutionException e) {
LOG.log(Level.WARNING, "Exception executing job: ["
+ spec.getJob().getId() + "] to node: ["
+ node.getIpAddr() + "]: Message: "
+ e.getMessage());
try {
// queue the job back up
LOG.log(Level.INFO, "Requeueing job: ["
+ spec.getJob().getId() + "]");
myJobQueue.requeueJob(spec);
// make sure to decrement the load
myMonitor.reduceLoad(node, load);
} catch (Exception ignore) {
}
}
} catch (MonitorException e) {
LOG.log(Level.WARNING, "Exception assigning load to resource "
+ "node: [" + node.getNodeId() + "]: load: [" + load
+ "]: Message: " + e.getMessage());
throw new SchedulerException(e.getMessage());
}
} else {
// could not find resource, push onto JobQueue