controller.registerHandler(GET, "/_flush", this);
controller.registerHandler(GET, "/{index}/_flush", this);
}
@Override public void handleRequest(final RestRequest request, final RestChannel channel) {
FlushRequest flushRequest = new FlushRequest(RestActions.splitIndices(request.param("index")));
// we just send back a response, no need to fork a listener
flushRequest.listenerThreaded(false);
BroadcastOperationThreading operationThreading = BroadcastOperationThreading.fromString(request.param("operationThreading"), BroadcastOperationThreading.SINGLE_THREAD);
if (operationThreading == BroadcastOperationThreading.NO_THREADS) {
// since we don't spawn, don't allow no_threads, but change it to a single thread
operationThreading = BroadcastOperationThreading.THREAD_PER_SHARD;
}
flushRequest.operationThreading(operationThreading);
flushRequest.refresh(request.paramAsBoolean("refresh", flushRequest.refresh()));
flushRequest.full(request.paramAsBoolean("full", flushRequest.full()));
client.admin().indices().flush(flushRequest, new ActionListener<FlushResponse>() {
@Override public void onResponse(FlushResponse response) {
try {
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
builder.startObject();