Search in sources :

Example 1 with ClearIndicesCacheRequest

use of org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest in project elasticsearch by elastic.

the class RestClearIndicesCacheAction method prepareRequest.

@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 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);
        }
    });
}
Also used : BaseRestHandler(org.elasticsearch.rest.BaseRestHandler) GET(org.elasticsearch.rest.RestRequest.Method.GET) RestResponse(org.elasticsearch.rest.RestResponse) RestBuilderListener(org.elasticsearch.rest.action.RestBuilderListener) IOException(java.io.IOException) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) RestController(org.elasticsearch.rest.RestController) ClearIndicesCacheResponse(org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse) Strings(org.elasticsearch.common.Strings) BytesRestResponse(org.elasticsearch.rest.BytesRestResponse) POST(org.elasticsearch.rest.RestRequest.Method.POST) Settings(org.elasticsearch.common.settings.Settings) RestActions.buildBroadcastShardsHeader(org.elasticsearch.rest.action.RestActions.buildBroadcastShardsHeader) Map(java.util.Map) IndicesOptions(org.elasticsearch.action.support.IndicesOptions) RestRequest(org.elasticsearch.rest.RestRequest) OK(org.elasticsearch.rest.RestStatus.OK) NodeClient(org.elasticsearch.client.node.NodeClient) ClearIndicesCacheRequest(org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest) ParseField(org.elasticsearch.common.ParseField) ClearIndicesCacheResponse(org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse) RestResponse(org.elasticsearch.rest.RestResponse) BytesRestResponse(org.elasticsearch.rest.BytesRestResponse) ClearIndicesCacheRequest(org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest) BytesRestResponse(org.elasticsearch.rest.BytesRestResponse) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) IOException(java.io.IOException)

Example 2 with ClearIndicesCacheRequest

use of org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest in project elasticsearch by elastic.

the class IndicesRequestIT method testClearCache.

public void testClearCache() {
    String clearCacheAction = ClearIndicesCacheAction.NAME + "[n]";
    interceptTransportActions(clearCacheAction);
    ClearIndicesCacheRequest clearIndicesCacheRequest = new ClearIndicesCacheRequest(randomIndicesOrAliases());
    internalCluster().coordOnlyNodeClient().admin().indices().clearCache(clearIndicesCacheRequest).actionGet();
    clearInterceptedActions();
    assertSameIndices(clearIndicesCacheRequest, clearCacheAction);
}
Also used : ClearIndicesCacheRequest(org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest)

Aggregations

ClearIndicesCacheRequest (org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest)2 IOException (java.io.IOException)1 Map (java.util.Map)1 ClearIndicesCacheResponse (org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse)1 IndicesOptions (org.elasticsearch.action.support.IndicesOptions)1 NodeClient (org.elasticsearch.client.node.NodeClient)1 ParseField (org.elasticsearch.common.ParseField)1 Strings (org.elasticsearch.common.Strings)1 Settings (org.elasticsearch.common.settings.Settings)1 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)1 BaseRestHandler (org.elasticsearch.rest.BaseRestHandler)1 BytesRestResponse (org.elasticsearch.rest.BytesRestResponse)1 RestController (org.elasticsearch.rest.RestController)1 RestRequest (org.elasticsearch.rest.RestRequest)1 GET (org.elasticsearch.rest.RestRequest.Method.GET)1 POST (org.elasticsearch.rest.RestRequest.Method.POST)1 RestResponse (org.elasticsearch.rest.RestResponse)1 OK (org.elasticsearch.rest.RestStatus.OK)1 RestActions.buildBroadcastShardsHeader (org.elasticsearch.rest.action.RestActions.buildBroadcastShardsHeader)1 RestBuilderListener (org.elasticsearch.rest.action.RestBuilderListener)1