HBASE-4974 Remove some resources leaks on the tests
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1212688 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3e608b3979
commit
d855d71ba8
|
@ -569,7 +569,10 @@ public class HBaseTestingUtility {
|
||||||
while (s.next() != null) {
|
while (s.next() != null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
s.close();
|
||||||
|
t.close();
|
||||||
LOG.info("Minicluster is up");
|
LOG.info("Minicluster is up");
|
||||||
|
//getHBaseAdmin();
|
||||||
return this.hbaseCluster;
|
return this.hbaseCluster;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,6 +591,8 @@ public class HBaseTestingUtility {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
LOG.info("HBase has been restarted");
|
LOG.info("HBase has been restarted");
|
||||||
|
s.close();
|
||||||
|
t.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -710,8 +715,9 @@ public class HBaseTestingUtility {
|
||||||
HColumnDescriptor.DEFAULT_REPLICATION_SCOPE);
|
HColumnDescriptor.DEFAULT_REPLICATION_SCOPE);
|
||||||
desc.addFamily(hcd);
|
desc.addFamily(hcd);
|
||||||
}
|
}
|
||||||
(new HBaseAdmin(getConfiguration())).createTable(desc, startKey,
|
HBaseAdmin admin = getHBaseAdmin();
|
||||||
endKey, numRegions);
|
admin.createTable(desc, startKey, endKey, numRegions);
|
||||||
|
admin.close();
|
||||||
return new HTable(getConfiguration(), tableName);
|
return new HTable(getConfiguration(), tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -730,7 +736,9 @@ public class HBaseTestingUtility {
|
||||||
for(byte[] family : families) {
|
for(byte[] family : families) {
|
||||||
desc.addFamily(new HColumnDescriptor(family));
|
desc.addFamily(new HColumnDescriptor(family));
|
||||||
}
|
}
|
||||||
getHBaseAdmin().createTable(desc);
|
HBaseAdmin admin = getHBaseAdmin();
|
||||||
|
admin.createTable(desc);
|
||||||
|
admin.close();
|
||||||
return new HTable(c, tableName);
|
return new HTable(c, tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -757,7 +765,9 @@ public class HBaseTestingUtility {
|
||||||
HColumnDescriptor.DEFAULT_REPLICATION_SCOPE);
|
HColumnDescriptor.DEFAULT_REPLICATION_SCOPE);
|
||||||
desc.addFamily(hcd);
|
desc.addFamily(hcd);
|
||||||
}
|
}
|
||||||
getHBaseAdmin().createTable(desc);
|
HBaseAdmin admin = getHBaseAdmin();
|
||||||
|
admin.createTable(desc);
|
||||||
|
admin.close();
|
||||||
return new HTable(c, tableName);
|
return new HTable(c, tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -796,7 +806,9 @@ public class HBaseTestingUtility {
|
||||||
HColumnDescriptor.DEFAULT_REPLICATION_SCOPE);
|
HColumnDescriptor.DEFAULT_REPLICATION_SCOPE);
|
||||||
desc.addFamily(hcd);
|
desc.addFamily(hcd);
|
||||||
}
|
}
|
||||||
getHBaseAdmin().createTable(desc);
|
HBaseAdmin admin = getHBaseAdmin();
|
||||||
|
admin.createTable(desc);
|
||||||
|
admin.close();
|
||||||
return new HTable(new Configuration(getConfiguration()), tableName);
|
return new HTable(new Configuration(getConfiguration()), tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -821,7 +833,9 @@ public class HBaseTestingUtility {
|
||||||
HColumnDescriptor.DEFAULT_REPLICATION_SCOPE);
|
HColumnDescriptor.DEFAULT_REPLICATION_SCOPE);
|
||||||
desc.addFamily(hcd);
|
desc.addFamily(hcd);
|
||||||
}
|
}
|
||||||
getHBaseAdmin().createTable(desc);
|
HBaseAdmin admin = getHBaseAdmin();
|
||||||
|
admin.createTable(desc);
|
||||||
|
admin.close();
|
||||||
return new HTable(new Configuration(getConfiguration()), tableName);
|
return new HTable(new Configuration(getConfiguration()), tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -849,7 +863,9 @@ public class HBaseTestingUtility {
|
||||||
desc.addFamily(hcd);
|
desc.addFamily(hcd);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
getHBaseAdmin().createTable(desc);
|
HBaseAdmin admin = getHBaseAdmin();
|
||||||
|
admin.createTable(desc);
|
||||||
|
admin.close();
|
||||||
return new HTable(new Configuration(getConfiguration()), tableName);
|
return new HTable(new Configuration(getConfiguration()), tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -861,6 +877,7 @@ public class HBaseTestingUtility {
|
||||||
HBaseAdmin admin = new HBaseAdmin(getConfiguration());
|
HBaseAdmin admin = new HBaseAdmin(getConfiguration());
|
||||||
admin.disableTable(tableName);
|
admin.disableTable(tableName);
|
||||||
admin.deleteTable(tableName);
|
admin.deleteTable(tableName);
|
||||||
|
admin.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -878,6 +895,7 @@ public class HBaseTestingUtility {
|
||||||
table.delete(del);
|
table.delete(del);
|
||||||
}
|
}
|
||||||
resScan = table.getScanner(scan);
|
resScan = table.getScanner(scan);
|
||||||
|
resScan.close();
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1067,11 +1085,16 @@ public class HBaseTestingUtility {
|
||||||
HConnection conn = table.getConnection();
|
HConnection conn = table.getConnection();
|
||||||
conn.clearRegionCache();
|
conn.clearRegionCache();
|
||||||
// assign all the new regions IF table is enabled.
|
// assign all the new regions IF table is enabled.
|
||||||
if (getHBaseAdmin().isTableEnabled(table.getTableName())) {
|
HBaseAdmin admin = getHBaseAdmin();
|
||||||
|
if (admin.isTableEnabled(table.getTableName())) {
|
||||||
for(HRegionInfo hri : newRegions) {
|
for(HRegionInfo hri : newRegions) {
|
||||||
hbaseCluster.getMaster().assignRegion(hri);
|
hbaseCluster.getMaster().assignRegion(hri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
admin.close();
|
||||||
|
meta.close();
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1103,6 +1126,8 @@ public class HBaseTestingUtility {
|
||||||
LOG.info("createMultiRegionsInMeta: inserted " + hri.toString());
|
LOG.info("createMultiRegionsInMeta: inserted " + hri.toString());
|
||||||
newRegions.add(hri);
|
newRegions.add(hri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
meta.close();
|
||||||
return newRegions;
|
return newRegions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1122,6 +1147,7 @@ public class HBaseTestingUtility {
|
||||||
rows.add(result.getRow());
|
rows.add(result.getRow());
|
||||||
}
|
}
|
||||||
s.close();
|
s.close();
|
||||||
|
t.close();
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1145,6 +1171,7 @@ public class HBaseTestingUtility {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.close();
|
s.close();
|
||||||
|
t.close();
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1272,7 +1299,7 @@ public class HBaseTestingUtility {
|
||||||
Thread.sleep(sleep);
|
Thread.sleep(sleep);
|
||||||
|
|
||||||
if (checkStatus) {
|
if (checkStatus) {
|
||||||
new HTable(new Configuration(conf), HConstants.META_TABLE_NAME);
|
new HTable(new Configuration(conf), HConstants.META_TABLE_NAME).close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1316,6 +1343,7 @@ public class HBaseTestingUtility {
|
||||||
public void closeRegion(byte[] regionName) throws IOException {
|
public void closeRegion(byte[] regionName) throws IOException {
|
||||||
HBaseAdmin admin = getHBaseAdmin();
|
HBaseAdmin admin = getHBaseAdmin();
|
||||||
admin.closeRegion(regionName, null);
|
admin.closeRegion(regionName, null);
|
||||||
|
admin.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1414,6 +1442,7 @@ public class HBaseTestingUtility {
|
||||||
System.currentTimeMillis() - startWait < timeoutMillis);
|
System.currentTimeMillis() - startWait < timeoutMillis);
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
}
|
}
|
||||||
|
admin.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1551,6 +1580,7 @@ public class HBaseTestingUtility {
|
||||||
result.clear();
|
result.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
scanner.close();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -221,6 +221,7 @@ public class TestAdmin {
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
assertTrue(ok);
|
assertTrue(ok);
|
||||||
|
ht.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -270,6 +271,9 @@ public class TestAdmin {
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
assertTrue(ok);
|
assertTrue(ok);
|
||||||
|
|
||||||
|
ht1.close();
|
||||||
|
ht2.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -277,7 +281,7 @@ public class TestAdmin {
|
||||||
HTableDescriptor [] tables = admin.listTables();
|
HTableDescriptor [] tables = admin.listTables();
|
||||||
int numTables = tables.length;
|
int numTables = tables.length;
|
||||||
TEST_UTIL.createTable(Bytes.toBytes("testCreateTable"),
|
TEST_UTIL.createTable(Bytes.toBytes("testCreateTable"),
|
||||||
HConstants.CATALOG_FAMILY);
|
HConstants.CATALOG_FAMILY).close();
|
||||||
tables = this.admin.listTables();
|
tables = this.admin.listTables();
|
||||||
assertEquals(numTables + 1, tables.length);
|
assertEquals(numTables + 1, tables.length);
|
||||||
}
|
}
|
||||||
|
@ -295,6 +299,7 @@ public class TestAdmin {
|
||||||
HTable table = new HTable(TEST_UTIL.getConfiguration(), "myTestTable");
|
HTable table = new HTable(TEST_UTIL.getConfiguration(), "myTestTable");
|
||||||
HTableDescriptor confirmedHtd = table.getTableDescriptor();
|
HTableDescriptor confirmedHtd = table.getTableDescriptor();
|
||||||
assertEquals(htd.compareTo(confirmedHtd), 0);
|
assertEquals(htd.compareTo(confirmedHtd), 0);
|
||||||
|
table.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -319,7 +324,7 @@ public class TestAdmin {
|
||||||
"hbase.online.schema.update.enable", true);
|
"hbase.online.schema.update.enable", true);
|
||||||
HTableDescriptor [] tables = admin.listTables();
|
HTableDescriptor [] tables = admin.listTables();
|
||||||
int numTables = tables.length;
|
int numTables = tables.length;
|
||||||
TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY);
|
TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY).close();
|
||||||
tables = this.admin.listTables();
|
tables = this.admin.listTables();
|
||||||
assertEquals(numTables + 1, tables.length);
|
assertEquals(numTables + 1, tables.length);
|
||||||
|
|
||||||
|
@ -407,7 +412,7 @@ public class TestAdmin {
|
||||||
"hbase.online.schema.update.enable", false);
|
"hbase.online.schema.update.enable", false);
|
||||||
HTableDescriptor[] tables = admin.listTables();
|
HTableDescriptor[] tables = admin.listTables();
|
||||||
int numTables = tables.length;
|
int numTables = tables.length;
|
||||||
TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY);
|
TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY).close();
|
||||||
tables = this.admin.listTables();
|
tables = this.admin.listTables();
|
||||||
assertEquals(numTables + 1, tables.length);
|
assertEquals(numTables + 1, tables.length);
|
||||||
|
|
||||||
|
@ -565,6 +570,7 @@ public class TestAdmin {
|
||||||
assertTrue(hri.getEndKey() == null || hri.getEndKey().length == 0);
|
assertTrue(hri.getEndKey() == null || hri.getEndKey().length == 0);
|
||||||
|
|
||||||
verifyRoundRobinDistribution(ht, expectedRegions);
|
verifyRoundRobinDistribution(ht, expectedRegions);
|
||||||
|
ht.close();
|
||||||
|
|
||||||
// Now test using start/end with a number of regions
|
// Now test using start/end with a number of regions
|
||||||
|
|
||||||
|
@ -584,8 +590,8 @@ public class TestAdmin {
|
||||||
admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
|
admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
|
||||||
admin.createTable(desc, startKey, endKey, expectedRegions);
|
admin.createTable(desc, startKey, endKey, expectedRegions);
|
||||||
|
|
||||||
ht = new HTable(TEST_UTIL.getConfiguration(), TABLE_2);
|
HTable ht2 = new HTable(TEST_UTIL.getConfiguration(), TABLE_2);
|
||||||
regions = ht.getRegionsInfo();
|
regions = ht2.getRegionsInfo();
|
||||||
assertEquals("Tried to create " + expectedRegions + " regions " +
|
assertEquals("Tried to create " + expectedRegions + " regions " +
|
||||||
"but only found " + regions.size(),
|
"but only found " + regions.size(),
|
||||||
expectedRegions, regions.size());
|
expectedRegions, regions.size());
|
||||||
|
@ -623,7 +629,8 @@ public class TestAdmin {
|
||||||
assertTrue(Bytes.equals(hri.getStartKey(), new byte [] {9,9,9,9,9,9,9,9,9,9}));
|
assertTrue(Bytes.equals(hri.getStartKey(), new byte [] {9,9,9,9,9,9,9,9,9,9}));
|
||||||
assertTrue(hri.getEndKey() == null || hri.getEndKey().length == 0);
|
assertTrue(hri.getEndKey() == null || hri.getEndKey().length == 0);
|
||||||
|
|
||||||
verifyRoundRobinDistribution(ht, expectedRegions);
|
verifyRoundRobinDistribution(ht2, expectedRegions);
|
||||||
|
ht2.close();
|
||||||
|
|
||||||
// Try once more with something that divides into something infinite
|
// Try once more with something that divides into something infinite
|
||||||
|
|
||||||
|
@ -639,14 +646,17 @@ public class TestAdmin {
|
||||||
admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
|
admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
|
||||||
admin.createTable(desc, startKey, endKey, expectedRegions);
|
admin.createTable(desc, startKey, endKey, expectedRegions);
|
||||||
|
|
||||||
ht = new HTable(TEST_UTIL.getConfiguration(), TABLE_3);
|
|
||||||
regions = ht.getRegionsInfo();
|
HTable ht3 = new HTable(TEST_UTIL.getConfiguration(), TABLE_3);
|
||||||
|
regions = ht3.getRegionsInfo();
|
||||||
assertEquals("Tried to create " + expectedRegions + " regions " +
|
assertEquals("Tried to create " + expectedRegions + " regions " +
|
||||||
"but only found " + regions.size(),
|
"but only found " + regions.size(),
|
||||||
expectedRegions, regions.size());
|
expectedRegions, regions.size());
|
||||||
System.err.println("Found " + regions.size() + " regions");
|
System.err.println("Found " + regions.size() + " regions");
|
||||||
|
|
||||||
verifyRoundRobinDistribution(ht, expectedRegions);
|
verifyRoundRobinDistribution(ht3, expectedRegions);
|
||||||
|
ht3.close();
|
||||||
|
|
||||||
|
|
||||||
// Try an invalid case where there are duplicate split keys
|
// Try an invalid case where there are duplicate split keys
|
||||||
splitKeys = new byte [][] {
|
splitKeys = new byte [][] {
|
||||||
|
@ -659,14 +669,15 @@ public class TestAdmin {
|
||||||
byte [] TABLE_4 = Bytes.add(tableName, Bytes.toBytes("_4"));
|
byte [] TABLE_4 = Bytes.add(tableName, Bytes.toBytes("_4"));
|
||||||
desc = new HTableDescriptor(TABLE_4);
|
desc = new HTableDescriptor(TABLE_4);
|
||||||
desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY));
|
desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY));
|
||||||
admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
|
HBaseAdmin ladmin = new HBaseAdmin(TEST_UTIL.getConfiguration());
|
||||||
try {
|
try {
|
||||||
admin.createTable(desc, splitKeys);
|
ladmin.createTable(desc, splitKeys);
|
||||||
assertTrue("Should not be able to create this table because of " +
|
assertTrue("Should not be able to create this table because of " +
|
||||||
"duplicate split keys", false);
|
"duplicate split keys", false);
|
||||||
} catch(IllegalArgumentException iae) {
|
} catch(IllegalArgumentException iae) {
|
||||||
// Expected
|
// Expected
|
||||||
}
|
}
|
||||||
|
ladmin.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -900,6 +911,7 @@ public class TestAdmin {
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
TEST_UTIL.deleteTable(tableName);
|
TEST_UTIL.deleteTable(tableName);
|
||||||
|
table.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -920,7 +932,7 @@ public class TestAdmin {
|
||||||
@Test
|
@Test
|
||||||
public void testEnableDisableAddColumnDeleteColumn() throws Exception {
|
public void testEnableDisableAddColumnDeleteColumn() throws Exception {
|
||||||
byte [] tableName = Bytes.toBytes("testMasterAdmin");
|
byte [] tableName = Bytes.toBytes("testMasterAdmin");
|
||||||
TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY);
|
TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY).close();
|
||||||
this.admin.disableTable(tableName);
|
this.admin.disableTable(tableName);
|
||||||
try {
|
try {
|
||||||
new HTable(TEST_UTIL.getConfiguration(), tableName);
|
new HTable(TEST_UTIL.getConfiguration(), tableName);
|
||||||
|
@ -1011,7 +1023,7 @@ public class TestAdmin {
|
||||||
admin.createTable(new HTableDescriptor(name + "SOMEUPPERCASE"));
|
admin.createTable(new HTableDescriptor(name + "SOMEUPPERCASE"));
|
||||||
admin.createTable(new HTableDescriptor(name));
|
admin.createTable(new HTableDescriptor(name));
|
||||||
// Before fix, below would fail throwing a NoServerForRegionException.
|
// Before fix, below would fail throwing a NoServerForRegionException.
|
||||||
new HTable(TEST_UTIL.getConfiguration(), name);
|
new HTable(TEST_UTIL.getConfiguration(), name).close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
|
@ -1033,6 +1045,7 @@ public class TestAdmin {
|
||||||
HBaseAdmin hbaseadmin = new HBaseAdmin(TEST_UTIL.getConfiguration());
|
HBaseAdmin hbaseadmin = new HBaseAdmin(TEST_UTIL.getConfiguration());
|
||||||
hbaseadmin.createTable(new HTableDescriptor(name), startKey, endKey,
|
hbaseadmin.createTable(new HTableDescriptor(name), startKey, endKey,
|
||||||
expectedRegions);
|
expectedRegions);
|
||||||
|
hbaseadmin.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1048,6 +1061,7 @@ public class TestAdmin {
|
||||||
Put put = new Put(value);
|
Put put = new Put(value);
|
||||||
put.add(HConstants.CATALOG_FAMILY, HConstants.CATALOG_FAMILY, value);
|
put.add(HConstants.CATALOG_FAMILY, HConstants.CATALOG_FAMILY, value);
|
||||||
table.put(put);
|
table.put(put);
|
||||||
|
table.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1089,7 +1103,7 @@ public class TestAdmin {
|
||||||
@Test (expected=TableExistsException.class)
|
@Test (expected=TableExistsException.class)
|
||||||
public void testTableExistsExceptionWithATable() throws IOException {
|
public void testTableExistsExceptionWithATable() throws IOException {
|
||||||
final byte [] name = Bytes.toBytes("testTableExistsExceptionWithATable");
|
final byte [] name = Bytes.toBytes("testTableExistsExceptionWithATable");
|
||||||
TEST_UTIL.createTable(name, HConstants.CATALOG_FAMILY);
|
TEST_UTIL.createTable(name, HConstants.CATALOG_FAMILY).close();
|
||||||
TEST_UTIL.createTable(name, HConstants.CATALOG_FAMILY);
|
TEST_UTIL.createTable(name, HConstants.CATALOG_FAMILY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1101,7 +1115,7 @@ public class TestAdmin {
|
||||||
public void testTableNotEnabledExceptionWithATable() throws IOException {
|
public void testTableNotEnabledExceptionWithATable() throws IOException {
|
||||||
final byte [] name = Bytes.toBytes(
|
final byte [] name = Bytes.toBytes(
|
||||||
"testTableNotEnabledExceptionWithATable");
|
"testTableNotEnabledExceptionWithATable");
|
||||||
TEST_UTIL.createTable(name, HConstants.CATALOG_FAMILY);
|
TEST_UTIL.createTable(name, HConstants.CATALOG_FAMILY).close();
|
||||||
this.admin.disableTable(name);
|
this.admin.disableTable(name);
|
||||||
this.admin.disableTable(name);
|
this.admin.disableTable(name);
|
||||||
}
|
}
|
||||||
|
@ -1114,8 +1128,12 @@ public class TestAdmin {
|
||||||
public void testTableNotDisabledExceptionWithATable() throws IOException {
|
public void testTableNotDisabledExceptionWithATable() throws IOException {
|
||||||
final byte [] name = Bytes.toBytes(
|
final byte [] name = Bytes.toBytes(
|
||||||
"testTableNotDisabledExceptionWithATable");
|
"testTableNotDisabledExceptionWithATable");
|
||||||
TEST_UTIL.createTable(name, HConstants.CATALOG_FAMILY);
|
HTable t = TEST_UTIL.createTable(name, HConstants.CATALOG_FAMILY);
|
||||||
|
try {
|
||||||
this.admin.enableTable(name);
|
this.admin.enableTable(name);
|
||||||
|
}finally {
|
||||||
|
t.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1131,7 +1149,7 @@ public class TestAdmin {
|
||||||
public void testShouldCloseTheRegionBasedOnTheEncodedRegionName()
|
public void testShouldCloseTheRegionBasedOnTheEncodedRegionName()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion");
|
byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion");
|
||||||
HBaseAdmin admin = createTable(TABLENAME);
|
createTableWithDefaultConf(TABLENAME);
|
||||||
|
|
||||||
HRegionInfo info = null;
|
HRegionInfo info = null;
|
||||||
HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);
|
HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);
|
||||||
|
@ -1152,7 +1170,7 @@ public class TestAdmin {
|
||||||
@Test
|
@Test
|
||||||
public void testCloseRegionIfInvalidRegionNameIsPassed() throws Exception {
|
public void testCloseRegionIfInvalidRegionNameIsPassed() throws Exception {
|
||||||
byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion1");
|
byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion1");
|
||||||
HBaseAdmin admin = createTable(TABLENAME);
|
createTableWithDefaultConf(TABLENAME);
|
||||||
|
|
||||||
HRegionInfo info = null;
|
HRegionInfo info = null;
|
||||||
HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);
|
HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);
|
||||||
|
@ -1174,7 +1192,7 @@ public class TestAdmin {
|
||||||
@Test
|
@Test
|
||||||
public void testCloseRegionThatFetchesTheHRIFromMeta() throws Exception {
|
public void testCloseRegionThatFetchesTheHRIFromMeta() throws Exception {
|
||||||
byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion2");
|
byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion2");
|
||||||
HBaseAdmin admin = createTable(TABLENAME);
|
createTableWithDefaultConf(TABLENAME);
|
||||||
|
|
||||||
HRegionInfo info = null;
|
HRegionInfo info = null;
|
||||||
HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);
|
HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);
|
||||||
|
@ -1204,7 +1222,7 @@ public class TestAdmin {
|
||||||
@Test
|
@Test
|
||||||
public void testCloseRegionWhenServerNameIsNull() throws Exception {
|
public void testCloseRegionWhenServerNameIsNull() throws Exception {
|
||||||
byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion3");
|
byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion3");
|
||||||
HBaseAdmin admin = createTable(TABLENAME);
|
createTableWithDefaultConf(TABLENAME);
|
||||||
|
|
||||||
HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);
|
HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);
|
||||||
|
|
||||||
|
@ -1228,7 +1246,7 @@ public class TestAdmin {
|
||||||
@Test
|
@Test
|
||||||
public void testCloseRegionWhenServerNameIsEmpty() throws Exception {
|
public void testCloseRegionWhenServerNameIsEmpty() throws Exception {
|
||||||
byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegionWhenServerNameIsEmpty");
|
byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegionWhenServerNameIsEmpty");
|
||||||
HBaseAdmin admin = createTable(TABLENAME);
|
createTableWithDefaultConf(TABLENAME);
|
||||||
|
|
||||||
HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);
|
HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);
|
||||||
|
|
||||||
|
@ -1251,7 +1269,7 @@ public class TestAdmin {
|
||||||
@Test
|
@Test
|
||||||
public void testCloseRegionWhenEncodedRegionNameIsNotGiven() throws Exception {
|
public void testCloseRegionWhenEncodedRegionNameIsNotGiven() throws Exception {
|
||||||
byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion4");
|
byte[] TABLENAME = Bytes.toBytes("TestHBACloseRegion4");
|
||||||
HBaseAdmin admin = createTable(TABLENAME);
|
createTableWithDefaultConf(TABLENAME);
|
||||||
|
|
||||||
HRegionInfo info = null;
|
HRegionInfo info = null;
|
||||||
HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);
|
HRegionServer rs = TEST_UTIL.getRSForFirstRegionInTable(TABLENAME);
|
||||||
|
@ -1284,6 +1302,14 @@ public class TestAdmin {
|
||||||
return admin;
|
return admin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createTableWithDefaultConf(byte[] TABLENAME) throws IOException {
|
||||||
|
HTableDescriptor htd = new HTableDescriptor(TABLENAME);
|
||||||
|
HColumnDescriptor hcd = new HColumnDescriptor("value");
|
||||||
|
htd.addFamily(hcd);
|
||||||
|
|
||||||
|
admin.createTable(htd, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHundredsOfTable() throws IOException{
|
public void testHundredsOfTable() throws IOException{
|
||||||
|
@ -1332,7 +1358,6 @@ public class TestAdmin {
|
||||||
|
|
||||||
HTableDescriptor desc = new HTableDescriptor(tableName);
|
HTableDescriptor desc = new HTableDescriptor(tableName);
|
||||||
desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY));
|
desc.addFamily(new HColumnDescriptor(HConstants.CATALOG_FAMILY));
|
||||||
admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
|
|
||||||
admin.createTable(desc, startKey, endKey, expectedRegions);
|
admin.createTable(desc, startKey, endKey, expectedRegions);
|
||||||
|
|
||||||
List<HRegionInfo> RegionInfos = admin.getTableRegions(tableName);
|
List<HRegionInfo> RegionInfos = admin.getTableRegions(tableName);
|
||||||
|
@ -1419,7 +1444,8 @@ public class TestAdmin {
|
||||||
private HRegionServer startAndWriteData(String tableName, byte[] value)
|
private HRegionServer startAndWriteData(String tableName, byte[] value)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
// When the META table can be opened, the region servers are running
|
// When the META table can be opened, the region servers are running
|
||||||
new HTable(TEST_UTIL.getConfiguration(), HConstants.META_TABLE_NAME);
|
new HTable(
|
||||||
|
TEST_UTIL.getConfiguration(), HConstants.META_TABLE_NAME).close();
|
||||||
HRegionServer regionServer = TEST_UTIL.getHBaseCluster()
|
HRegionServer regionServer = TEST_UTIL.getHBaseCluster()
|
||||||
.getRegionServerThreads().get(0).getRegionServer();
|
.getRegionServerThreads().get(0).getRegionServer();
|
||||||
|
|
||||||
|
@ -1444,6 +1470,8 @@ public class TestAdmin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table.close();
|
||||||
return regionServer;
|
return regionServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -202,14 +202,16 @@ public class TestCatalogJanitor {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean stopped = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop(String why) {
|
public void stop(String why) {
|
||||||
//no-op
|
stopped = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isStopped() {
|
public boolean isStopped() {
|
||||||
return false;
|
return stopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -458,6 +460,9 @@ public class TestCatalogJanitor {
|
||||||
|
|
||||||
// Super parent should get cleaned up now both splita and splitb are gone.
|
// Super parent should get cleaned up now both splita and splitb are gone.
|
||||||
assertTrue(janitor.cleanParent(parent, regions.get(parent)));
|
assertTrue(janitor.cleanParent(parent, regions.get(parent)));
|
||||||
|
|
||||||
|
services.stop("test finished");
|
||||||
|
janitor.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String setRootDirAndCleanIt(final HBaseTestingUtility htu,
|
private String setRootDirAndCleanIt(final HBaseTestingUtility htu,
|
||||||
|
|
|
@ -199,7 +199,9 @@ public class TestScannersWithFilters {
|
||||||
table.delete(d);
|
table.delete(d);
|
||||||
}
|
}
|
||||||
numRows -= 2;
|
numRows -= 2;
|
||||||
|
table.close();
|
||||||
}
|
}
|
||||||
|
admin.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
|
Loading…
Reference in New Issue