for (int i = 0; i < (numBookies*3)+1; i++) {
lhbefore.addEntry("data".getBytes());
}
// Add a dead bookie to the cluster
ServerConfiguration conf = newServerConfiguration();
Bookie deadBookie1 = new Bookie(conf) {
@Override
public void recoveryAddEntry(ByteBuffer entry, WriteCallback cb, Object ctx, byte[] masterKey)
throws IOException, BookieException {
// drop request to simulate a slow and failed bookie
throw new IOException("Couldn't write for some reason");
}
};
bsConfs.add(conf);
bs.add(startBookie(conf, deadBookie1));
// kill first bookie server
InetSocketAddress bookie1 = lhbefore.getLedgerMetadata().currentEnsemble.get(0);
ServerConfiguration conf1 = killBookie(bookie1);
// Try to recover and fence the ledger after killing one bookie in the
// ensemble in the ensemble, and another bookie is available in zk, but not writtable
try {
bkc.openLedger(lhbefore.getId(), digestType, "".getBytes());
fail("Shouldn't be able to open ledger, there should be entries missing");
} catch (BKException.BKLedgerRecoveryException e) {
// expected
}
// restart the first server, kill the second
bsConfs.add(conf1);
bs.add(startBookie(conf1));
InetSocketAddress bookie2 = lhbefore.getLedgerMetadata().currentEnsemble.get(1);
ServerConfiguration conf2 = killBookie(bookie2);
// using async, because this could trigger an assertion
final AtomicInteger returnCode = new AtomicInteger(0);
final CountDownLatch openLatch = new CountDownLatch(1);
bkc.asyncOpenLedger(lhbefore.getId(), digestType, "".getBytes(),