Package org.apache.bookkeeper.client
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classCallback for recovery of a single ledger fragment.(package private) static class -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLedgerFragmentReplicator(BookKeeper bkc, StatsLogger statsLogger, ClientConfiguration conf) -
Method Summary
Modifier and TypeMethodDescription(package private) voidbatchRecoverLedgerFragmentEntry(long startEntryId, long endEntryId, LedgerHandle lh, org.apache.zookeeper.AsyncCallback.VoidCallback ledgerFragmentMcb, Set<BookieId> newBookies, BiConsumer<Long, Long> onReadEntryFailureCallback) (package private) voidrecoverLedgerFragmentEntry(Long entryId, LedgerHandle lh, org.apache.zookeeper.AsyncCallback.VoidCallback ledgerFragmentEntryMcb, Set<BookieId> newBookies, BiConsumer<Long, Long> onReadEntryFailureCallback) 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.(package private) voidreplicate(LedgerHandle lh, LedgerFragment lf, org.apache.zookeeper.AsyncCallback.VoidCallback ledgerFragmentMcb, Set<BookieId> targetBookieAddresses, BiConsumer<Long, Long> onReadEntryFailureCallback) 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.(package private) 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.
-
Field Details
-
replicationThrottle
-
-
Constructor Details
-
LedgerFragmentReplicator
-
LedgerFragmentReplicator
-
-
Method Details
-
replicate
void replicate(LedgerHandle lh, LedgerFragment lf, org.apache.zookeeper.AsyncCallback.VoidCallback ledgerFragmentMcb, Set<BookieId> targetBookieAddresses, BiConsumer<Long, Long> onReadEntryFailureCallback) throws InterruptedExceptionThis 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 ledgerlf- LedgerFragment to replicateledgerFragmentMcb- 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 InterruptedExceptionThis 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 ledgerledgerFragmentEntryMcb- 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
-