Package org.apache.bookkeeper.client
Class RegionAwareEnsemblePlacementPolicy
java.lang.Object
org.apache.bookkeeper.client.TopologyAwareEnsemblePlacementPolicy
org.apache.bookkeeper.client.RackawareEnsemblePlacementPolicyImpl
org.apache.bookkeeper.client.RackawareEnsemblePlacementPolicy
org.apache.bookkeeper.client.RegionAwareEnsemblePlacementPolicy
- All Implemented Interfaces:
EnsemblePlacementPolicy,ITopologyAwareEnsemblePlacementPolicy<BookieNode>
A placement policy use region information in the network topology for placing ensembles.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.bookkeeper.client.TopologyAwareEnsemblePlacementPolicy
TopologyAwareEnsemblePlacementPolicy.DefaultResolver, TopologyAwareEnsemblePlacementPolicy.DNSResolverDecorator, TopologyAwareEnsemblePlacementPolicy.EnsembleForReplacementWithNoConstraints, TopologyAwareEnsemblePlacementPolicy.RRTopologyAwareCoverageEnsemble, TopologyAwareEnsemblePlacementPolicy.TruePredicateNested classes/interfaces inherited from interface org.apache.bookkeeper.client.EnsemblePlacementPolicy
EnsemblePlacementPolicy.PlacementPolicyAdherence, EnsemblePlacementPolicy.PlacementResult<T>Nested classes/interfaces inherited from interface org.apache.bookkeeper.client.ITopologyAwareEnsemblePlacementPolicy
ITopologyAwareEnsemblePlacementPolicy.Ensemble<T extends Node>, ITopologyAwareEnsemblePlacementPolicy.Predicate<T extends Node> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ConcurrentMap<BookieId,String> protected Featureprotected Stringprotected booleanprotected booleanprotected FeatureProvider(package private) static final org.slf4j.Logger(package private) static final intprotected intprotected Stringprotected final Map<String,TopologyAwareEnsemblePlacementPolicy> static final String(package private) static final int(package private) static final intstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String(package private) static final StringFields inherited from class org.apache.bookkeeper.client.RackawareEnsemblePlacementPolicy
slaveFields inherited from class org.apache.bookkeeper.client.RackawareEnsemblePlacementPolicyImpl
enforceDurability, enforceMinNumRacksPerWriteQuorum, failedToResolveNetworkLocationCounter, ignoreLocalNodeInPlacementPolicy, LOCAL_FAIL_MASK, LOCAL_MASK, localNode, MASK_BITS, maxWeightMultiple, minNumRacksPerWriteQuorum, numWritableBookiesInDefaultRack, RACKNAME_DISTANCE_FROM_LEAVES, READ_ONLY_MASK, readReorderedCounter, REMOTE_FAIL_MASK, REMOTE_MASK, reorderReadsRandom, reorderThresholdPendingRequests, REPP_RANDOM_READ_REORDERING, SLOW_MASK, slowBookies, stabilizePeriodSeconds, statsLogger, timer, UNAVAIL_MASK, useHostnameResolveLocalNodePlacementPolicyFields inherited from class org.apache.bookkeeper.client.TopologyAwareEnsemblePlacementPolicy
bookieAddressResolver, bookieInfoMap, bookiesJoinedCounter, bookiesLeftCounter, dnsResolver, historyBookies, isWeighted, knownBookies, readOnlyBookies, REPP_DNS_RESOLVER_CLASS, rwLock, topology, weightedSelection -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringgetLocalRegion(BookieNode node) protected StringvoidhandleBookiesThatJoined(Set<BookieId> joinedBookies) Handle bookies that joined.voidhandleBookiesThatLeft(Set<BookieId> leftBookies) Handle bookies that left.initialize(ClientConfiguration conf, Optional<DNSToSwitchMapping> optionalDnsResolver, io.netty.util.HashedWheelTimer timer, FeatureProvider featureProvider, StatsLogger statsLogger, BookieAddressResolver bookieAddressResolver) Initialize the policy.isEnsembleAdheringToPlacementPolicy(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.newEnsemble(int ensembleSize, int writeQuorumSize, int ackQuorumSize, Map<String, byte[]> customMetadata, Set<BookieId> excludedBookies) Choose numBookies bookies for ensemble.voidonBookieRackChange(List<BookieId> bookieAddressList) Handle rack change for the bookies.protected StringparseBookieRegion(BookieId addr) reorderReadLACSequence(List<BookieId> ensemble, BookiesHealthInfo bookiesHealthInfo, DistributionSchedule.WriteSet writeSet) Reorder the read last add confirmed sequence of a given write quorum writeSet.reorderReadSequence(List<BookieId> ensemble, BookiesHealthInfo bookiesHealthInfo, DistributionSchedule.WriteSet writeSet) Reorder the read sequence of a given write quorum writeSet.replaceBookie(int ensembleSize, int writeQuorumSize, int ackQuorumSize, Map<String, byte[]> customMetadata, List<BookieId> currentEnsemble, BookieId bookieToReplace, Set<BookieId> excludeBookies) Choose a new bookie to replace bookieToReplace.protected BookieNodereplaceFromRack(BookieNode bookieNodeToReplace, Set<Node> excludeBookies, ITopologyAwareEnsemblePlacementPolicy.Predicate<BookieNode> predicate, ITopologyAwareEnsemblePlacementPolicy.Ensemble<BookieNode> ensemble, boolean enforceDurability) protected List<BookieNode>selectRandomFromRegions(Set<String> availableRegions, int numBookies, Set<Node> excludeBookies, ITopologyAwareEnsemblePlacementPolicy.Predicate<BookieNode> predicate, ITopologyAwareEnsemblePlacementPolicy.Ensemble<BookieNode> ensemble) voidupdateBookieInfo(Map<BookieId, BookieInfoReader.BookieInfo> bookieInfoMap) Send the bookie info details.Methods inherited from class org.apache.bookkeeper.client.RackawareEnsemblePlacementPolicy
initialize, initialize, newEnsemble, onClusterChanged, replaceToAdherePlacementPolicy, selectFromNetworkLocation, selectFromNetworkLocation, selectFromNetworkLocation, uninitalizeMethods inherited from class org.apache.bookkeeper.client.RackawareEnsemblePlacementPolicyImpl
addDefaultRackBookiesIfMinNumRacksIsEnforced, areAckedBookiesAdheringToPlacementPolicy, getDefaultRack, newEnsembleInternal, registerSlowBookie, reorderReadSequenceWithRegion, selectRandom, selectRandomFromRack, selectRandomInternal, withDefaultRackMethods inherited from class org.apache.bookkeeper.client.TopologyAwareEnsemblePlacementPolicy
convertBookiesToNodes, convertBookieToNode, createBookieNode, createDummyLocalBookieNode, differBetweenBookies, getNetworkLocations, resolveNetworkLocation, shuffleWithMaskMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.bookkeeper.client.EnsemblePlacementPolicy
areAckedBookiesAdheringToPlacementPolicy, getStickyReadBookieIndex, registerSlowBookie
-
Field Details
-
LOG
static final org.slf4j.Logger LOG -
REPP_REGIONS_TO_WRITE
- See Also:
-
REPP_MINIMUM_REGIONS_FOR_DURABILITY
- See Also:
-
REPP_ENABLE_DURABILITY_ENFORCEMENT_IN_REPLACE
- See Also:
-
REPP_DISABLE_DURABILITY_FEATURE_NAME
- See Also:
-
REPP_DISALLOW_BOOKIE_PLACEMENT_IN_REGION_FEATURE_NAME
- See Also:
-
REPP_DISABLE_DURABILITY_ENFORCEMENT_FEATURE
- See Also:
-
REPP_ENABLE_VALIDATION
- See Also:
-
REGION_AWARE_ANOMALOUS_ENSEMBLE
- See Also:
-
MINIMUM_REGIONS_FOR_DURABILITY_DEFAULT
static final int MINIMUM_REGIONS_FOR_DURABILITY_DEFAULT- See Also:
-
REGIONID_DISTANCE_FROM_LEAVES
static final int REGIONID_DISTANCE_FROM_LEAVES- See Also:
-
UNKNOWN_REGION
- See Also:
-
REMOTE_NODE_IN_REORDER_SEQUENCE
static final int REMOTE_NODE_IN_REORDER_SEQUENCE- See Also:
-
perRegionPlacement
-
address2Region
-
featureProvider
-
disallowBookiePlacementInRegionFeatureName
-
myRegion
-
minRegionsForDurability
protected int minRegionsForDurability -
enableValidation
protected boolean enableValidation -
enforceDurabilityInReplace
protected boolean enforceDurabilityInReplace -
disableDurabilityFeature
-
-
Constructor Details
-
RegionAwareEnsemblePlacementPolicy
RegionAwareEnsemblePlacementPolicy()
-
-
Method Details
-
getLocalRegion
-
getRegion
-
parseBookieRegion
-
handleBookiesThatLeft
Description copied from interface:ITopologyAwareEnsemblePlacementPolicyHandle bookies that left.- Specified by:
handleBookiesThatLeftin interfaceITopologyAwareEnsemblePlacementPolicy<BookieNode>- Overrides:
handleBookiesThatLeftin classRackawareEnsemblePlacementPolicy- Parameters:
leftBookies- bookies that left
-
handleBookiesThatJoined
Description copied from interface:ITopologyAwareEnsemblePlacementPolicyHandle bookies that joined.- Specified by:
handleBookiesThatJoinedin interfaceITopologyAwareEnsemblePlacementPolicy<BookieNode>- Overrides:
handleBookiesThatJoinedin classRackawareEnsemblePlacementPolicy- Parameters:
joinedBookies- bookies that joined.
-
onBookieRackChange
Description copied from interface:ITopologyAwareEnsemblePlacementPolicyHandle rack change for the bookies.- Specified by:
onBookieRackChangein interfaceITopologyAwareEnsemblePlacementPolicy<BookieNode>- Overrides:
onBookieRackChangein classTopologyAwareEnsemblePlacementPolicy
-
initialize
public RegionAwareEnsemblePlacementPolicy initialize(ClientConfiguration conf, Optional<DNSToSwitchMapping> optionalDnsResolver, io.netty.util.HashedWheelTimer timer, FeatureProvider featureProvider, StatsLogger statsLogger, BookieAddressResolver bookieAddressResolver) Description copied from interface:EnsemblePlacementPolicyInitialize the policy.- Specified by:
initializein interfaceEnsemblePlacementPolicy- Overrides:
initializein classRackawareEnsemblePlacementPolicyImpl- Parameters:
conf- client configurationoptionalDnsResolver- dns resolvertimer- timerfeatureProvider- feature providerstatsLogger- stats logger
-
selectRandomFromRegions
protected List<BookieNode> selectRandomFromRegions(Set<String> availableRegions, int numBookies, Set<Node> excludeBookies, ITopologyAwareEnsemblePlacementPolicy.Predicate<BookieNode> predicate, ITopologyAwareEnsemblePlacementPolicy.Ensemble<BookieNode> ensemble) throws BKException.BKNotEnoughBookiesException -
newEnsemble
public EnsemblePlacementPolicy.PlacementResult<List<BookieId>> newEnsemble(int ensembleSize, int writeQuorumSize, int ackQuorumSize, Map<String, byte[]> customMetadata, Set<BookieId> excludedBookies) throws BKException.BKNotEnoughBookiesExceptionDescription copied from interface:EnsemblePlacementPolicyChoose numBookies bookies for ensemble. If the count is more than the number of available nodes,BKException.BKNotEnoughBookiesExceptionis thrown.The implementation should respect to the replace settings. The size of the returned bookie list should be equal to the provide
ensembleSize.customMetadatais the same user defined data that user provides whenBookKeeper.createLedger(int, int, int, BookKeeper.DigestType, byte[], Map).If 'enforceMinNumRacksPerWriteQuorum' config is enabled then the bookies belonging to default faultzone (rack) will be excluded while selecting bookies.
- Specified by:
newEnsemblein interfaceEnsemblePlacementPolicy- Overrides:
newEnsemblein classRackawareEnsemblePlacementPolicy- Parameters:
ensembleSize- Ensemble SizewriteQuorumSize- Write Quorum SizeackQuorumSize- the value of ackQuorumSize (added since 4.5)customMetadata- the value of customMetadata. it is the same user defined metadata that user provides inBookKeeper.createLedger(int, int, int, BookKeeper.DigestType, byte[])excludedBookies- Bookies that should not be considered as targets.- Returns:
- a placement result containing list of bookie addresses for the ensemble.
- Throws:
BKException.BKNotEnoughBookiesException- if not enough bookies available.
-
replaceBookie
public EnsemblePlacementPolicy.PlacementResult<BookieId> replaceBookie(int ensembleSize, int writeQuorumSize, int ackQuorumSize, Map<String, byte[]> customMetadata, List<BookieId> currentEnsemble, BookieId bookieToReplace, Set<BookieId> excludeBookies) throws BKException.BKNotEnoughBookiesExceptionDescription copied from interface:EnsemblePlacementPolicyChoose a new bookie to replace bookieToReplace. If no bookie available in the cluster,BKException.BKNotEnoughBookiesExceptionis thrown.If 'enforceMinNumRacksPerWriteQuorum' config is enabled then the bookies belonging to default faultzone (rack) will be excluded while selecting bookies.
- Specified by:
replaceBookiein interfaceEnsemblePlacementPolicy- Overrides:
replaceBookiein classRackawareEnsemblePlacementPolicy- Parameters:
ensembleSize- the value of ensembleSizewriteQuorumSize- the value of writeQuorumSizeackQuorumSize- the value of ackQuorumSize (added since 4.5)customMetadata- the value of customMetadata. it is the same user defined metadata that user provides inBookKeeper.createLedger(int, int, int, BookKeeper.DigestType, byte[])currentEnsemble- the value of currentEnsemblebookieToReplace- bookie to replaceexcludeBookies- bookies that should not be considered as candidate.- Returns:
- a placement result containing the new bookie address.
- Throws:
BKException.BKNotEnoughBookiesException
-
replaceFromRack
protected BookieNode replaceFromRack(BookieNode bookieNodeToReplace, Set<Node> excludeBookies, ITopologyAwareEnsemblePlacementPolicy.Predicate<BookieNode> predicate, ITopologyAwareEnsemblePlacementPolicy.Ensemble<BookieNode> ensemble, boolean enforceDurability) throws BKException.BKNotEnoughBookiesException -
reorderReadSequence
public final DistributionSchedule.WriteSet reorderReadSequence(List<BookieId> ensemble, BookiesHealthInfo bookiesHealthInfo, DistributionSchedule.WriteSet writeSet) Description copied from interface:EnsemblePlacementPolicyReorder the read sequence of a given write quorum writeSet.- Specified by:
reorderReadSequencein interfaceEnsemblePlacementPolicy- Overrides:
reorderReadSequencein classRackawareEnsemblePlacementPolicy- Parameters:
ensemble- Ensemble to read entries.bookiesHealthInfo- Health info for bookieswriteSet- 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.
-
reorderReadLACSequence
public final DistributionSchedule.WriteSet reorderReadLACSequence(List<BookieId> ensemble, BookiesHealthInfo bookiesHealthInfo, DistributionSchedule.WriteSet writeSet) Description copied from interface:EnsemblePlacementPolicyReorder the read last add confirmed sequence of a given write quorum writeSet.- Specified by:
reorderReadLACSequencein interfaceEnsemblePlacementPolicy- Overrides:
reorderReadLACSequencein classRackawareEnsemblePlacementPolicy- Parameters:
ensemble- Ensemble to read entries.bookiesHealthInfo- Health info for bookieswriteSet- 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.
-
isEnsembleAdheringToPlacementPolicy
public EnsemblePlacementPolicy.PlacementPolicyAdherence isEnsembleAdheringToPlacementPolicy(List<BookieId> ensembleList, int writeQuorumSize, int ackQuorumSize) Description copied from interface:EnsemblePlacementPolicyreturns 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:
isEnsembleAdheringToPlacementPolicyin interfaceEnsemblePlacementPolicy- Overrides:
isEnsembleAdheringToPlacementPolicyin classRackawareEnsemblePlacementPolicyImpl- Parameters:
ensembleList- list of BookieId of bookies in the ensemblewriteQuorumSize- writeQuorumSize of the ensembleackQuorumSize- ackQuorumSize of the ensemble- Returns:
-
updateBookieInfo
Description copied from interface:EnsemblePlacementPolicySend the bookie info details.- Specified by:
updateBookieInfoin interfaceEnsemblePlacementPolicy- Overrides:
updateBookieInfoin classTopologyAwareEnsemblePlacementPolicy- Parameters:
bookieInfoMap- A map that has the bookie to BookieInfo
-