hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r675048 - in /hadoop/hbase/trunk: CHANGES.txt src/java/org/apache/hadoop/hbase/client/HConnectionManager.java src/java/org/apache/hadoop/hbase/ipc/HbaseRPC.java src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Date Tue, 08 Jul 2008 23:20:02 GMT
Author: stack
Date: Tue Jul  8 16:20:02 2008
New Revision: 675048

URL: http://svn.apache.org/viewvc?rev=675048&view=rev
Log:
HBASE-727 Client caught in an infinite loop when trying to connect to cached server locations

Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HbaseRPC.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=675048&r1=675047&r2=675048&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Tue Jul  8 16:20:02 2008
@@ -169,6 +169,8 @@
    HBASE-703   Invalid regions listed by regionserver.jsp (Izaak Rubin via Stack)
    HBASE-674   Memcache size unreliable
    HBASE-726   Unit tests won't run because of a typo (Sebastien Rainville via Stack)
+   HBASE-727   Client caught in an infinite loop when trying to connect to cached
+               server locations (Izaak Rubin via Stack)
    
   IMPROVEMENTS
    HBASE-559   MR example job to count table rows

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=675048&r1=675047&r2=675048&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/client/HConnectionManager.java Tue
Jul  8 16:20:02 2008
@@ -118,6 +118,7 @@
     private final Class<? extends HRegionInterface> serverInterfaceClass;
     private final long pause;
     private final int numRetries;
+    private final int maxRPCAttempts;
 
     private final Integer masterLock = new Integer(0);
     private volatile boolean closed;
@@ -164,6 +165,7 @@
 
       this.pause = conf.getLong("hbase.client.pause", 30 * 1000);
       this.numRetries = conf.getInt("hbase.client.retries.number", 5);
+      this.maxRPCAttempts = conf.getInt("hbase.client.rpc.maxattempts", 1);
       
       this.master = null;
       this.masterChecked = false;
@@ -761,7 +763,8 @@
 
           try {
             server = (HRegionInterface)HbaseRPC.waitForProxy(serverInterfaceClass,
-                versionId, regionServer.getInetSocketAddress(), this.conf);
+                versionId, regionServer.getInetSocketAddress(), this.conf, 
+                this.maxRPCAttempts);
           } catch (RemoteException e) {
             throw RemoteExceptionHandler.decodeRemoteException(e);
           }

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HbaseRPC.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HbaseRPC.java?rev=675048&r1=675047&r2=675048&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HbaseRPC.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HbaseRPC.java Tue Jul  8 16:20:02
2008
@@ -28,6 +28,7 @@
 import java.net.InetSocketAddress;
 import java.net.SocketTimeoutException;
 import java.io.*;
+import java.util.ArrayList;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.Collection;
@@ -36,6 +37,7 @@
 
 import org.apache.commons.logging.*;
 
+import org.apache.hadoop.hbase.client.RetriesExhaustedException;
 import org.apache.hadoop.hbase.io.HbaseObjectWritable;
 import org.apache.hadoop.io.*;
 import org.apache.hadoop.ipc.Client;
@@ -273,16 +275,28 @@
     }
   }
   
+  /** 
+   * @param maxAttempts the number of times that getProxy() should be called before 
+   * giving up.  If a negative number is passed, it will retry indefinitely.
+   */
   public static VersionedProtocol waitForProxy(Class protocol,
                                                long clientVersion,
                                                InetSocketAddress addr,
-                                               Configuration conf
-                                               ) throws IOException {
-    while (true) {
+                                               Configuration conf,
+                                               int maxAttempts) throws IOException {
+    int reconnectAttempts = 0;
+	while (true) {
       try {
         return getProxy(protocol, clientVersion, addr, conf);
       } catch(ConnectException se) {  // namenode has not been started
         LOG.info("Server at " + addr + " not available yet, Zzzzz...");
+        if (maxAttempts >= 0 && ++reconnectAttempts >= maxAttempts) {
+        	LOG.info("Server at " + addr + " could not be reached after " + 
+        			reconnectAttempts + " tries, giving up.");
+        	throw new RetriesExhaustedException(addr.toString(), "unknown".getBytes(), 
+        			"unknown".getBytes(), reconnectAttempts - 1, 
+        			new ArrayList<Throwable>());
+        }
       } catch(SocketTimeoutException te) {  // namenode is busy
         LOG.info("Problem connecting to server: " + addr);
       }

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=675048&r1=675047&r2=675048&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Tue
Jul  8 16:20:02 2008
@@ -700,11 +700,11 @@
       LOG.debug("Telling master at " +
         conf.get(MASTER_ADDRESS) + " that we are up");
     }
-    // Do initial RPC setup.
+    // Do initial RPC setup.  The final argument indicates that the RPC should retry indefinitely.
     this.hbaseMaster = (HMasterRegionInterface)HbaseRPC.waitForProxy(
       HMasterRegionInterface.class, HMasterRegionInterface.versionID,
       new HServerAddress(conf.get(MASTER_ADDRESS)).getInetSocketAddress(),
-      this.conf);
+      this.conf, -1);
     MapWritable result = null;
     long lastMsg = 0;
     while(!stopRequested.get()) {



Mime
View raw message