Search in sources :

Example 16 with UnavailableException

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);
}
Also used : ZkLedgerUnderreplicationManager(org.apache.bookkeeper.meta.ZkLedgerUnderreplicationManager) LedgerUnderreplicationManager(org.apache.bookkeeper.meta.LedgerUnderreplicationManager) UnavailableException(org.apache.bookkeeper.replication.ReplicationException.UnavailableException) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.Test)

Aggregations

UnavailableException (org.apache.bookkeeper.replication.ReplicationException.UnavailableException)16 BKException (org.apache.bookkeeper.client.BKException)4 LedgerUnderreplicationManager (org.apache.bookkeeper.meta.LedgerUnderreplicationManager)4 BKAuditException (org.apache.bookkeeper.replication.ReplicationException.BKAuditException)4 CompatibilityException (org.apache.bookkeeper.replication.ReplicationException.CompatibilityException)4 KeeperException (org.apache.zookeeper.KeeperException)4 BookieSocketAddress (org.apache.bookkeeper.net.BookieSocketAddress)3 Watcher (org.apache.zookeeper.Watcher)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 List (java.util.List)2 Set (java.util.Set)2 BKNoSuchLedgerExistsException (org.apache.bookkeeper.client.BKException.BKNoSuchLedgerExistsException)2 BookKeeperTestClient (org.apache.bookkeeper.client.BookKeeperTestClient)2 LedgerFragment (org.apache.bookkeeper.client.LedgerFragment)2 LedgerHandle (org.apache.bookkeeper.client.LedgerHandle)2 ClientConfiguration (org.apache.bookkeeper.conf.ClientConfiguration)2 ServerConfiguration (org.apache.bookkeeper.conf.ServerConfiguration)2