ClusterHistogram implements Metric { public ClusterHistogram(final long[] buckets) { if (buckets == null) { this.buckets = new long[]{1, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000}; } else if (buckets.length == 0) { throw new IllegalStateException("The number of buckets should not be null or 0."); } else if (buckets.length > MAX_BUCKET_COUNT) { throw new IllegalStateException("The number of buckets should be no larger than " + MAX_BUCKET_COUNT); } else { this.buckets = buckets; this.buckets = new long[buckets.length+1]; for (int i = 0; i < buckets.length; i++) { this.buckets[i] = buckets[i]; } this.buckets[buckets.length] = Long.MAX_VALUE; Arrays.sort(this.buckets); } } ClusterHistogram(final long[] buckets);  ClusterHistogram(); abstract void update(long value); long[] getBuckets(); abstract Map<Long, Map<Long, Long>> getBucketValues(long startTime);  }
@Test public void testClusterHistogram() { ClusterHistogram ch = MetricManager.getClusterHistogram("test", MetricName.build("cluster.histogram"), new long[]{1, 10, 100}); ch.update(100); Assert.assertTrue(ch.getClass().getName().startsWith("com.alibaba.metrics.NOPMetricManager")); }