public Map<String, NodeStats> getNodesStats() throws Exception { NodesStatsResponse nodesStats = esClient.admin().cluster().prepareNodesStats().all().get(); return nodesStats.getNodesMap(); }
/** * Hostname and Port to talk to will be same server for now optionally we * might want the ip to poll. * * NOTE: This class shouldn't be a singleton and this shouldn't be cached. * * This will work only if Elasticsearch runs. */ public ESTransportClient(String host, int port, String clusterName) throws IOException, InterruptedException { Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", clusterName) .put("client.transport.sniff", true) .build(); client = new TransportClient(settings); client.addTransportAddress(new InetSocketTransportAddress(host,port)); ndStatsRequestBuilder = client.admin().cluster().prepareNodesStats("_local").all(); }