use of com.twitter.distributedlog.bk.SimpleLedgerAllocator.AllocationException in project distributedlog by twitter.
the class TestLedgerAllocator method testAllocatorWithoutEnoughBookies.
@Test(timeout = 60000)
public void testAllocatorWithoutEnoughBookies() throws Exception {
String allocationPath = "/allocator-without-enough-bookies";
DistributedLogConfiguration confLocal = new DistributedLogConfiguration();
confLocal.addConfiguration(conf);
confLocal.setEnsembleSize(numBookies * 2);
confLocal.setWriteQuorumSize(numBookies * 2);
SimpleLedgerAllocator allocator1 = createAllocator(allocationPath, confLocal);
allocator1.allocate();
ZKTransaction txn1 = newTxn();
try {
FutureUtils.result(allocator1.tryObtain(txn1, NULL_LISTENER));
fail("Should fail allocating ledger if there aren't enough bookies");
} catch (AllocationException ioe) {
// expected
assertEquals(Phase.ERROR, ioe.getPhase());
}
byte[] data = zkc.get().getData(allocationPath, false, null);
assertEquals(0, data.length);
}
Aggregations