Skip to content

Commit 31f2083

Browse files
committed
getHistogram() -> getSnapshot()
1 parent f96674c commit 31f2083

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

server/src/main/java/org/elasticsearch/common/metrics/ExponentialBucketHistogram.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void addObservation(long observedValue) {
6363
* @return An array of frequencies of handling times in buckets with upper bounds as returned by {@link #getBucketUpperBounds()}, plus
6464
* an extra bucket for handling times longer than the longest upper bound.
6565
*/
66-
public long[] getHistogram() {
66+
public long[] getSnapshot() {
6767
final long[] histogram = new long[BUCKET_COUNT];
6868
for (int i = 0; i < BUCKET_COUNT; i++) {
6969
histogram[i] = buckets[i].longValue();
@@ -79,7 +79,7 @@ public long[] getHistogram() {
7979
*/
8080
public long getPercentile(float percentile) {
8181
assert percentile >= 0 && percentile <= 1;
82-
final long[] snapshot = getHistogram();
82+
final long[] snapshot = getSnapshot();
8383
final long totalCount = Arrays.stream(snapshot).sum();
8484
long percentileIndex = (long) Math.ceil(totalCount * percentile);
8585
// Find which bucket has the Nth percentile value and return the upper bound value.

server/src/main/java/org/elasticsearch/http/HttpRouteStatsTracker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public HttpRouteStats getStats() {
102102
responseStats.count().longValue(),
103103
responseStats.totalSize().longValue(),
104104
responseStats.getHistogram(),
105-
responseTimeMillisHistogram.getHistogram()
105+
responseTimeMillisHistogram.getSnapshot()
106106
);
107107
}
108108
}

server/src/main/java/org/elasticsearch/transport/TcpTransport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,8 +1001,8 @@ public final TransportStats getStats() {
10011001
bytesRead,
10021002
messagesSent,
10031003
bytesWritten,
1004-
networkService.getHandlingTimeMillisHistogram().getHistogram(),
1005-
outboundHandlingTimeMillisHistogram.getHistogram(),
1004+
networkService.getHandlingTimeMillisHistogram().getSnapshot(),
1005+
outboundHandlingTimeMillisHistogram.getSnapshot(),
10061006
requestHandlers.getStats()
10071007
);
10081008
}

server/src/test/java/org/elasticsearch/common/metrics/ExponentialBucketHistogramTests.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,46 +18,46 @@
1818

1919
public class ExponentialBucketHistogramTests extends ESTestCase {
2020

21-
public void testHistogram() {
21+
public void testSnapshot() {
2222
final ExponentialBucketHistogram histogram = new ExponentialBucketHistogram();
2323

24-
assertArrayEquals(new long[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, histogram.getHistogram());
24+
assertArrayEquals(new long[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, histogram.getSnapshot());
2525

2626
histogram.addObservation(0L);
27-
assertArrayEquals(new long[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, histogram.getHistogram());
27+
assertArrayEquals(new long[] { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, histogram.getSnapshot());
2828

2929
histogram.addObservation(1L);
30-
assertArrayEquals(new long[] { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, histogram.getHistogram());
30+
assertArrayEquals(new long[] { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, histogram.getSnapshot());
3131

3232
histogram.addObservation(2L);
33-
assertArrayEquals(new long[] { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, histogram.getHistogram());
33+
assertArrayEquals(new long[] { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, histogram.getSnapshot());
3434

3535
histogram.addObservation(3L);
36-
assertArrayEquals(new long[] { 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, histogram.getHistogram());
36+
assertArrayEquals(new long[] { 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, histogram.getSnapshot());
3737

3838
histogram.addObservation(4L);
39-
assertArrayEquals(new long[] { 1, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, histogram.getHistogram());
39+
assertArrayEquals(new long[] { 1, 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, histogram.getSnapshot());
4040

4141
histogram.addObservation(127L);
42-
assertArrayEquals(new long[] { 1, 1, 2, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, histogram.getHistogram());
42+
assertArrayEquals(new long[] { 1, 1, 2, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, histogram.getSnapshot());
4343

4444
histogram.addObservation(128L);
45-
assertArrayEquals(new long[] { 1, 1, 2, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, histogram.getHistogram());
45+
assertArrayEquals(new long[] { 1, 1, 2, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, histogram.getSnapshot());
4646

4747
histogram.addObservation(65535L);
48-
assertArrayEquals(new long[] { 1, 1, 2, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0 }, histogram.getHistogram());
48+
assertArrayEquals(new long[] { 1, 1, 2, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0 }, histogram.getSnapshot());
4949

5050
histogram.addObservation(65536L);
51-
assertArrayEquals(new long[] { 1, 1, 2, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1 }, histogram.getHistogram());
51+
assertArrayEquals(new long[] { 1, 1, 2, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1 }, histogram.getSnapshot());
5252

5353
histogram.addObservation(Long.MAX_VALUE);
54-
assertArrayEquals(new long[] { 1, 1, 2, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 2 }, histogram.getHistogram());
54+
assertArrayEquals(new long[] { 1, 1, 2, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 2 }, histogram.getSnapshot());
5555

5656
histogram.addObservation(randomLongBetween(65536L, Long.MAX_VALUE));
57-
assertArrayEquals(new long[] { 1, 1, 2, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 3 }, histogram.getHistogram());
57+
assertArrayEquals(new long[] { 1, 1, 2, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 3 }, histogram.getSnapshot());
5858

5959
histogram.addObservation(randomLongBetween(Long.MIN_VALUE, 0L));
60-
assertArrayEquals(new long[] { 2, 1, 2, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 3 }, histogram.getHistogram());
60+
assertArrayEquals(new long[] { 2, 1, 2, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 3 }, histogram.getSnapshot());
6161
}
6262

6363
public void testHistogramRandom() {
@@ -73,7 +73,7 @@ public void testHistogramRandom() {
7373
histogram.addObservation(between(lowerBound, upperBound));
7474
}
7575

76-
assertArrayEquals(expectedCounts, histogram.getHistogram());
76+
assertArrayEquals(expectedCounts, histogram.getSnapshot());
7777
}
7878

7979
public void testBoundsConsistency() {

0 commit comments

Comments
 (0)