StreamingMetrics: Preparation for removing pull mode

This patch expose the check stream registration as an external static
method.

Signed-off-by: Amnon Heiman <amnon@scylladb.com>
This commit is contained in:
Amnon Heiman 2016-05-02 14:46:43 +03:00
parent 5c33a8afa7
commit 0bfaba0a82

View File

@ -55,6 +55,7 @@ public class StreamingMetrics
public static final Counter totalOutgoingBytes = APIMetrics.newCounter("/stream_manager/metrics/outgoing", DefaultNameFactory.createMetricName(TYPE_NAME, "TotalOutgoingBytes", null));
public final Counter incomingBytes;
public final Counter outgoingBytes;
private static APIClient s_c = new APIClient();
public static void register_mbeans() {
TimerTask taskToExecute = new CheckRegistration();
@ -68,13 +69,9 @@ public class StreamingMetrics
outgoingBytes= APIMetrics.newCounter("/stream_manager/metrics/outgoing/" + peer, factory.createMetricName("OutgoingBytes"));
}
private static final class CheckRegistration extends TimerTask {
private APIClient c = new APIClient();
@Override
public void run() {
public static boolean checkRegistration() {
try {
JsonArray streams = c.getJsonArray("/stream_manager/");
JsonArray streams = s_c.getJsonArray("/stream_manager/");
Set<String> all = new HashSet<String>();
for (int i = 0; i < streams.size(); i ++) {
JsonArray sessions = streams.getJsonObject(i).getJsonArray("sessions");
@ -95,7 +92,15 @@ public class StreamingMetrics
}
} catch (Exception e) {
// ignoring exceptions, will retry on the next interval
return false;
}
return true;
}
private static final class CheckRegistration extends TimerTask {
@Override
public void run() {
checkRegistration();
}
}
}