APIHistogram: Support APITimer
With the move to APITimer, in many occasion a histogram will not update itself, instead it will be updated by the APITimer. This breaks the update values functionality so that a histogram that is included in an APITimer will not try to update it self. Signed-off-by: Amnon Heiman <amnon@scylladb.com>
This commit is contained in:
parent
4d1f8ed7c9
commit
eca6451832
@ -10,6 +10,8 @@ import java.lang.reflect.Field;
|
|||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
|
import javax.json.JsonObject;
|
||||||
|
|
||||||
import com.scylladb.jmx.api.APIClient;
|
import com.scylladb.jmx.api.APIClient;
|
||||||
import com.yammer.metrics.stats.Sample;
|
import com.yammer.metrics.stats.Sample;
|
||||||
import com.yammer.metrics.stats.Snapshot;
|
import com.yammer.metrics.stats.Snapshot;
|
||||||
@ -101,14 +103,7 @@ public class APIHistogram extends Histogram {
|
|||||||
this(url, type, UPDATE_INTERVAL);
|
this(url, type, UPDATE_INTERVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update() {
|
public void updateValue(HistogramValues vals) {
|
||||||
long now = System.currentTimeMillis();
|
|
||||||
if (now - last_update < UPDATE_INTERVAL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
last_update = now;
|
|
||||||
clear();
|
|
||||||
HistogramValues vals = c.getHistogramValue(url);
|
|
||||||
try {
|
try {
|
||||||
if (vals.sample != null) {
|
if (vals.sample != null) {
|
||||||
for (long v : vals.sample) {
|
for (long v : vals.sample) {
|
||||||
@ -128,6 +123,25 @@ public class APIHistogram extends Histogram {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
if (url == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
if (now - last_update < UPDATE_INTERVAL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
last_update = now;
|
||||||
|
clear();
|
||||||
|
JsonObject obj = c.getJsonObj(url, null);
|
||||||
|
if (obj.containsKey("hist")) {
|
||||||
|
updateValue(APIClient.json2histogram(obj.getJsonObject("hist")));
|
||||||
|
} else {
|
||||||
|
updateValue(APIClient.json2histogram(obj));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of values recorded.
|
* Returns the number of values recorded.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user