Search in sources :

Example 1 with AllocationException

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);
}
Also used : DistributedLogConfiguration(com.twitter.distributedlog.DistributedLogConfiguration) ZKTransaction(com.twitter.distributedlog.zk.ZKTransaction) AllocationException(com.twitter.distributedlog.bk.SimpleLedgerAllocator.AllocationException) Test(org.junit.Test)

Aggregations

DistributedLogConfiguration (com.twitter.distributedlog.DistributedLogConfiguration)1 AllocationException (com.twitter.distributedlog.bk.SimpleLedgerAllocator.AllocationException)1 ZKTransaction (com.twitter.distributedlog.zk.ZKTransaction)1 Test (org.junit.Test)1