ServerConfiguration conf = bsConfs.get(0);
killBookie(0);
final CountDownLatch latch = new CountDownLatch(1);
final CountDownLatch shutdownComplete = new CountDownLatch(1);
// simulating ZooKeeper exception by assigning a closed zk client to bk
BookieServer bkServer = new BookieServer(conf) {
protected Bookie newBookie(ServerConfiguration conf)
throws IOException, KeeperException, InterruptedException,
BookieException {
return new Bookie(conf) {
@Override
public void addEntry(ByteBuffer entry, WriteCallback cb,
Object ctx, byte[] masterKey)
throws IOException, BookieException {
throw new OutOfMemoryError();
}
};
}
};
bkServer.start();
LedgerHandle lh = bkc.createLedger(1, 1, BookKeeper.DigestType.CRC32, "passwd".getBytes());
lh.asyncAddEntry("test".getBytes(), new AddCallback() {
@Override
public void addComplete(int rc, LedgerHandle lh, long entryId, Object ctx) {
// dont care, only trying to trigger OOM
}
}, null);
bkServer.join();
Assert.assertFalse("Should have died", bkServer.isRunning());
Assert.assertEquals("Should have died with server exception code",
ExitCode.SERVER_EXCEPTION, bkServer.getExitCode());
}