HBASE-10362. HBCK changes for supporting region replicas
git-svn-id: https://svn.apache.org/repos/asf/hbase/branches/hbase-10070@1571884 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d7d9f8db62
commit
87b2b923e2
|
@ -80,6 +80,7 @@ import org.apache.hadoop.hbase.client.HConnection;
|
|||
import org.apache.hadoop.hbase.client.HConnectionManager;
|
||||
import org.apache.hadoop.hbase.client.HTable;
|
||||
import org.apache.hadoop.hbase.client.MetaScanner;
|
||||
import org.apache.hadoop.hbase.client.RegionReplicaUtil;
|
||||
import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitor;
|
||||
import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase;
|
||||
import org.apache.hadoop.hbase.client.Put;
|
||||
|
@ -1763,6 +1764,7 @@ public class HBaseFsck extends Configured {
|
|||
if (hbi.containsOnlyHdfsEdits()) {
|
||||
return;
|
||||
}
|
||||
if (hbi.isSkipChecks()) return;
|
||||
if (inMeta && inHdfs && isDeployed && deploymentMatchesMeta && shouldBeDeployed) {
|
||||
return;
|
||||
} else if (inMeta && inHdfs && !shouldBeDeployed && !isDeployed) {
|
||||
|
@ -1927,13 +1929,11 @@ public class HBaseFsck extends Configured {
|
|||
*/
|
||||
SortedMap<TableName, TableInfo> checkIntegrity() throws IOException {
|
||||
tablesInfo = new TreeMap<TableName,TableInfo> ();
|
||||
List<HbckInfo> noHDFSRegionInfos = new ArrayList<HbckInfo>();
|
||||
LOG.debug("There are " + regionInfoMap.size() + " region info entries");
|
||||
for (HbckInfo hbi : regionInfoMap.values()) {
|
||||
// Check only valid, working regions
|
||||
if (hbi.metaEntry == null) {
|
||||
// this assumes that consistency check has run loadMetaEntry
|
||||
noHDFSRegionInfos.add(hbi);
|
||||
Path p = hbi.getHdfsRegionDir();
|
||||
if (p == null) {
|
||||
errors.report("No regioninfo in Meta or HDFS. " + hbi);
|
||||
|
@ -3399,6 +3399,7 @@ public class HBaseFsck extends Configured {
|
|||
// check to see if the existence of this region matches the region in META
|
||||
for (HRegionInfo r:regions) {
|
||||
HbckInfo hbi = hbck.getOrCreateInfo(r.getEncodedName());
|
||||
if (!RegionReplicaUtil.isDefaultReplica(r)) hbi.setSkipChecks(true);
|
||||
hbi.addServer(r, rsinfo);
|
||||
}
|
||||
} catch (IOException e) { // unable to connect to the region server.
|
||||
|
|
|
@ -357,7 +357,19 @@ public class TestHBaseFsck {
|
|||
* @throws KeeperException
|
||||
*/
|
||||
HTable setupTable(TableName tablename) throws Exception {
|
||||
return setupTableWithRegionReplica(tablename, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup a clean table with a certain region_replica count
|
||||
* @param tableName
|
||||
* @param replicaCount
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
HTable setupTableWithRegionReplica(TableName tablename, int replicaCount) throws Exception {
|
||||
HTableDescriptor desc = new HTableDescriptor(tablename);
|
||||
desc.setRegionReplication(replicaCount);
|
||||
HColumnDescriptor hcd = new HColumnDescriptor(Bytes.toString(FAM));
|
||||
desc.addFamily(hcd); // If a table has no CF's it doesn't get checked
|
||||
TEST_UTIL.getHBaseAdmin().createTable(desc, SPLITS);
|
||||
|
@ -553,6 +565,23 @@ public class TestHBaseFsck {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This creates a table with region_replica > 1 and verifies hbck runs
|
||||
* successfully
|
||||
*/
|
||||
@Test
|
||||
public void testHbckWithRegionReplica() throws Exception {
|
||||
TableName table =
|
||||
TableName.valueOf("tableWithReplica");
|
||||
try {
|
||||
setupTableWithRegionReplica(table, 2);
|
||||
assertNoErrors(doFsck(conf, false));
|
||||
assertEquals(ROWKEYS.length, countRows());
|
||||
} finally {
|
||||
deleteTable(table);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get region info from local cluster.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue