REQ - the type of request the client will send.RESP - the type of response the client expects to receive.public class NetworkClient<REQ extends MessageBody,RESP extends MessageBody> extends Object
MessageBody.| Constructor and Description |
|---|
NetworkClient(String clientName,
int numEventLoopThreads,
MessageSerializer<REQ,RESP> serializer,
ServiceRequestStats stats)
Creates a client with the specified number of event loop threads.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getClientName() |
boolean |
isEventGroupShutdown() |
CompletableFuture<RESP> |
sendRequest(InetSocketAddress serverAddress,
REQ request) |
CompletableFuture<Void> |
shutdown()
Shuts down the client and closes all connections.
|
public NetworkClient(String clientName, int numEventLoopThreads, MessageSerializer<REQ,RESP> serializer, ServiceRequestStats stats)
clientName - the name of the client.numEventLoopThreads - number of event loop threads (minimum 1).serializer - the serializer used to (de-)serialize messages.stats - the statistics collector.public String getClientName()
public CompletableFuture<RESP> sendRequest(InetSocketAddress serverAddress, REQ request)
public CompletableFuture<Void> shutdown()
After a call to this method, all returned futures will be failed.
CompletableFuture that will be completed when the shutdown process is done.public boolean isEventGroupShutdown()
Copyright © 2023–2024 The Apache Software Foundation. All rights reserved.