Interface EnsemblePlacementPolicy

    • Method Detail

      • uninitalize

        void uninitalize()
        Uninitialize the policy.
      • onClusterChanged

        java.util.Set<BookieId> onClusterChanged​(java.util.Set<BookieId> writableBookies,
                                                 java.util.Set<BookieId> readOnlyBookies)
        A consistent view of the cluster (what bookies are available as writable, what bookies are available as readonly) is updated when any changes happen in the cluster.

        The implementation should take actions when the cluster view is changed. So subsequent newEnsemble(int, int, int, Map, Set) and replaceBookie(int, int, int, java.util.Map, java.util.List, BookieId, java.util.Set) can choose proper bookies.

        Parameters:
        writableBookies - All the bookies in the cluster available for write/read.
        readOnlyBookies - All the bookies in the cluster available for readonly.
        Returns:
        the dead bookies during this cluster change.
      • registerSlowBookie

        void registerSlowBookie​(BookieId bookieSocketAddress,
                                long entryId)
        Register a bookie as slow so that it is tried after available and read-only bookies.
        Parameters:
        bookieSocketAddress - Address of bookie host
        entryId - Entry ID that caused a speculative timeout on the bookie.
      • reorderReadSequence

        DistributionSchedule.WriteSet reorderReadSequence​(java.util.List<BookieId> ensemble,
                                                          BookiesHealthInfo bookiesHealthInfo,
                                                          DistributionSchedule.WriteSet writeSet)
        Reorder the read sequence of a given write quorum writeSet.
        Parameters:
        ensemble - Ensemble to read entries.
        bookiesHealthInfo - Health info for bookies
        writeSet - Write quorum to read entries. This will be modified, rather than allocating a new WriteSet.
        Returns:
        The read sequence. This will be the same object as the passed in writeSet.
        Since:
        4.5
      • reorderReadLACSequence

        DistributionSchedule.WriteSet reorderReadLACSequence​(java.util.List<BookieId> ensemble,
                                                             BookiesHealthInfo bookiesHealthInfo,
                                                             DistributionSchedule.WriteSet writeSet)
        Reorder the read last add confirmed sequence of a given write quorum writeSet.
        Parameters:
        ensemble - Ensemble to read entries.
        bookiesHealthInfo - Health info for bookies
        writeSet - Write quorum to read entries. This will be modified, rather than allocating a new WriteSet.
        Returns:
        The read sequence. This will be the same object as the passed in writeSet.
        Since:
        4.5
      • updateBookieInfo

        default void updateBookieInfo​(java.util.Map<BookieId,​BookieInfoReader.BookieInfo> bookieInfoMap)
        Send the bookie info details.
        Parameters:
        bookieInfoMap - A map that has the bookie to BookieInfo
        Since:
        4.5
      • getStickyReadBookieIndex

        default int getStickyReadBookieIndex​(LedgerMetadata metadata,
                                             java.util.Optional<java.lang.Integer> currentStickyBookieIndex)
        Select one bookie to the "sticky" bookie where all reads for a particular ledger will be directed to.

        The default implementation will pick a bookie randomly from the ensemble. Other placement policies will be able to do better decisions based on additional informations (eg: rack or region awareness).

        Parameters:
        metadata - the LedgerMetadata object
        currentStickyBookieIndex - if we are changing the sticky bookie after a read failure, the current sticky bookie is passed in so that we will avoid choosing it again
        Returns:
        the index, within the ensemble of the bookie chosen as the sticky bookie
        Since:
        4.9
      • isEnsembleAdheringToPlacementPolicy

        default EnsemblePlacementPolicy.PlacementPolicyAdherence isEnsembleAdheringToPlacementPolicy​(java.util.List<BookieId> ensembleList,
                                                                                                     int writeQuorumSize,
                                                                                                     int ackQuorumSize)
        returns AdherenceLevel if the Ensemble is strictly/softly/fails adhering to placement policy, like in the case of RackawareEnsemblePlacementPolicy, bookies in the writeset are from 'minNumRacksPerWriteQuorum' number of racks. And in the case of RegionawareEnsemblePlacementPolicy, check for minimumRegionsForDurability, reppRegionsToWrite, rack distribution within a region and other parameters of RegionAwareEnsemblePlacementPolicy. In ZoneAwareEnsemblePlacementPolicy if bookies in the writeset are from 'desiredNumOfZones' then it is considered as MEETS_STRICT if they are from 'minNumOfZones' then it is considered as MEETS_SOFT otherwise considered as FAIL.
        Parameters:
        ensembleList - list of BookieId of bookies in the ensemble
        writeQuorumSize - writeQuorumSize of the ensemble
        ackQuorumSize - ackQuorumSize of the ensemble
        Returns:
      • areAckedBookiesAdheringToPlacementPolicy

        default boolean areAckedBookiesAdheringToPlacementPolicy​(java.util.Set<BookieId> ackedBookies,
                                                                 int writeQuorumSize,
                                                                 int ackQuorumSize)
        Returns true if the bookies that have acknowledged a write adhere to the minimum fault domains as defined in the placement policy in use. Ex: In the case of RackawareEnsemblePlacementPolicy, bookies belong to at least 'minNumRacksPerWriteQuorum' number of racks.
        Parameters:
        ackedBookies - list of BookieId of bookies that have acknowledged a write.
        writeQuorumSize - writeQuorumSize of the ensemble
        ackQuorumSize - ackQuorumSize of the ensemble
        Returns:
      • replaceToAdherePlacementPolicy

        default EnsemblePlacementPolicy.PlacementResult<java.util.List<BookieId>> replaceToAdherePlacementPolicy​(int ensembleSize,
                                                                                                                 int writeQuorumSize,
                                                                                                                 int ackQuorumSize,
                                                                                                                 java.util.Set<BookieId> excludeBookies,
                                                                                                                 java.util.List<BookieId> currentEnsemble)
        Returns placement result. If the currentEnsemble is not adhering placement policy, returns new ensemble that adheres placement policy. It should be implemented so as to minify the number of bookies replaced.
        Parameters:
        ensembleSize - ensemble size
        writeQuorumSize - writeQuorumSize of the ensemble
        ackQuorumSize - ackQuorumSize of the ensemble
        excludeBookies - bookies that should not be considered as targets
        currentEnsemble - current ensemble
        Returns:
        a placement result