@Internal @ChannelHandler.Sharable public class KvStateServerHandler extends AbstractServerHandler<KvStateInternalRequest,KvStateResponse>
InternalKvState
instances and write the result to the channel.
The network threads receive the message, deserialize it and dispatch the query task. The actual query is handled in a separate thread as it might otherwise block the network threads (file I/O etc.).
queryExecutor
Constructor and Description |
---|
KvStateServerHandler(KvStateServerImpl server,
KvStateRegistry kvStateRegistry,
MessageSerializer<KvStateInternalRequest,KvStateResponse> serializer,
KvStateRequestStats stats)
Create the handler used by the
KvStateServerImpl . |
Modifier and Type | Method and Description |
---|---|
CompletableFuture<KvStateResponse> |
handleRequest(long requestId,
KvStateInternalRequest request)
Handles an incoming request and returns a
CompletableFuture containing the corresponding response. |
CompletableFuture<Void> |
shutdown()
Shuts down any handler-specific resources, e.g.
|
channelActive, channelInactive, channelRead, exceptionCaught, getServerName
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
public KvStateServerHandler(KvStateServerImpl server, KvStateRegistry kvStateRegistry, MessageSerializer<KvStateInternalRequest,KvStateResponse> serializer, KvStateRequestStats stats)
KvStateServerImpl
.server
- the KvStateServerImpl
using the handler.kvStateRegistry
- registry to query.serializer
- the MessageSerializer
used to (de-) serialize the different messages.stats
- server statistics collector.public CompletableFuture<KvStateResponse> handleRequest(long requestId, KvStateInternalRequest request)
AbstractServerHandler
CompletableFuture
containing the corresponding response.
NOTE: This method is called by multiple threads.
handleRequest
in class AbstractServerHandler<KvStateInternalRequest,KvStateResponse>
requestId
- the id of the received request to be handled.request
- the request to be handled.public CompletableFuture<Void> shutdown()
AbstractServerHandler
CompletableFuture
.
If an exception is thrown during the shutdown process, then that exception will be included in the returned future.
shutdown
in class AbstractServerHandler<KvStateInternalRequest,KvStateResponse>
CompletableFuture
that will be completed when the shutdown
process actually finishes.Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.