// read queue info from config file
QueueManager queueManager = taskTrackerManager.getQueueManager();
Set<String> queues = queueManager.getQueues();
// Sanity check: there should be at least one queue.
if (0 == queues.size()) {
throw new IllegalStateException("System has no queue configured");
}
Set<String> queuesWithoutConfiguredGC = new HashSet<String>();
float totalCapacity = 0.0f;
for (String queueName: queues) {
float gc = schedConf.getGuaranteedCapacity(queueName);
if(gc == -1.0) {
queuesWithoutConfiguredGC.add(queueName);
}else {
totalCapacity += gc;
}
int ulMin = schedConf.getMinimumUserLimitPercent(queueName);
long reclaimTimeLimit = schedConf.getReclaimTimeLimit(queueName) * 1000;
// create our QSI and add to our hashmap
QueueSchedulingInfo qsi = new QueueSchedulingInfo(queueName, gc,
ulMin, reclaimTimeLimit, jobQueuesManager);
queueInfoMap.put(queueName, qsi);
// create the queues of job objects
boolean supportsPrio = schedConf.isPrioritySupported(queueName);
jobQueuesManager.createQueue(queueName, supportsPrio);
SchedulingDisplayInfo schedulingInfo =
new SchedulingDisplayInfo(queueName, this);
queueManager.setSchedulerInfo(queueName, schedulingInfo);
}
float remainingQuantityToAllocate = 100 - totalCapacity;
float quantityToAllocate =
remainingQuantityToAllocate/queuesWithoutConfiguredGC.size();
for(String queue: queuesWithoutConfiguredGC) {
QueueSchedulingInfo qsi = queueInfoMap.get(queue);
qsi.guaranteedCapacityPercent = quantityToAllocate;
schedConf.setGuaranteedCapacity(queue, quantityToAllocate);
}
// check if there's a queue with the default name. If not, we quit.
if (!queueInfoMap.containsKey(DEFAULT_QUEUE_NAME)) {
throw new IllegalStateException("System has no default queue configured");
}
if (totalCapacity > 100.0) {
throw new IllegalArgumentException("Sum of queue capacities over 100% at "
+ totalCapacity);
}