}
if (selected.size() == 0) return;
int nbGivePerQueue = nbMsgGive / selected.size();
LBMessageGive msgGive = new LBMessageGive(validityPeriod, rateOfFlow);
if (nbGivePerQueue == 0 && nbMsgGive > 0) {
// send all to the first element of clusterQueue.
AgentId id = (AgentId) selected.get(0);
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG,
"LoadingFactor.processGive" +
" nbMsgGive = " + nbMsgGive +
", id = " + id);
msgGive.setClientMessages(clusterQueue.getClientMessages(nbMsgGive, null, true));
clusterQueue.forward(id, msgGive);
} else {
// dispatch to cluster.
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG,
"LoadingFactor.processGive" +
" givePerQueue = " + nbGivePerQueue +
", selected = " + selected);
for (Iterator e = selected.iterator(); e.hasNext();) {
AgentId id = (AgentId) e.next();
msgGive.setClientMessages(clusterQueue.getClientMessages(nbGivePerQueue, null, true));
clusterQueue.forward(id, msgGive);
}
}
}