HBASE-1754 use TCP keepalives
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@805252 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ed8ba5dff3
commit
4d6f9bef90
|
@ -77,6 +77,7 @@ public class HBaseClient {
|
|||
//maxIdleTime msecs
|
||||
final protected int maxRetries; //the max. no. of retries for socket connections
|
||||
protected boolean tcpNoDelay; // if T then disable Nagle's Algorithm
|
||||
protected boolean tcpKeepAlive; // if T then use keepalives
|
||||
protected int pingInterval; // how often sends ping to the server in msecs
|
||||
|
||||
protected SocketFactory socketFactory; // how to create sockets
|
||||
|
@ -301,6 +302,7 @@ public class HBaseClient {
|
|||
try {
|
||||
this.socket = socketFactory.createSocket();
|
||||
this.socket.setTcpNoDelay(tcpNoDelay);
|
||||
this.socket.setKeepAlive(tcpKeepAlive);
|
||||
// connection time out is 20s
|
||||
NetUtils.connect(this.socket, remoteId.getAddress(), 20000);
|
||||
this.socket.setSoTimeout(pingInterval);
|
||||
|
@ -637,6 +639,7 @@ public class HBaseClient {
|
|||
conf.getInt("ipc.client.connection.maxidletime", 10000); //10s
|
||||
this.maxRetries = conf.getInt("ipc.client.connect.max.retries", 10);
|
||||
this.tcpNoDelay = conf.getBoolean("ipc.client.tcpnodelay", false);
|
||||
this.tcpKeepAlive = conf.getBoolean("ipc.client.tcpkeepalive", true);
|
||||
this.pingInterval = getPingInterval(conf);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("The ping interval is" + this.pingInterval + "ms.");
|
||||
|
|
|
@ -146,6 +146,7 @@ public abstract class HBaseServer {
|
|||
private int maxQueueSize;
|
||||
protected int socketSendBufferSize;
|
||||
protected final boolean tcpNoDelay; // if T then disable Nagle's Algorithm
|
||||
protected final boolean tcpKeepAlive; // if T then use keepalives
|
||||
|
||||
volatile protected boolean running = true; // true while server runs
|
||||
protected BlockingQueue<Call> callQueue; // queued calls
|
||||
|
@ -391,6 +392,7 @@ public abstract class HBaseServer {
|
|||
|
||||
channel.configureBlocking(false);
|
||||
channel.socket().setTcpNoDelay(tcpNoDelay);
|
||||
channel.socket().setKeepAlive(tcpKeepAlive);
|
||||
SelectionKey readKey = channel.register(selector, SelectionKey.OP_READ);
|
||||
c = new Connection(channel, System.currentTimeMillis());
|
||||
readKey.attach(c);
|
||||
|
@ -998,6 +1000,7 @@ public abstract class HBaseServer {
|
|||
this.rpcMetrics = new HBaseRpcMetrics(serverName,
|
||||
Integer.toString(this.port));
|
||||
this.tcpNoDelay = conf.getBoolean("ipc.server.tcpnodelay", false);
|
||||
this.tcpKeepAlive = conf.getBoolean("ipc.server.tcpkeepalive", true);
|
||||
|
||||
// Create the responder here
|
||||
responder = new Responder();
|
||||
|
|
Loading…
Reference in New Issue