|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hbase.ipc.HBaseClient
@InterfaceAudience.Private public class HBaseClient
A client for an IPC service. IPC calls take a single Protobuf message as a request and returns a single Protobuf message as result. A service runs on a port and is defined by a parameter class and a value class.
See HBaseServer
Nested Class Summary | |
---|---|
protected class |
HBaseClient.Call
A call waiting for a value. |
static class |
HBaseClient.CallTimeoutException
Client-side call timeout |
protected class |
HBaseClient.Connection
Thread that reads responses and notifies callers. |
protected static class |
HBaseClient.ConnectionId
This class holds the address and the user ticket. |
static class |
HBaseClient.FailedServerException
|
Field Summary | |
---|---|
protected String |
clusterId
|
protected org.apache.hadoop.conf.Configuration |
conf
|
protected PoolMap<HBaseClient.ConnectionId,HBaseClient.Connection> |
connections
|
protected int |
counter
|
static int |
FAILED_SERVER_EXPIRY_DEFAULT
|
static String |
FAILED_SERVER_EXPIRY_KEY
|
protected org.apache.hadoop.hbase.ipc.HBaseClient.FailedServers |
failedServers
|
protected long |
failureSleep
|
static org.apache.commons.logging.Log |
LOG
|
protected int |
maxIdleTime
|
protected int |
maxRetries
|
protected int |
pingInterval
|
protected AtomicBoolean |
running
|
protected SocketFactory |
socketFactory
|
protected int |
socketTimeout
|
protected boolean |
tcpKeepAlive
|
protected boolean |
tcpNoDelay
|
protected static Map<String,org.apache.hadoop.security.token.TokenSelector<? extends org.apache.hadoop.security.token.TokenIdentifier>> |
tokenHandlers
|
Constructor Summary | |
---|---|
HBaseClient(org.apache.hadoop.conf.Configuration conf,
String clusterId)
Construct an IPC client with the default SocketFactory |
|
HBaseClient(org.apache.hadoop.conf.Configuration conf,
String clusterId,
SocketFactory factory)
Construct an IPC client whose values are of the Message
class. |
Method Summary | |
---|---|
Pair<com.google.protobuf.Message,CellScanner> |
call(Method method,
com.google.protobuf.Message param,
CellScanner cells,
InetSocketAddress addr,
Class<? extends IpcProtocol> protocol,
User ticket,
int rpcTimeout)
Make a call, passing param , to the IPC server running at
address which is servicing the protocol protocol,
with the ticket credentials, returning the value. |
void |
cancelConnections(String hostname,
int port,
IOException ioe)
Interrupt the connections to the given ip:port server. |
protected HBaseClient.Connection |
createConnection(HBaseClient.ConnectionId remoteId,
Codec codec,
org.apache.hadoop.io.compress.CompressionCodec compressor)
Creates a connection. |
protected HBaseClient.Connection |
getConnection(InetSocketAddress addr,
Class<? extends IpcProtocol> protocol,
User ticket,
int rpcTimeout,
HBaseClient.Call call,
Codec codec,
org.apache.hadoop.io.compress.CompressionCodec compressor)
|
protected static int |
getPoolSize(org.apache.hadoop.conf.Configuration config)
Return the pool size specified in the configuration, which is applicable only if the pool type is PoolMap.PoolType.RoundRobin . |
protected static PoolMap.PoolType |
getPoolType(org.apache.hadoop.conf.Configuration config)
Return the pool type specified in the configuration, which must be set to either PoolMap.PoolType.RoundRobin or PoolMap.PoolType.ThreadLocal ,
otherwise default to the former. |
static void |
setPingInterval(org.apache.hadoop.conf.Configuration conf,
int pingInterval)
set the ping interval value in configuration |
static void |
setSocketTimeout(org.apache.hadoop.conf.Configuration conf,
int socketTimeout)
Set the socket timeout |
void |
stop()
Stop all threads related to this client. |
protected IOException |
wrapException(InetSocketAddress addr,
IOException exception)
Take an IOException and the address we were trying to connect to and return an IOException with the input exception as the cause. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final org.apache.commons.logging.Log LOG
protected final PoolMap<HBaseClient.ConnectionId,HBaseClient.Connection> connections
protected int counter
protected final AtomicBoolean running
protected final org.apache.hadoop.conf.Configuration conf
protected final int maxIdleTime
protected final int maxRetries
protected final long failureSleep
protected final boolean tcpNoDelay
protected final boolean tcpKeepAlive
protected int pingInterval
protected int socketTimeout
protected org.apache.hadoop.hbase.ipc.HBaseClient.FailedServers failedServers
protected final SocketFactory socketFactory
protected String clusterId
public static final String FAILED_SERVER_EXPIRY_KEY
public static final int FAILED_SERVER_EXPIRY_DEFAULT
protected static final Map<String,org.apache.hadoop.security.token.TokenSelector<? extends org.apache.hadoop.security.token.TokenIdentifier>> tokenHandlers
Constructor Detail |
---|
public HBaseClient(org.apache.hadoop.conf.Configuration conf, String clusterId, SocketFactory factory)
Message
class.
conf
- configurationfactory
- socket factorypublic HBaseClient(org.apache.hadoop.conf.Configuration conf, String clusterId)
conf
- configurationMethod Detail |
---|
public static void setPingInterval(org.apache.hadoop.conf.Configuration conf, int pingInterval)
conf
- ConfigurationpingInterval
- the ping intervalpublic static void setSocketTimeout(org.apache.hadoop.conf.Configuration conf, int socketTimeout)
conf
- ConfigurationsocketTimeout
- the socket timeoutprotected HBaseClient.Connection createConnection(HBaseClient.ConnectionId remoteId, Codec codec, org.apache.hadoop.io.compress.CompressionCodec compressor) throws IOException
remoteId
- - the ConnectionId to use for the connection creation.
IOException
protected static PoolMap.PoolType getPoolType(org.apache.hadoop.conf.Configuration config)
PoolMap.PoolType.RoundRobin
or PoolMap.PoolType.ThreadLocal
,
otherwise default to the former.
For applications with many user threads, use a small round-robin pool. For
applications with few user threads, you may want to try using a
thread-local pool. In any case, the number of HBaseClient
instances
should not exceed the operating system's hard limit on the number of
connections.
config
- configuration
PoolMap.PoolType.RoundRobin
or
PoolMap.PoolType.ThreadLocal
protected static int getPoolSize(org.apache.hadoop.conf.Configuration config)
PoolMap.PoolType.RoundRobin
.
config
-
public void stop()
public Pair<com.google.protobuf.Message,CellScanner> call(Method method, com.google.protobuf.Message param, CellScanner cells, InetSocketAddress addr, Class<? extends IpcProtocol> protocol, User ticket, int rpcTimeout) throws InterruptedException, IOException
param
, to the IPC server running at
address
which is servicing the protocol
protocol,
with the ticket
credentials, returning the value.
Throws exceptions if there are network problems or if the remote code
threw an exception.
method
- param
- cells
- addr
- protocol
- ticket
- Be careful which ticket you pass. A new user will mean a new Connection.
User.getCurrent()
makes a new instance of User each time so will be a new Connection
each time.rpcTimeout
-
InterruptedException
IOException
protected IOException wrapException(InetSocketAddress addr, IOException exception)
addr
- target addressexception
- the relevant exception
public void cancelConnections(String hostname, int port, IOException ioe)
protected HBaseClient.Connection getConnection(InetSocketAddress addr, Class<? extends IpcProtocol> protocol, User ticket, int rpcTimeout, HBaseClient.Call call, Codec codec, org.apache.hadoop.io.compress.CompressionCodec compressor) throws IOException, InterruptedException
IOException
InterruptedException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |