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) {
|
if (connection == null) {
|
||||||
connection = new HConnectionImplementation(conf, true);
|
connection = new HConnectionImplementation(conf, true);
|
||||||
HBASE_INSTANCES.put(connectionKey, connection);
|
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();
|
connection.incCount();
|
||||||
return connection;
|
return connection;
|
||||||
|
@ -2203,6 +2207,7 @@ public class HConnectionManager {
|
||||||
LOG.fatal(msg);
|
LOG.fatal(msg);
|
||||||
}
|
}
|
||||||
this.aborted = true;
|
this.aborted = true;
|
||||||
|
close();
|
||||||
this.closed = true;
|
this.closed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2282,7 +2287,11 @@ public class HConnectionManager {
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
if (managed) {
|
if (managed) {
|
||||||
|
if (aborted) {
|
||||||
|
HConnectionManager.deleteStaleConnection(this);
|
||||||
|
} else {
|
||||||
HConnectionManager.deleteConnection(this, stopProxy, false);
|
HConnectionManager.deleteConnection(this, stopProxy, false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
close(true);
|
close(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,10 @@ import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.SynchronousQueue;
|
import java.util.concurrent.SynchronousQueue;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
@ -37,6 +40,8 @@ import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.hbase.*;
|
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.master.HMaster;
|
||||||
import org.apache.hadoop.hbase.regionserver.HRegionServer;
|
import org.apache.hadoop.hbase.regionserver.HRegionServer;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
|
@ -101,6 +106,28 @@ public class TestHCM {
|
||||||
return HConnectionTestingUtility.getConnectionCount();
|
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
|
* Test that when we delete a location using the first row of a region
|
||||||
* that we really delete it.
|
* that we really delete it.
|
||||||
|
|
Loading…
Reference in New Issue