From ba0ed7cbc791a30879af4c2413b7e790a71d480e Mon Sep 17 00:00:00 2001 From: Amnon Heiman Date: Thu, 3 Dec 2015 12:11:31 +0200 Subject: [PATCH] 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 --- .../org/apache/cassandra/metrics/ColumnFamilyMetrics.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java b/src/main/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java index 448ff79..c2d9fe2 100644 --- a/src/main/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java +++ b/src/main/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java @@ -417,7 +417,7 @@ public class ColumnFamilyMetrics { protected Gauge createColumnFamilyGauge(final String url, final String name) { Gauge gauge = new Gauge() { 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 gauge = new Gauge() { public Integer value() { - return c.getIntValue(url + "/" + cfName); + return (int)c.getDoubleValue(url + "/" + cfName); } }; return createColumnFamilyGauge(url, name, gauge);