Class LedgerRecoveryOp

  • All Implemented Interfaces:
    AsyncCallback.AddCallback, AsyncCallback.AddCallbackWithLatency, org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.ReadEntryListener

    class LedgerRecoveryOp
    extends java.lang.Object
    implements org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.ReadEntryListener, AsyncCallback.AddCallback
    This class encapsulated the ledger recovery operation. It first does a read with entry-id of -1 (BookieProtocol.LAST_ADD_CONFIRMED) to all bookies. Then starting from the last confirmed entry (from hints in the ledger entries), it reads forward until it is not able to find a particular entry.
    • Field Detail

      • LOG

        static final org.slf4j.Logger LOG
      • promise

        final java.util.concurrent.CompletableFuture<LedgerHandle> promise
      • readCount

        final java.util.concurrent.atomic.AtomicLong readCount
      • writeCount

        final java.util.concurrent.atomic.AtomicLong writeCount
      • readDone

        volatile boolean readDone
      • startEntryToRead

        volatile long startEntryToRead
      • endEntryToRead

        volatile long endEntryToRead
      • entryListener

        org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.ReadEntryListener entryListener
    • Method Detail

      • setEntryListener

        LedgerRecoveryOp setEntryListener​(org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.ReadEntryListener entryListener)
        Set an entry listener to listen on individual recovery reads during recovery procedure.
        Parameters:
        entryListener - entry listener
        Returns:
        ledger recovery operation
      • initiate

        public java.util.concurrent.CompletableFuture<LedgerHandle> initiate()
      • onEntryComplete

        public void onEntryComplete​(int rc,
                                    LedgerHandle lh,
                                    LedgerEntry entry,
                                    java.lang.Object ctx)
        Description copied from interface: org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.ReadEntryListener
        On given entry completed.
        Specified by:
        onEntryComplete in interface org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.ReadEntryListener
        Parameters:
        rc - result code of reading this entry.
        lh - ledger handle.
        entry - ledger entry.
        ctx - callback context.
      • addComplete

        public void addComplete​(int rc,
                                LedgerHandle lh,
                                long entryId,
                                java.lang.Object ctx)
        Description copied from interface: AsyncCallback.AddCallback
        Callback to implement if latency information is not desired.
        Specified by:
        addComplete in interface AsyncCallback.AddCallback
        Parameters:
        rc - return code
        lh - ledger handle
        entryId - entry identifier
        ctx - context object