/** * Constructor that takes in a BookKeeper instance . This will be useful, * when user already has bk instance ready. * * @param bkc * - bookkeeper instance * @param statsLogger * - stats logger */ public BookKeeperAdmin(final BookKeeper bkc, StatsLogger statsLogger) { this.bkc = bkc; ownsBK = false; this.lfr = new LedgerFragmentReplicator(bkc, statsLogger); this.mFactory = bkc.ledgerManagerFactory; }
/** * This method asynchronously recovers a ledger fragment which is a * contiguous portion of a ledger that was stored in an ensemble that * included the failed bookie. * * @param lh * - LedgerHandle for the ledger * @param ledgerFragment * - LedgerFragment to replicate * @param ledgerFragmentMcb * - MultiCallback to invoke once we've recovered the current * ledger fragment. * @param newBookies * - New bookies we want to use to recover and replicate the * ledger entries that were stored on the failed bookie. */ private void asyncRecoverLedgerFragment(final LedgerHandle lh, final LedgerFragment ledgerFragment, final AsyncCallback.VoidCallback ledgerFragmentMcb, final Set<BookieSocketAddress> newBookies) throws InterruptedException { lfr.replicate(lh, ledgerFragment, ledgerFragmentMcb, newBookies); }
final Set<BookieSocketAddress> targetBookieAddresses) throws InterruptedException { Set<LedgerFragment> partionedFragments = splitIntoSubFragments(lh, lf, bkc.getConf().getRereplicationEntryBatchSize()); LOG.info("Replicating fragment {} in {} sub fragments.", lf, partionedFragments.size()); replicateNextBatch(lh, partionedFragments.iterator(), ledgerFragmentMcb, targetBookieAddresses);
if (fragments.hasNext()) { try { replicateFragmentInternal(lh, fragments.next(), new AsyncCallback.VoidCallback() { @Override
BKException.Code.LedgerRecoveryException); for (final Long entryId : entriesToReplicate) { recoverLedgerFragmentEntry(entryId, lh, ledgerFragmentEntryMcb, newBookies);
/** * Constructor that takes in a configuration object so we know * how to connect to ZooKeeper to retrieve information about the BookKeeper * cluster. We need this before we can do any type of admin operations on * the BookKeeper cluster. * * @param conf * Client Configuration Object * @throws IOException * throws this exception if there is an error instantiating the * ZooKeeper client. * @throws InterruptedException * Throws this exception if there is an error instantiating the * BookKeeper client. * @throws BKException * Throws this exception if there is an error instantiating the * BookKeeper client. */ public BookKeeperAdmin(ClientConfiguration conf) throws IOException, InterruptedException, BKException { // Create the BookKeeper client instance bkc = new BookKeeper(conf); ownsBK = true; this.lfr = new LedgerFragmentReplicator(bkc, NullStatsLogger.INSTANCE); this.mFactory = bkc.ledgerManagerFactory; }