hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1207466 - in /hbase/branches/0.90: CHANGES.txt src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
Date Mon, 28 Nov 2011 17:09:55 GMT
Author: tedyu
Date: Mon Nov 28 17:09:55 2011
New Revision: 1207466

URL: http://svn.apache.org/viewvc?rev=1207466&view=rev
Log:
HBASE-4773  HBaseAdmin may leak ZooKeeper connections (Xufeng)

Modified:
    hbase/branches/0.90/CHANGES.txt
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java

Modified: hbase/branches/0.90/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/CHANGES.txt?rev=1207466&r1=1207465&r2=1207466&view=diff
==============================================================================
--- hbase/branches/0.90/CHANGES.txt (original)
+++ hbase/branches/0.90/CHANGES.txt Mon Nov 28 17:09:55 2011
@@ -99,6 +99,7 @@ Release 0.90.5 - Unreleased
    HBASE-3952  Guava snuck back in as a dependency via HBASE-3777
    HBASE-4862  Splitting hlog and opening region concurrently may cause data loss
                (Chunhui Shen)
+   HBASE-4773  HBaseAdmin may leak ZooKeeper connections (Xufeng)
 
   IMPROVEMENT
    HBASE-4205  Enhance HTable javadoc (Eric Charles)

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java?rev=1207466&r1=1207465&r2=1207466&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java Mon Nov
28 17:09:55 2011
@@ -22,6 +22,7 @@ package org.apache.hadoop.hbase.client;
 import java.io.Closeable;
 import java.io.IOException;
 import java.io.InterruptedIOException;
+import java.lang.reflect.UndeclaredThrowableException;
 import java.net.SocketTimeoutException;
 import java.util.Arrays;
 import java.util.List;
@@ -69,7 +70,7 @@ import org.apache.hadoop.util.StringUtil
 public class HBaseAdmin implements Abortable, Closeable {
   private final Log LOG = LogFactory.getLog(this.getClass().getName());
 //  private final HConnection connection;
-  private final HConnection connection;
+  private HConnection connection;
   private volatile Configuration conf;
   private final long pause;
   private final int numRetries;
@@ -92,7 +93,32 @@ public class HBaseAdmin implements Abort
     this.pause = this.conf.getLong("hbase.client.pause", 1000);
     this.numRetries = this.conf.getInt("hbase.client.retries.number", 10);
     this.retryLongerMultiplier = this.conf.getInt("hbase.client.retries.longer.multiplier",
10);
-    this.connection.getMaster();
+    int tries = 0;
+    for (; tries < numRetries; ++tries) {
+      try {
+        this.connection.getMaster();
+        break;
+      } catch (MasterNotRunningException mnre) {
+        HConnectionManager.deleteConnection(this.conf, false);
+        this.connection = HConnectionManager.getConnection(this.conf);
+      } catch (UndeclaredThrowableException ute) {
+        HConnectionManager.deleteConnection(this.conf, false);
+        this.connection = HConnectionManager.getConnection(this.conf);
+      }
+      try { // Sleep
+        Thread.sleep(getPauseTime(tries));
+      } catch (InterruptedException e) {
+        Thread.currentThread().interrupt();
+        // we should delete connection between client and zookeeper
+        HConnectionManager.deleteConnection(this.conf, false);
+        throw new MasterNotRunningException("Interrupted");
+      }
+    }
+    if (tries >= numRetries) {
+      // we should delete connection between client and zookeeper
+      HConnectionManager.deleteConnection(this.conf, false);
+      throw new MasterNotRunningException("Retried " + numRetries + " times");
+    }
   }
 
   /**



Mime
View raw message