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:
Andrew Kyle Purtell 2009-08-18 02:06:51 +00:00
parent ed8ba5dff3
commit 4d6f9bef90
2 changed files with 7 additions and 1 deletions

View File

@ -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.");

View File

@ -145,7 +145,8 @@ public abstract class HBaseServer {
private int maxQueueSize;
protected int socketSendBufferSize;
protected final boolean tcpNoDelay; // if T then disable Nagle's Algorithm
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();