Class DataIntegrityCheckImpl
- java.lang.Object
-
- org.apache.bookkeeper.bookie.datainteg.DataIntegrityCheckImpl
-
- All Implemented Interfaces:
DataIntegrityCheck
public class DataIntegrityCheckImpl extends java.lang.Object implements DataIntegrityCheck
An implementation of the DataIntegrityCheck interface.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
DataIntegrityCheckImpl.LedgerResult
-
Constructor Summary
Constructors Constructor Description DataIntegrityCheckImpl(BookieId bookieId, LedgerManager ledgerManager, LedgerStorage ledgerStorage, EntryCopier entryCopier, BookKeeperAdmin admin, io.reactivex.rxjava3.core.Scheduler scheduler)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) io.reactivex.rxjava3.core.Single<java.lang.Long>
checkAndRecoverLedgerEntries(long ledgerId, LedgerMetadata metadata, java.lang.String runId)
Check whether the local storage has all the entries as specified in the metadata.(package private) java.util.concurrent.CompletableFuture<java.util.Set<DataIntegrityCheckImpl.LedgerResult>>
checkAndRecoverLedgers(java.util.Map<java.lang.Long,LedgerMetadata> ledgers, java.lang.String runId)
Check each ledger passed.(package private) static boolean
ensemblesContainBookie(LedgerMetadata metadata, BookieId bookieId)
(package private) java.util.concurrent.CompletableFuture<java.util.Map<java.lang.Long,LedgerMetadata>>
getCachedOrReadMetadata(java.lang.String runId)
(package private) boolean
isEntryMissing(WriteSets writeSets, java.util.NavigableMap<java.lang.Long,java.lang.Integer> bookieIndices, long ledgerId, long entryId)
(package private) io.reactivex.rxjava3.core.Maybe<java.lang.Long>
maybeCopyEntry(WriteSets writeSets, java.util.NavigableMap<java.lang.Long,java.lang.Integer> bookieIndices, long ledgerId, long entryId, EntryCopier.Batch batch)
boolean
needsFullCheck()
Whether we need to run a full check.(package private) io.reactivex.rxjava3.core.Single<LedgerMetadata>
recoverLedger(long ledgerId, java.lang.String runId)
(package private) io.reactivex.rxjava3.core.Maybe<LedgerMetadata>
recoverLedgerIfInLimbo(long ledgerId, LedgerMetadata origMetadata, java.lang.String runId)
Run ledger recovery on all a ledger if it has been marked as in limbo.java.util.concurrent.CompletableFuture<java.lang.Void>
runFullCheck()
Run full check of bookies local data.java.util.concurrent.CompletableFuture<java.lang.Void>
runPreBootCheck(java.lang.String reason)
Run quick preboot check.(package private) void
updateMetadataCache(java.util.Map<java.lang.Long,LedgerMetadata> ledgers)
-
-
-
Constructor Detail
-
DataIntegrityCheckImpl
public DataIntegrityCheckImpl(BookieId bookieId, LedgerManager ledgerManager, LedgerStorage ledgerStorage, EntryCopier entryCopier, BookKeeperAdmin admin, io.reactivex.rxjava3.core.Scheduler scheduler)
-
-
Method Detail
-
runPreBootCheck
public java.util.concurrent.CompletableFuture<java.lang.Void> runPreBootCheck(java.lang.String reason)
Description copied from interface:DataIntegrityCheck
Run quick preboot check. This check should do enough to ensure that it is safe to complete the boot sequence without compromising correctness. To this end, if it finds that this bookie is part of the last ensemble of an unclosed ledger, it must prevent the bookie from being able store new entries for that ledger and must prevent the bookie from taking part in the discovery of the last entry of that ledger.- Specified by:
runPreBootCheck
in interfaceDataIntegrityCheck
-
needsFullCheck
public boolean needsFullCheck() throws java.io.IOException
Description copied from interface:DataIntegrityCheck
Whether we need to run a full check. This condition can be set by the runPreBoot() call to run a full check in the background once the bookie is running. This can later be used to run the full check periodically, or to exponentially backoff and retry when some transient condition prevents a ledger being fixed during a full check.- Specified by:
needsFullCheck
in interfaceDataIntegrityCheck
- Throws:
java.io.IOException
-
runFullCheck
public java.util.concurrent.CompletableFuture<java.lang.Void> runFullCheck()
Description copied from interface:DataIntegrityCheck
Run full check of bookies local data. This check should ensure that if the metadata service states that it should have an entry, then it should have that entry. If the entry is missing, it should copy it from another available source.- Specified by:
runFullCheck
in interfaceDataIntegrityCheck
-
updateMetadataCache
void updateMetadataCache(java.util.Map<java.lang.Long,LedgerMetadata> ledgers)
-
getCachedOrReadMetadata
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.Long,LedgerMetadata>> getCachedOrReadMetadata(java.lang.String runId)
-
checkAndRecoverLedgers
java.util.concurrent.CompletableFuture<java.util.Set<DataIntegrityCheckImpl.LedgerResult>> checkAndRecoverLedgers(java.util.Map<java.lang.Long,LedgerMetadata> ledgers, java.lang.String runId)
Check each ledger passed. If the ledger is in limbo, recover it. Check that the bookie has all entries that it is expected to have. Copy any entries that are missing.- Returns:
- The set of results for all ledgers passed. A result can be OK, Missing or Error. OK and missing ledgers do not need to be looked at again. Error should be retried.
-
recoverLedgerIfInLimbo
io.reactivex.rxjava3.core.Maybe<LedgerMetadata> recoverLedgerIfInLimbo(long ledgerId, LedgerMetadata origMetadata, java.lang.String runId)
Run ledger recovery on all a ledger if it has been marked as in limbo.- Returns:
- a maybe with the most up-to-date metadata we have for the ledger. If the ledger has been deleted, returns empty.
-
recoverLedger
io.reactivex.rxjava3.core.Single<LedgerMetadata> recoverLedger(long ledgerId, java.lang.String runId)
-
checkAndRecoverLedgerEntries
io.reactivex.rxjava3.core.Single<java.lang.Long> checkAndRecoverLedgerEntries(long ledgerId, LedgerMetadata metadata, java.lang.String runId)
Check whether the local storage has all the entries as specified in the metadata. If not, copy them from other available nodes. Returns a single value which is the ledgerId or an error if any entry failed to copy should throw error if any entry failed to copy.
-
maybeCopyEntry
io.reactivex.rxjava3.core.Maybe<java.lang.Long> maybeCopyEntry(WriteSets writeSets, java.util.NavigableMap<java.lang.Long,java.lang.Integer> bookieIndices, long ledgerId, long entryId, EntryCopier.Batch batch)
- Returns:
- the number of bytes copied.
-
isEntryMissing
boolean isEntryMissing(WriteSets writeSets, java.util.NavigableMap<java.lang.Long,java.lang.Integer> bookieIndices, long ledgerId, long entryId) throws java.io.IOException, BookieException
- Throws:
java.io.IOException
BookieException
-
ensemblesContainBookie
static boolean ensemblesContainBookie(LedgerMetadata metadata, BookieId bookieId)
-
-