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) classLedgerRecoveryOp.RecoveryReadOp
-
Field Summary
Fields Modifier and Type Field Description (package private) ClientContextclientCtx(package private) longendEntryToRead(package private) BookkeeperInternalCallbacks.ReadEntryListenerentryListener(package private) LedgerHandlelh(package private) static org.slf4j.LoggerLOG(package private) LedgerMetadatametadataForRecovery(package private) java.util.concurrent.CompletableFuture<LedgerHandle>promise(package private) java.util.concurrent.atomic.AtomicLongreadCount(package private) booleanreadDone(package private) longstartEntryToRead(package private) java.util.concurrent.atomic.AtomicLongwriteCount
-
Constructor Summary
Constructors Constructor Description LedgerRecoveryOp(LedgerHandle lh, ClientContext clientCtx)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddComplete(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()voidonEntryComplete(int rc, LedgerHandle lh, LedgerEntry entry, java.lang.Object ctx)On given entry completed.(package private) LedgerRecoveryOpsetEntryListener(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.ReadEntryListenerOn given entry completed.- Specified by:
onEntryCompletein 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.AddCallbackCallback to implement if latency information is not desired.- Specified by:
addCompletein interfaceAsyncCallback.AddCallback- Parameters:
rc- return codelh- ledger handleentryId- entry identifierctx- context object
-
-