Class AggregatingTrimmer
java.lang.Object
org.glassfish.jersey.server.internal.monitoring.AggregatingTrimmer
- All Implemented Interfaces:
SlidingWindowTrimmer<Long>
An aggregating trimmer for sliding window measurements. This trimmer updates registered time reservoirs with the aggregated
measurements for the values it trimmed.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<TimeReservoir<AggregatedValueObject>> private final longprivate final AtomicBooleanThe lock that prevents other threads to trim the associated reservoir in parallel.private final longprivate final TimeUnitprivate TimeReservoir<Long> -
Constructor Summary
ConstructorsConstructorDescriptionAggregatingTrimmer(long startTime, TimeUnit startUnitTime, long chunkTimeSize, TimeUnit chunkTimeSizeUnit) Creates the trimmer that updates the registered time reservoirs with the aggregated measurements for the values it trimmed. -
Method Summary
Modifier and TypeMethodDescription(package private) static longlowerBound(long key, long startTime, long chunkSize, int power) Calculates lower bound for given key so that following conditions are trueprivate longlowerBound(Long key) voidregister(TimeReservoir<AggregatedValueObject> timeReservoirListener) Registers given aggregating sliding window reservoir to get updates from this trimmer.voidsetTimeReservoir(TimeReservoir<Long> timeReservoirNotifier) voidtrim(ConcurrentNavigableMap<Long, Long> map, long key) Trim the measurements provided as the map from the head up to the key (not inclusive).private longupperBound(long chunkLowerBound, long key)
-
Field Details
-
aggregatedReservoirListeners
-
timeReservoirNotifier
-
startTime
private final long startTime -
startUnitTime
-
chunkSize
private final long chunkSize -
locked
The lock that prevents other threads to trim the associated reservoir in parallel.
-
-
Constructor Details
-
AggregatingTrimmer
public AggregatingTrimmer(long startTime, TimeUnit startUnitTime, long chunkTimeSize, TimeUnit chunkTimeSizeUnit) Creates the trimmer that updates the registered time reservoirs with the aggregated measurements for the values it trimmed.- Parameters:
startTime- The start time that determines the offset for the chunks.startUnitTime- The time unit of the start time.chunkTimeSize- The size of one "time chunk".chunkTimeSizeUnit- The time unit of the time chunk.
-
-
Method Details
-
upperBound
private long upperBound(long chunkLowerBound, long key) -
lowerBound
-
lowerBound
static long lowerBound(long key, long startTime, long chunkSize, int power) Calculates lower bound for given key so that following conditions are truelowerBound <= key && key < lowerBound + chunkSize- The lower bound is a multiple of chunk size with an offset calculated as
(startTime % chunkSize) << power
The power is used to shift the offset because all the keys are also expected to be shifted with the power.- Parameters:
key- The key to find the lower bound for.startTime- The start time that determines the offset for the chunks.chunkSize- The size of one chunk.power- The power the keys are expected to be shifted with.- Returns:
- The lower bound for given arguments satisfying conditions stated above.
-
register
Registers given aggregating sliding window reservoir to get updates from this trimmer.- Parameters:
timeReservoirListener- The aggregated sliding window reservoir to update with trimmed measurements
-
setTimeReservoir
- Specified by:
setTimeReservoirin interfaceSlidingWindowTrimmer<Long>- Parameters:
timeReservoirNotifier- The reservoir that uses this trimmer.
-
getTimeReservoirNotifier
- Returns:
- The reservoir that produces the data this trimmer aggregates and trims.