From 1a76ba53369868cb21944e4609130de26202fdc4 Mon Sep 17 00:00:00 2001 From: Jean-Daniel Cryans Date: Fri, 2 Aug 2013 20:22:33 +0000 Subject: [PATCH] HBASE-8983 HBaseConnection#deleteAllConnections does not always delete (Nicolas Liochon via JD) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1509846 13f79535-47bb-0310-9956-ffa450edef68 --- .../hbase/client/HConnectionManager.java | 20 +++++++++++++++---- .../apache/hadoop/hbase/MiniHBaseCluster.java | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java index 2b27b5404b0..87af4575487 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java @@ -317,19 +317,31 @@ public class HConnectionManager { } /** - * Delete information for all connections. + * Delete information for all connections. Close or not the connection, depending on the + * staleConnection boolean and the ref count. By default, you should use it with + * staleConnection to true. */ - public static void deleteAllConnections() { + public static void deleteAllConnections(boolean staleConnection) { synchronized (CONNECTION_INSTANCES) { Set connectionKeys = new HashSet(); connectionKeys.addAll(CONNECTION_INSTANCES.keySet()); for (HConnectionKey connectionKey : connectionKeys) { - deleteConnection(connectionKey, false); + deleteConnection(connectionKey, staleConnection); } CONNECTION_INSTANCES.clear(); } } + /** + * Delete information for all connections.. + * @deprecated kept for backward compatibility, but the behavior is broken. HBASE-8983 + */ + @Deprecated + public static void deleteAllConnections() { + deleteAllConnections(false); + } + + private static void deleteConnection(HConnection connection, boolean staleConnection) { synchronized (CONNECTION_INSTANCES) { for (Entry e: CONNECTION_INSTANCES.entrySet()) { @@ -352,7 +364,7 @@ public class HConnectionManager { } } else { LOG.error("Connection not found in the list, can't delete it "+ - "(connection key=" + connectionKey + "). May be the key was modified?"); + "(connection key=" + connectionKey + "). May be the key was modified?", new Exception()); } } } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java index 75cca706850..6fa9df050a2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java @@ -507,7 +507,7 @@ public class MiniHBaseCluster extends HBaseCluster { if (this.hbaseCluster != null) { this.hbaseCluster.shutdown(); } - HConnectionManager.deleteAllConnections(); + HConnectionManager.deleteAllConnections(false); } @Override