Class RackawareEnsemblePlacementPolicyImpl

    • Field Detail

      • LOG

        static final org.slf4j.Logger LOG
      • maxWeightMultiple

        int maxWeightMultiple
      • minNumRacksPerWriteQuorum

        protected int minNumRacksPerWriteQuorum
      • enforceMinNumRacksPerWriteQuorum

        protected boolean enforceMinNumRacksPerWriteQuorum
      • ignoreLocalNodeInPlacementPolicy

        protected boolean ignoreLocalNodeInPlacementPolicy

        public static final java.lang.String REPP_RANDOM_READ_REORDERING
        See Also:
        Constant Field Values

        static final int RACKNAME_DISTANCE_FROM_LEAVES
        See Also:
        Constant Field Values
      • timer

        protected io.netty.util.HashedWheelTimer timer
      • slowBookies

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

        protected localNode
      • reorderReadsRandom

        protected boolean reorderReadsRandom
      • enforceDurability

        protected boolean enforceDurability
      • stabilizePeriodSeconds

        protected int stabilizePeriodSeconds
      • reorderThresholdPendingRequests

        protected int reorderThresholdPendingRequests
      • readReorderedCounter

                  help="The distribution of number of bookies reordered on each read request")
        protected OpStatsLogger readReorderedCounter
      • failedToResolveNetworkLocationCounter

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

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

      • RackawareEnsemblePlacementPolicyImpl

      • RackawareEnsemblePlacementPolicyImpl

        RackawareEnsemblePlacementPolicyImpl​(boolean enforceDurability)
    • Method Detail

      • initialize

        protected RackawareEnsemblePlacementPolicyImpl initialize​( dnsResolver,
                                                                  io.netty.util.HashedWheelTimer timer,
                                                                  boolean reorderReadsRandom,
                                                                  int stabilizePeriodSeconds,
                                                                  int reorderThresholdPendingRequests,
                                                                  boolean isWeighted,
                                                                  int maxWeightMultiple,
                                                                  int minNumRacksPerWriteQuorum,
                                                                  boolean enforceMinNumRacksPerWriteQuorum,
                                                                  boolean ignoreLocalNodeInPlacementPolicy,
                                                                  StatsLogger statsLogger,
                                                                  org.apache.bookkeeper.proto.BookieAddressResolver bookieAddressResolver)
        Initialize the policy.
        dnsResolver - the object used to resolve addresses to their network address
        initialized ensemble placement policy
      • getDefaultRack

        public java.lang.String getDefaultRack()
      • initialize

        public RackawareEnsemblePlacementPolicyImpl 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
      • uninitalize

        public void uninitalize()
        Description copied from interface: EnsemblePlacementPolicy
        Uninitialize the policy.
      • addDefaultRackBookiesIfMinNumRacksIsEnforced

        protected java.util.Set<> addDefaultRackBookiesIfMinNumRacksIsEnforced​(java.util.Set<> excludeBookies)
      • 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.
      • 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.
      • reorderReadSequenceWithRegion

        DistributionSchedule.WriteSet reorderReadSequenceWithRegion​(java.util.List<> ensemble,
                                                                    DistributionSchedule.WriteSet writeSet,
                                                                    java.util.Map<java.lang.Integer,​java.lang.String> writeSetWithRegion,
                                                                    BookiesHealthInfo bookiesHealthInfo,
                                                                    boolean regionAware,
                                                                    java.lang.String myRegion,
                                                                    int remoteNodeInReorderSequence)
        This function orders the read sequence with a given region. For region-unaware policies (e.g. RackAware), we pass in false for regionAware and an empty myRegion. When this happens, any remote list will stay empty. The ordering is as follows (the R* at the beginning of each list item is only present for region aware policies). 1. available (local) bookies 2. R* a remote bookie (based on remoteNodeInReorderSequence 3. R* remaining (local) bookies 4. R* remaining remote bookies 5. read only bookies 6. slow bookies 7. unavailable bookies
        ensemble - ensemble of bookies
        writeSet - write set
        writeSetWithRegion - write set with region information
        bookiesHealthInfo - heuristics about health of boookies
        regionAware - whether or not a region-aware policy is used
        myRegion - current region of policy
        remoteNodeInReorderSequence - number of local bookies to try before trying a remote bookie
        ordering of bookies to send read to
      • 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
      • replaceToAdherePlacementPolicy

        public EnsemblePlacementPolicy.PlacementResult<java.util.List<>> replaceToAdherePlacementPolicy​(int ensembleSize,
                                                                                                                                          int writeQuorumSize,
                                                                                                                                          int ackQuorumSize,
                                                                                                                                          java.util.Set<> excludeBookies,
                                                                                                                                          java.util.List<> currentEnsemble)
        Description copied from interface: EnsemblePlacementPolicy
        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.
        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
        a placement result