|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.kafka.clients.NetworkClient
public class NetworkClient
A network client for asynchronous request/response network i/o. This is an internal class used to implement the user-facing producer and consumer clients.
This class is not thread-safe!
Constructor Summary | |
---|---|
NetworkClient(Selectable selector,
Metadata metadata,
java.lang.String clientId,
int maxInFlightRequestsPerConnection,
long reconnectBackoffMs,
int socketSendBuffer,
int socketReceiveBuffer)
|
Method Summary | |
---|---|
void |
close()
Close the network client |
int |
inFlightRequestCount()
Get the number of in-flight requests |
boolean |
isReady(Node node,
long now)
Check if the node with the given id is ready to send more requests. |
Node |
leastLoadedNode(long now)
Choose the node with the fewest outstanding requests which is at least eligible for connection. |
RequestHeader |
nextRequestHeader(ApiKeys key)
Generate a request header for the given API key |
java.util.List<ClientResponse> |
poll(java.util.List<ClientRequest> requests,
long timeout,
long now)
Initiate the given requests and check for any new responses, waiting up to the specified time. |
boolean |
ready(Node node,
long now)
Begin connecting to the given node, return true if we are already connected and ready to send to that node. |
void |
wakeup()
Interrupt the client if it is blocked waiting on I/O. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NetworkClient(Selectable selector, Metadata metadata, java.lang.String clientId, int maxInFlightRequestsPerConnection, long reconnectBackoffMs, int socketSendBuffer, int socketReceiveBuffer)
Method Detail |
---|
public boolean ready(Node node, long now)
ready
in interface KafkaClient
node
- The node to checknow
- The current timestamp
public boolean isReady(Node node, long now)
isReady
in interface KafkaClient
node
- The given node idnow
- The current time in ms
public java.util.List<ClientResponse> poll(java.util.List<ClientRequest> requests, long timeout, long now)
poll
in interface KafkaClient
requests
- The requests to initiatetimeout
- The maximum amount of time to wait (in ms) for responses if there are none immediatelynow
- The current time in milliseconds
public int inFlightRequestCount()
inFlightRequestCount
in interface KafkaClient
public RequestHeader nextRequestHeader(ApiKeys key)
nextRequestHeader
in interface KafkaClient
key
- The api key
public void wakeup()
wakeup
in interface KafkaClient
public void close()
close
in interface KafkaClient
public Node leastLoadedNode(long now)
leastLoadedNode
in interface KafkaClient
now
- The current time in ms
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |