Java Code Examples for org.elasticsearch.action.admin.indices.stats.IndicesStatsRequest#clear()
The following examples show how to use
org.elasticsearch.action.admin.indices.stats.IndicesStatsRequest#clear() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InternalClusterInfoService.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * Retrieve the latest indices stats, calling the listener when complete * @return a latch that can be used to wait for the indices stats to complete if desired */ protected CountDownLatch updateIndicesStats(final ActionListener<IndicesStatsResponse> listener) { final CountDownLatch latch = new CountDownLatch(1); final IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest(); indicesStatsRequest.clear(); indicesStatsRequest.store(true); transportIndicesStatsAction.execute(indicesStatsRequest, new LatchedActionListener<>(listener, latch)); return latch; }
Example 2
Source File: InternalClusterInfoService.java From crate with Apache License 2.0 | 5 votes |
/** * Retrieve the latest indices stats, calling the listener when complete * @return a latch that can be used to wait for the indices stats to complete if desired */ private CountDownLatch updateIndicesStats(final ActionListener<IndicesStatsResponse> listener) { final CountDownLatch latch = new CountDownLatch(1); final IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest(); indicesStatsRequest.clear(); indicesStatsRequest.store(true); client.admin().indices().stats(indicesStatsRequest, new LatchedActionListener<>(listener, latch)); return latch; }
Example 3
Source File: RestIndicesStatsAction.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest(); indicesStatsRequest.indicesOptions(IndicesOptions.fromRequest(request, indicesStatsRequest.indicesOptions())); indicesStatsRequest.indices(Strings.splitStringByCommaToArray(request.param("index"))); indicesStatsRequest.types(Strings.splitStringByCommaToArray(request.param("types"))); Set<String> metrics = Strings.splitStringByCommaToSet(request.param("metric", "_all")); // short cut, if no metrics have been specified in URI if (metrics.size() == 1 && metrics.contains("_all")) { indicesStatsRequest.all(); } else { indicesStatsRequest.clear(); indicesStatsRequest.docs(metrics.contains("docs")); indicesStatsRequest.store(metrics.contains("store")); indicesStatsRequest.indexing(metrics.contains("indexing")); indicesStatsRequest.search(metrics.contains("search")); indicesStatsRequest.get(metrics.contains("get")); indicesStatsRequest.merge(metrics.contains("merge")); indicesStatsRequest.refresh(metrics.contains("refresh")); indicesStatsRequest.flush(metrics.contains("flush")); indicesStatsRequest.warmer(metrics.contains("warmer")); indicesStatsRequest.queryCache(metrics.contains("query_cache")); indicesStatsRequest.percolate(metrics.contains("percolate")); indicesStatsRequest.segments(metrics.contains("segments")); indicesStatsRequest.fieldData(metrics.contains("fielddata")); indicesStatsRequest.completion(metrics.contains("completion")); indicesStatsRequest.suggest(metrics.contains("suggest")); indicesStatsRequest.requestCache(metrics.contains("request_cache")); indicesStatsRequest.recovery(metrics.contains("recovery")); indicesStatsRequest.translog(metrics.contains("translog")); } if (request.hasParam("groups")) { indicesStatsRequest.groups(Strings.splitStringByCommaToArray(request.param("groups"))); } if (request.hasParam("types")) { indicesStatsRequest.types(Strings.splitStringByCommaToArray(request.param("types"))); } if (indicesStatsRequest.completion() && (request.hasParam("fields") || request.hasParam("completion_fields"))) { indicesStatsRequest.completionFields(request.paramAsStringArray("completion_fields", request.paramAsStringArray("fields", Strings.EMPTY_ARRAY))); } if (indicesStatsRequest.fieldData() && (request.hasParam("fields") || request.hasParam("fielddata_fields"))) { indicesStatsRequest.fieldDataFields(request.paramAsStringArray("fielddata_fields", request.paramAsStringArray("fields", Strings.EMPTY_ARRAY))); } client.admin().indices().stats(indicesStatsRequest, new RestBuilderListener<IndicesStatsResponse>(channel) { @Override public RestResponse buildResponse(IndicesStatsResponse response, XContentBuilder builder) throws Exception { builder.startObject(); buildBroadcastShardsHeader(builder, request, response); response.toXContent(builder, request); builder.endObject(); return new BytesRestResponse(OK, builder); } }); }