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 2015/05/24 02:25:42 UTC

hbase git commit: HBASE-13757 TestMultiParallel (and others) failing on 0.98 since HBASE-13712

Repository: hbase
Updated Branches:
  refs/heads/0.98 ac3536ce2 -> a4ce4db45


HBASE-13757 TestMultiParallel (and others) failing on 0.98 since HBASE-13712


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/a4ce4db4
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/a4ce4db4
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/a4ce4db4

Branch: refs/heads/0.98
Commit: a4ce4db45b2b5b01df514c395fe7e946dbaf8851
Parents: ac3536c
Author: Andrew Purtell <ap...@apache.org>
Authored: Sat May 23 14:38:45 2015 -0700
Committer: Andrew Purtell <ap...@apache.org>
Committed: Sat May 23 14:38:45 2015 -0700

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/tool/Canary.java    | 38 +++++++++++---------
 .../hadoop/hbase/HBaseTestingUtility.java       |  6 +++-
 2 files changed, 26 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/a4ce4db4/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java
index f55bc3c..d08f344 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/tool/Canary.java
@@ -591,7 +591,7 @@ public final class Canary implements Tool {
             String[] tables = generateMonitorTables(this.targets);
             this.initialized = true;
             for (String table : tables) {
-              taskFutures.addAll(Canary.sniff(admin, sink, table, executor));
+              taskFutures.addAll(Canary.sniff(connection, sink, table, executor));
             }
           } else {
             taskFutures.addAll(sniff());
@@ -655,7 +655,7 @@ public final class Canary implements Tool {
       List<Future<Void>> taskFutures = new LinkedList<Future<Void>>();
       for (HTableDescriptor table : admin.listTables()) {
         if (admin.isTableEnabled(table.getTableName())) {
-          taskFutures.addAll(Canary.sniff(admin, sink, table, executor));
+          taskFutures.addAll(Canary.sniff(connection, sink, table.getTableName(), executor));
         }
       }
       return taskFutures;
@@ -666,9 +666,9 @@ public final class Canary implements Tool {
    * Canary entry point for specified table.
    * @throws Exception
    */
-  public static void sniff(final HBaseAdmin admin, TableName tableName) throws Exception {
+  public static void sniff(final HConnection connection, TableName tableName) throws Exception {
     List<Future<Void>> taskFutures =
-        Canary.sniff(admin, new StdOutSink(), tableName.getNameAsString(),
+        Canary.sniff(connection, new StdOutSink(), tableName.getNameAsString(),
           new ScheduledThreadPoolExecutor(1));
     for (Future<Void> future : taskFutures) {
       future.get();
@@ -679,32 +679,36 @@ public final class Canary implements Tool {
    * Canary entry point for specified table.
    * @throws Exception
    */
-  private static List<Future<Void>> sniff(final HBaseAdmin admin, final Sink sink, String tableName,
-      ExecutorService executor) throws Exception {
-    if (admin.isTableEnabled(TableName.valueOf(tableName))) {
-      return Canary.sniff(admin, sink, admin.getTableDescriptor(TableName.valueOf(tableName)),
-        executor);
-    } else {
-      LOG.warn(String.format("Table %s is not enabled", tableName));
+  private static List<Future<Void>> sniff(final HConnection connection, final Sink sink,
+    String tableName, ExecutorService executor) throws Exception {
+    HBaseAdmin admin = new HBaseAdmin(connection);
+    try {
+      if (admin.isTableEnabled(TableName.valueOf(tableName))) {
+        return Canary.sniff(connection, sink, TableName.valueOf(tableName), executor);
+      } else {
+        LOG.warn(String.format("Table %s is not enabled", tableName));
+      }
+      return new LinkedList<Future<Void>>();
+    } finally {
+      admin.close();
     }
-    return new LinkedList<Future<Void>>();
   }
 
   /*
    * Loops over regions that owns this table, and output some information abouts the state.
    */
-  private static List<Future<Void>> sniff(final HBaseAdmin admin, final Sink sink,
-      HTableDescriptor tableDesc, ExecutorService executor) throws Exception {
+  private static List<Future<Void>> sniff(final HConnection connection, final Sink sink,
+      TableName tableName, ExecutorService executor) throws Exception {
     HTableInterface table = null;
     try {
-      table = admin.getConnection().getTable(tableDesc.getTableName());
+      table = connection.getTable(tableName);
     } catch (TableNotFoundException e) {
       return new ArrayList<Future<Void>>();
     }
     List<RegionTask> tasks = new ArrayList<RegionTask>();
     try {
-      for (HRegionInfo region : admin.getTableRegions(tableDesc.getTableName())) {
-        tasks.add(new RegionTask(admin.getConnection(), region, sink));
+      for (HRegionInfo region : ((HTable)table).getRegionLocations().keySet()) {
+        tasks.add(new RegionTask(connection, region, sink));
       }
     } finally {
       table.close();

http://git-wip-us.apache.org/repos/asf/hbase/blob/a4ce4db4/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
index 254eb5a..ca7dcb4 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
@@ -61,6 +61,7 @@ import org.apache.hadoop.hbase.client.Durability;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.client.HConnection;
+import org.apache.hadoop.hbase.client.HConnectionManager;
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.client.Result;
@@ -2763,10 +2764,13 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility {
     // online in the regionserver is the very last thing done and can take a little while to happen.
     // Below we do a get.  The get will retry if a NotServeringRegionException or a
     // RegionOpeningException.  It is crass but when done all will be online.
+    HConnection connection = HConnectionManager.createConnection(conf);
     try {
-      Canary.sniff(admin, TableName.valueOf(table));
+      Canary.sniff(connection, TableName.valueOf(table));
     } catch (Exception e) {
       throw new IOException(e);
+    } finally {
+      connection.close();
     }
   }