Search in sources :

Example 1 with SyncOpenCallback

use of org.apache.bookkeeper.client.SyncCallbackUtils.SyncOpenCallback in project bookkeeper by apache.

the class BookKeeper method openLedgerNoRecovery.

/**
 * Synchronous, unsafe open ledger call.
 *
 * @see #asyncOpenLedgerNoRecovery
 * @param lId
 *          ledger identifier
 * @param digestType
 *          digest type, either MAC or CRC32
 * @param passwd
 *          password
 * @return a handle to the open ledger
 * @throws InterruptedException
 * @throws BKException
 */
public LedgerHandle openLedgerNoRecovery(long lId, DigestType digestType, byte[] passwd) throws BKException, InterruptedException {
    CompletableFuture<LedgerHandle> future = new CompletableFuture<>();
    SyncOpenCallback result = new SyncOpenCallback(future);
    /*
         * Calls async open ledger
         */
    asyncOpenLedgerNoRecovery(lId, digestType, passwd, result, null);
    return SyncCallbackUtils.waitForResult(future);
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) SyncOpenCallback(org.apache.bookkeeper.client.SyncCallbackUtils.SyncOpenCallback)

Example 2 with SyncOpenCallback

use of org.apache.bookkeeper.client.SyncCallbackUtils.SyncOpenCallback in project bookkeeper by apache.

the class BookKeeperAdmin method openLedger.

/**
 * Open a ledger as an administrator. This means that no digest password
 * checks are done. Otherwise, the call is identical to
 * BookKeeper#openLedger
 *
 * @param lId
 *            - ledger identifier
 * @see BookKeeper#openLedger
 */
public LedgerHandle openLedger(final long lId) throws InterruptedException, BKException {
    CompletableFuture<LedgerHandle> future = new CompletableFuture<>();
    SyncOpenCallback result = new SyncOpenCallback(future);
    new LedgerOpenOp(bkc, lId, result, null).initiate();
    return SyncCallbackUtils.waitForResult(future);
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) SyncOpenCallback(org.apache.bookkeeper.client.SyncCallbackUtils.SyncOpenCallback)

Example 3 with SyncOpenCallback

use of org.apache.bookkeeper.client.SyncCallbackUtils.SyncOpenCallback in project bookkeeper by apache.

the class BookKeeper method openLedger.

/**
 * Synchronous open ledger call.
 *
 * @see #asyncOpenLedger
 * @param lId
 *          ledger identifier
 * @param digestType
 *          digest type, either MAC or CRC32
 * @param passwd
 *          password
 * @return a handle to the open ledger
 * @throws InterruptedException
 * @throws BKException
 */
public LedgerHandle openLedger(long lId, DigestType digestType, byte[] passwd) throws BKException, InterruptedException {
    CompletableFuture<LedgerHandle> future = new CompletableFuture<>();
    SyncOpenCallback result = new SyncOpenCallback(future);
    /*
         * Calls async open ledger
         */
    asyncOpenLedger(lId, digestType, passwd, result, null);
    return SyncCallbackUtils.waitForResult(future);
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) SyncOpenCallback(org.apache.bookkeeper.client.SyncCallbackUtils.SyncOpenCallback)

Example 4 with SyncOpenCallback

use of org.apache.bookkeeper.client.SyncCallbackUtils.SyncOpenCallback in project bookkeeper by apache.

the class BookKeeperAdmin method openLedgerNoRecovery.

/**
 * Open a ledger as an administrator without recovering the ledger. This
 * means that no digest password checks are done. Otherwise, the call is
 * identical to BookKeeper#openLedgerNoRecovery
 *
 * @param lId
 *            ledger identifier
 * @see BookKeeper#openLedgerNoRecovery
 */
@SuppressWarnings("unchecked")
public LedgerHandle openLedgerNoRecovery(final long lId) throws InterruptedException, BKException {
    CompletableFuture<LedgerHandle> future = new CompletableFuture<>();
    SyncOpenCallback result = new SyncOpenCallback(future);
    new LedgerOpenOp(bkc, lId, result, null).initiateWithoutRecovery();
    return SyncCallbackUtils.waitForResult(future);
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) SyncOpenCallback(org.apache.bookkeeper.client.SyncCallbackUtils.SyncOpenCallback)

Aggregations

CompletableFuture (java.util.concurrent.CompletableFuture)4 SyncOpenCallback (org.apache.bookkeeper.client.SyncCallbackUtils.SyncOpenCallback)4