Package org.elasticsearch.rest.action
Class RestActions.NodesResponseRestListener<NodesResponse extends BaseNodesResponse & org.elasticsearch.common.xcontent.ToXContent>
java.lang.Object
org.elasticsearch.rest.action.RestActionListener<Response>
org.elasticsearch.rest.action.RestResponseListener<Response>
org.elasticsearch.rest.action.RestBuilderListener<NodesResponse>
org.elasticsearch.rest.action.RestActions.NodesResponseRestListener<NodesResponse>
- All Implemented Interfaces:
ActionListener<NodesResponse>
- Enclosing class:
- RestActions
public static class RestActions.NodesResponseRestListener<NodesResponse extends BaseNodesResponse & org.elasticsearch.common.xcontent.ToXContent>
extends RestBuilderListener<NodesResponse>
NodesResponseRestBuilderListener automatically translates any BaseNodesResponse (multi-node) response that is
ToXContent-compatible into a RestResponse with the necessary header info (e.g., "cluster_name").
This is meant to avoid a slew of anonymous classes doing (or worse):
client.admin().cluster().request(nodesRequest, new RestBuilderListener<NodesResponse>(channel) {
public RestResponse buildResponse(NodesResponse response, XContentBuilder builder) throws Exception {
return RestActions.nodesResponse(builder, ToXContent.EMPTY_PARAMS, response);
}
});
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.action.ActionListener
ActionListener.Delegating<Response,DelegateResponse>, ActionListener.DelegatingActionListener<T>, ActionListener.DelegatingFailureActionListener<T,R>, ActionListener.MappedActionListener<Response,MappedResponse>, ActionListener.RunAfterActionListener<T>, ActionListener.RunBeforeActionListener<T> -
Field Summary
Fields inherited from class org.elasticsearch.rest.action.RestActionListener
channel -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildResponse(NodesResponse response, org.elasticsearch.common.xcontent.XContentBuilder builder)Builds a response to send back over the channel.Methods inherited from class org.elasticsearch.rest.action.RestBuilderListener
buildResponseMethods inherited from class org.elasticsearch.rest.action.RestResponseListener
processResponseMethods inherited from class org.elasticsearch.rest.action.RestActionListener
ensureOpen, onFailure, onResponseMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.action.ActionListener
delegateFailure, delegateResponse, map
-
Constructor Details
-
NodesResponseRestListener
-
-
Method Details
-
buildResponse
public RestResponse buildResponse(NodesResponse response, org.elasticsearch.common.xcontent.XContentBuilder builder) throws ExceptionDescription copied from class:RestBuilderListenerBuilds a response to send back over the channel. Implementors should ensure that they close the providedXContentBuilderusing theXContentBuilder.close()method.- Specified by:
buildResponsein classRestBuilderListener<NodesResponse extends BaseNodesResponse & org.elasticsearch.common.xcontent.ToXContent>- Throws:
Exception
-