Class ZoneawareEnsemblePlacementPolicy
- java.lang.Object
-
- org.apache.bookkeeper.client.TopologyAwareEnsemblePlacementPolicy
-
- org.apache.bookkeeper.client.ZoneawareEnsemblePlacementPolicyImpl
-
- org.apache.bookkeeper.client.ZoneawareEnsemblePlacementPolicy
-
- All Implemented Interfaces:
EnsemblePlacementPolicy
,ITopologyAwareEnsemblePlacementPolicy<BookieNode>
public class ZoneawareEnsemblePlacementPolicy extends ZoneawareEnsemblePlacementPolicyImpl implements ITopologyAwareEnsemblePlacementPolicy<BookieNode>
A placement policy implementation use zone information for placing ensembles.- See Also:
EnsemblePlacementPolicy
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.bookkeeper.client.ZoneawareEnsemblePlacementPolicyImpl
ZoneawareEnsemblePlacementPolicyImpl.ZoneAwareNodeLocation
-
Nested classes/interfaces inherited from class org.apache.bookkeeper.client.TopologyAwareEnsemblePlacementPolicy
TopologyAwareEnsemblePlacementPolicy.DefaultResolver, TopologyAwareEnsemblePlacementPolicy.DNSResolverDecorator, TopologyAwareEnsemblePlacementPolicy.EnsembleForReplacementWithNoConstraints, TopologyAwareEnsemblePlacementPolicy.RRTopologyAwareCoverageEnsemble, TopologyAwareEnsemblePlacementPolicy.TruePredicate
-
Nested 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
Fields Modifier and Type Field Description (package private) ZoneawareEnsemblePlacementPolicyImpl
slave
-
Fields inherited from class org.apache.bookkeeper.client.ZoneawareEnsemblePlacementPolicyImpl
address2NodePlacement, desiredNumZonesPerWriteQuorum, enforceStrictZoneawarePlacement, failedToResolveNetworkLocationCounter, LOG, maxWeightMultiple, minNumZonesPerWriteQuorum, myNode, myZone, numWritableBookiesInDefaultFaultDomain, reorderReadsRandom, reorderThresholdPendingRequests, slowBookies, stabilizePeriodSeconds, statsLogger, timer, UNKNOWN_ZONE, unresolvedNodeLocation
-
Fields 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 Constructor Description ZoneawareEnsemblePlacementPolicy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
handleBookiesThatJoined(java.util.Set<BookieId> joinedBookies)
Handle bookies that joined.void
handleBookiesThatLeft(java.util.Set<BookieId> leftBookies)
Handle bookies that left.EnsemblePlacementPolicy
initialize(ClientConfiguration conf, java.util.Optional<DNSToSwitchMapping> optionalDnsResolver, io.netty.util.HashedWheelTimer timer, FeatureProvider featureProvider, StatsLogger statsLogger, BookieAddressResolver bookieAddressResolver)
Initialize the policy.EnsemblePlacementPolicy.PlacementResult<java.util.List<BookieId>>
newEnsemble(int ensembleSize, int writeQuorumSize, int ackQuorumSize, java.util.Map<java.lang.String,byte[]> customMetadata, java.util.Set<BookieId> excludeBookies)
Choose numBookies bookies for ensemble.java.util.Set<BookieId>
onClusterChanged(java.util.Set<BookieId> writableBookies, java.util.Set<BookieId> readOnlyBookies)
A consistent view of the cluster (what bookies are available as writable, what bookies are available as readonly) is updated when any changes happen in the cluster.EnsemblePlacementPolicy.PlacementResult<BookieId>
replaceBookie(int ensembleSize, int writeQuorumSize, int ackQuorumSize, java.util.Map<java.lang.String,byte[]> customMetadata, java.util.List<BookieId> currentEnsemble, BookieId bookieToReplace, java.util.Set<BookieId> excludeBookies)
Choose a new bookie to replace bookieToReplace.void
uninitalize()
Uninitialize the policy.-
Methods inherited from class org.apache.bookkeeper.client.ZoneawareEnsemblePlacementPolicyImpl
addDefaultFaultDomainBookies, areAckedBookiesAdheringToPlacementPolicy, getDefaultFaultDomain, getZoneAwareNodeLocation, getZoneAwareNodeLocation, isEnsembleAdheringToPlacementPolicy, newEnsemble, registerSlowBookie, reorderReadLACSequence, reorderReadSequence, selectFromNetworkLocation, selectFromNetworkLocation, selectFromNetworkLocation, withDefaultFaultDomain
-
Methods inherited from class org.apache.bookkeeper.client.TopologyAwareEnsemblePlacementPolicy
convertBookiesToNodes, convertBookieToNode, createBookieNode, createDummyLocalBookieNode, differBetweenBookies, getDefaultRack, getNetworkLocations, onBookieRackChange, resolveNetworkLocation, shuffleWithMask, updateBookieInfo
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.bookkeeper.client.EnsemblePlacementPolicy
areAckedBookiesAdheringToPlacementPolicy, getStickyReadBookieIndex, isEnsembleAdheringToPlacementPolicy, registerSlowBookie, reorderReadLACSequence, reorderReadSequence, replaceToAdherePlacementPolicy, updateBookieInfo
-
Methods inherited from interface org.apache.bookkeeper.client.ITopologyAwareEnsemblePlacementPolicy
newEnsemble, onBookieRackChange, selectFromNetworkLocation, selectFromNetworkLocation, selectFromNetworkLocation
-
-
-
-
Field Detail
-
slave
ZoneawareEnsemblePlacementPolicyImpl slave
-
-
Method Detail
-
initialize
public EnsemblePlacementPolicy initialize(ClientConfiguration conf, java.util.Optional<DNSToSwitchMapping> optionalDnsResolver, io.netty.util.HashedWheelTimer timer, FeatureProvider featureProvider, StatsLogger statsLogger, BookieAddressResolver bookieAddressResolver)
Description copied from interface:EnsemblePlacementPolicy
Initialize the policy.- Specified by:
initialize
in interfaceEnsemblePlacementPolicy
- Overrides:
initialize
in classZoneawareEnsemblePlacementPolicyImpl
- Parameters:
conf
- client configurationoptionalDnsResolver
- dns resolvertimer
- timerfeatureProvider
- feature providerstatsLogger
- stats logger
-
uninitalize
public void uninitalize()
Description copied from interface:EnsemblePlacementPolicy
Uninitialize the policy.- Specified by:
uninitalize
in interfaceEnsemblePlacementPolicy
- Overrides:
uninitalize
in classZoneawareEnsemblePlacementPolicyImpl
-
onClusterChanged
public java.util.Set<BookieId> onClusterChanged(java.util.Set<BookieId> writableBookies, java.util.Set<BookieId> readOnlyBookies)
Description copied from interface:EnsemblePlacementPolicy
A consistent view of the cluster (what bookies are available as writable, what bookies are available as readonly) is updated when any changes happen in the cluster.The implementation should take actions when the cluster view is changed. So subsequent
EnsemblePlacementPolicy.newEnsemble(int, int, int, Map, Set)
andEnsemblePlacementPolicy.replaceBookie(int, int, int, java.util.Map, java.util.List, BookieId, java.util.Set)
can choose proper bookies.- Specified by:
onClusterChanged
in interfaceEnsemblePlacementPolicy
- Overrides:
onClusterChanged
in classTopologyAwareEnsemblePlacementPolicy
- Parameters:
writableBookies
- All the bookies in the cluster available for write/read.readOnlyBookies
- All the bookies in the cluster available for readonly.- Returns:
- the dead bookies during this cluster change.
-
newEnsemble
public EnsemblePlacementPolicy.PlacementResult<java.util.List<BookieId>> newEnsemble(int ensembleSize, int writeQuorumSize, int ackQuorumSize, java.util.Map<java.lang.String,byte[]> customMetadata, java.util.Set<BookieId> excludeBookies) throws BKException.BKNotEnoughBookiesException
Description copied from interface:EnsemblePlacementPolicy
Choose numBookies bookies for ensemble. If the count is more than the number of available nodes,BKException.BKNotEnoughBookiesException
is thrown.The implementation should respect to the replace settings. The size of the returned bookie list should be equal to the provide
ensembleSize
.customMetadata
is 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:
newEnsemble
in interfaceEnsemblePlacementPolicy
- Overrides:
newEnsemble
in classZoneawareEnsemblePlacementPolicyImpl
- 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[])
excludeBookies
- 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, java.util.Map<java.lang.String,byte[]> customMetadata, java.util.List<BookieId> currentEnsemble, BookieId bookieToReplace, java.util.Set<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 interfaceEnsemblePlacementPolicy
- Overrides:
replaceBookie
in classZoneawareEnsemblePlacementPolicyImpl
- 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
-
handleBookiesThatLeft
public void handleBookiesThatLeft(java.util.Set<BookieId> leftBookies)
Description copied from interface:ITopologyAwareEnsemblePlacementPolicy
Handle bookies that left.- Specified by:
handleBookiesThatLeft
in interfaceITopologyAwareEnsemblePlacementPolicy<BookieNode>
- Overrides:
handleBookiesThatLeft
in classTopologyAwareEnsemblePlacementPolicy
- Parameters:
leftBookies
- bookies that left
-
handleBookiesThatJoined
public void handleBookiesThatJoined(java.util.Set<BookieId> joinedBookies)
Description copied from interface:ITopologyAwareEnsemblePlacementPolicy
Handle bookies that joined.- Specified by:
handleBookiesThatJoined
in interfaceITopologyAwareEnsemblePlacementPolicy<BookieNode>
- Overrides:
handleBookiesThatJoined
in classTopologyAwareEnsemblePlacementPolicy
- Parameters:
joinedBookies
- bookies that joined.
-
-