Class LedgerFragmentReplicator


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

      • replicate

        void replicate​(LedgerHandle lh,
                       LedgerFragment lf,
                       org.apache.zookeeper.AsyncCallback.VoidCallback ledgerFragmentMcb,
                       java.util.Set<BookieId> targetBookieAddresses,
                       java.util.function.BiConsumer<java.lang.Long,​java.lang.Long> onReadEntryFailureCallback)
                throws java.lang.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:
        java.lang.InterruptedException
      • splitIntoSubFragments

        static java.util.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​(java.lang.Long entryId,
                                        LedgerHandle lh,
                                        org.apache.zookeeper.AsyncCallback.VoidCallback ledgerFragmentEntryMcb,
                                        java.util.Set<BookieId> newBookies,
                                        java.util.function.BiConsumer<java.lang.Long,​java.lang.Long> onReadEntryFailureCallback)
                                 throws java.lang.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:
        java.lang.InterruptedException
      • batchRecoverLedgerFragmentEntry

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