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
This commit is contained in:
parent
3ad1139378
commit
1a76ba5336
|
@ -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) {
|
synchronized (CONNECTION_INSTANCES) {
|
||||||
Set<HConnectionKey> connectionKeys = new HashSet<HConnectionKey>();
|
Set<HConnectionKey> connectionKeys = new HashSet<HConnectionKey>();
|
||||||
connectionKeys.addAll(CONNECTION_INSTANCES.keySet());
|
connectionKeys.addAll(CONNECTION_INSTANCES.keySet());
|
||||||
for (HConnectionKey connectionKey : connectionKeys) {
|
for (HConnectionKey connectionKey : connectionKeys) {
|
||||||
deleteConnection(connectionKey, false);
|
deleteConnection(connectionKey, staleConnection);
|
||||||
}
|
}
|
||||||
CONNECTION_INSTANCES.clear();
|
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) {
|
private static void deleteConnection(HConnection connection, boolean staleConnection) {
|
||||||
synchronized (CONNECTION_INSTANCES) {
|
synchronized (CONNECTION_INSTANCES) {
|
||||||
for (Entry<HConnectionKey, HConnectionImplementation> e: CONNECTION_INSTANCES.entrySet()) {
|
for (Entry<HConnectionKey, HConnectionImplementation> e: CONNECTION_INSTANCES.entrySet()) {
|
||||||
|
@ -352,7 +364,7 @@ public class HConnectionManager {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG.error("Connection not found in the list, can't delete it "+
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -507,7 +507,7 @@ public class MiniHBaseCluster extends HBaseCluster {
|
||||||
if (this.hbaseCluster != null) {
|
if (this.hbaseCluster != null) {
|
||||||
this.hbaseCluster.shutdown();
|
this.hbaseCluster.shutdown();
|
||||||
}
|
}
|
||||||
HConnectionManager.deleteAllConnections();
|
HConnectionManager.deleteAllConnections(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue