File ledgerDir = File.createTempFile("bookie", "ledger");
ledgerDir.delete();
ledgerDir.mkdir();
Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(ledgerDir));
ServerConfiguration conf = new ServerConfiguration()
.setZkServers(null)
.setAllowLoopback(true)
.setJournalDirName(journalDir.getPath())
.setLedgerDirNames(new String[] { ledgerDir.getPath() })
.setFlushInterval(1000)
.setPageLimit(1);
Bookie b = new Bookie(conf);
b.start();
for (int i = 1; i <= numLedgers; i++) {
ByteBuffer packet = generateEntry(i, 1);
b.addEntry(packet, new Bookie.NopWriteCallback(), null, "passwd".getBytes());
}
conf = new ServerConfiguration()
.setAllowLoopback(true)
.setZkServers(null)
.setJournalDirName(journalDir.getPath())
.setLedgerDirNames(new String[] { ledgerDir.getPath() });