@Test(timeout=60000)
public void testDirectoryMissing() throws Exception {
String[] ledgerDirs = new String[] {
newDirectory(), newDirectory(), newDirectory() };
String journalDir = newDirectory();
ServerConfiguration conf = new ServerConfiguration()
.setAllowLoopback(true)
.setZkServers(zkutil.getZooKeeperConnectString())
.setJournalDirName(journalDir)
.setLedgerDirNames(ledgerDirs)
.setBookiePort(bookiePort);
Bookie b = new Bookie(conf); // should work fine
b.start();
b.shutdown();
conf.setLedgerDirNames(new String[] { ledgerDirs[0], ledgerDirs[1] });
try {
Bookie b2 = new Bookie(conf);
fail("Shouldn't have been able to start");
} catch (BookieException.InvalidCookieException ice) {
// correct behaviour
}
conf.setJournalDirName(newDirectory()).setLedgerDirNames(ledgerDirs);
try {
Bookie b2 = new Bookie(conf);
fail("Shouldn't have been able to start");
} catch (BookieException.InvalidCookieException ice) {
// correct behaviour
}
conf.setJournalDirName(journalDir);
b = new Bookie(conf);
b.start();
b.shutdown();
}