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 java.lang.Object implements ITopologyAwareEnsemblePlacementPolicy<BookieNode>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classTopologyAwareEnsemblePlacementPolicy.DefaultResolver(package private) static classTopologyAwareEnsemblePlacementPolicy.DNSResolverDecoratorDecorator for any existing dsn resolver.protected static classTopologyAwareEnsemblePlacementPolicy.EnsembleForReplacementWithNoConstraintsprotected static classTopologyAwareEnsemblePlacementPolicy.RRTopologyAwareCoverageEnsembleA 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 classTopologyAwareEnsemblePlacementPolicy.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 protected BookieAddressResolverbookieAddressResolverprotected java.util.Map<BookieNode,WeightedRandomSelection.WeightedObject>bookieInfoMapprotected OpStatsLoggerbookiesJoinedCounterprotected OpStatsLoggerbookiesLeftCounterprotected DNSToSwitchMappingdnsResolverprotected java.util.Map<BookieId,BookieNode>historyBookies(package private) booleanisWeightedprotected java.util.Map<BookieId,BookieNode>knownBookies(package private) static org.slf4j.LoggerLOGprotected com.google.common.collect.ImmutableSet<BookieId>readOnlyBookiesstatic java.lang.StringREPP_DNS_RESOLVER_CLASSprotected java.util.concurrent.locks.ReentrantReadWriteLockrwLockprotected NetworkTopologytopologyprotected WeightedRandomSelection<BookieNode>weightedSelection
-
Constructor Summary
Constructors Constructor Description TopologyAwareEnsemblePlacementPolicy()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Set<Node>convertBookiesToNodes(java.util.Collection<BookieId> bookies)protected BookieNodeconvertBookieToNode(BookieId addr)protected BookieNodecreateBookieNode(BookieId addr)protected BookieNodecreateDummyLocalBookieNode(java.lang.String hostname)static intdifferBetweenBookies(java.util.List<BookieId> bookiesA, java.util.List<BookieId> bookiesB)protected java.lang.StringgetDefaultRack()(package private) static java.util.Set<java.lang.String>getNetworkLocations(java.util.Set<Node> bookieNodes)voidhandleBookiesThatJoined(java.util.Set<BookieId> joinedBookies)Handle bookies that joined.voidhandleBookiesThatLeft(java.util.Set<BookieId> leftBookies)Handle bookies that left.voidonBookieRackChange(java.util.List<BookieId> bookieAddressList)Handle rack change for the bookies.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.DistributionSchedule.WriteSetreorderReadLACSequence(java.util.List<BookieId> ensemble, BookiesHealthInfo bookiesHealthInfo, DistributionSchedule.WriteSet writeSet)Reorder the read last add confirmed sequence of a given write quorum writeSet.DistributionSchedule.WriteSetreorderReadSequence(java.util.List<BookieId> ensemble, BookiesHealthInfo bookiesHealthInfo, DistributionSchedule.WriteSet writeSet)Reorder the read sequence of a given write quorum writeSet.protected java.lang.StringresolveNetworkLocation(BookieId addr)(package private) static voidshuffleWithMask(DistributionSchedule.WriteSet writeSet, int mask, int bits)Shuffle all the entries of an array that matches a mask.voidupdateBookieInfo(java.util.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, wait
-
Methods inherited from interface org.apache.bookkeeper.client.EnsemblePlacementPolicy
areAckedBookiesAdheringToPlacementPolicy, getStickyReadBookieIndex, initialize, isEnsembleAdheringToPlacementPolicy, newEnsemble, registerSlowBookie, replaceBookie, replaceToAdherePlacementPolicy, uninitalize
-
Methods inherited from interface org.apache.bookkeeper.client.ITopologyAwareEnsemblePlacementPolicy
newEnsemble, selectFromNetworkLocation, selectFromNetworkLocation, selectFromNetworkLocation
-
-
-
-
Field Detail
-
LOG
static final org.slf4j.Logger LOG
-
REPP_DNS_RESOLVER_CLASS
public static final java.lang.String REPP_DNS_RESOLVER_CLASS
- See Also:
- Constant Field Values
-
knownBookies
protected final java.util.Map<BookieId,BookieNode> knownBookies
-
historyBookies
protected final java.util.Map<BookieId,BookieNode> historyBookies
-
rwLock
protected final java.util.concurrent.locks.ReentrantReadWriteLock rwLock
-
bookieInfoMap
protected java.util.Map<BookieNode,WeightedRandomSelection.WeightedObject> bookieInfoMap
-
readOnlyBookies
protected com.google.common.collect.ImmutableSet<BookieId> readOnlyBookies
-
isWeighted
boolean isWeighted
-
weightedSelection
protected WeightedRandomSelection<BookieNode> weightedSelection
-
topology
protected NetworkTopology topology
-
dnsResolver
protected DNSToSwitchMapping dnsResolver
-
bookieAddressResolver
protected BookieAddressResolver 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
-
-
Method Detail
-
getNetworkLocations
static java.util.Set<java.lang.String> getNetworkLocations(java.util.Set<Node> bookieNodes)
-
shuffleWithMask
static void shuffleWithMask(DistributionSchedule.WriteSet writeSet, int mask, int bits)
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(java.util.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(java.util.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
public java.util.Set<BookieId> onClusterChanged(java.util.Set<BookieId> writableBookies, java.util.Set<BookieId> readOnlyBookies)
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
public void handleBookiesThatLeft(java.util.Set<BookieId> leftBookies)
Description copied from interface:ITopologyAwareEnsemblePlacementPolicyHandle bookies that left.- Specified by:
handleBookiesThatLeftin interfaceITopologyAwareEnsemblePlacementPolicy<BookieNode>- Parameters:
leftBookies- bookies that left
-
handleBookiesThatJoined
public void handleBookiesThatJoined(java.util.Set<BookieId> joinedBookies)
Description copied from interface:ITopologyAwareEnsemblePlacementPolicyHandle bookies that joined.- Specified by:
handleBookiesThatJoinedin interfaceITopologyAwareEnsemblePlacementPolicy<BookieNode>- Parameters:
joinedBookies- bookies that joined.
-
onBookieRackChange
public void onBookieRackChange(java.util.List<BookieId> bookieAddressList)
Description copied from interface:ITopologyAwareEnsemblePlacementPolicyHandle rack change for the bookies.- Specified by:
onBookieRackChangein interfaceITopologyAwareEnsemblePlacementPolicy<BookieNode>
-
differBetweenBookies
public static int differBetweenBookies(java.util.List<BookieId> bookiesA, java.util.List<BookieId> bookiesB)
-
updateBookieInfo
public void updateBookieInfo(java.util.Map<BookieId,BookieInfoReader.BookieInfo> bookieInfoMap)
Description copied from interface:EnsemblePlacementPolicySend the bookie info details.- Specified by:
updateBookieInfoin interfaceEnsemblePlacementPolicy- Parameters:
bookieInfoMap- A map that has the bookie to BookieInfo
-
createBookieNode
protected BookieNode createBookieNode(BookieId addr)
-
createDummyLocalBookieNode
protected BookieNode createDummyLocalBookieNode(java.lang.String hostname)
-
resolveNetworkLocation
protected java.lang.String resolveNetworkLocation(BookieId addr)
-
getDefaultRack
protected java.lang.String getDefaultRack()
-
convertBookiesToNodes
protected java.util.Set<Node> convertBookiesToNodes(java.util.Collection<BookieId> bookies)
-
convertBookieToNode
protected BookieNode convertBookieToNode(BookieId addr)
-
-