Class DefaultEnsemblePlacementPolicy

    • Field Detail

      • LOG

        static final org.slf4j.Logger LOG
      • EMPTY_SET

        static final java.util.Set<org.apache.bookkeeper.net.BookieId> EMPTY_SET
    • Constructor Detail

      • DefaultEnsemblePlacementPolicy

        DefaultEnsemblePlacementPolicy()
    • Method Detail

      • replaceBookie

        public EnsemblePlacementPolicy.PlacementResult<org.apache.bookkeeper.net.BookieId> replaceBookie​(int ensembleSize,
                                                                                                         int writeQuorumSize,
                                                                                                         int ackQuorumSize,
                                                                                                         java.util.Map<java.lang.String,​byte[]> customMetadata,
                                                                                                         java.util.List<org.apache.bookkeeper.net.BookieId> currentEnsemble,
                                                                                                         org.apache.bookkeeper.net.BookieId bookieToReplace,
                                                                                                         java.util.Set<org.apache.bookkeeper.net.BookieId> 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
        Parameters:
        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.
        Returns:
        a placement result containing the new bookie address.
        Throws:
        BKException.BKNotEnoughBookiesException
      • registerSlowBookie

        public void registerSlowBookie​(org.apache.bookkeeper.net.BookieId 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
        Parameters:
        bookieSocketAddress - Address of bookie host
        entryId - Entry ID that caused a speculative timeout on the bookie.
      • reorderReadLACSequence

        public DistributionSchedule.WriteSet reorderReadLACSequence​(java.util.List<org.apache.bookkeeper.net.BookieId> 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
        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.
      • initialize

        public EnsemblePlacementPolicy initialize​(ClientConfiguration conf,
                                                  java.util.Optional<org.apache.bookkeeper.net.DNSToSwitchMapping> 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
        Parameters:
        conf - client configuration
        optionalDnsResolver - dns resolver
        hashedWheelTimer - timer
        featureProvider - feature provider
        statsLogger - stats logger
      • isEnsembleAdheringToPlacementPolicy

        public EnsemblePlacementPolicy.PlacementPolicyAdherence isEnsembleAdheringToPlacementPolicy​(java.util.List<org.apache.bookkeeper.net.BookieId> 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
        Parameters:
        ensembleList - list of BookieId of bookies in the ensemble
        writeQuorumSize - writeQuorumSize of the ensemble
        ackQuorumSize - ackQuorumSize of the ensemble
        Returns: