From 908833117445f25752a3adbbe121f0df3f3c944e Mon Sep 17 00:00:00 2001 From: zhangduo Date: Thu, 21 Jun 2018 15:28:52 +0800 Subject: [PATCH] HBASE-20767 Always close hbaseAdmin along with connection in HBTU --- .../apache/hadoop/hbase/HBaseTestingUtility.java | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) 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 2bdb0a0..7cc9333 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 @@ -1051,12 +1051,15 @@ public class HBaseTestingUtility extends HBaseZKTestingUtility { * Starts the hbase cluster up again after shutting it down previously in a * test. Use this if you want to keep dfs/zk up and just stop/start hbase. * @param servers number of region servers - * @throws IOException */ public void restartHBaseCluster(int servers) throws IOException, InterruptedException { - if(connection != null){ - connection.close(); - connection = null; + if (hbaseAdmin != null) { + hbaseAdmin.close(); + hbaseAdmin = null; + } + if (this.connection != null) { + this.connection.close(); + this.connection = null; } this.hbaseCluster = new MiniHBaseCluster(this.conf, servers); // Don't leave here till we've done a successful scan of the hbase:meta @@ -1092,10 +1095,6 @@ public class HBaseTestingUtility extends HBaseZKTestingUtility { */ public void shutdownMiniCluster() throws Exception { LOG.info("Shutting down minicluster"); - if (this.connection != null && !this.connection.isClosed()) { - this.connection.close(); - this.connection = null; - } shutdownMiniHBaseCluster(); shutdownMiniDFSCluster(); shutdownMiniZKCluster(); @@ -1107,14 +1106,16 @@ public class HBaseTestingUtility extends HBaseZKTestingUtility { /** * Shutdown HBase mini cluster. Does not shutdown zk or dfs if running. - * @throws IOException */ public void shutdownMiniHBaseCluster() throws IOException { if (hbaseAdmin != null) { hbaseAdmin.close(); hbaseAdmin = null; } - + if (this.connection != null) { + this.connection.close(); + this.connection = null; + } // unset the configuration for MIN and MAX RS to start conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, -1); conf.setInt(ServerManager.WAIT_ON_REGIONSERVERS_MAXTOSTART, -1); @@ -1124,7 +1125,6 @@ public class HBaseTestingUtility extends HBaseZKTestingUtility { this.hbaseCluster.waitUntilShutDown(); this.hbaseCluster = null; } - if (zooKeeperWatcher != null) { zooKeeperWatcher.close(); zooKeeperWatcher = null; -- 2.7.4