Class TNonblockingMultiFetchClient
Parameters: int maxRecvBufBytesPerServer - an upper limit for receive buffer size per server (in byte). If a response from a server exceeds this limit, the client will not allocate memory or read response data for it.
int fetchTimeoutSeconds - time limit for fetching responses from all servers (in second). After the timeout, the fetch job is stopped and available responses are returned.
ByteBuffer requestBuf - request message that is sent to all servers.
Output: Responses are stored in an array of ByteBuffers. Index of elements in this array corresponds to index of servers in the server list. Content in a ByteBuffer may be in one of the following forms: 1. First 4 bytes form an integer indicating length of following data, then followed by the data. 2. First 4 bytes form an integer indicating length of following data, then followed by nothing - this happens when the response data size exceeds maxRecvBufBytesPerServer, and the client will not read any response data. 3. No data in the ByteBuffer - this happens when the server does not return any response within fetchTimeoutSeconds.
In some special cases (no servers are given, fetchTimeoutSeconds less than or equal to 0, requestBuf is null), the return is null.
Note: It assumes all remote servers are TNonblockingServers and use TFramedTransport.
-
Constructor Summary
ConstructorDescriptionTNonblockingMultiFetchClient
(int maxRecvBufBytesPerServer, int fetchTimeoutSeconds, ByteBuffer requestBuf, List<InetSocketAddress> servers) -
Method Summary
Modifier and TypeMethodDescriptionfetch()
Main entry function for fetching from servers.int
int
Returns a copy of requestBuf, so that requestBuf will not be modified by others.
-
Constructor Details
-
TNonblockingMultiFetchClient
public TNonblockingMultiFetchClient(int maxRecvBufBytesPerServer, int fetchTimeoutSeconds, ByteBuffer requestBuf, List<InetSocketAddress> servers)
-
-
Method Details
-
getMaxRecvBufBytesPerServer
public int getMaxRecvBufBytesPerServer() -
getFetchTimeoutSeconds
public int getFetchTimeoutSeconds() -
getRequestBuf
Returns a copy of requestBuf, so that requestBuf will not be modified by others.- Returns:
- a copy of requestBuf.
-
getServerList
-
getFetchStats
-
fetch
Main entry function for fetching from servers.- Returns:
- The fetched data.
-