Module org.elasticsearch.server
Package org.elasticsearch.transport
Class TransportService.ContextRestoreResponseHandler<T extends TransportResponse>
java.lang.Object
org.elasticsearch.transport.TransportService.ContextRestoreResponseHandler<T>
- All Implemented Interfaces:
Writeable.Reader<T>
,TransportResponseHandler<T>
- Enclosing class:
- TransportService
public static final class TransportService.ContextRestoreResponseHandler<T extends TransportResponse>
extends Object
implements TransportResponseHandler<T>
This handler wrapper ensures that the response thread executes with the correct thread context. Before any of the handle methods
are invoked we restore the context.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.transport.TransportResponseHandler
TransportResponseHandler.Empty
-
Field Summary
Fields inherited from interface org.elasticsearch.transport.TransportResponseHandler
TRANSPORT_WORKER
-
Constructor Summary
ConstructorsConstructorDescriptionContextRestoreResponseHandler
(Supplier<ThreadContext.StoredContext> contextSupplier, TransportResponseHandler<T> delegate) -
Method Summary
Modifier and TypeMethodDescriptionexecutor()
void
void
handleResponse
(T response) read
(StreamInput in) ReadV
-type value from a stream.toString()
-
Constructor Details
-
ContextRestoreResponseHandler
public ContextRestoreResponseHandler(Supplier<ThreadContext.StoredContext> contextSupplier, TransportResponseHandler<T> delegate)
-
-
Method Details
-
read
Description copied from interface:Writeable.Reader
ReadV
-type value from a stream.- Specified by:
read
in interfaceWriteable.Reader<T extends TransportResponse>
- Parameters:
in
- Input to read the value from- Throws:
IOException
-
handleResponse
- Specified by:
handleResponse
in interfaceTransportResponseHandler<T extends TransportResponse>
-
handleException
- Specified by:
handleException
in interfaceTransportResponseHandler<T extends TransportResponse>
-
executor
- Specified by:
executor
in interfaceTransportResponseHandler<T extends TransportResponse>
- Returns:
- the executor to use to deserialize the response and notify the listener. You must only use
EsExecutors.DIRECT_EXECUTOR_SERVICE
(or equivalentlyTransportResponseHandler.TRANSPORT_WORKER
) for very performance-critical actions, and even then only if the deserialization and handling work is very cheap, because this executor will perform all the work for responses from remote nodes on the receiving transport worker itself.
-
toString
-