Class ZoneawareEnsemblePlacementPolicyImpl

    • Field Detail

      • LOG

        static final org.slf4j.Logger LOG
      • slowBookies

        protected<,​java.lang.Long> slowBookies
      • myNode

        protected myNode
      • myZone

        protected java.lang.String myZone
      • reorderReadsRandom

        protected boolean reorderReadsRandom
      • stabilizePeriodSeconds

        protected int stabilizePeriodSeconds
      • reorderThresholdPendingRequests

        protected int reorderThresholdPendingRequests
      • maxWeightMultiple

        protected int maxWeightMultiple
      • minNumZonesPerWriteQuorum

        protected int minNumZonesPerWriteQuorum
      • desiredNumZonesPerWriteQuorum

        protected int desiredNumZonesPerWriteQuorum
      • enforceStrictZoneawarePlacement

        protected boolean enforceStrictZoneawarePlacement
      • timer

        protected io.netty.util.HashedWheelTimer timer
      • failedToResolveNetworkLocationCounter

                  help="Counter for number of times DNSResolverDecorator failed to resolve Network Location")
        protected Counter failedToResolveNetworkLocationCounter
      • numWritableBookiesInDefaultFaultDomain

                  help="Gauge for the number of writable Bookies in default fault domain")
        protected Gauge<java.lang.Integer> numWritableBookiesInDefaultFaultDomain
    • Constructor Detail

      • ZoneawareEnsemblePlacementPolicyImpl

    • Method Detail

      • initialize

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

        public java.lang.String getDefaultFaultDomain()
      • uninitalize

        public void uninitalize()
        Description copied from interface: EnsemblePlacementPolicy
        Uninitialize the policy.
      • 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.

        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.
      • addDefaultFaultDomainBookies

        protected java.util.Set<> addDefaultFaultDomainBookies​(java.util.Set<> excludeBookies)
      • 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.
        bookieSocketAddress - Address of bookie host
        entryId - Entry ID that caused a speculative timeout on the bookie.
      • 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.
        ensembleList - list of BookieId of bookies in the ensemble
        writeQuorumSize - writeQuorumSize of the ensemble
        ackQuorumSize - ackQuorumSize of the ensemble
      • areAckedBookiesAdheringToPlacementPolicy

        public boolean areAckedBookiesAdheringToPlacementPolicy​(java.util.Set<> ackedBookies,
                                                                int writeQuorumSize,
                                                                int ackQuorumSize)
        Description copied from interface: EnsemblePlacementPolicy
        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.
        ackedBookies - list of BookieId of bookies that have acknowledged a write.
        writeQuorumSize - writeQuorumSize of the ensemble
        ackQuorumSize - ackQuorumSize of the ensemble