Class LedgerFragmentReplicator

java.lang.Object
org.apache.bookkeeper.client.LedgerFragmentReplicator

@StatsDoc(name="replication_worker", help="Ledger fragment replicator related stats") public class LedgerFragmentReplicator extends Object
This is the helper class for replicating the fragments from one bookie to another.
  • Field Details

  • Constructor Details

  • Method Details

    • replicate

      void replicate(LedgerHandle lh, LedgerFragment lf, org.apache.zookeeper.AsyncCallback.VoidCallback ledgerFragmentMcb, Set<BookieId> targetBookieAddresses, BiConsumer<Long,Long> onReadEntryFailureCallback) throws InterruptedException
      This method replicate a ledger fragment which is a contiguous portion of a ledger that was stored in an ensemble that included the failed bookie. It will Splits the fragment into multiple sub fragments by keeping the max entries up to the configured value of rereplicationEntryBatchSize and then it re-replicates that batched entry fragments one by one. After re-replication of all batched entry fragments, it will update the ensemble info with new Bookie once
      Parameters:
      lh - LedgerHandle for the ledger
      lf - LedgerFragment to replicate
      ledgerFragmentMcb - MultiCallback to invoke once we've recovered the current ledger fragment.
      targetBookieAddresses - New bookies we want to use to recover and replicate the ledger entries that were stored on the failed bookie.
      Throws:
      InterruptedException
    • splitIntoSubFragments

      static Set<LedgerFragment> splitIntoSubFragments(LedgerHandle lh, LedgerFragment ledgerFragment, long rereplicationEntryBatchSize)
      Split the full fragment into batched entry fragments by keeping rereplicationEntryBatchSize of entries in each one and can treat them as sub fragments.
    • recoverLedgerFragmentEntry

      void recoverLedgerFragmentEntry(Long entryId, LedgerHandle lh, org.apache.zookeeper.AsyncCallback.VoidCallback ledgerFragmentEntryMcb, Set<BookieId> newBookies, BiConsumer<Long,Long> onReadEntryFailureCallback) throws InterruptedException
      This method asynchronously recovers a specific ledger entry by reading the values via the BookKeeper Client (which would read it from the other replicas) and then writing it to the chosen new bookie.
      Parameters:
      entryId - Ledger Entry ID to recover.
      lh - LedgerHandle for the ledger
      ledgerFragmentEntryMcb - MultiCallback to invoke once we've recovered the current ledger entry.
      newBookies - New bookies we want to use to recover and replicate the ledger entries that were stored on the failed bookie.
      Throws:
      InterruptedException
    • batchRecoverLedgerFragmentEntry

      void batchRecoverLedgerFragmentEntry(long startEntryId, long endEntryId, LedgerHandle lh, org.apache.zookeeper.AsyncCallback.VoidCallback ledgerFragmentMcb, Set<BookieId> newBookies, BiConsumer<Long,Long> onReadEntryFailureCallback) throws InterruptedException
      Throws:
      InterruptedException