Merge "Adding the row estimated histogram to column family" from Amnon

"This series adds the JMX API to the row estimated histogram. It adds a
 get function in the APIClient to fetch the data. The implementation is
 based on the column_family.json for the API call and on utils.json for
 the estimated histogram definition."
This commit is contained in:
Pekka Enberg 2015-08-26 14:25:06 +03:00
commit 4598323f02
4 changed files with 36 additions and 9 deletions

View File

@ -539,4 +539,19 @@ public class APIClient {
public HistogramValues getHistogramValue(String url) { public HistogramValues getHistogramValue(String url) {
return getHistogramValue(url, null); return getHistogramValue(url, null);
} }
public long[] getEstimatedHistogramAsLongArrValue(String string,
MultivaluedMap<String, String> queryParams) {
JsonObject obj = getJsonObj(string, queryParams);
JsonArray arr = obj.getJsonArray("buckets");
long res[] = new long[arr.size()];
for (int i = 0; i< arr.size(); i++) {
res[i] = arr.getJsonNumber(i).longValue();
}
return res;
}
public long[] getEstimatedHistogramAsLongArrValue(String string) {
return getEstimatedHistogramAsLongArrValue(string, null);
}
} }

View File

@ -584,7 +584,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean {
@Deprecated @Deprecated
public long[] getEstimatedRowSizeHistogram() { public long[] getEstimatedRowSizeHistogram() {
log(" getEstimatedRowSizeHistogram()"); log(" getEstimatedRowSizeHistogram()");
return c.getLongArrValue(""); return c.getEstimatedHistogramAsLongArrValue("/column_family/metrics/estimated_row_size_histogram/" + getCFName());
} }
/** /**

View File

@ -225,7 +225,7 @@ public class ColumnFamilyMetrics {
factory.createMetricName("EstimatedRowSizeHistogram"), factory.createMetricName("EstimatedRowSizeHistogram"),
new Gauge<long[]>() { new Gauge<long[]>() {
public long[] value() { public long[] value() {
return c.getLongArrValue("/column_family/metrics/estimated_row_size_histogram/" return c.getEstimatedHistogramAsLongArrValue("/column_family/metrics/estimated_row_size_histogram/"
+ cfName); + cfName);
} }
}); });
@ -233,7 +233,7 @@ public class ColumnFamilyMetrics {
factory.createMetricName("EstimatedColumnCountHistogram"), factory.createMetricName("EstimatedColumnCountHistogram"),
new Gauge<long[]>() { new Gauge<long[]>() {
public long[] value() { public long[] value() {
return c.getLongArrValue("/column_family/metrics/estimated_column_count_histogram/" return c.getEstimatedHistogramAsLongArrValue("/column_family/metrics/estimated_column_count_histogram/"
+ cfName); + cfName);
} }
}); });
@ -252,13 +252,13 @@ public class ColumnFamilyMetrics {
return c.getDoubleValue("/column_family/metrics/compression_ratio/"); return c.getDoubleValue("/column_family/metrics/compression_ratio/");
} }
}); });
readLatency = new LatencyMetrics("/column_family/metrics/read_latency/" readLatency = new LatencyMetrics("/column_family/metrics/read_latency",
+ cfName, factory, "Read"); cfName, factory, "Read");
writeLatency = new LatencyMetrics( writeLatency = new LatencyMetrics(
"/column_family/metrics/write_latency/" + cfName, factory, "/column_family/metrics/write_latency", cfName, factory,
"Write"); "Write");
rangeLatency = new LatencyMetrics( rangeLatency = new LatencyMetrics(
"/column_family/metrics/range_latency/" + cfName, factory, "/column_family/metrics/range_latency", cfName, factory,
"Range"); "Range");
pendingFlushes = createColumnFamilyCounter( pendingFlushes = createColumnFamilyCounter(
"/column_family/metrics/pending_flushes", "PendingFlushes"); "/column_family/metrics/pending_flushes", "PendingFlushes");

View File

@ -102,6 +102,18 @@ public class LatencyMetrics {
factory.createMetricName(namePrefix + "TotalLatency")); factory.createMetricName(namePrefix + "TotalLatency"));
} }
public LatencyMetrics(String url, String paramName,
MetricNameFactory factory, String namePrefix) {
this.factory = factory;
this.namePrefix = namePrefix;
latency = APIMetrics.newTimer(url + "/histogram/" + paramName,
factory.createMetricName(namePrefix + "Latency"),
TimeUnit.MICROSECONDS, TimeUnit.SECONDS);
totalLatency = APIMetrics.newCounter(url + "/" + paramName,
factory.createMetricName(namePrefix + "TotalLatency"));
}
/** /**
* Create LatencyMetrics with given group, type, prefix to append to each * Create LatencyMetrics with given group, type, prefix to append to each
* metric name, and scope. Any updates to this will also run on parent * metric name, and scope. Any updates to this will also run on parent
@ -130,8 +142,8 @@ public class LatencyMetrics {
} }
public void release() { public void release() {
APIMetrics.defaultRegistry().removeMetric( APIMetrics.defaultRegistry()
factory.createMetricName(namePrefix + "Latency")); .removeMetric(factory.createMetricName(namePrefix + "Latency"));
APIMetrics.defaultRegistry().removeMetric( APIMetrics.defaultRegistry().removeMetric(
factory.createMetricName(namePrefix + "TotalLatency")); factory.createMetricName(namePrefix + "TotalLatency"));
} }