use of com.datastax.oss.driver.api.core.metrics.Metrics in project zipkin by openzipkin.
the class CassandraStorageExtension method poolInFlight.
// Use metrics to wait for in-flight requests to settle per
// https://groups.google.com/a/lists.datastax.com/g/java-driver-user/c/5um_yGNynow/m/cInH5I5jBgAJ
static boolean poolInFlight(CqlSession session) {
Collection<Node> nodes = session.getMetadata().getNodes().values();
Optional<Metrics> metrics = session.getMetrics();
for (Node node : nodes) {
int inFlight = metrics.flatMap(m -> m.getNodeMetric(node, DefaultNodeMetric.IN_FLIGHT)).map(m -> ((Gauge<Integer>) m).getValue()).orElse(0);
if (inFlight > 0)
return true;
}
return false;
}
Aggregations