final Calendar currentTime = Calendar.getInstance();
final LinkedList killList = new LinkedList();
for (int i = 0; i < toSweep.length; i++) {
final Sweepable sw = toSweep[i];
if (sw != null) {
final boolean expired = isExpired(sw.getTerminationTime(),
currentTime);
if (expired) {
logger.debug("Sweep found that " + Lager.id(sw.getID()) + " is expired.");
}
if (sw.isZombie()) {
// Only attempt on the following attempt # of sweeper runs:
// 1st, 2nd, 3rd, 6th, 10th, 15th, 25th, and then on modulo 20's
final Integer exists = this.zombieBackoffs.get(sw.getID());
final Integer attemptCount;
if (exists == null) {
attemptCount = 1;
} else {
attemptCount = exists + 1;
}
this.zombieBackoffs.put(sw.getID(), attemptCount);
int actualRetryNumber = attemptCount;
if (attemptCount < 40) {
switch (attemptCount) {
case 1:
break;
case 2:
break;
case 3:
break;
case 6:
actualRetryNumber = 4;
break;
case 10:
actualRetryNumber = 5;
break;
case 15:
actualRetryNumber = 6;
break;
case 25:
actualRetryNumber = 7;
break;
default:
continue;
}
} else {
if (attemptCount % 20 != 0) {
continue;
} else {
actualRetryNumber = 6 + attemptCount / 20;
}
}
logger.warn(Lager.ev(sw.getID()) + "Node that could not be destroyed " +
"previously, attempting again. Retry #" + actualRetryNumber);
}
if (expired || sw.isZombie()) {
final DestroyFutureTask task =
new DestroyFutureTask(sw.getID(), this.home);
killList.add(new FutureTask(task));
}
}
}