@Override public String toString() { StringBuilder message = new StringBuilder(); message.append("ES clear cache request"); if (request.indices().length > 0) { message.append(String.format(" on indices '%s'", StringUtils.join(request.indices(), ","))); } String[] fields = request.fields(); if (fields != null && fields.length > 0) { message.append(String.format(" on fields '%s'", StringUtils.join(fields, ","))); } if (request.queryCache()) { message.append(" with filter cache"); } if (request.fieldDataCache()) { message.append(" with field data cache"); } if (request.requestCache()) { message.append(" with request cache"); } return message.toString(); } }
@Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { ClearIndicesCacheRequest clearIndicesCacheRequest = new ClearIndicesCacheRequest( Strings.splitStringByCommaToArray(request.param("index"))); clearIndicesCacheRequest.indicesOptions(IndicesOptions.fromRequest(request, clearIndicesCacheRequest.indicesOptions())); fromRequest(request, clearIndicesCacheRequest); return channel -> client.admin().indices().clearCache(clearIndicesCacheRequest, new RestToXContentListener<>(channel)); }
@Override protected ClearIndicesCacheRequest readRequestFrom(StreamInput in) throws IOException { final ClearIndicesCacheRequest request = new ClearIndicesCacheRequest(); request.readFrom(in); return request; }
/** * Creates a clean indices cache request. * * @param indices The indices to clean their caches. Use {@code null} or {@code _all} to execute against all indices * @return The request */ public static ClearIndicesCacheRequest clearIndicesCacheRequest(String... indices) { return new ClearIndicesCacheRequest(indices); }
public ClearIndicesCacheRequestBuilder setFields(String... fields) { request.fields(fields); return this; }
public ClearIndicesCacheRequestBuilder setFieldDataCache(boolean fieldDataCache) { request.fieldDataCache(fieldDataCache); return this; }
public ClearIndicesCacheRequestBuilder setRequestCache(boolean requestCache) { request.requestCache(requestCache); return this; }
public ClearIndicesCacheRequestBuilder setQueryCache(boolean queryCache) { request.queryCache(queryCache); return this; }
public ClearCacheRequestBuilder<JsonInput, JsonOutput> indices(String... indices) { request.indices(indices); return this; }
public ClearIndicesCacheRequestBuilder(ElasticsearchClient client, ClearIndicesCacheAction action) { super(client, action, new ClearIndicesCacheRequest()); }
public ClearIndicesCacheRequestBuilder setFields(String... fields) { request.fields(fields); return this; }
public ClearIndicesCacheRequestBuilder setFieldDataCache(boolean fieldDataCache) { request.fieldDataCache(fieldDataCache); return this; }
public ClearIndicesCacheRequestBuilder setRequestCache(boolean requestCache) { request.requestCache(requestCache); return this; }
public ClearIndicesCacheRequestBuilder setQueryCache(boolean queryCache) { request.queryCache(queryCache); return this; }
@Override protected EmptyResult shardOperation(ClearIndicesCacheRequest request, ShardRouting shardRouting) { indicesService.clearIndexShardCache(shardRouting.shardId(), request.queryCache(), request.fieldDataCache(), request.requestCache(), request.fields()); return EmptyResult.INSTANCE; }
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { ClearIndicesCacheRequest clearIndicesCacheRequest = new ClearIndicesCacheRequest(Strings.splitStringByCommaToArray(request.param("index"))); clearIndicesCacheRequest.indicesOptions(IndicesOptions.fromRequest(request, clearIndicesCacheRequest.indicesOptions())); fromRequest(request, clearIndicesCacheRequest, parseFieldMatcher); client.admin().indices().clearCache(clearIndicesCacheRequest, new RestBuilderListener<ClearIndicesCacheResponse>(channel) { @Override public RestResponse buildResponse(ClearIndicesCacheResponse response, XContentBuilder builder) throws Exception { builder.startObject(); buildBroadcastShardsHeader(builder, request, response); builder.endObject(); return new BytesRestResponse(OK, builder); } }); }
@Override protected ClearIndicesCacheRequest readRequestFrom(StreamInput in) throws IOException { final ClearIndicesCacheRequest request = new ClearIndicesCacheRequest(); request.readFrom(in); return request; }
/** * Creates a clean indices cache request. * * @param indices The indices to clean their caches. Use <tt>null</tt> or <tt>_all</tt> to execute against all indices * @return The request */ public static ClearIndicesCacheRequest clearIndicesCacheRequest(String... indices) { return new ClearIndicesCacheRequest(indices); }
public ClearCacheRequestBuilder<JsonInput, JsonOutput> fields(String... fields) { request.fields(fields); return this; }
public ClearIndicesCacheRequestBuilder setFieldDataCache(boolean fieldDataCache) { request.fieldDataCache(fieldDataCache); return this; }