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.HConnectionManager;
|
||||||
import org.apache.hadoop.hbase.client.HTable;
|
import org.apache.hadoop.hbase.client.HTable;
|
||||||
import org.apache.hadoop.hbase.client.MetaScanner;
|
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.MetaScannerVisitor;
|
||||||
import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase;
|
import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase;
|
||||||
import org.apache.hadoop.hbase.client.Put;
|
import org.apache.hadoop.hbase.client.Put;
|
||||||
|
@ -1763,6 +1764,7 @@ public class HBaseFsck extends Configured {
|
||||||
if (hbi.containsOnlyHdfsEdits()) {
|
if (hbi.containsOnlyHdfsEdits()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (hbi.isSkipChecks()) return;
|
||||||
if (inMeta && inHdfs && isDeployed && deploymentMatchesMeta && shouldBeDeployed) {
|
if (inMeta && inHdfs && isDeployed && deploymentMatchesMeta && shouldBeDeployed) {
|
||||||
return;
|
return;
|
||||||
} else if (inMeta && inHdfs && !shouldBeDeployed && !isDeployed) {
|
} else if (inMeta && inHdfs && !shouldBeDeployed && !isDeployed) {
|
||||||
|
@ -1927,13 +1929,11 @@ public class HBaseFsck extends Configured {
|
||||||
*/
|
*/
|
||||||
SortedMap<TableName, TableInfo> checkIntegrity() throws IOException {
|
SortedMap<TableName, TableInfo> checkIntegrity() throws IOException {
|
||||||
tablesInfo = new TreeMap<TableName,TableInfo> ();
|
tablesInfo = new TreeMap<TableName,TableInfo> ();
|
||||||
List<HbckInfo> noHDFSRegionInfos = new ArrayList<HbckInfo>();
|
|
||||||
LOG.debug("There are " + regionInfoMap.size() + " region info entries");
|
LOG.debug("There are " + regionInfoMap.size() + " region info entries");
|
||||||
for (HbckInfo hbi : regionInfoMap.values()) {
|
for (HbckInfo hbi : regionInfoMap.values()) {
|
||||||
// Check only valid, working regions
|
// Check only valid, working regions
|
||||||
if (hbi.metaEntry == null) {
|
if (hbi.metaEntry == null) {
|
||||||
// this assumes that consistency check has run loadMetaEntry
|
// this assumes that consistency check has run loadMetaEntry
|
||||||
noHDFSRegionInfos.add(hbi);
|
|
||||||
Path p = hbi.getHdfsRegionDir();
|
Path p = hbi.getHdfsRegionDir();
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
errors.report("No regioninfo in Meta or HDFS. " + hbi);
|
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
|
// check to see if the existence of this region matches the region in META
|
||||||
for (HRegionInfo r:regions) {
|
for (HRegionInfo r:regions) {
|
||||||
HbckInfo hbi = hbck.getOrCreateInfo(r.getEncodedName());
|
HbckInfo hbi = hbck.getOrCreateInfo(r.getEncodedName());
|
||||||
|
if (!RegionReplicaUtil.isDefaultReplica(r)) hbi.setSkipChecks(true);
|
||||||
hbi.addServer(r, rsinfo);
|
hbi.addServer(r, rsinfo);
|
||||||
}
|
}
|
||||||
} catch (IOException e) { // unable to connect to the region server.
|
} catch (IOException e) { // unable to connect to the region server.
|
||||||
|
|
|
@ -357,7 +357,19 @@ public class TestHBaseFsck {
|
||||||
* @throws KeeperException
|
* @throws KeeperException
|
||||||
*/
|
*/
|
||||||
HTable setupTable(TableName tablename) throws Exception {
|
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);
|
HTableDescriptor desc = new HTableDescriptor(tablename);
|
||||||
|
desc.setRegionReplication(replicaCount);
|
||||||
HColumnDescriptor hcd = new HColumnDescriptor(Bytes.toString(FAM));
|
HColumnDescriptor hcd = new HColumnDescriptor(Bytes.toString(FAM));
|
||||||
desc.addFamily(hcd); // If a table has no CF's it doesn't get checked
|
desc.addFamily(hcd); // If a table has no CF's it doesn't get checked
|
||||||
TEST_UTIL.getHBaseAdmin().createTable(desc, SPLITS);
|
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.
|
* Get region info from local cluster.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue