Package org.apache.thrift
Class TNonblockingMultiFetchClient
- java.lang.Object
-
- org.apache.thrift.TNonblockingMultiFetchClient
-
public class TNonblockingMultiFetchClient extends java.lang.Object
This class uses a single thread to set up non-blocking sockets to a set of remote servers (hostname and port pairs), and sends a same request to all these servers. It then fetches responses from servers. 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
Constructors Constructor Description TNonblockingMultiFetchClient(int maxRecvBufBytesPerServer, int fetchTimeoutSeconds, java.nio.ByteBuffer requestBuf, java.util.List<java.net.InetSocketAddress> servers)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.nio.ByteBuffer[]
fetch()
main entry function for fetching from serversTNonblockingMultiFetchStats
getFetchStats()
int
getFetchTimeoutSeconds()
int
getMaxRecvBufBytesPerServer()
java.nio.ByteBuffer
getRequestBuf()
return a duplication of requestBuf, so that requestBuf will not be modified by others.java.util.List<java.net.InetSocketAddress>
getServerList()
-
-
-
Method Detail
-
getMaxRecvBufBytesPerServer
public int getMaxRecvBufBytesPerServer()
-
getFetchTimeoutSeconds
public int getFetchTimeoutSeconds()
-
getRequestBuf
public java.nio.ByteBuffer getRequestBuf()
return a duplication of requestBuf, so that requestBuf will not be modified by others.
-
getServerList
public java.util.List<java.net.InetSocketAddress> getServerList()
-
getFetchStats
public TNonblockingMultiFetchStats getFetchStats()
-
fetch
public java.nio.ByteBuffer[] fetch()
main entry function for fetching from servers
-
-