Histogram samples from
live recorded data without interrupting or stalling active recording of values. Each interval
histogram provided contains all value counts accumulated since the previous interval histogram
was taken.
This pattern is commonly used in logging interval histogram information while recording is ongoing.
Recorder supports concurrent
Recorder#recordValue or
Recorder#recordValueWithExpectedInterval calls.
Recording calls are wait-free on architectures that support atomic increment operations, and
are lock-free on architectures that do not.
A common pattern for using a Recorder looks like this:
Recorder recorder = new Recorder(2); // Two decimal point accuracy
Histogram intervalHistogram = null;
...
[start of some loop construct that periodically wants to grab an interval histogram]
...
// Get interval histogram, recycling previous interval histogram:
intervalHistogram = recorder.getIntervalHistogram(intervalHistogram);
histogramLogWriter.outputIntervalHistogram(intervalHistogram);
...
[end of loop construct]
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private static class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private volatile Histogram | |
| private Histogram | |
| private final long | |
| private static AtomicLong | |
| private final WriterReaderPhaser |
| Access | Constructor and Description |
|---|---|
| public | Recorder(final int
Specifies the precision to use. This is the number of significant
decimal digits to which the histogram will maintain value resolution
and separation. Must be a non-negative integer between 0 and 5. numberOfSignificantValueDigits, boolean Specifies whether the recorder will uses a packed internal representation or not. packed)Construct an auto-resizing |
| public | Recorder(final int
Specifies the precision to use. This is the number of significant
decimal digits to which the histogram will maintain value resolution
and separation. Must be a non-negative integer between 0 and 5. numberOfSignificantValueDigits)Construct an auto-resizing |
| public | Recorder(final long
The highest value to be tracked by the histogram. Must be a positive
integer that is >= 2. highestTrackableValue, final int Specifies the precision to use. This is the number of significant
decimal digits to which the histogram will maintain value resolution
and separation. Must be a non-negative integer between 0 and 5. numberOfSignificantValueDigits)Construct a |
| public | Recorder(final long
The lowest value that can be tracked (distinguished from 0) by the histogram.
Must be a positive integer that is >= 1. May be internally rounded
down to nearest power of 2. lowestDiscernibleValue, final long The highest value to be tracked by the histogram. Must be a positive
integer that is >= (2 * lowestDiscernibleValue). highestTrackableValue, final int Specifies the precision to use. This is the number of significant
decimal digits to which the histogram will maintain value resolution
and separation. Must be a non-negative integer between 0 and 5. numberOfSignificantValueDigits)Construct a |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized Histogram | Returns: a histogram containing the value counts accumulated since the last interval histogram was taken.Get a new instance of an interval histogram, which will include a stable, consistent view of all value counts accumulated since the last interval histogram was taken. |
| public synchronized Histogram | Returns: a histogram containing the value counts accumulated since the last interval histogram was taken.a previously returned interval histogram (from this instance of
histogramToRecycle)Recorder) that may be recycled to avoid allocation and
copy operations.Get an interval histogram, which will include a stable, consistent view of all value counts accumulated since the last interval histogram was taken. |
| public synchronized Histogram | Returns: a histogram containing the value counts accumulated since the last interval histogram was taken.a previously returned interval histogram that may be recycled to avoid allocation and
copy operations. histogramToRecycle, boolean enforeContainingInstance)Get an interval histogram, which will include a stable, consistent view of all value counts accumulated since the last interval histogram was taken. |
| public synchronized void | getIntervalHistogramInto(Histogram
the histogram into which the interval histogram's data should be copied targetHistogram)Place a copy of the value counts accumulated since accumulated (since the last interval histogram
was taken) into |
| private void | |
| public void | recordValue(final long
the value to record value)Implements org. |
| public void | recordValueWithCount(final long
The value to be recorded value, final long The number of occurrences of this value to record count)Implements org. |
| public void | recordValueWithExpectedInterval(final long
The value to record value, final long If expectedIntervalBetweenValueSamples is larger than 0, add
auto-generated value records as appropriate if value is larger
than expectedIntervalBetweenValueSamples expectedIntervalBetweenValueSamples)Implements org. To compensate for the loss of sampled values when a recorded value is larger than the expected interval between value samples, Histogram will auto-generate an additional series of decreasingly-smaller (down to the expectedIntervalBetweenValueSamples) value records. |
| public synchronized void | reset()
Implements org. |
| private void |
| activeHistogram | back to summary |
|---|---|
| private volatile Histogram activeHistogram | |
| inactiveHistogram | back to summary |
|---|---|
| private Histogram inactiveHistogram | |
| instanceId | back to summary |
|---|---|
| private final long instanceId | |
| instanceIdSequencer | back to summary |
|---|---|
| private static AtomicLong instanceIdSequencer | |
| recordingPhaser | back to summary |
|---|---|
| private final WriterReaderPhaser recordingPhaser | |
| Recorder | back to summary |
|---|---|
| public Recorder(final int numberOfSignificantValueDigits, boolean packed) Construct an auto-resizing
Depending on the valuer of the
| |
| Recorder | back to summary |
|---|---|
| public Recorder(final int numberOfSignificantValueDigits) Construct an auto-resizing
| |
| Recorder | back to summary |
|---|---|
| public Recorder(final long highestTrackableValue, final int numberOfSignificantValueDigits) Construct a
| |
| Recorder | back to summary |
|---|---|
| public Recorder(final long lowestDiscernibleValue, final long highestTrackableValue, final int numberOfSignificantValueDigits) Construct a
| |
| getIntervalHistogram | back to summary |
|---|---|
| public synchronized Histogram getIntervalHistogram() Get a new instance of an interval histogram, which will include a stable, consistent view of all value counts accumulated since the last interval histogram was taken.
Calling
| |
| getIntervalHistogram | back to summary |
|---|---|
| public synchronized Histogram getIntervalHistogram(Histogram histogramToRecycle) Get an interval histogram, which will include a stable, consistent view of all value counts accumulated since the last interval histogram was taken.
Note The caller is responsible for not recycling the same returned interval histogram more than once. If the same interval histogram instance is recycled more than once, behavior is undefined.
Calling | |
| getIntervalHistogram | back to summary |
|---|---|
| public synchronized Histogram getIntervalHistogram(Histogram histogramToRecycle, boolean enforeContainingInstance) Get an interval histogram, which will include a stable, consistent view of all value counts accumulated since the last interval histogram was taken.
Note The caller is responsible for not recycling the same returned interval histogram more than once. If the same interval histogram instance is recycled more than once, behavior is undefined.
Calling
| |
| getIntervalHistogramInto | back to summary |
|---|---|
| public synchronized void getIntervalHistogramInto(Histogram targetHistogram) Place a copy of the value counts accumulated since accumulated (since the last interval histogram
was taken) into
| |
| performIntervalSample | back to summary |
|---|---|
| private void performIntervalSample() | |
| recordValue | back to summary |
|---|---|
| public void recordValue(final long value) throws ArrayIndexOutOfBoundsException Implements org. Record a value
| |
| recordValueWithCount | back to summary |
|---|---|
| public void recordValueWithCount(final long value, final long count) throws ArrayIndexOutOfBoundsException Implements org. Record a value in the histogram (adding to the value's current count)
| |
| recordValueWithExpectedInterval | back to summary |
|---|---|
| public void recordValueWithExpectedInterval(final long value, final long expectedIntervalBetweenValueSamples) throws ArrayIndexOutOfBoundsException Implements org. Record a value To compensate for the loss of sampled values when a recorded value is larger than the expected interval between value samples, Histogram will auto-generate an additional series of decreasingly-smaller (down to the expectedIntervalBetweenValueSamples) value records.
See related notes
| |
| reset | back to summary |
|---|---|
| public synchronized void reset() Implements org. Reset any value counts accumulated thus far.
| |
| validateFitAsReplacementHistogram | back to summary |
|---|---|
| private void validateFitAsReplacementHistogram(Histogram replacementHistogram, boolean enforeContainingInstance) | |
| Modifier and Type | Field and Description |
|---|---|
| private final long |
| Access | Constructor and Description |
|---|---|
| private | InternalAtomicHistogram(long id, long lowestDiscernibleValue, long highestTrackableValue, int numberOfSignificantValueDigits)
|
| containingInstanceId | back to summary |
|---|---|
| private final long containingInstanceId | |
| InternalAtomicHistogram | back to summary |
|---|---|
| private InternalAtomicHistogram(long id, long lowestDiscernibleValue, long highestTrackableValue, int numberOfSignificantValueDigits) | |
| Modifier and Type | Field and Description |
|---|---|
| private final long |
| Access | Constructor and Description |
|---|---|
| private |
| containingInstanceId | back to summary |
|---|---|
| private final long containingInstanceId | |
| InternalConcurrentHistogram | back to summary |
|---|---|
| private InternalConcurrentHistogram(long id, int numberOfSignificantValueDigits) | |
| Modifier and Type | Field and Description |
|---|---|
| private final long |
| Access | Constructor and Description |
|---|---|
| private |
| containingInstanceId | back to summary |
|---|---|
| private final long containingInstanceId | |
| InternalPackedConcurrentHistogram | back to summary |
|---|---|
| private InternalPackedConcurrentHistogram(long id, int numberOfSignificantValueDigits) | |