Search in sources :

Example 11 with IndexStats

use of org.elasticsearch.action.admin.indices.stats.IndexStats in project sonarqube by SonarSource.

the class EsMonitor method indexAttributes.

private LinkedHashMap<String, LinkedHashMap<String, Object>> indexAttributes() {
    LinkedHashMap<String, LinkedHashMap<String, Object>> indices = new LinkedHashMap<>();
    IndicesStatsResponse indicesStats = esClient.prepareStats().all().get();
    for (Map.Entry<String, IndexStats> indexStats : indicesStats.getIndices().entrySet()) {
        LinkedHashMap<String, Object> attributes = new LinkedHashMap<>();
        indices.put(indexStats.getKey(), attributes);
        attributes.put("Docs", indexStats.getValue().getPrimaries().getDocs().getCount());
        attributes.put("Shards", indexStats.getValue().getShards().length);
        attributes.put("Store Size", byteCountToDisplaySize(indexStats.getValue().getPrimaries().getStore().getSizeInBytes()));
    }
    return indices;
}
Also used : IndicesStatsResponse(org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse) IndexStats(org.elasticsearch.action.admin.indices.stats.IndexStats) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

IndexStats (org.elasticsearch.action.admin.indices.stats.IndexStats)11 ShardStats (org.elasticsearch.action.admin.indices.stats.ShardStats)7 IndicesStatsResponse (org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse)3 ShardRouting (org.elasticsearch.cluster.routing.ShardRouting)3 ImmutableList (com.google.common.collect.ImmutableList)2 IOException (java.io.IOException)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 ElasticsearchException (org.elasticsearch.ElasticsearchException)2 SyncedFlushResponse (org.elasticsearch.action.admin.indices.flush.SyncedFlushResponse)2 IndexShardStats (org.elasticsearch.action.admin.indices.stats.IndexShardStats)2 SearchResponse (org.elasticsearch.action.search.SearchResponse)2 Client (org.elasticsearch.client.Client)2 ClusterState (org.elasticsearch.cluster.ClusterState)2 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)2 Index (org.elasticsearch.index.Index)2 IntHashSet (com.carrotsearch.hppc.IntHashSet)1 IntProcedure (com.carrotsearch.hppc.procedures.IntProcedure)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 FileVisitResult (java.nio.file.FileVisitResult)1 Files (java.nio.file.Files)1