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