Created
December 8, 2014 09:35
-
-
Save olim7t/08026acfff09e475390d to your computer and use it in GitHub Desktop.
Monitor inFlight queries of DataStax Java driver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void reportInFlightQueries(Session session) { | |
Session.State state = session.getState(); | |
System.out.printf("State of %s:%n", session); | |
for (Host host : state.getConnectedHosts()) { | |
int connections = state.getOpenConnections(host); | |
int inFlight = state.getInFlightQueries(host); | |
System.out.printf("\t%s:\tconnections=%2s\tinFlight=%4s\tmean=%4s%n", | |
host, | |
connections, | |
inFlight, | |
inFlight / connections); | |
} | |
} | |
// Example of scheduling it at regular intervals: | |
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); | |
executor.scheduleWithFixedDelay(new Runnable() { | |
@Override public void run() { | |
reportInFlightQueries(session); | |
} | |
}, 60, 60, TimeUnit.SECONDS); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment