Package org.apache.bookkeeper.client
Class TopologyAwareEnsemblePlacementPolicy
java.lang.Object
org.apache.bookkeeper.client.TopologyAwareEnsemblePlacementPolicy
- All Implemented Interfaces:
EnsemblePlacementPolicy,ITopologyAwareEnsemblePlacementPolicy<BookieNode>
- Direct Known Subclasses:
RackawareEnsemblePlacementPolicyImpl,ZoneawareEnsemblePlacementPolicyImpl
abstract class TopologyAwareEnsemblePlacementPolicy
extends Object
implements ITopologyAwareEnsemblePlacementPolicy<BookieNode>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class(package private) static classDecorator for any existing dsn resolver.protected static classprotected static classA predicate checking the rack coverage for write quorum inRoundRobinDistributionSchedule, which ensures that a write quorum should be covered by at least two racks.protected static classNested 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 BookieAddressResolverprotected Map<BookieNode,WeightedRandomSelection.WeightedObject> protected OpStatsLoggerprotected OpStatsLoggerprotected DNSToSwitchMappingprotected final Map<BookieId,BookieNode> (package private) booleanprotected final Map<BookieId,BookieNode> (package private) static final org.slf4j.Loggerprotected com.google.common.collect.ImmutableSet<BookieId>static final Stringprotected final ReentrantReadWriteLockprotected NetworkTopologyprotected WeightedRandomSelection<BookieNode> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertBookiesToNodes(Collection<BookieId> bookies) protected BookieNodeconvertBookieToNode(BookieId addr) protected BookieNodecreateBookieNode(BookieId addr) protected BookieNodecreateDummyLocalBookieNode(String hostname) static intdifferBetweenBookies(List<BookieId> bookiesA, List<BookieId> bookiesB) protected StringgetNetworkLocations(Set<Node> bookieNodes) voidhandleBookiesThatJoined(Set<BookieId> joinedBookies) Handle bookies that joined.voidhandleBookiesThatLeft(Set<BookieId> leftBookies) Handle bookies that left.voidonBookieRackChange(List<BookieId> bookieAddressList) Handle rack change for the bookies.onClusterChanged(Set<BookieId> writableBookies, 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.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.protected String(package private) static voidshuffleWithMask(DistributionSchedule.WriteSet writeSet, int mask, int bits) Shuffle all the entries of an array that matches a mask.voidupdateBookieInfo(Map<BookieId, BookieInfoReader.BookieInfo> bookieInfoMap) Send the bookie info details.Methods 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, initialize, isEnsembleAdheringToPlacementPolicy, newEnsemble, registerSlowBookie, replaceBookie, replaceToAdherePlacementPolicy, uninitalizeMethods inherited from interface org.apache.bookkeeper.client.ITopologyAwareEnsemblePlacementPolicy
newEnsemble, selectFromNetworkLocation, selectFromNetworkLocation, selectFromNetworkLocation
-
Field Details
-
LOG
static final org.slf4j.Logger LOG -
REPP_DNS_RESOLVER_CLASS
- See Also:
-
knownBookies
-
historyBookies
-
rwLock
-
bookieInfoMap
-
readOnlyBookies
-
isWeighted
boolean isWeighted -
weightedSelection
-
topology
-
dnsResolver
-
bookieAddressResolver
-
bookiesJoinedCounter
@StatsDoc(name="BOOKIES_JOINED", help="The distribution of number of bookies joined the cluster on each network topology change") protected OpStatsLogger bookiesJoinedCounter -
bookiesLeftCounter
@StatsDoc(name="BOOKIES_LEFT", help="The distribution of number of bookies left the cluster on each network topology change") protected OpStatsLogger bookiesLeftCounter
-
-
Constructor Details
-
TopologyAwareEnsemblePlacementPolicy
TopologyAwareEnsemblePlacementPolicy()
-
-
Method Details
-
getNetworkLocations
-
shuffleWithMask
Shuffle all the entries of an array that matches a mask. It assumes all entries with the same mask are contiguous in the array. -
reorderReadSequence
public 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- 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 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- 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.
-
onClusterChanged
Description copied from interface:EnsemblePlacementPolicyA 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:
onClusterChangedin interfaceEnsemblePlacementPolicy- 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.
-
handleBookiesThatLeft
Description copied from interface:ITopologyAwareEnsemblePlacementPolicyHandle bookies that left.- Specified by:
handleBookiesThatLeftin interfaceITopologyAwareEnsemblePlacementPolicy<BookieNode>- Parameters:
leftBookies- bookies that left
-
handleBookiesThatJoined
Description copied from interface:ITopologyAwareEnsemblePlacementPolicyHandle bookies that joined.- Specified by:
handleBookiesThatJoinedin interfaceITopologyAwareEnsemblePlacementPolicy<BookieNode>- Parameters:
joinedBookies- bookies that joined.
-
onBookieRackChange
Description copied from interface:ITopologyAwareEnsemblePlacementPolicyHandle rack change for the bookies.- Specified by:
onBookieRackChangein interfaceITopologyAwareEnsemblePlacementPolicy<BookieNode>
-
differBetweenBookies
-
updateBookieInfo
Description copied from interface:EnsemblePlacementPolicySend the bookie info details.- Specified by:
updateBookieInfoin interfaceEnsemblePlacementPolicy- Parameters:
bookieInfoMap- A map that has the bookie to BookieInfo
-
createBookieNode
-
createDummyLocalBookieNode
-
resolveNetworkLocation
-
getDefaultRack
-
convertBookiesToNodes
-
convertBookieToNode
-