HBASE-8983 HBaseConnection#deleteAllConnections does not always delete
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1504606 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
20e0f2b625
commit
8a21171f31
|
@ -318,19 +318,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<HConnectionKey> connectionKeys = new HashSet<HConnectionKey>();
|
||||
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<HConnectionKey, HConnectionImplementation> e: CONNECTION_INSTANCES.entrySet()) {
|
||||
|
|
|
@ -507,7 +507,7 @@ public class MiniHBaseCluster extends HBaseCluster {
|
|||
if (this.hbaseCluster != null) {
|
||||
this.hbaseCluster.shutdown();
|
||||
}
|
||||
HConnectionManager.deleteAllConnections();
|
||||
HConnectionManager.deleteAllConnections(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,6 +28,8 @@ import org.apache.hadoop.hbase.util.Bytes;
|
|||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
|
@ -49,7 +51,7 @@ public class TestReplicationDisableInactivePeer extends TestReplicationBase {
|
|||
|
||||
// enabling and shutdown the peer
|
||||
admin.enablePeer("2");
|
||||
utility2.shutdownMiniHBaseCluster();
|
||||
utility2.getHBaseCluster().getMaster().shutdown();
|
||||
|
||||
byte[] rowkey = Bytes.toBytes("disable inactive peer");
|
||||
Put put = new Put(rowkey);
|
||||
|
|
Loading…
Reference in New Issue