Revert "HBASE-12652 Allow unmanaged connections in MetaTableAccessor (Solomon Duskis)"
This reverts commit 1c99261f53
.
This commit is contained in:
parent
bb1b2f4eeb
commit
4587a693b0
|
@ -22,9 +22,8 @@ import com.google.protobuf.ServiceException;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.hbase.client.ClusterConnection;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.client.Connection;
|
||||
import org.apache.hadoop.hbase.client.ConnectionFactory;
|
||||
import org.apache.hadoop.hbase.client.Delete;
|
||||
|
@ -171,31 +170,37 @@ public class MetaTableAccessor {
|
|||
}
|
||||
|
||||
/**
|
||||
* Callers should call close on the returned {@link Table} instance.
|
||||
* @param connection connection we're using to access Meta
|
||||
* @return An {@link Table} for <code>hbase:meta</code>
|
||||
* Callers should call close on the returned {@link HTable} instance.
|
||||
* @param connection connection we're using to access table
|
||||
* @param tableName Table to get an {@link org.apache.hadoop.hbase.client.HTable} against.
|
||||
* @return An {@link org.apache.hadoop.hbase.client.HTable} for <code>tableName</code>
|
||||
* @throws IOException
|
||||
* @SuppressWarnings("deprecation")
|
||||
*/
|
||||
static Table getMetaHTable(final Connection connection)
|
||||
private static Table getHTable(final Connection connection, final TableName tableName)
|
||||
throws IOException {
|
||||
// We used to pass whole CatalogTracker in here, now we just pass in Connection
|
||||
if (connection == null || connection.isClosed()) {
|
||||
throw new NullPointerException("No connection");
|
||||
}
|
||||
// If the passed in 'connection' is 'managed' -- i.e. every second test uses
|
||||
// a Table or an HBaseAdmin with managed connections -- then doing
|
||||
// an HTable or an HBaseAdmin with managed connections -- then doing
|
||||
// connection.getTable will throw an exception saying you are NOT to use
|
||||
// managed connections getting tables. Leaving this as it is for now. Will
|
||||
// revisit when inclined to change all tests. User code probaby makes use of
|
||||
// managed connections too so don't change it till post hbase 1.0.
|
||||
//
|
||||
// There should still be a way to use this method with an unmanaged connection.
|
||||
if (connection instanceof ClusterConnection) {
|
||||
if (((ClusterConnection) connection).isManaged()) {
|
||||
return new HTable(TableName.META_TABLE_NAME, (ClusterConnection) connection);
|
||||
}
|
||||
}
|
||||
return connection.getTable(TableName.META_TABLE_NAME);
|
||||
return new HTable(tableName, connection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callers should call close on the returned {@link HTable} instance.
|
||||
* @param connection connection we're using to access Meta
|
||||
* @return An {@link HTable} for <code>hbase:meta</code>
|
||||
* @throws IOException
|
||||
*/
|
||||
static Table getMetaHTable(final Connection connection)
|
||||
throws IOException {
|
||||
return getHTable(connection, TableName.META_TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -803,7 +808,7 @@ public class MetaTableAccessor {
|
|||
* @return a pair of HRegionInfo or PairOfSameType(null, null) if the region is not a split
|
||||
* parent
|
||||
*/
|
||||
public static PairOfSameType<HRegionInfo> getDaughterRegions(Result data) {
|
||||
public static PairOfSameType<HRegionInfo> getDaughterRegions(Result data) throws IOException {
|
||||
HRegionInfo splitA = getHRegionInfo(data, HConstants.SPLITA_QUALIFIER);
|
||||
HRegionInfo splitB = getHRegionInfo(data, HConstants.SPLITB_QUALIFIER);
|
||||
|
||||
|
@ -817,7 +822,7 @@ public class MetaTableAccessor {
|
|||
* @return a pair of HRegionInfo or PairOfSameType(null, null) if the region is not a split
|
||||
* parent
|
||||
*/
|
||||
public static PairOfSameType<HRegionInfo> getMergeRegions(Result data) {
|
||||
public static PairOfSameType<HRegionInfo> getMergeRegions(Result data) throws IOException {
|
||||
HRegionInfo mergeA = getHRegionInfo(data, HConstants.MERGEA_QUALIFIER);
|
||||
HRegionInfo mergeB = getHRegionInfo(data, HConstants.MERGEB_QUALIFIER);
|
||||
|
||||
|
@ -1084,8 +1089,8 @@ public class MetaTableAccessor {
|
|||
|
||||
/**
|
||||
* Adds a hbase:meta row for the specified new region to the given catalog table. The
|
||||
* Table is not flushed or closed.
|
||||
* @param meta the Table for META
|
||||
* HTable is not flushed or closed.
|
||||
* @param meta the HTable for META
|
||||
* @param regionInfo region information
|
||||
* @throws IOException if problem connecting or updating meta
|
||||
*/
|
||||
|
@ -1100,7 +1105,7 @@ public class MetaTableAccessor {
|
|||
* {@link #splitRegion(org.apache.hadoop.hbase.client.Connection,
|
||||
* HRegionInfo, HRegionInfo, HRegionInfo, ServerName)}
|
||||
* if you want to do that.
|
||||
* @param meta the Table for META
|
||||
* @param meta the HTable for META
|
||||
* @param regionInfo region information
|
||||
* @param splitA first split daughter of the parent regionInfo
|
||||
* @param splitB second split daughter of the parent regionInfo
|
||||
|
|
|
@ -282,11 +282,5 @@ public interface ClusterConnection extends HConnection {
|
|||
* @return RpcRetryingCallerFactory
|
||||
*/
|
||||
RpcRetryingCallerFactory getNewRpcRetryingCallerFactory(Configuration conf);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return true if this is a managed connection.
|
||||
*/
|
||||
boolean isManaged();
|
||||
}
|
||||
|
||||
|
|
|
@ -437,9 +437,4 @@ abstract class ConnectionAdapter implements ClusterConnection {
|
|||
public RpcRetryingCallerFactory getNewRpcRetryingCallerFactory(Configuration conf) {
|
||||
return wrappedConnection.getNewRpcRetryingCallerFactory(conf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isManaged() {
|
||||
return wrappedConnection.isManaged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2476,11 +2476,6 @@ class ConnectionManager {
|
|||
public RpcRetryingCallerFactory getNewRpcRetryingCallerFactory(Configuration conf) {
|
||||
return RpcRetryingCallerFactory.instantiate(conf, this.interceptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isManaged() {
|
||||
return managed;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1757,7 +1757,7 @@ public class HBaseFsck extends Configured {
|
|||
for (OnlineEntry rse : hi.deployedEntries) {
|
||||
LOG.debug("Undeploy region " + rse.hri + " from " + rse.hsa);
|
||||
try {
|
||||
HBaseFsckRepair.closeRegionSilentlyAndWait(connection, rse.hsa, rse.hri);
|
||||
HBaseFsckRepair.closeRegionSilentlyAndWait(admin, rse.hsa, rse.hri);
|
||||
offline(rse.hri.getRegionName());
|
||||
} catch (IOException ioe) {
|
||||
LOG.warn("Got exception when attempting to offline region "
|
||||
|
@ -1809,7 +1809,7 @@ public class HBaseFsck extends Configured {
|
|||
}
|
||||
|
||||
// close the region -- close files and remove assignment
|
||||
HBaseFsckRepair.closeRegionSilentlyAndWait(connection, serverName, hri);
|
||||
HBaseFsckRepair.closeRegionSilentlyAndWait(admin, serverName, hri);
|
||||
}
|
||||
|
||||
private void tryAssignmentRepair(HbckInfo hbi, String msg) throws IOException,
|
||||
|
@ -1974,7 +1974,7 @@ public class HBaseFsck extends Configured {
|
|||
if (shouldFixAssignments()) {
|
||||
errors.print("Trying to close the region " + descriptiveName);
|
||||
setShouldRerun();
|
||||
HBaseFsckRepair.fixMultiAssignment(connection, hbi.metaEntry, hbi.deployedOn);
|
||||
HBaseFsckRepair.fixMultiAssignment(admin, hbi.metaEntry, hbi.deployedOn);
|
||||
}
|
||||
} else if (inMeta && inHdfs && isMultiplyDeployed) {
|
||||
errors.reportError(ERROR_CODE.MULTI_DEPLOYED, "Region " + descriptiveName
|
||||
|
@ -1985,7 +1985,7 @@ public class HBaseFsck extends Configured {
|
|||
if (shouldFixAssignments()) {
|
||||
errors.print("Trying to fix assignment error...");
|
||||
setShouldRerun();
|
||||
HBaseFsckRepair.fixMultiAssignment(connection, hbi.metaEntry, hbi.deployedOn);
|
||||
HBaseFsckRepair.fixMultiAssignment(admin, hbi.metaEntry, hbi.deployedOn);
|
||||
}
|
||||
} else if (inMeta && inHdfs && isDeployed && !deploymentMatchesMeta) {
|
||||
errors.reportError(ERROR_CODE.SERVER_DOES_NOT_MATCH_META, "Region "
|
||||
|
@ -1996,7 +1996,7 @@ public class HBaseFsck extends Configured {
|
|||
if (shouldFixAssignments()) {
|
||||
errors.print("Trying to fix assignment error...");
|
||||
setShouldRerun();
|
||||
HBaseFsckRepair.fixMultiAssignment(connection, hbi.metaEntry, hbi.deployedOn);
|
||||
HBaseFsckRepair.fixMultiAssignment(admin, hbi.metaEntry, hbi.deployedOn);
|
||||
HBaseFsckRepair.waitUntilAssigned(admin, hbi.getHdfsHRI());
|
||||
}
|
||||
} else {
|
||||
|
@ -2901,7 +2901,7 @@ public class HBaseFsck extends Configured {
|
|||
errors.print("Trying to fix a problem with hbase:meta..");
|
||||
setShouldRerun();
|
||||
// try fix it (treat is a dupe assignment)
|
||||
HBaseFsckRepair.fixMultiAssignment(connection, metaHbckInfo.metaEntry, servers);
|
||||
HBaseFsckRepair.fixMultiAssignment(admin, metaHbckInfo.metaEntry, servers);
|
||||
}
|
||||
}
|
||||
// rerun hbck with hopefully fixed META
|
||||
|
|
|
@ -18,20 +18,23 @@
|
|||
*/
|
||||
package org.apache.hadoop.hbase.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hadoop.hbase.HRegionInfo;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.MetaTableAccessor;
|
||||
import org.apache.hadoop.hbase.ServerName;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.ZooKeeperConnectionException;
|
||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.hbase.MetaTableAccessor;
|
||||
import org.apache.hadoop.hbase.client.Admin;
|
||||
import org.apache.hadoop.hbase.client.Connection;
|
||||
import org.apache.hadoop.hbase.client.ConnectionFactory;
|
||||
import org.apache.hadoop.hbase.client.HBaseAdmin;
|
||||
import org.apache.hadoop.hbase.client.HConnection;
|
||||
import org.apache.hadoop.hbase.client.HTable;
|
||||
import org.apache.hadoop.hbase.client.Table;
|
||||
|
@ -41,12 +44,6 @@ import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.AdminService;
|
|||
import org.apache.hadoop.hbase.regionserver.HRegion;
|
||||
import org.apache.zookeeper.KeeperException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* This class contains helper methods that repair parts of hbase's filesystem
|
||||
* contents.
|
||||
|
@ -60,22 +57,22 @@ public class HBaseFsckRepair {
|
|||
* and then force ZK unassigned node to OFFLINE to trigger assignment by
|
||||
* master.
|
||||
*
|
||||
* @param connection HBase connection to the cluster
|
||||
* @param admin HBase admin used to undeploy
|
||||
* @param region Region to undeploy
|
||||
* @param servers list of Servers to undeploy from
|
||||
*/
|
||||
public static void fixMultiAssignment(HConnection connection, HRegionInfo region,
|
||||
public static void fixMultiAssignment(HBaseAdmin admin, HRegionInfo region,
|
||||
List<ServerName> servers)
|
||||
throws IOException, KeeperException, InterruptedException {
|
||||
HRegionInfo actualRegion = new HRegionInfo(region);
|
||||
|
||||
// Close region on the servers silently
|
||||
for(ServerName server : servers) {
|
||||
closeRegionSilentlyAndWait(connection, server, actualRegion);
|
||||
closeRegionSilentlyAndWait(admin, server, actualRegion);
|
||||
}
|
||||
|
||||
// Force ZK node to OFFLINE so master assigns
|
||||
forceOfflineInZK(connection.getAdmin(), actualRegion);
|
||||
forceOfflineInZK(admin, actualRegion);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,15 +146,16 @@ public class HBaseFsckRepair {
|
|||
* (default 120s) to close the region. This bypasses the active hmaster.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void closeRegionSilentlyAndWait(HConnection connection,
|
||||
public static void closeRegionSilentlyAndWait(HBaseAdmin admin,
|
||||
ServerName server, HRegionInfo region) throws IOException, InterruptedException {
|
||||
HConnection connection = admin.getConnection();
|
||||
AdminService.BlockingInterface rs = connection.getAdmin(server);
|
||||
try {
|
||||
ProtobufUtil.closeRegion(rs, server, region.getRegionName(), false);
|
||||
} catch (IOException e) {
|
||||
LOG.warn("Exception when closing region: " + region.getRegionNameAsString(), e);
|
||||
}
|
||||
long timeout = connection.getConfiguration()
|
||||
long timeout = admin.getConfiguration()
|
||||
.getLong("hbase.hbck.close.timeout", 120000);
|
||||
long expiration = timeout + System.currentTimeMillis();
|
||||
while (System.currentTimeMillis() < expiration) {
|
||||
|
@ -179,11 +177,9 @@ public class HBaseFsckRepair {
|
|||
*/
|
||||
public static void fixMetaHoleOnline(Configuration conf,
|
||||
HRegionInfo hri) throws IOException {
|
||||
Connection conn = ConnectionFactory.createConnection(conf);
|
||||
Table meta = conn.getTable(TableName.META_TABLE_NAME);
|
||||
Table meta = new HTable(conf, TableName.META_TABLE_NAME);
|
||||
MetaTableAccessor.addRegionToMeta(meta, hri);
|
||||
meta.close();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.apache.hadoop.conf.Configuration;
|
|||
import org.apache.hadoop.hbase.client.Admin;
|
||||
import org.apache.hadoop.hbase.client.Get;
|
||||
import org.apache.hadoop.hbase.client.Connection;
|
||||
import org.apache.hadoop.hbase.client.ConnectionFactory;
|
||||
import org.apache.hadoop.hbase.client.HConnectionManager;
|
||||
import org.apache.hadoop.hbase.client.HTable;
|
||||
import org.apache.hadoop.hbase.client.Result;
|
||||
|
@ -63,11 +62,10 @@ public class TestMetaTableAccessor {
|
|||
// responsive. 1 second is default as is ten retries.
|
||||
c.setLong("hbase.client.pause", 1000);
|
||||
c.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 10);
|
||||
connection = ConnectionFactory.createConnection(c);
|
||||
connection = HConnectionManager.getConnection(c);
|
||||
}
|
||||
|
||||
@AfterClass public static void afterClass() throws Exception {
|
||||
connection.close();
|
||||
UTIL.shutdownMiniCluster();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,11 +21,14 @@ package org.apache.hadoop.hbase;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.hbase.client.Admin;
|
||||
import org.apache.hadoop.hbase.client.Connection;
|
||||
import org.apache.hadoop.hbase.client.ConnectionFactory;
|
||||
import org.apache.hadoop.hbase.client.HBaseAdmin;
|
||||
import org.apache.hadoop.hbase.client.HTable;
|
||||
import org.apache.hadoop.hbase.client.RegionLocator;
|
||||
|
@ -44,12 +47,6 @@ import org.junit.runner.RunWith;
|
|||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Test whether region re-balancing works. (HBASE-71)
|
||||
*/
|
||||
|
@ -100,8 +97,7 @@ public class TestRegionRebalancing {
|
|||
@SuppressWarnings("deprecation")
|
||||
public void testRebalanceOnRegionServerNumberChange()
|
||||
throws IOException, InterruptedException {
|
||||
Connection connection = ConnectionFactory.createConnection(UTIL.getConfiguration());
|
||||
Admin admin = connection.getAdmin();
|
||||
HBaseAdmin admin = new HBaseAdmin(UTIL.getConfiguration());
|
||||
admin.createTable(this.desc, Arrays.copyOfRange(HBaseTestingUtility.KEYS,
|
||||
1, HBaseTestingUtility.KEYS.length));
|
||||
this.table = new HTable(UTIL.getConfiguration(), this.desc.getTableName());
|
||||
|
|
|
@ -137,8 +137,6 @@ public class HConnectionTestingUtility {
|
|||
RetryingCallerInterceptorFactory.NO_OP_INTERCEPTOR));
|
||||
HTableInterface t = Mockito.mock(HTableInterface.class);
|
||||
Mockito.when(c.getTable((TableName)Mockito.any())).thenReturn(t);
|
||||
ResultScanner rs = Mockito.mock(ResultScanner.class);
|
||||
Mockito.when(t.getScanner((Scan)Mockito.any())).thenReturn(rs);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,6 @@ import org.apache.hadoop.hbase.testclassification.LargeTests;
|
|||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.Tag;
|
||||
import org.apache.hadoop.hbase.client.Admin;
|
||||
import org.apache.hadoop.hbase.client.Connection;
|
||||
import org.apache.hadoop.hbase.client.ConnectionFactory;
|
||||
import org.apache.hadoop.hbase.client.Durability;
|
||||
import org.apache.hadoop.hbase.client.Get;
|
||||
import org.apache.hadoop.hbase.client.HBaseAdmin;
|
||||
|
@ -74,9 +72,6 @@ public class TestReplicationWithTags {
|
|||
|
||||
private static ReplicationAdmin replicationAdmin;
|
||||
|
||||
private static Connection connection1;
|
||||
private static Connection connection2;
|
||||
|
||||
private static Table htable1;
|
||||
private static Table htable2;
|
||||
|
||||
|
@ -141,13 +136,22 @@ public class TestReplicationWithTags {
|
|||
fam.setMaxVersions(3);
|
||||
fam.setScope(HConstants.REPLICATION_SCOPE_GLOBAL);
|
||||
table.addFamily(fam);
|
||||
try (Connection conn = ConnectionFactory.createConnection(conf1);
|
||||
Admin admin = conn.getAdmin()) {
|
||||
Admin admin = null;
|
||||
try {
|
||||
admin = new HBaseAdmin(conf1);
|
||||
admin.createTable(table, HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE);
|
||||
} finally {
|
||||
if (admin != null) {
|
||||
admin.close();
|
||||
}
|
||||
}
|
||||
try (Connection conn = ConnectionFactory.createConnection(conf2);
|
||||
Admin admin = conn.getAdmin()) {
|
||||
try {
|
||||
admin = new HBaseAdmin(conf2);
|
||||
admin.createTable(table, HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE);
|
||||
} finally {
|
||||
if(admin != null){
|
||||
admin.close();
|
||||
}
|
||||
}
|
||||
htable1 = new HTable(conf1, TABLE_NAME);
|
||||
htable1.setWriteBufferSize(1024);
|
||||
|
|
|
@ -265,12 +265,12 @@ public class TestHBaseFsck {
|
|||
* This method is used to undeploy a region -- close it and attempt to
|
||||
* remove its state from the Master.
|
||||
*/
|
||||
private void undeployRegion(HConnection conn, ServerName sn,
|
||||
private void undeployRegion(HBaseAdmin admin, ServerName sn,
|
||||
HRegionInfo hri) throws IOException, InterruptedException {
|
||||
try {
|
||||
HBaseFsckRepair.closeRegionSilentlyAndWait(conn, sn, hri);
|
||||
HBaseFsckRepair.closeRegionSilentlyAndWait(admin, sn, hri);
|
||||
if (!hri.isMetaTable()) {
|
||||
conn.getAdmin().offline(hri.getRegionName());
|
||||
admin.offline(hri.getRegionName());
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
LOG.warn("Got exception when attempting to offline region "
|
||||
|
@ -303,7 +303,6 @@ public class TestHBaseFsck {
|
|||
dumpMeta(htd.getTableName());
|
||||
|
||||
Map<HRegionInfo, ServerName> hris = tbl.getRegionLocations();
|
||||
HConnection conn = (HConnection) ConnectionFactory.createConnection(conf);
|
||||
for (Entry<HRegionInfo, ServerName> e: hris.entrySet()) {
|
||||
HRegionInfo hri = e.getKey();
|
||||
ServerName hsa = e.getValue();
|
||||
|
@ -315,7 +314,7 @@ public class TestHBaseFsck {
|
|||
|
||||
if (unassign) {
|
||||
LOG.info("Undeploying region " + hri + " from server " + hsa);
|
||||
undeployRegion(conn, hsa, hri);
|
||||
undeployRegion(new HBaseAdmin(conf), hsa, hri);
|
||||
}
|
||||
|
||||
if (regionInfoOnly) {
|
||||
|
@ -353,7 +352,6 @@ public class TestHBaseFsck {
|
|||
TEST_UTIL.getMetaTableRows(htd.getTableName());
|
||||
LOG.info("*** After delete:");
|
||||
dumpMeta(htd.getTableName());
|
||||
conn.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -412,9 +410,8 @@ public class TestHBaseFsck {
|
|||
* @throws IOException
|
||||
*/
|
||||
void deleteTable(TableName tablename) throws IOException {
|
||||
HConnection conn = (HConnection) ConnectionFactory.createConnection(conf);
|
||||
Admin admin = conn.getAdmin();
|
||||
conn.clearRegionCache();
|
||||
HBaseAdmin admin = new HBaseAdmin(conf);
|
||||
admin.getConnection().clearRegionCache();
|
||||
if (admin.isTableEnabled(tablename)) {
|
||||
admin.disableTableAsync(tablename);
|
||||
}
|
||||
|
@ -434,8 +431,6 @@ public class TestHBaseFsck {
|
|||
}
|
||||
}
|
||||
admin.deleteTable(tablename);
|
||||
admin.close();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -813,7 +808,7 @@ public class TestHBaseFsck {
|
|||
public void testSidelineOverlapRegion() throws Exception {
|
||||
TableName table =
|
||||
TableName.valueOf("testSidelineOverlapRegion");
|
||||
try (HConnection conn = (HConnection) ConnectionFactory.createConnection(conf)){
|
||||
try {
|
||||
setupTable(table);
|
||||
assertEquals(ROWKEYS.length, countRows());
|
||||
|
||||
|
@ -855,7 +850,7 @@ public class TestHBaseFsck {
|
|||
}
|
||||
|
||||
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
|
||||
HBaseFsckRepair.closeRegionSilentlyAndWait(conn,
|
||||
HBaseFsckRepair.closeRegionSilentlyAndWait(admin,
|
||||
cluster.getRegionServer(k).getServerName(), hbi.getHdfsHRI());
|
||||
admin.offline(regionName);
|
||||
break;
|
||||
|
@ -864,7 +859,7 @@ public class TestHBaseFsck {
|
|||
|
||||
assertNotNull(regionName);
|
||||
assertNotNull(serverName);
|
||||
Table meta = conn.getTable(TableName.META_TABLE_NAME, executorService);
|
||||
Table meta = new HTable(conf, TableName.META_TABLE_NAME, executorService);
|
||||
Put put = new Put(regionName);
|
||||
put.add(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER,
|
||||
Bytes.toBytes(serverName.getHostAndPort()));
|
||||
|
@ -1476,8 +1471,8 @@ public class TestHBaseFsck {
|
|||
public void testSplitDaughtersNotInMeta() throws Exception {
|
||||
TableName table =
|
||||
TableName.valueOf("testSplitdaughtersNotInMeta");
|
||||
try (HConnection conn = (HConnection) ConnectionFactory.createConnection(conf);
|
||||
Table meta = conn.getTable(TableName.META_TABLE_NAME)){
|
||||
Table meta = null;
|
||||
try {
|
||||
setupTable(table);
|
||||
assertEquals(ROWKEYS.length, countRows());
|
||||
|
||||
|
@ -1485,11 +1480,13 @@ public class TestHBaseFsck {
|
|||
TEST_UTIL.getHBaseAdmin().flush(table);
|
||||
HRegionLocation location = tbl.getRegionLocation("B");
|
||||
|
||||
meta = new HTable(conf, TableName.META_TABLE_NAME);
|
||||
HRegionInfo hri = location.getRegionInfo();
|
||||
|
||||
// do a regular split
|
||||
HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
|
||||
byte[] regionName = location.getRegionInfo().getRegionName();
|
||||
conn.getAdmin().splitRegion(location.getRegionInfo().getRegionName(), Bytes.toBytes("BM"));
|
||||
admin.splitRegion(location.getRegionInfo().getRegionName(), Bytes.toBytes("BM"));
|
||||
TestEndToEndSplitTransaction.blockUntilRegionSplit(
|
||||
TEST_UTIL.getConfiguration(), 60000, regionName, true);
|
||||
|
||||
|
@ -1497,8 +1494,8 @@ public class TestHBaseFsck {
|
|||
|
||||
// Delete daughter regions from meta, but not hdfs, unassign it.
|
||||
Map<HRegionInfo, ServerName> hris = tbl.getRegionLocations();
|
||||
undeployRegion(conn, hris.get(daughters.getFirst()), daughters.getFirst());
|
||||
undeployRegion(conn, hris.get(daughters.getSecond()), daughters.getSecond());
|
||||
undeployRegion(admin, hris.get(daughters.getFirst()), daughters.getFirst());
|
||||
undeployRegion(admin, hris.get(daughters.getSecond()), daughters.getSecond());
|
||||
|
||||
meta.delete(new Delete(daughters.getFirst().getRegionName()));
|
||||
meta.delete(new Delete(daughters.getSecond().getRegionName()));
|
||||
|
@ -1532,6 +1529,7 @@ public class TestHBaseFsck {
|
|||
assertNoErrors(doFsck(conf, false)); //should be fixed by now
|
||||
} finally {
|
||||
deleteTable(table);
|
||||
IOUtils.closeQuietly(meta);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2256,9 +2254,13 @@ public class TestHBaseFsck {
|
|||
HRegionInfo hri = metaLocation.getRegionInfo();
|
||||
if (unassign) {
|
||||
LOG.info("Undeploying meta region " + hri + " from server " + hsa);
|
||||
try (HConnection unmanagedConnection =
|
||||
(HConnection) ConnectionFactory.createConnection(conf)) {
|
||||
undeployRegion(unmanagedConnection, hsa, hri);
|
||||
Connection unmanagedConnection = ConnectionFactory.createConnection(conf);
|
||||
HBaseAdmin admin = (HBaseAdmin) unmanagedConnection.getAdmin();
|
||||
try {
|
||||
undeployRegion(admin, hsa, hri);
|
||||
} finally {
|
||||
admin.close();
|
||||
unmanagedConnection.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue