use of org.apache.bookkeeper.replication.ReplicationException.UnavailableException in project bookkeeper by apache.
the class TestLedgerUnderreplicationManager method testDisableLedegerReplication.
/**
* Test disabling the ledger re-replication. After disabling, it will not be
* able to getLedgerToRereplicate(). This calls will enter into infinite
* waiting until enabling rereplication process
*/
@Test
public void testDisableLedegerReplication() throws Exception {
final LedgerUnderreplicationManager replicaMgr = lmf1.newLedgerUnderreplicationManager();
// simulate few urLedgers before disabling
final Long ledgerA = 0xfeadeefdacL;
final String missingReplica = "localhost:3181";
// disabling replication
replicaMgr.disableLedgerReplication();
LOG.info("Disabled Ledeger Replication");
try {
replicaMgr.markLedgerUnderreplicated(ledgerA, missingReplica);
} catch (UnavailableException e) {
LOG.debug("Unexpected exception while marking urLedger", e);
fail("Unexpected exception while marking urLedger" + e.getMessage());
}
Future<Long> fA = getLedgerToReplicate(replicaMgr);
try {
fA.get(1, TimeUnit.SECONDS);
fail("Shouldn't be able to find a ledger to replicate");
} catch (TimeoutException te) {
// expected behaviour, as the replication is disabled
isLedgerReplicationDisabled = false;
}
assertTrue("Ledger replication is not disabled!", !isLedgerReplicationDisabled);
}
Aggregations