Package org.apache.bookkeeper.client
Class DynamicWeightedRandomSelectionImpl<T>
java.lang.Object
org.apache.bookkeeper.client.DynamicWeightedRandomSelectionImpl<T>
- All Implemented Interfaces:
WeightedRandomSelection<T>
DynamicWeightedRandomSelectionImpl class implements both getNextRandom
overloaded methods. Where getNextRandom() method considers all bookies it
knows of as candidates, but getNextRandom(Collection selectedNodes) method
considers only 'selectedNodes' as candidates.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.bookkeeper.client.WeightedRandomSelection
WeightedRandomSelection.WeightedObject -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final org.slf4j.Logger(package private) int(package private) Random(package private) final ReadWriteLock(package private) final Map<T,WeightedRandomSelection.WeightedObject> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetNextRandom(Collection<T> selectedNodes) voidsetMaxProbabilityMultiplier(int max) voidupdateMap(Map<T, WeightedRandomSelection.WeightedObject> updatedMap)
-
Field Details
-
LOG
static final org.slf4j.Logger LOG -
maxProbabilityMultiplier
int maxProbabilityMultiplier -
weightMap
-
rwLock
-
rand
Random rand
-
-
Constructor Details
-
DynamicWeightedRandomSelectionImpl
DynamicWeightedRandomSelectionImpl() -
DynamicWeightedRandomSelectionImpl
DynamicWeightedRandomSelectionImpl(int maxMultiplier)
-
-
Method Details
-
updateMap
- Specified by:
updateMapin interfaceWeightedRandomSelection<T>
-
getNextRandom
- Specified by:
getNextRandomin interfaceWeightedRandomSelection<T>
-
getNextRandom
- Specified by:
getNextRandomin interfaceWeightedRandomSelection<T>
-
setMaxProbabilityMultiplier
public void setMaxProbabilityMultiplier(int max) - Specified by:
setMaxProbabilityMultiplierin interfaceWeightedRandomSelection<T>
-