}
/** Updates the plan with all pairs of nodes from this bucket which need to be connected */
public void updatePlan() {
while (!this.sources.isEmpty() && !this.targets.isEmpty()) {
Source source = this.sources.poll();
Target target = this.targets.poll();
if (!wasUrgent(source) && !wasUrgent(target)) {
// Due to ordering of DataNodes we can skip the rest
break;
}
long size = moveSize(source, target);
if (size > 0) {
scheduleTask(source, size, target);
}
if (source.getAvailableMoveSize() > 0) {
this.sources.add(source);
}
if (target.getAvailableMoveSize() > 0) {
this.targets.add(target);
}