@Override
 public void handleRequest(final RestRequest request, final RestChannel channel) {
   PutWarmerRequest putWarmerRequest = new PutWarmerRequest(request.param("name"));
   putWarmerRequest.listenerThreaded(false);
   SearchRequest searchRequest =
       new SearchRequest(Strings.splitStringByCommaToArray(request.param("index")))
           .types(Strings.splitStringByCommaToArray(request.param("type")))
           .source(request.content(), request.contentUnsafe());
   searchRequest.indicesOptions(
       IndicesOptions.fromRequest(request, searchRequest.indicesOptions()));
   putWarmerRequest.searchRequest(searchRequest);
   putWarmerRequest.timeout(request.paramAsTime("timeout", putWarmerRequest.timeout()));
   putWarmerRequest.masterNodeTimeout(
       request.paramAsTime("master_timeout", putWarmerRequest.masterNodeTimeout()));
   client
       .admin()
       .indices()
       .putWarmer(
           putWarmerRequest, new AcknowledgedRestResponseActionListener(request, channel, logger));
 }
  @Override
  public void handleRequest(final RestRequest request, final RestChannel channel) {
    PutWarmerRequest putWarmerRequest = new PutWarmerRequest(request.param("name"));
    putWarmerRequest.listenerThreaded(false);
    SearchRequest searchRequest =
        new SearchRequest(RestActions.splitIndices(request.param("index")))
            .types(RestActions.splitTypes(request.param("type")))
            .source(request.content(), request.contentUnsafe());
    putWarmerRequest.searchRequest(searchRequest);
    client
        .admin()
        .indices()
        .putWarmer(
            putWarmerRequest,
            new ActionListener<PutWarmerResponse>() {
              @Override
              public void onResponse(PutWarmerResponse response) {
                try {
                  XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
                  builder
                      .startObject()
                      .field("ok", true)
                      .field("acknowledged", response.isAcknowledged());
                  builder.endObject();
                  channel.sendResponse(new XContentRestResponse(request, OK, builder));
                } catch (IOException e) {
                  onFailure(e);
                }
              }

              @Override
              public void onFailure(Throwable e) {
                try {
                  channel.sendResponse(new XContentThrowableRestResponse(request, e));
                } catch (IOException e1) {
                  logger.error("Failed to send failure response", e1);
                }
              }
            });
  }