Search in sources :

Example 6 with BKDigestMatchException

use of org.apache.bookkeeper.client.BKException.BKDigestMatchException in project bookkeeper by apache.

the class BookKeeperApiTest method testOpenLedgerDigestUnmatched.

private void testOpenLedgerDigestUnmatched(boolean autodetection) throws Exception {
    ClientConfiguration conf = new ClientConfiguration();
    conf.setEnableDigestTypeAutodetection(autodetection);
    mockBookKeeperGetConf(conf);
    long lId;
    try (WriteHandle writer = result(newCreateLedgerOp().withAckQuorumSize(1).withWriteQuorumSize(2).withEnsembleSize(3).withDigestType(DigestType.MAC).withPassword(password).execute())) {
        lId = writer.getId();
        assertEquals(-1L, writer.getLastAddPushed());
    }
    try (ReadHandle ignored = result(newOpenLedgerOp().withDigestType(DigestType.CRC32).withPassword(password).withLedgerId(lId).execute())) {
        if (!autodetection) {
            fail("Should fail to open read handle if digest type auto detection is disabled.");
        }
    } catch (BKDigestMatchException bme) {
        if (autodetection) {
            fail("Should not fail to open read handle if digest type auto detection is enabled.");
        }
    }
}
Also used : BKDigestMatchException(org.apache.bookkeeper.client.BKException.BKDigestMatchException) ClientConfiguration(org.apache.bookkeeper.conf.ClientConfiguration)

Aggregations

BKDigestMatchException (org.apache.bookkeeper.client.BKException.BKDigestMatchException)6 ByteBuf (io.netty.buffer.ByteBuf)2 RecoveryData (org.apache.bookkeeper.proto.checksum.DigestManager.RecoveryData)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 ClientConfiguration (org.apache.bookkeeper.conf.ClientConfiguration)1 BookieSocketAddress (org.apache.bookkeeper.net.BookieSocketAddress)1 BookkeeperInternalCallbacks (org.apache.bookkeeper.proto.BookkeeperInternalCallbacks)1 ByteBufList (org.apache.bookkeeper.util.ByteBufList)1 ArgumentMatchers.anyLong (org.mockito.ArgumentMatchers.anyLong)1