HBASE-7369 HConnectionManager should remove aborted connections (Bryan Baugher)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1429556 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8f16cdfb65
commit
27739350c0
|
@ -211,6 +211,10 @@ public class HConnectionManager {
|
|||
if (connection == null) {
|
||||
connection = new HConnectionImplementation(conf, true);
|
||||
HBASE_INSTANCES.put(connectionKey, connection);
|
||||
} else if (connection.isClosed()) {
|
||||
HConnectionManager.deleteConnection(connectionKey, true, true);
|
||||
connection = new HConnectionImplementation(conf, true);
|
||||
HBASE_INSTANCES.put(connectionKey, connection);
|
||||
}
|
||||
connection.incCount();
|
||||
return connection;
|
||||
|
@ -2196,13 +2200,14 @@ public class HConnectionManager {
|
|||
closeZooKeeperWatcher();
|
||||
}
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
if (t != null) {
|
||||
LOG.fatal(msg, t);
|
||||
} else {
|
||||
LOG.fatal(msg);
|
||||
}
|
||||
this.aborted = true;
|
||||
close();
|
||||
this.closed = true;
|
||||
}
|
||||
}
|
||||
|
@ -2282,7 +2287,11 @@ public class HConnectionManager {
|
|||
@Override
|
||||
public void close() {
|
||||
if (managed) {
|
||||
HConnectionManager.deleteConnection(this, stopProxy, false);
|
||||
if (aborted) {
|
||||
HConnectionManager.deleteStaleConnection(this);
|
||||
} else {
|
||||
HConnectionManager.deleteConnection(this, stopProxy, false);
|
||||
}
|
||||
} else {
|
||||
close(true);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,10 @@ import java.lang.reflect.Field;
|
|||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
@ -37,6 +40,8 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.*;
|
||||
import org.apache.hadoop.hbase.client.HConnectionManager.HConnectionImplementation;
|
||||
import org.apache.hadoop.hbase.client.HConnectionManager.HConnectionKey;
|
||||
import org.apache.hadoop.hbase.master.HMaster;
|
||||
import org.apache.hadoop.hbase.regionserver.HRegionServer;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
|
@ -100,6 +105,28 @@ public class TestHCM {
|
|||
private static int getHConnectionManagerCacheSize(){
|
||||
return HConnectionTestingUtility.getConnectionCount();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void abortingHConnectionRemovesItselfFromHCM() throws Exception {
|
||||
// Save off current HConnections
|
||||
Map<HConnectionKey, HConnectionImplementation> oldHBaseInstances =
|
||||
new HashMap<HConnectionKey, HConnectionImplementation>();
|
||||
oldHBaseInstances.putAll(HConnectionManager.HBASE_INSTANCES);
|
||||
|
||||
HConnectionManager.HBASE_INSTANCES.clear();
|
||||
|
||||
try {
|
||||
HConnection connection = HConnectionManager.getConnection(TEST_UTIL.getConfiguration());
|
||||
connection.abort("test abortingHConnectionRemovesItselfFromHCM", new Exception(
|
||||
"test abortingHConnectionRemovesItselfFromHCM"));
|
||||
Assert.assertNotSame(connection,
|
||||
HConnectionManager.getConnection(TEST_UTIL.getConfiguration()));
|
||||
} finally {
|
||||
// Put original HConnections back
|
||||
HConnectionManager.HBASE_INSTANCES.clear();
|
||||
HConnectionManager.HBASE_INSTANCES.putAll(oldHBaseInstances);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that when we delete a location using the first row of a region
|
||||
|
|
Loading…
Reference in New Issue