HBASE-5027 HConnection.create(final Connection conf) does not clone, it creates a new Configuration reading *.xmls and then does a merge.
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1214871 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
32490bddce
commit
52dbd69707
|
@ -23,6 +23,7 @@ package org.apache.hadoop.hbase;
|
|||
import com.sun.management.UnixOperatingSystemMXBean;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.hbase.client.HConnectionTestingUtility;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.OperatingSystemMXBean;
|
||||
|
@ -64,6 +65,10 @@ public class ResourceChecker {
|
|||
}
|
||||
}
|
||||
|
||||
public long getConnectionCount(){
|
||||
return HConnectionTestingUtility.getConnectionCount();
|
||||
}
|
||||
|
||||
static {
|
||||
osStats =
|
||||
ManagementFactory.getOperatingSystemMXBean();
|
||||
|
@ -92,6 +97,8 @@ public class ResourceChecker {
|
|||
|
||||
private long initialThreadsCount;
|
||||
private long initialFileHandlesCount;
|
||||
private long initialConnectionCount;
|
||||
|
||||
|
||||
public boolean checkThreads(String tagLine) {
|
||||
boolean isOk = true;
|
||||
|
@ -126,8 +133,11 @@ public class ResourceChecker {
|
|||
}
|
||||
|
||||
logInfo(tagLine);
|
||||
|
||||
initialThreadsCount = rc.getThreadsCount();
|
||||
initialFileHandlesCount = rc.getOpenFileDescriptorCount();
|
||||
initialConnectionCount= rc.getConnectionCount();
|
||||
|
||||
check(tagLine);
|
||||
}
|
||||
|
||||
|
@ -140,11 +150,17 @@ public class ResourceChecker {
|
|||
rc.getOpenFileDescriptorCount() + " file descriptors" +
|
||||
(initialFileHandlesCount > 0 ?
|
||||
" (was " + initialFileHandlesCount + "). " : " ") +
|
||||
rc.getConnectionCount() + " connections" +
|
||||
(initialConnectionCount > 0 ?
|
||||
" (was " + initialConnectionCount + "), " : ", ") +
|
||||
(initialThreadsCount > 0 && rc.getThreadsCount() > initialThreadsCount ?
|
||||
" -thread leak?- " : "") +
|
||||
(initialFileHandlesCount > 0 &&
|
||||
rc.getOpenFileDescriptorCount() > initialFileHandlesCount ?
|
||||
" -file handle leak?- " : "")
|
||||
" -file handle leak?- " : "") +
|
||||
(initialConnectionCount > 0 &&
|
||||
rc.getConnectionCount() > initialConnectionCount ?
|
||||
" -connection leak?- " : "" )
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.mockito.Mockito;
|
|||
/**
|
||||
* {@link HConnection} testing utility.
|
||||
*/
|
||||
@Category(SmallTests.class)
|
||||
public class HConnectionTestingUtility {
|
||||
/*
|
||||
* Not part of {@link HBaseTestingUtility} because this class is not
|
||||
|
@ -85,4 +84,14 @@ public class HConnectionTestingUtility {
|
|||
return connection;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Count of extant connection instances
|
||||
*/
|
||||
public static int getConnectionCount() {
|
||||
synchronized (HConnectionManager.HBASE_INSTANCES) {
|
||||
return HConnectionManager.HBASE_INSTANCES.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,11 +49,7 @@ import org.apache.hadoop.hbase.regionserver.HRegionServer;
|
|||
import org.apache.hadoop.hbase.regionserver.wal.HLogUtilsForTests;
|
||||
import org.apache.hadoop.hbase.InvalidFamilyOperationException;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.*;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
|
||||
|
@ -1481,9 +1477,12 @@ public class TestAdmin {
|
|||
@Test
|
||||
public void testCheckHBaseAvailableClosesConnection() throws Exception {
|
||||
Configuration conf = TEST_UTIL.getConfiguration();
|
||||
for(int i=0; i<1000;i++) {
|
||||
HBaseAdmin.checkHBaseAvailable(conf);
|
||||
}
|
||||
|
||||
int initialCount = HConnectionTestingUtility.getConnectionCount();
|
||||
HBaseAdmin.checkHBaseAvailable(conf);
|
||||
int finalCount = HConnectionTestingUtility.getConnectionCount();
|
||||
|
||||
Assert.assertEquals(initialCount, finalCount) ;
|
||||
}
|
||||
|
||||
@org.junit.Rule
|
||||
|
|
Loading…
Reference in New Issue