Package com.github.ambry.network
Interface NetworkClient
-
- All Superinterfaces:
java.lang.AutoCloseable
,java.io.Closeable
public interface NetworkClient extends java.io.Closeable
ANetworkClient
provides a method for sending a list of requests to one or more destinations, and receiving responses for sent requests.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
java.util.List<ResponseInfo>
sendAndPoll(java.util.List<RequestInfo> requestsToSend, java.util.Set<java.lang.Integer> requestsToDrop, int pollTimeoutMs)
Attempt to send the given requests and poll for responses from the network.void
wakeup()
Wake up the NetworkClient if it is within asendAndPoll(List, Set, int)
sleep.int
warmUpConnections(java.util.List<DataNodeId> dataNodeIds, int connectionWarmUpPercentagePerDataNode, long timeForWarmUp, java.util.List<ResponseInfo> responseInfoList)
Warm up connections to dataNodes in a specified time window.
-
-
-
Method Detail
-
sendAndPoll
java.util.List<ResponseInfo> sendAndPoll(java.util.List<RequestInfo> requestsToSend, java.util.Set<java.lang.Integer> requestsToDrop, int pollTimeoutMs)
Attempt to send the given requests and poll for responses from the network. Any requests that cannot be sent out are added to a queue. Every time this method is called, it will first attempt sending the requests in the queue (or time them out) and then attempt sending the newly added requests.- Parameters:
requestsToSend
- the list ofRequestInfo
representing the requests that need to be sent out. This could be empty.requestsToDrop
- the list of correlation IDs representing the requests that can be dropped by closing the connection.pollTimeoutMs
- the poll timeout.- Returns:
- a list of
ResponseInfo
representing the responses received for any requests that were sent out so far. - Throws:
java.lang.IllegalStateException
- if the NetworkClient is closed.
-
warmUpConnections
int warmUpConnections(java.util.List<DataNodeId> dataNodeIds, int connectionWarmUpPercentagePerDataNode, long timeForWarmUp, java.util.List<ResponseInfo> responseInfoList)
Warm up connections to dataNodes in a specified time window.- Parameters:
dataNodeIds
- warm up target nodes.connectionWarmUpPercentagePerDataNode
- percentage of max connections would like to establish in the warmup.timeForWarmUp
- max time to wait for connections' establish in milliseconds.responseInfoList
- records responses from disconnected connections.- Returns:
- number of connections established successfully.
-
wakeup
void wakeup()
Wake up the NetworkClient if it is within asendAndPoll(List, Set, int)
sleep.
-
close
void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
-