Package org.apache.bookkeeper.client
Class DynamicWeightedRandomSelectionImpl<T>
- java.lang.Object
-
- org.apache.bookkeeper.client.DynamicWeightedRandomSelectionImpl<T>
-
- All Implemented Interfaces:
WeightedRandomSelection<T>
class DynamicWeightedRandomSelectionImpl<T> extends java.lang.Object implements 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
Fields Modifier and Type Field Description (package private) static org.slf4j.Logger
LOG
(package private) int
maxProbabilityMultiplier
(package private) java.util.Random
rand
(package private) java.util.concurrent.locks.ReadWriteLock
rwLock
(package private) java.util.Map<T,WeightedRandomSelection.WeightedObject>
weightMap
-
Constructor Summary
Constructors Constructor Description DynamicWeightedRandomSelectionImpl()
DynamicWeightedRandomSelectionImpl(int maxMultiplier)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
getNextRandom()
T
getNextRandom(java.util.Collection<T> selectedNodes)
void
setMaxProbabilityMultiplier(int max)
void
updateMap(java.util.Map<T,WeightedRandomSelection.WeightedObject> updatedMap)
-
-
-
Field Detail
-
LOG
static final org.slf4j.Logger LOG
-
maxProbabilityMultiplier
int maxProbabilityMultiplier
-
weightMap
final java.util.Map<T,WeightedRandomSelection.WeightedObject> weightMap
-
rwLock
final java.util.concurrent.locks.ReadWriteLock rwLock
-
rand
java.util.Random rand
-
-
Method Detail
-
updateMap
public void updateMap(java.util.Map<T,WeightedRandomSelection.WeightedObject> updatedMap)
- Specified by:
updateMap
in interfaceWeightedRandomSelection<T>
-
getNextRandom
public T getNextRandom()
- Specified by:
getNextRandom
in interfaceWeightedRandomSelection<T>
-
getNextRandom
public T getNextRandom(java.util.Collection<T> selectedNodes)
- Specified by:
getNextRandom
in interfaceWeightedRandomSelection<T>
-
setMaxProbabilityMultiplier
public void setMaxProbabilityMultiplier(int max)
- Specified by:
setMaxProbabilityMultiplier
in interfaceWeightedRandomSelection<T>
-
-