Package org.apache.bookkeeper.client
Class LedgerRecoveryOp
- java.lang.Object
-
- org.apache.bookkeeper.client.LedgerRecoveryOp
-
- All Implemented Interfaces:
AsyncCallback.AddCallback
,AsyncCallback.AddCallbackWithLatency
,BookkeeperInternalCallbacks.ReadEntryListener
class LedgerRecoveryOp extends java.lang.Object implements 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
LedgerRecoveryOp.RecoveryReadOp
-
Field Summary
Fields Modifier and Type Field Description (package private) ClientContext
clientCtx
(package private) long
endEntryToRead
(package private) BookkeeperInternalCallbacks.ReadEntryListener
entryListener
(package private) LedgerHandle
lh
(package private) static org.slf4j.Logger
LOG
(package private) LedgerMetadata
metadataForRecovery
(package private) java.util.concurrent.CompletableFuture<LedgerHandle>
promise
(package private) java.util.concurrent.atomic.AtomicLong
readCount
(package private) boolean
readDone
(package private) long
startEntryToRead
(package private) java.util.concurrent.atomic.AtomicLong
writeCount
-
Constructor Summary
Constructors Constructor Description LedgerRecoveryOp(LedgerHandle lh, ClientContext clientCtx)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addComplete(int rc, LedgerHandle lh, long entryId, java.lang.Object ctx)
Callback to implement if latency information is not desired.java.util.concurrent.CompletableFuture<LedgerHandle>
initiate()
void
onEntryComplete(int rc, LedgerHandle lh, LedgerEntry entry, java.lang.Object ctx)
On given entry completed.(package private) LedgerRecoveryOp
setEntryListener(BookkeeperInternalCallbacks.ReadEntryListener entryListener)
Set an entry listener to listen on individual recovery reads during recovery procedure.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.bookkeeper.client.AsyncCallback.AddCallback
addCompleteWithLatency
-
-
-
-
Field Detail
-
LOG
static final org.slf4j.Logger LOG
-
lh
final LedgerHandle lh
-
clientCtx
final ClientContext clientCtx
-
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
-
metadataForRecovery
LedgerMetadata metadataForRecovery
-
entryListener
BookkeeperInternalCallbacks.ReadEntryListener entryListener
-
-
Constructor Detail
-
LedgerRecoveryOp
public LedgerRecoveryOp(LedgerHandle lh, ClientContext clientCtx)
-
-
Method Detail
-
setEntryListener
LedgerRecoveryOp setEntryListener(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:BookkeeperInternalCallbacks.ReadEntryListener
On given entry completed.- Specified by:
onEntryComplete
in interfaceBookkeeperInternalCallbacks.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 interfaceAsyncCallback.AddCallback
- Parameters:
rc
- return codelh
- ledger handleentryId
- entry identifierctx
- context object
-
-