private String getGroomToSchedule(Map<String, GroomServerStatus> grooms,
Map<GroomServerStatus, Integer> tasksInGroomMap,
String[] possibleLocations) {
for (String location : possibleLocations) {
GroomServerStatus groom = grooms.get(location);
if (groom == null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Could not find groom for location " + location);
}
continue;
}
Integer taskInGroom = tasksInGroomMap.get(groom);
taskInGroom = (taskInGroom == null) ? 0 : taskInGroom;
if (LOG.isDebugEnabled()) {
LOG.debug("taskInGroom = " + taskInGroom + " max tasks = "
+ groom.getMaxTasks() + " location = " + location
+ " groomhostname = " + groom.getGroomHostName());
}
if (taskInGroom < groom.getMaxTasks()
&& location.equals(groom.getGroomHostName())) {
return groom.getGroomHostName();
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("Returning null");
}