You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2011/01/21 03:08:27 UTC

svn commit: r1061596 - in /hbase/trunk: CHANGES.txt src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java

Author: apurtell
Date: Fri Jan 21 02:08:27 2011
New Revision: 1061596

URL: http://svn.apache.org/viewvc?rev=1061596&view=rev
Log:
HBASE-3456 Fix hardcoding of 20 second socket timeout down in HBaseClient

Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1061596&r1=1061595&r2=1061596&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Fri Jan 21 02:08:27 2011
@@ -27,6 +27,7 @@ Release 0.91.0 - Unreleased
    HBASE-3403  Region orphaned after failure during split
    HBASE-3387  Pair does not deep check arrays for equality -- REVERT THIS PATCH
    HBASE-3449  Server shutdown handlers deadlocked waiting for META
+   HBASE-3456  Fix hardcoding of 20 second socket timeout down in HBaseClient
 
 
   IMPROVEMENTS

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java?rev=1061596&r1=1061595&r2=1061596&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/ipc/HBaseClient.java Fri Jan 21 02:08:27 2011
@@ -80,12 +80,15 @@ public class HBaseClient {
   protected final boolean tcpNoDelay; // if T then disable Nagle's Algorithm
   protected final boolean tcpKeepAlive; // if T then use keepalives
   protected int pingInterval; // how often sends ping to the server in msecs
+  protected int socketTimeout; // socket timeout
 
   protected final SocketFactory socketFactory;           // how to create sockets
   private int refCount = 1;
 
   final private static String PING_INTERVAL_NAME = "ipc.ping.interval";
-  final static int DEFAULT_PING_INTERVAL = 60000; // 1 min
+  final private static String SOCKET_TIMEOUT = "ipc.socket.timeout";
+  final static int DEFAULT_PING_INTERVAL = 60000;  // 1 min
+  final static int DEFAULT_SOCKET_TIMEOUT = 20000; // 20 seconds
   final static int PING_CALL_ID = -1;
 
   /**
@@ -94,7 +97,6 @@ public class HBaseClient {
    * @param conf Configuration
    * @param pingInterval the ping interval
    */
-  @SuppressWarnings({"UnusedDeclaration"})
   public static void setPingInterval(Configuration conf, int pingInterval) {
     conf.setInt(PING_INTERVAL_NAME, pingInterval);
   }
@@ -111,6 +113,22 @@ public class HBaseClient {
   }
 
   /**
+   * Set the socket timeout
+   * @param conf Configuration
+   * @param socketTimeout the socket timeout
+   */
+  public static void setSocketTimeout(Configuration conf, int socketTimeout) {
+    conf.setInt(SOCKET_TIMEOUT, socketTimeout);
+  }
+
+  /**
+   * @return the socket timeout
+   */
+  static int getSocketTimeout(Configuration conf) {
+    return conf.getInt(SOCKET_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
+  }
+
+  /**
    * Increment this client's reference count
    *
    */
@@ -309,8 +327,8 @@ public class HBaseClient {
             this.socket = socketFactory.createSocket();
             this.socket.setTcpNoDelay(tcpNoDelay);
             this.socket.setKeepAlive(tcpKeepAlive);
-            // connection time out is 20s
-            NetUtils.connect(this.socket, remoteId.getAddress(), 20000);
+            NetUtils.connect(this.socket, remoteId.getAddress(),
+              getSocketTimeout(conf));
             if (remoteId.rpcTimeout > 0) {
               pingInterval = remoteId.rpcTimeout; // overwrite pingInterval
             }