ledgers.add(0xffffbeefL);
ledgers.add(0xfacebeefL);
String missingReplica = "localhost:3181";
int count = 0;
LedgerUnderreplicationManager m = lmf1.newLedgerUnderreplicationManager();
Iterator<Long> iter = ledgers.iterator();
while (iter.hasNext()) {
m.markLedgerUnderreplicated(iter.next(), missingReplica);
count++;
}
List<Future<Long>> futures = new ArrayList<Future<Long>>();
for (int i = 0; i < count; i++) {
futures.add(getLedgerToReplicate(m));
}
for (Future<Long> f : futures) {
Long l = f.get(5, TimeUnit.SECONDS);
assertTrue(ledgers.remove(l));
}
Future<Long> f = getLedgerToReplicate(m);
try {
f.get(5, TimeUnit.SECONDS);
fail("Shouldn't be able to find a ledger to replicate");
} catch (TimeoutException te) {
// correct behaviour
}
Long newl = 0xfefefefefefeL;
m.markLedgerUnderreplicated(newl, missingReplica);
assertEquals("Should have got the one just added", newl, f.get(5, TimeUnit.SECONDS));
}