Package org.apache.bookkeeper.client
Class LedgerFragmentReplicator
- java.lang.Object
-
- org.apache.bookkeeper.client.LedgerFragmentReplicator
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
LedgerFragmentReplicator.SingleFragmentCallback
Callback for recovery of a single ledger fragment.(package private) static class
LedgerFragmentReplicator.Throttler
-
Field Summary
Fields Modifier and Type Field Description protected LedgerFragmentReplicator.Throttler
replicationThrottle
-
Constructor Summary
Constructors Constructor Description LedgerFragmentReplicator(BookKeeper bkc, ClientConfiguration conf)
LedgerFragmentReplicator(BookKeeper bkc, StatsLogger statsLogger, ClientConfiguration conf)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) 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)
(package private) 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)
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) 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)
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 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.
-
-
-
Field Detail
-
replicationThrottle
protected LedgerFragmentReplicator.Throttler replicationThrottle
-
-
Constructor Detail
-
LedgerFragmentReplicator
public LedgerFragmentReplicator(BookKeeper bkc, StatsLogger statsLogger, ClientConfiguration conf)
-
LedgerFragmentReplicator
public LedgerFragmentReplicator(BookKeeper bkc, ClientConfiguration conf)
-
-
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 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:
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 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:
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
-
-