Search in sources :

Example 1 with IndicesStatsResponse

use of org.sonar.server.es.response.IndicesStatsResponse in project sonarqube by SonarSource.

the class EsClient method indicesStats.

// https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-stats.html
public IndicesStatsResponse indicesStats(String... indices) {
    return execute(() -> {
        Request request = new Request("GET", "/" + (indices.length > 0 ? (String.join(",", indices) + "/") : "") + "_stats");
        request.addParameter("level", "shards");
        Response response = restHighLevelClient.getLowLevelClient().performRequest(request);
        return IndicesStatsResponse.toIndicesStatsResponse(gson.fromJson(EntityUtils.toString(response.getEntity()), JsonObject.class));
    }, () -> computeDetailsAsString(indices));
}
Also used : GetResponse(org.elasticsearch.action.get.GetResponse) ClearIndicesCacheResponse(org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse) ForceMergeResponse(org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse) GetIndexResponse(org.elasticsearch.client.indices.GetIndexResponse) SearchResponse(org.elasticsearch.action.search.SearchResponse) DeleteResponse(org.elasticsearch.action.delete.DeleteResponse) GetSettingsResponse(org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse) BulkResponse(org.elasticsearch.action.bulk.BulkResponse) Response(org.elasticsearch.client.Response) CreateIndexResponse(org.elasticsearch.client.indices.CreateIndexResponse) ClusterStatsResponse(org.sonar.server.es.response.ClusterStatsResponse) GetMappingsResponse(org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse) ClearScrollResponse(org.elasticsearch.action.search.ClearScrollResponse) IndexResponse(org.elasticsearch.action.index.IndexResponse) NodeStatsResponse(org.sonar.server.es.response.NodeStatsResponse) ClusterHealthResponse(org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse) AcknowledgedResponse(org.elasticsearch.action.support.master.AcknowledgedResponse) RefreshResponse(org.elasticsearch.action.admin.indices.refresh.RefreshResponse) IndicesStatsResponse(org.sonar.server.es.response.IndicesStatsResponse) GetMappingsRequest(org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest) DeleteRequest(org.elasticsearch.action.delete.DeleteRequest) IndexRequest(org.elasticsearch.action.index.IndexRequest) GetRequest(org.elasticsearch.action.get.GetRequest) ClusterHealthRequest(org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest) ClearIndicesCacheRequest(org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest) GetSettingsRequest(org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest) GetIndexRequest(org.elasticsearch.client.indices.GetIndexRequest) ClearScrollRequest(org.elasticsearch.action.search.ClearScrollRequest) SearchRequest(org.elasticsearch.action.search.SearchRequest) UpdateSettingsRequest(org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest) ForceMergeRequest(org.elasticsearch.action.admin.indices.forcemerge.ForceMergeRequest) RefreshRequest(org.elasticsearch.action.admin.indices.refresh.RefreshRequest) DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest) CreateIndexRequest(org.elasticsearch.client.indices.CreateIndexRequest) Request(org.elasticsearch.client.Request) PutMappingRequest(org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest) SearchScrollRequest(org.elasticsearch.action.search.SearchScrollRequest) BulkRequest(org.elasticsearch.action.bulk.BulkRequest) JsonObject(com.google.gson.JsonObject)

Example 2 with IndicesStatsResponse

use of org.sonar.server.es.response.IndicesStatsResponse in project sonarqube by SonarSource.

the class EsIndexesSection method completeIndexAttributes.

private void completeIndexAttributes(ProtobufSystemInfo.Section.Builder protobuf) {
    IndicesStatsResponse indicesStats = esClient.indicesStats();
    for (IndexStats indexStats : indicesStats.getAllIndexStats()) {
        String prefix = "Index " + indexStats.getName() + " - ";
        setAttribute(protobuf, prefix + "Docs", indexStats.getDocCount());
        setAttribute(protobuf, prefix + "Shards", indexStats.getShardsCount());
        setAttribute(protobuf, prefix + "Store Size", humanReadableByteCountSI(indexStats.getStoreSizeBytes()));
    }
}
Also used : IndicesStatsResponse(org.sonar.server.es.response.IndicesStatsResponse) IndexStats(org.sonar.server.es.response.IndexStats)

Aggregations

IndicesStatsResponse (org.sonar.server.es.response.IndicesStatsResponse)2 JsonObject (com.google.gson.JsonObject)1 ClusterHealthRequest (org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest)1 ClusterHealthResponse (org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse)1 ClearIndicesCacheRequest (org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest)1 ClearIndicesCacheResponse (org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse)1 DeleteIndexRequest (org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)1 ForceMergeRequest (org.elasticsearch.action.admin.indices.forcemerge.ForceMergeRequest)1 ForceMergeResponse (org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse)1 GetMappingsRequest (org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest)1 GetMappingsResponse (org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse)1 PutMappingRequest (org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest)1 RefreshRequest (org.elasticsearch.action.admin.indices.refresh.RefreshRequest)1 RefreshResponse (org.elasticsearch.action.admin.indices.refresh.RefreshResponse)1 GetSettingsRequest (org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest)1 GetSettingsResponse (org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse)1 UpdateSettingsRequest (org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest)1 BulkRequest (org.elasticsearch.action.bulk.BulkRequest)1 BulkResponse (org.elasticsearch.action.bulk.BulkResponse)1 DeleteRequest (org.elasticsearch.action.delete.DeleteRequest)1