Class DefaultEnsemblePlacementPolicy

    • Field Detail

      • LOG

        static final org.slf4j.Logger LOG
      • EMPTY_SET

        static final java.util.Set<> EMPTY_SET
    • Constructor Detail

      • DefaultEnsemblePlacementPolicy

    • Method Detail

      • replaceBookie

        public EnsemblePlacementPolicy.PlacementResult<> replaceBookie​(int ensembleSize,
                                                                                                         int writeQuorumSize,
                                                                                                         int ackQuorumSize,
                                                                                                         java.util.Map<java.lang.String,​byte[]> customMetadata,
                                                                                                         java.util.List<> currentEnsemble,
                                                                                                         java.util.Set<> excludeBookies)
                                                                                                  throws BKException.BKNotEnoughBookiesException
        Description copied from interface: EnsemblePlacementPolicy
        Choose a new bookie to replace bookieToReplace. If no bookie available in the cluster, BKException.BKNotEnoughBookiesException is thrown.

        If 'enforceMinNumRacksPerWriteQuorum' config is enabled then the bookies belonging to default faultzone (rack) will be excluded while selecting bookies.

        Specified by:
        replaceBookie in interface EnsemblePlacementPolicy
        ensembleSize - the value of ensembleSize
        writeQuorumSize - the value of writeQuorumSize
        ackQuorumSize - the value of ackQuorumSize (added since 4.5)
        customMetadata - the value of customMetadata. it is the same user defined metadata that user provides in BookKeeper.createLedger(int, int, int, BookKeeper.DigestType, byte[])
        currentEnsemble - the value of currentEnsemble
        bookieToReplace - bookie to replace
        excludeBookies - bookies that should not be considered as candidate.
        a placement result containing the new bookie address.
      • registerSlowBookie

        public void registerSlowBookie​( bookieSocketAddress,
                                       long entryId)
        Description copied from interface: EnsemblePlacementPolicy
        Register a bookie as slow so that it is tried after available and read-only bookies.
        Specified by:
        registerSlowBookie in interface EnsemblePlacementPolicy
        bookieSocketAddress - Address of bookie host
        entryId - Entry ID that caused a speculative timeout on the bookie.
      • reorderReadLACSequence

        public DistributionSchedule.WriteSet reorderReadLACSequence​(java.util.List<> ensemble,
                                                                    BookiesHealthInfo bookiesHealthInfo,
                                                                    DistributionSchedule.WriteSet writeSet)
        Description copied from interface: EnsemblePlacementPolicy
        Reorder the read last add confirmed sequence of a given write quorum writeSet.
        Specified by:
        reorderReadLACSequence in interface EnsemblePlacementPolicy
        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.
        The read sequence. This will be the same object as the passed in writeSet.
      • initialize

        public EnsemblePlacementPolicy initialize​(ClientConfiguration conf,
                                                  java.util.Optional<> optionalDnsResolver,
                                                  io.netty.util.HashedWheelTimer hashedWheelTimer,
                                                  FeatureProvider featureProvider,
                                                  StatsLogger statsLogger,
                                                  org.apache.bookkeeper.proto.BookieAddressResolver bookieAddressResolver)
        Description copied from interface: EnsemblePlacementPolicy
        Initialize the policy.
        Specified by:
        initialize in interface EnsemblePlacementPolicy
        conf - client configuration
        optionalDnsResolver - dns resolver
        hashedWheelTimer - timer
        featureProvider - feature provider
        statsLogger - stats logger
      • isEnsembleAdheringToPlacementPolicy

        public EnsemblePlacementPolicy.PlacementPolicyAdherence isEnsembleAdheringToPlacementPolicy​(java.util.List<> ensembleList,
                                                                                                    int writeQuorumSize,
                                                                                                    int ackQuorumSize)
        Description copied from interface: EnsemblePlacementPolicy
        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.
        Specified by:
        isEnsembleAdheringToPlacementPolicy in interface EnsemblePlacementPolicy
        ensembleList - list of BookieId of bookies in the ensemble
        writeQuorumSize - writeQuorumSize of the ensemble
        ackQuorumSize - ackQuorumSize of the ensemble