@Override
  public void doRequest(final RestRequest request, final RestChannel channel, final Client client) {
    final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
    clusterStateRequest.clear().nodes(true);
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
    clusterStateRequest.masterNodeTimeout(
        request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));

    client
        .admin()
        .cluster()
        .state(
            clusterStateRequest,
            new RestActionListener<ClusterStateResponse>(channel) {
              @Override
              public void processResponse(final ClusterStateResponse clusterStateResponse) {
                NodesInfoRequest nodesInfoRequest = new NodesInfoRequest();
                nodesInfoRequest.clear().jvm(true).os(true).process(true);
                client
                    .admin()
                    .cluster()
                    .nodesInfo(
                        nodesInfoRequest,
                        new RestActionListener<NodesInfoResponse>(channel) {
                          @Override
                          public void processResponse(final NodesInfoResponse nodesInfoResponse) {
                            NodesStatsRequest nodesStatsRequest = new NodesStatsRequest();
                            nodesStatsRequest
                                .clear()
                                .jvm(true)
                                .os(true)
                                .fs(true)
                                .indices(true)
                                .process(true)
                                .script(true);
                            client
                                .admin()
                                .cluster()
                                .nodesStats(
                                    nodesStatsRequest,
                                    new RestResponseListener<NodesStatsResponse>(channel) {
                                      @Override
                                      public RestResponse buildResponse(
                                          NodesStatsResponse nodesStatsResponse) throws Exception {
                                        return RestTable.buildResponse(
                                            buildTable(
                                                request,
                                                clusterStateResponse,
                                                nodesInfoResponse,
                                                nodesStatsResponse),
                                            channel);
                                      }
                                    });
                          }
                        });
              }
            });
  }
  @Override
  public void doRequest(final RestRequest request, final RestChannel channel) {
    final ClusterStateRequest clusterStateRequest = new ClusterStateRequest();
    clusterStateRequest.clear().nodes(true);
    clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local()));
    clusterStateRequest.masterNodeTimeout(
        request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout()));

    client
        .admin()
        .cluster()
        .state(
            clusterStateRequest,
            new RestResponseListener<ClusterStateResponse>(channel) {
              @Override
              public RestResponse buildResponse(final ClusterStateResponse clusterStateResponse)
                  throws Exception {
                return RestTable.buildResponse(buildTable(request, clusterStateResponse), channel);
              }
            });
  }