Skip to content

Commit 4fc1f37

Browse files
committed
HBASE-27095 HbckChore should produce a report
In #4470 for HBASE-26192, it was noted that the HbckChore is kind of a pain to use and test because it maintains a bunch of local state. By contract, the CatalogJanitorChore makes a nice self-contained report. Let's update HbckChore to do the same. Signed-off-by: Andrew Purtell <apurtell@apache.org>
1 parent 2c08bd0 commit 4fc1f37

File tree

9 files changed

+275
-250
lines changed

9 files changed

+275
-250
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
import org.apache.hadoop.hbase.master.cleaner.LogCleaner;
133133
import org.apache.hadoop.hbase.master.cleaner.ReplicationBarrierCleaner;
134134
import org.apache.hadoop.hbase.master.cleaner.SnapshotCleanerChore;
135+
import org.apache.hadoop.hbase.master.hbck.HbckChore;
135136
import org.apache.hadoop.hbase.master.http.MasterDumpServlet;
136137
import org.apache.hadoop.hbase.master.http.MasterRedirectServlet;
137138
import org.apache.hadoop.hbase.master.http.MasterStatusServlet;

hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
import org.apache.hadoop.hbase.master.assignment.RegionStateNode;
6868
import org.apache.hadoop.hbase.master.assignment.RegionStates;
6969
import org.apache.hadoop.hbase.master.cleaner.HFileCleaner;
70+
import org.apache.hadoop.hbase.master.hbck.HbckChore;
7071
import org.apache.hadoop.hbase.master.janitor.MetaFixer;
7172
import org.apache.hadoop.hbase.master.locking.LockProcedure;
7273
import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;

hbase-server/src/main/java/org/apache/hadoop/hbase/master/HbckChore.java renamed to hbase-server/src/main/java/org/apache/hadoop/hbase/master/hbck/HbckChore.java

Lines changed: 56 additions & 157 deletions
Large diffs are not rendered by default.
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.hadoop.hbase.master.hbck;
19+
20+
import java.time.Instant;
21+
import java.util.HashMap;
22+
import java.util.HashSet;
23+
import java.util.List;
24+
import java.util.Map;
25+
import java.util.Set;
26+
import org.apache.hadoop.fs.Path;
27+
import org.apache.hadoop.hbase.ServerName;
28+
import org.apache.hadoop.hbase.util.HbckRegionInfo;
29+
import org.apache.hadoop.hbase.util.Pair;
30+
import org.apache.yetus.audience.InterfaceAudience;
31+
32+
/**
33+
* The result of an {@link HbckChore} execution.
34+
*/
35+
@InterfaceAudience.Private
36+
public class HbckReport {
37+
38+
private final Map<String, HbckRegionInfo> regionInfoMap = new HashMap<>();
39+
private final Set<String> disabledTableRegions = new HashSet<>();
40+
private final Set<String> splitParentRegions = new HashSet<>();
41+
private final Map<String, ServerName> orphanRegionsOnRS = new HashMap<>();
42+
private final Map<String, Path> orphanRegionsOnFS = new HashMap<>();
43+
private final Map<String, Pair<ServerName, List<ServerName>>> inconsistentRegions =
44+
new HashMap<>();
45+
46+
private Instant checkingStartTimestamp = null;
47+
private Instant checkingEndTimestamp = null;
48+
49+
/**
50+
* Used for web ui to show when the HBCK checking started.
51+
*/
52+
public Instant getCheckingStartTimestamp() {
53+
return checkingStartTimestamp;
54+
}
55+
56+
public void setCheckingStartTimestamp(Instant checkingStartTimestamp) {
57+
this.checkingStartTimestamp = checkingStartTimestamp;
58+
}
59+
60+
/**
61+
* Used for web ui to show when the HBCK checking report generated.
62+
*/
63+
public Instant getCheckingEndTimestamp() {
64+
return checkingEndTimestamp;
65+
}
66+
67+
public void setCheckingEndTimestamp(Instant checkingEndTimestamp) {
68+
this.checkingEndTimestamp = checkingEndTimestamp;
69+
}
70+
71+
/**
72+
* This map contains the state of all hbck items. It maps from encoded region name to
73+
* HbckRegionInfo structure. The information contained in HbckRegionInfo is used to detect and
74+
* correct consistency (hdfs/meta/deployment) problems.
75+
*/
76+
public Map<String, HbckRegionInfo> getRegionInfoMap() {
77+
return regionInfoMap;
78+
}
79+
80+
public Set<String> getDisabledTableRegions() {
81+
return disabledTableRegions;
82+
}
83+
84+
public Set<String> getSplitParentRegions() {
85+
return splitParentRegions;
86+
}
87+
88+
/**
89+
* The regions only opened on RegionServers, but no region info in meta.
90+
*/
91+
public Map<String, ServerName> getOrphanRegionsOnRS() {
92+
return orphanRegionsOnRS;
93+
}
94+
95+
/**
96+
* The regions have directory on FileSystem, but no region info in meta.
97+
*/
98+
public Map<String, Path> getOrphanRegionsOnFS() {
99+
return orphanRegionsOnFS;
100+
}
101+
102+
/**
103+
* The inconsistent regions. There are three case: case 1. Master thought this region opened, but
104+
* no regionserver reported it. case 2. Master thought this region opened on Server1, but
105+
* regionserver reported Server2 case 3. More than one regionservers reported opened this region
106+
*/
107+
public Map<String, Pair<ServerName, List<ServerName>>> getInconsistentRegions() {
108+
return inconsistentRegions;
109+
}
110+
}

0 commit comments

Comments
 (0)