for (NodeInfo n : nodesInfo.getNodes()) {
TransportClient tc = new TransportClient(settings).addTransportAddress(n.getNode().address());
// randomize the combination of flags set
// Uses reflection to find methods in an attempt to future-proof this test against newly added flags
NodesStatsRequestBuilder nsBuilder = tc.admin().cluster().prepareNodesStats();
Class c = nsBuilder.getClass();
for (Method method : c.getDeclaredMethods()) {
if (method.getName().startsWith("set")) {
if (method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == boolean.class) {
method.invoke(nsBuilder, randomBoolean());
}
} else if ((method.getName().equals("all") || method.getName().equals("clear")) && randomBoolean()) {
method.invoke(nsBuilder);
}
}
NodesStatsResponse ns = nsBuilder.execute().actionGet();
tc.close();
}
}