Class DataIntegrityCheckImpl

java.lang.Object
org.apache.bookkeeper.bookie.datainteg.DataIntegrityCheckImpl
All Implemented Interfaces:
DataIntegrityCheck

public class DataIntegrityCheckImpl extends Object implements DataIntegrityCheck
An implementation of the DataIntegrityCheck interface.
  • Constructor Details

  • Method Details

    • runPreBootCheck

      public CompletableFuture<Void> runPreBootCheck(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 interface DataIntegrityCheck
    • needsFullCheck

      public boolean needsFullCheck() throws 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 interface DataIntegrityCheck
      Throws:
      IOException
    • runFullCheck

      public CompletableFuture<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 interface DataIntegrityCheck
    • updateMetadataCache

      void updateMetadataCache(Map<Long,LedgerMetadata> ledgers)
    • getCachedOrReadMetadata

      CompletableFuture<Map<Long,LedgerMetadata>> getCachedOrReadMetadata(String runId)
    • checkAndRecoverLedgers

      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, 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, String runId)
    • checkAndRecoverLedgerEntries

      io.reactivex.rxjava3.core.Single<Long> checkAndRecoverLedgerEntries(long ledgerId, LedgerMetadata metadata, 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<Long> maybeCopyEntry(WriteSets writeSets, NavigableMap<Long,Integer> bookieIndices, long ledgerId, long entryId, EntryCopier.Batch batch)
      Returns:
      the number of bytes copied.
    • isEntryMissing

      boolean isEntryMissing(WriteSets writeSets, NavigableMap<Long,Integer> bookieIndices, long ledgerId, long entryId) throws IOException, BookieException
      Throws:
      IOException
      BookieException
    • ensemblesContainBookie

      static boolean ensemblesContainBookie(LedgerMetadata metadata, BookieId bookieId)