|
Akka/Scala example source code file (HdrHistogram.scala)
The HdrHistogram.scala Akka example source code
/**
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.testkit.metrics
import com.codahale.metrics.Metric
import org.{ HdrHistogram ⇒ hdr }
/**
* Adapts Gil Tene's HdrHistogram to Metric's Metric interface.
*
* @param highestTrackableValue The highest value to be tracked by the histogram. Must be a positive
* integer that is >= 2.
* @param numberOfSignificantValueDigits 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.
*/
private[akka] class HdrHistogram(
highestTrackableValue: Long,
numberOfSignificantValueDigits: Int,
val unit: String = "")
extends Metric {
private val hist = new hdr.Histogram(highestTrackableValue, numberOfSignificantValueDigits)
def update(value: Long) {
try
hist.recordValue(value)
catch {
case ex: ArrayIndexOutOfBoundsException ⇒ throw wrapHistogramOutOfBoundsException(value, ex)
}
}
def updateWithCount(value: Long, count: Long) {
try
hist.recordValueWithCount(value, count)
catch {
case ex: ArrayIndexOutOfBoundsException ⇒ throw wrapHistogramOutOfBoundsException(value, ex)
}
}
private def wrapHistogramOutOfBoundsException(value: Long, ex: ArrayIndexOutOfBoundsException): IllegalArgumentException =
new IllegalArgumentException(s"Given value $value can not be stored in this histogram " +
s"(min: ${hist.getLowestTrackableValue}, max: ${hist.getHighestTrackableValue}})", ex)
def getData = hist.copy().getHistogramData
}
Other Akka source code examplesHere is a short list of links related to this Akka HdrHistogram.scala source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.