Class DataIntegrityCheckImpl

  • All Implemented Interfaces:
    DataIntegrityCheck

    public class DataIntegrityCheckImpl
    extends java.lang.Object
    implements DataIntegrityCheck
    An implementation of the DataIntegrityCheck interface.
    • 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 interface DataIntegrityCheck
      • 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 interface DataIntegrityCheck
        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 interface DataIntegrityCheck
      • 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 he 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)