public class KvStateClient extends Object
This client can be used by multiple threads concurrently. Operations are executed asynchronously and return Futures to their result.
The incoming pipeline looks as follows:
Socket.read() -> LengthFieldBasedFrameDecoder -> KvStateServerHandler
Received binary messages are expected to contain a frame length field. Netty's
LengthFieldBasedFrameDecoder is used to fully receive the frame before
giving it to our
Connections are established and closed by the client. The server only closes the connection on a fatal failure that cannot be recovered.
|Constructor and Description|
Creates a client with the specified number of event loop threads.
|Modifier and Type||Method and Description|
Closes the connection to the given server address if it exists.
Returns a future holding the serialized request result.
Shuts down the client and closes all connections.
public KvStateClient(int numEventLoopThreads, KvStateRequestStats stats)
numEventLoopThreads- Number of event loop threads (minimum 1).
public scala.concurrent.Future<byte> getKvState(KvStateServerAddress serverAddress, KvStateID kvStateId, byte serializedKeyAndNamespace)
If the server does not serve a KvState instance with the given ID,
the Future will be failed with a
If the KvState instance does not hold any data for the given key
and namespace, the Future will be failed with a
All other failures are forwarded to the Future.
serverAddress- Address of the server to query
kvStateId- ID of the KvState instance to query
serializedKeyAndNamespace- Serialized key and namespace to query KvState instance with
public void shutDown()
After a call to this method, all returned futures will be failed.
public void closeConnection(KvStateServerAddress serverAddress)
If there is a request to the server a new connection will be established.
serverAddress- Target address of the connection to close
Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.