private long getIndexSize(){ long indexSize = 0L; final String indexName = indexLocationStrategy.getIndexInitialName(); try { final IndicesStatsResponse statsResponse = esProvider.getClient() .admin() .indices() .prepareStats(indexName) .all() .execute() .actionGet(); final CommonStats indexStats = statsResponse.getIndex(indexName).getTotal(); indexSize = indexStats.getStore().getSizeInBytes(); } catch (IndexMissingException e) { // if for some reason the index size does not exist, // log an error and we can assume size is 0 as it doesn't exist logger.error("Unable to get size for index {} due to IndexMissingException for app {}", indexName, indexLocationStrategy.getApplicationScope().getApplication().getUuid()); } return indexSize; }
@Override protected void masterOperation(final ResizeRequest resizeRequest, final ClusterState state, final ActionListener<ResizeResponse> listener) { // there is no need to fetch docs stats for split but we keep it simple and do it anyway for simplicity of the code final String sourceIndex = indexNameExpressionResolver.resolveDateMathExpression(resizeRequest.getSourceIndex()); final String targetIndex = indexNameExpressionResolver.resolveDateMathExpression(resizeRequest.getTargetIndexRequest().index()); client.admin().indices().prepareStats(sourceIndex).clear().setDocs(true).execute(new ActionListener<IndicesStatsResponse>() { @Override public void onResponse(IndicesStatsResponse indicesStatsResponse) { CreateIndexClusterStateUpdateRequest updateRequest = prepareCreateIndexRequest(resizeRequest, state, (i) -> { IndexShardStats shard = indicesStatsResponse.getIndex(sourceIndex).getIndexShards().get(i); return shard == null ? null : shard.getPrimary().getDocs(); }, sourceIndex, targetIndex); createIndexService.createIndex( updateRequest, ActionListener.wrap(response -> listener.onResponse(new ResizeResponse(response.isAcknowledged(), response.isShardsAcknowledged(), updateRequest.index())), listener::onFailure ) ); } @Override public void onFailure(Exception e) { listener.onFailure(e); } }); }
client.admin().indices().prepareStats(sourceIndexName).clear().setDocs(true).execute( new ActionListener<IndicesStatsResponse>() { @Override
@Override public String[] getManagedIndexNames(ElasticsearchSingleDocumentSearchIndex es) { Map<String, IndexStats> indices = es.getClient().admin().indices().prepareStats().execute().actionGet().getIndices(); Set<String> indexNames = indices.keySet(); return indexNames.toArray(new String[indexNames.size()]); }
public Set<String> getIndexNamesFromElasticsearch() { return client.admin().indices().prepareStats().execute().actionGet().getIndices().keySet(); }
public Set<String> getIndexNamesFromElasticsearch() { return client.admin().indices().prepareStats().execute().actionGet().getIndices().keySet(); }
public Set<String> getIndexNamesFromElasticsearch() { return client.admin().indices().prepareStats().execute().actionGet().getIndices().keySet(); }
public Set<String> getIndexNamesFromElasticsearch() { return client.admin().indices().prepareStats().execute().actionGet().getIndices().keySet(); }
public Map<String, IndexStats> getIndexStats() throws Exception { IndicesStatsResponse resp = esClient.admin().indices().prepareStats().all().get(); return resp.getIndices(); }
protected void loadIndexInfos() { Set<String> indicesToQuery = toSet(getConfig().getIndicesToQuery()); Map<String, IndexStats> indices = client.admin().indices().prepareStats().execute().actionGet().getIndices(); for (String indexName : indices.keySet()) { if (!indicesToQuery.contains(indexName)) { LOGGER.debug("skipping index " + indexName + ", not in indicesToQuery"); continue; } IndexInfo indexInfo = indexInfos.get(indexName); if (indexInfo != null) { continue; } LOGGER.debug("loading index info for " + indexName); indexInfo = createIndexInfo(indexName); indexInfos.put(indexName, indexInfo); } }
protected void loadIndexInfos() { Set<String> indicesToQuery = toSet(getConfig().getIndicesToQuery()); Map<String, IndexStats> indices = client.admin().indices().prepareStats().execute().actionGet().getIndices(); for (String indexName : indices.keySet()) { if (!indicesToQuery.contains(indexName)) { LOGGER.debug("skipping index " + indexName + ", not in indicesToQuery"); continue; } IndexInfo indexInfo = indexInfos.get(indexName); if (indexInfo != null) { continue; } LOGGER.debug("loading index info for " + indexName); indexInfo = createIndexInfo(indexName); indexInfos.put(indexName, indexInfo); } }
protected void loadIndexInfos() { Set<String> indicesToQuery = toSet(getConfig().getIndicesToQuery()); Map<String, IndexStats> indices = client.admin().indices().prepareStats().execute().actionGet().getIndices(); for (String indexName : indices.keySet()) { if (!indicesToQuery.contains(indexName)) { LOGGER.debug("skipping index " + indexName + ", not in indicesToQuery"); continue; } IndexInfo indexInfo = indexInfos.get(indexName); if (indexInfo != null) { continue; } LOGGER.debug("loading index info for " + indexName); indexInfo = createIndexInfo(indexName); indexInfos.put(indexName, indexInfo); } }
final IndicesStatsResponse indicesStatsResponse = client.admin().indices().prepareStats(indices).get();
@Override protected void masterOperation(final ShrinkRequest shrinkRequest, final ClusterState state, final ActionListener<ShrinkResponse> listener) { final String sourceIndex = indexNameExpressionResolver.resolveDateMathExpression(shrinkRequest.getSourceIndex()); client.admin().indices().prepareStats(sourceIndex).clear().setDocs(true).execute(new ActionListener<IndicesStatsResponse>() { @Override public void onResponse(IndicesStatsResponse indicesStatsResponse) { CreateIndexClusterStateUpdateRequest updateRequest = prepareCreateIndexRequest(shrinkRequest, state, (i) -> { IndexShardStats shard = indicesStatsResponse.getIndex(sourceIndex).getIndexShards().get(i); return shard == null ? null : shard.getPrimary().getDocs(); }, indexNameExpressionResolver); createIndexService.createIndex(updateRequest, ActionListener.wrap(response -> listener.onResponse(new ShrinkResponse(response.isAcknowledged(), response.isShardsAcked())), listener::onFailure)); } @Override public void onFailure(Exception e) { listener.onFailure(e); } }); }
@Override protected void masterOperation(final ResizeRequest resizeRequest, final ClusterState state, final ActionListener<ResizeResponse> listener) { // there is no need to fetch docs stats for split but we keep it simple and do it anyway for simplicity of the code final String sourceIndex = indexNameExpressionResolver.resolveDateMathExpression(resizeRequest.getSourceIndex()); final String targetIndex = indexNameExpressionResolver.resolveDateMathExpression(resizeRequest.getTargetIndexRequest().index()); client.admin().indices().prepareStats(sourceIndex).clear().setDocs(true).execute(new ActionListener<IndicesStatsResponse>() { @Override public void onResponse(IndicesStatsResponse indicesStatsResponse) { CreateIndexClusterStateUpdateRequest updateRequest = prepareCreateIndexRequest(resizeRequest, state, (i) -> { IndexShardStats shard = indicesStatsResponse.getIndex(sourceIndex).getIndexShards().get(i); return shard == null ? null : shard.getPrimary().getDocs(); }, sourceIndex, targetIndex); createIndexService.createIndex( updateRequest, ActionListener.wrap(response -> listener.onResponse(new ResizeResponse(response.isAcknowledged(), response.isShardsAcknowledged(), updateRequest.index())), listener::onFailure ) ); } @Override public void onFailure(Exception e) { listener.onFailure(e); } }); }
@Override protected void masterOperation(final ResizeRequest resizeRequest, final ClusterState state, final ActionListener<ResizeResponse> listener) { // there is no need to fetch docs stats for split but we keep it simple and do it anyway for simplicity of the code final String sourceIndex = indexNameExpressionResolver.resolveDateMathExpression(resizeRequest.getSourceIndex()); final String targetIndex = indexNameExpressionResolver.resolveDateMathExpression(resizeRequest.getTargetIndexRequest().index()); client.admin().indices().prepareStats(sourceIndex).clear().setDocs(true).execute(new ActionListener<IndicesStatsResponse>() { @Override public void onResponse(IndicesStatsResponse indicesStatsResponse) { CreateIndexClusterStateUpdateRequest updateRequest = prepareCreateIndexRequest(resizeRequest, state, (i) -> { IndexShardStats shard = indicesStatsResponse.getIndex(sourceIndex).getIndexShards().get(i); return shard == null ? null : shard.getPrimary().getDocs(); }, sourceIndex, targetIndex); createIndexService.createIndex( updateRequest, ActionListener.wrap(response -> listener.onResponse(new ResizeResponse(response.isAcknowledged(), response.isShardsAcknowledged(), updateRequest.index())), listener::onFailure ) ); } @Override public void onFailure(Exception e) { listener.onFailure(e); } }); }
protected void assertSeqNos() throws Exception { assertBusy(() -> { IndicesStatsResponse stats = client().admin().indices().prepareStats().clear().get(); for (IndexStats indexStats : stats.getIndices().values()) { for (IndexShardStats indexShardStats : indexStats.getIndexShards().values()) {
private QueryCacheStats getQueryCacheStats(String index) { IndicesStatsResponse statsResponse = client().admin().indices().prepareStats(index).setQueryCache(true).setRefresh(true).get(); return statsResponse.getIndex(index).getTotal().getQueryCache(); }
NodesStatsResponse nodesStatsResponse = index.getClient().admin().cluster().prepareNodesStats().get(); ClusterStateResponse clusterStateResponse = index.getClient().admin().cluster().prepareState().get(); IndicesStatsResponse indicesStatsResponse = index.getClient().admin().indices().prepareStats().all().get();
final String rolloverIndexName = indexNameExpressionResolver.resolveDateMathExpression(unresolvedName); client.admin().indices().prepareStats(sourceIndexName).clear().setDocs(true).execute( new ActionListener<IndicesStatsResponse>() { @Override