createColumnFamilyGauge to support double values return from the API

There are cases where the API uses double to return a value that the JMX
expect to be long.

For example in mean column row size. This type difference should not be
a problem and the result should be cast to long or int.

This patch allows the values to be double and cast the result to int or
long.

This fix (scylla-jmx)
Fixes #12

Signed-off-by: Amnon Heiman <amnon@scylladb.com>
This commit is contained in:
Amnon Heiman 2015-12-03 12:11:31 +02:00 committed by Pekka Enberg
parent 3a69e3d9da
commit ba0ed7cbc7

View File

@ -417,7 +417,7 @@ public class ColumnFamilyMetrics {
protected Gauge<Long> createColumnFamilyGauge(final String url, final String name) {
Gauge<Long> gauge = new Gauge<Long>() {
public Long value() {
return c.getLongValue(url + "/" + cfName);
return (long)c.getDoubleValue(url + "/" + cfName);
}
};
return createColumnFamilyGauge(url, name, gauge);
@ -432,7 +432,7 @@ public class ColumnFamilyMetrics {
final String name) {
Gauge<Integer> gauge = new Gauge<Integer>() {
public Integer value() {
return c.getIntValue(url + "/" + cfName);
return (int)c.getDoubleValue(url + "/" + cfName);
}
};
return createColumnFamilyGauge(url, name, gauge);