Search in sources :

Example 1 with SingleFragmentCallback

use of org.apache.bookkeeper.client.LedgerFragmentReplicator.SingleFragmentCallback in project bookkeeper by apache.

the class BookKeeperAdmin method replicateLedgerFragment.

private void replicateLedgerFragment(LedgerHandle lh, final LedgerFragment ledgerFragment, final Map<Integer, BookieSocketAddress> targetBookieAddresses) throws InterruptedException, BKException {
    CompletableFuture<Void> result = new CompletableFuture<>();
    ResultCallBack resultCallBack = new ResultCallBack(result);
    SingleFragmentCallback cb = new SingleFragmentCallback(resultCallBack, lh, ledgerFragment.getFirstEntryId(), getReplacementBookiesMap(ledgerFragment, targetBookieAddresses));
    Set<BookieSocketAddress> targetBookieSet = Sets.newHashSet();
    targetBookieSet.addAll(targetBookieAddresses.values());
    asyncRecoverLedgerFragment(lh, ledgerFragment, cb, targetBookieSet);
    try {
        SyncCallbackUtils.waitForResult(result);
    } catch (BKException err) {
        throw BKException.create(bkc.getReturnRc(err.getCode()));
    }
}
Also used : SingleFragmentCallback(org.apache.bookkeeper.client.LedgerFragmentReplicator.SingleFragmentCallback) CompletableFuture(java.util.concurrent.CompletableFuture) BookieSocketAddress(org.apache.bookkeeper.net.BookieSocketAddress)

Aggregations

CompletableFuture (java.util.concurrent.CompletableFuture)1 SingleFragmentCallback (org.apache.bookkeeper.client.LedgerFragmentReplicator.SingleFragmentCallback)1 BookieSocketAddress (org.apache.bookkeeper.net.BookieSocketAddress)1