HBASE-5051 HBaseTestingUtility#getHBaseAdmin() creates a new HBaseAdmin instance at each call - revert
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1215307 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
15d9af3d42
commit
3f016b62fd
|
@ -1478,12 +1478,10 @@ implements HMasterInterface, HMasterRegionInterface, MasterServices, Server {
|
||||||
LOG.error("Error call master coprocessor preShutdown()", ioe);
|
LOG.error("Error call master coprocessor preShutdown()", ioe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.assignmentManager != null) this.assignmentManager.shutdown();
|
this.assignmentManager.shutdown();
|
||||||
if (this.serverManager != null) this.serverManager.shutdownCluster();
|
this.serverManager.shutdownCluster();
|
||||||
try {
|
try {
|
||||||
if (this.clusterStatusTracker != null){
|
this.clusterStatusTracker.setClusterDown();
|
||||||
this.clusterStatusTracker.setClusterDown();
|
|
||||||
}
|
|
||||||
} catch (KeeperException e) {
|
} catch (KeeperException e) {
|
||||||
LOG.error("ZooKeeper exception trying to set cluster as down in ZK", e);
|
LOG.error("ZooKeeper exception trying to set cluster as down in ZK", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -579,9 +579,8 @@ public class HBaseTestingUtility {
|
||||||
}
|
}
|
||||||
s.close();
|
s.close();
|
||||||
t.close();
|
t.close();
|
||||||
|
|
||||||
getHBaseAdmin(); // create immediately the hbaseAdmin
|
|
||||||
LOG.info("Minicluster is up");
|
LOG.info("Minicluster is up");
|
||||||
|
//getHBaseAdmin();
|
||||||
return this.hbaseCluster;
|
return this.hbaseCluster;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -643,10 +642,6 @@ public class HBaseTestingUtility {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void shutdownMiniHBaseCluster() throws IOException {
|
public void shutdownMiniHBaseCluster() throws IOException {
|
||||||
if (hbaseAdmin != null) {
|
|
||||||
hbaseAdmin.close();
|
|
||||||
hbaseAdmin = null;
|
|
||||||
}
|
|
||||||
if (this.hbaseCluster != null) {
|
if (this.hbaseCluster != null) {
|
||||||
this.hbaseCluster.shutdown();
|
this.hbaseCluster.shutdown();
|
||||||
// Wait till hbase is down before going on to shutdown zk.
|
// Wait till hbase is down before going on to shutdown zk.
|
||||||
|
@ -728,7 +723,9 @@ public class HBaseTestingUtility {
|
||||||
HColumnDescriptor.DEFAULT_REPLICATION_SCOPE);
|
HColumnDescriptor.DEFAULT_REPLICATION_SCOPE);
|
||||||
desc.addFamily(hcd);
|
desc.addFamily(hcd);
|
||||||
}
|
}
|
||||||
getHBaseAdmin().createTable(desc, startKey, endKey, numRegions);
|
HBaseAdmin admin = getHBaseAdmin();
|
||||||
|
admin.createTable(desc, startKey, endKey, numRegions);
|
||||||
|
admin.close();
|
||||||
return new HTable(getConfiguration(), tableName);
|
return new HTable(getConfiguration(), tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -747,7 +744,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -774,7 +773,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -813,7 +814,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -838,7 +841,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -866,7 +871,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -875,8 +882,10 @@ public class HBaseTestingUtility {
|
||||||
* @param tableName existing table
|
* @param tableName existing table
|
||||||
*/
|
*/
|
||||||
public void deleteTable(byte[] tableName) throws IOException {
|
public void deleteTable(byte[] tableName) throws IOException {
|
||||||
getHBaseAdmin().disableTable(tableName);
|
HBaseAdmin admin = new HBaseAdmin(getConfiguration());
|
||||||
getHBaseAdmin().deleteTable(tableName);
|
admin.disableTable(tableName);
|
||||||
|
admin.deleteTable(tableName);
|
||||||
|
admin.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1084,12 +1093,14 @@ 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();
|
meta.close();
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
|
@ -1312,21 +1323,14 @@ public class HBaseTestingUtility {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a HBaseAdmin instance.
|
* Returns a HBaseAdmin instance.
|
||||||
* This instance is shared between HBaseTestingUtility intance users.
|
|
||||||
* Don't close it, it will be closed automatically when the
|
|
||||||
* cluster shutdowns
|
|
||||||
*
|
*
|
||||||
* @return The HBaseAdmin instance.
|
* @return The HBaseAdmin instance.
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public synchronized HBaseAdmin getHBaseAdmin()
|
public HBaseAdmin getHBaseAdmin()
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (hbaseAdmin == null){
|
return new HBaseAdmin(new Configuration(getConfiguration()));
|
||||||
hbaseAdmin = new HBaseAdmin(new Configuration(getConfiguration()));
|
|
||||||
}
|
|
||||||
return hbaseAdmin;
|
|
||||||
}
|
}
|
||||||
private HBaseAdmin hbaseAdmin = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the named region.
|
* Closes the named region.
|
||||||
|
@ -1345,7 +1349,9 @@ public class HBaseTestingUtility {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void closeRegion(byte[] regionName) throws IOException {
|
public void closeRegion(byte[] regionName) throws IOException {
|
||||||
getHBaseAdmin().closeRegion(regionName, null);
|
HBaseAdmin admin = getHBaseAdmin();
|
||||||
|
admin.closeRegion(regionName, null);
|
||||||
|
admin.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1437,12 +1443,14 @@ public class HBaseTestingUtility {
|
||||||
|
|
||||||
public void waitTableAvailable(byte[] table, long timeoutMillis)
|
public void waitTableAvailable(byte[] table, long timeoutMillis)
|
||||||
throws InterruptedException, IOException {
|
throws InterruptedException, IOException {
|
||||||
|
HBaseAdmin admin = getHBaseAdmin();
|
||||||
long startWait = System.currentTimeMillis();
|
long startWait = System.currentTimeMillis();
|
||||||
while (!getHBaseAdmin().isTableAvailable(table)) {
|
while (!admin.isTableAvailable(table)) {
|
||||||
assertTrue("Timed out waiting for table " + Bytes.toStringBinary(table),
|
assertTrue("Timed out waiting for table " + Bytes.toStringBinary(table),
|
||||||
System.currentTimeMillis() - startWait < timeoutMillis);
|
System.currentTimeMillis() - startWait < timeoutMillis);
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
}
|
}
|
||||||
|
admin.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1852,7 +1860,6 @@ public class HBaseTestingUtility {
|
||||||
totalNumberOfRegions);
|
totalNumberOfRegions);
|
||||||
|
|
||||||
admin.createTable(desc, splits);
|
admin.createTable(desc, splits);
|
||||||
admin.close();
|
|
||||||
} catch (MasterNotRunningException e) {
|
} catch (MasterNotRunningException e) {
|
||||||
LOG.error("Master not running", e);
|
LOG.error("Master not running", e);
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
|
@ -1866,7 +1873,6 @@ public class HBaseTestingUtility {
|
||||||
public static int getMetaRSPort(Configuration conf) throws IOException {
|
public static int getMetaRSPort(Configuration conf) throws IOException {
|
||||||
HTable table = new HTable(conf, HConstants.META_TABLE_NAME);
|
HTable table = new HTable(conf, HConstants.META_TABLE_NAME);
|
||||||
HRegionLocation hloc = table.getRegionLocation(Bytes.toBytes(""));
|
HRegionLocation hloc = table.getRegionLocation(Bytes.toBytes(""));
|
||||||
table.close();
|
|
||||||
return hloc.getPort();
|
return hloc.getPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,11 +82,12 @@ public class TestAdmin {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
this.admin = TEST_UTIL.getHBaseAdmin();
|
this.admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
|
this.admin.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -197,7 +197,6 @@ public class TestFromClientSide {
|
||||||
assertArrayEquals(T2, kvs[3].getValue());
|
assertArrayEquals(T2, kvs[3].getValue());
|
||||||
assertArrayEquals(T1, kvs[4].getValue());
|
assertArrayEquals(T1, kvs[4].getValue());
|
||||||
scanner.close();
|
scanner.close();
|
||||||
h.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -126,7 +126,6 @@ public class TestConstraint {
|
||||||
Throwable t = causes.get(0);
|
Throwable t = causes.get(0);
|
||||||
assertEquals(ConstraintException.class, t.getClass());
|
assertEquals(ConstraintException.class, t.getClass());
|
||||||
}
|
}
|
||||||
table.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -231,7 +230,6 @@ public class TestConstraint {
|
||||||
table.put(put);
|
table.put(put);
|
||||||
// and we make sure that constraints were not run...
|
// and we make sure that constraints were not run...
|
||||||
assertFalse(CheckWasRunConstraint.wasRun);
|
assertFalse(CheckWasRunConstraint.wasRun);
|
||||||
table.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
|
|
@ -186,7 +186,6 @@ public class TestImportExport {
|
||||||
HColumnDescriptor.DEFAULT_BLOOMFILTER,
|
HColumnDescriptor.DEFAULT_BLOOMFILTER,
|
||||||
HConstants.REPLICATION_SCOPE_LOCAL));
|
HConstants.REPLICATION_SCOPE_LOCAL));
|
||||||
UTIL.getHBaseAdmin().createTable(desc);
|
UTIL.getHBaseAdmin().createTable(desc);
|
||||||
t.close();
|
|
||||||
t = new HTable(UTIL.getConfiguration(), IMPORT_TABLE);
|
t = new HTable(UTIL.getConfiguration(), IMPORT_TABLE);
|
||||||
args = new String[] {
|
args = new String[] {
|
||||||
IMPORT_TABLE,
|
IMPORT_TABLE,
|
||||||
|
@ -214,6 +213,5 @@ public class TestImportExport {
|
||||||
assertEquals(now+2, res[4].getTimestamp());
|
assertEquals(now+2, res[4].getTimestamp());
|
||||||
assertEquals(now+1, res[5].getTimestamp());
|
assertEquals(now+1, res[5].getTimestamp());
|
||||||
assertEquals(now, res[6].getTimestamp());
|
assertEquals(now, res[6].getTimestamp());
|
||||||
t.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,8 @@ public class TestLoadIncrementalHFilesSplitRecovery {
|
||||||
htd.addFamily(new HColumnDescriptor(family(i)));
|
htd.addFamily(new HColumnDescriptor(family(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
util.getHBaseAdmin().createTable(htd);
|
HBaseAdmin admin = util.getHBaseAdmin();
|
||||||
|
admin.createTable(htd);
|
||||||
} catch (TableExistsException tee) {
|
} catch (TableExistsException tee) {
|
||||||
LOG.info("Table " + table + " already exists");
|
LOG.info("Table " + table + " already exists");
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@ public class TestMaster {
|
||||||
public void testMasterOpsWhileSplitting() throws Exception {
|
public void testMasterOpsWhileSplitting() throws Exception {
|
||||||
MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
|
MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
|
||||||
HMaster m = cluster.getMaster();
|
HMaster m = cluster.getMaster();
|
||||||
|
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
|
||||||
|
|
||||||
HTable ht = TEST_UTIL.createTable(TABLENAME, FAMILYNAME);
|
HTable ht = TEST_UTIL.createTable(TABLENAME, FAMILYNAME);
|
||||||
TEST_UTIL.loadTable(ht, FAMILYNAME);
|
TEST_UTIL.loadTable(ht, FAMILYNAME);
|
||||||
|
@ -90,7 +91,7 @@ public class TestMaster {
|
||||||
registerListener(EventType.RS_ZK_REGION_SPLIT, list);
|
registerListener(EventType.RS_ZK_REGION_SPLIT, list);
|
||||||
|
|
||||||
LOG.info("Splitting table");
|
LOG.info("Splitting table");
|
||||||
TEST_UTIL.getHBaseAdmin().split(TABLENAME);
|
admin.split(TABLENAME);
|
||||||
LOG.info("Waiting for split result to be about to open");
|
LOG.info("Waiting for split result to be about to open");
|
||||||
split.await(60, TimeUnit.SECONDS);
|
split.await(60, TimeUnit.SECONDS);
|
||||||
try {
|
try {
|
||||||
|
@ -112,6 +113,7 @@ public class TestMaster {
|
||||||
} finally {
|
} finally {
|
||||||
proceed.countDown();
|
proceed.countDown();
|
||||||
}
|
}
|
||||||
|
admin.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
static class RegionSplitListener implements EventHandlerListener {
|
static class RegionSplitListener implements EventHandlerListener {
|
||||||
|
|
|
@ -236,7 +236,8 @@ public class TestHRegionServerBulkLoad {
|
||||||
htd.addFamily(new HColumnDescriptor(family(i)));
|
htd.addFamily(new HColumnDescriptor(family(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
UTIL.getHBaseAdmin().createTable(htd);
|
HBaseAdmin admin = UTIL.getHBaseAdmin();
|
||||||
|
admin.createTable(htd);
|
||||||
} catch (TableExistsException tee) {
|
} catch (TableExistsException tee) {
|
||||||
LOG.info("Table " + table + " already exists");
|
LOG.info("Table " + table + " already exists");
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,8 +123,7 @@ public class TestLogRollAbort {
|
||||||
LOG.info("Starting testRSAbortWithUnflushedEdits()");
|
LOG.info("Starting testRSAbortWithUnflushedEdits()");
|
||||||
|
|
||||||
// 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(),
|
new HTable(TEST_UTIL.getConfiguration(), HConstants.META_TABLE_NAME);
|
||||||
HConstants.META_TABLE_NAME).close();
|
|
||||||
|
|
||||||
// Create the test table and open it
|
// Create the test table and open it
|
||||||
String tableName = this.getClass().getSimpleName();
|
String tableName = this.getClass().getSimpleName();
|
||||||
|
|
|
@ -201,6 +201,7 @@ public class TestScannersWithFilters {
|
||||||
numRows -= 2;
|
numRows -= 2;
|
||||||
table.close();
|
table.close();
|
||||||
}
|
}
|
||||||
|
admin.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
|
|
@ -123,7 +123,6 @@ public class TestTableResource {
|
||||||
assertEquals(m.size(), 2);
|
assertEquals(m.size(), 2);
|
||||||
regionMap = m;
|
regionMap = m;
|
||||||
LOG.info("regions: " + regionMap);
|
LOG.info("regions: " + regionMap);
|
||||||
table.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
|
|
@ -233,8 +233,6 @@ public class OfflineMetaRebuildTestCore {
|
||||||
}
|
}
|
||||||
meta.delete(dels);
|
meta.delete(dels);
|
||||||
meta.flushCommits();
|
meta.flushCommits();
|
||||||
scanner.close();
|
|
||||||
meta.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue