From eddd5739a14ceb5cfc9b9c7d2e357eea96bd9703 Mon Sep 17 00:00:00 2001 From: rahulgidwani Date: Fri, 6 Feb 2015 15:14:18 -0800 Subject: [PATCH] HBASE-12891 Parallel execution for Hbck checkRegionConsistency Signed-off-by: Andrew Purtell --- .../apache/hadoop/hbase/util/HBaseFsck.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java index 8e1d848d971..96bd0f70591 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java @@ -1703,9 +1703,19 @@ public class HBaseFsck extends Configured implements Closeable { throws IOException, KeeperException, InterruptedException { // Divide the checks in two phases. One for default/primary replicas and another // for the non-primary ones. Keeps code cleaner this way. + List workItems = + new ArrayList(regionInfoMap.size()); for (java.util.Map.Entry e: regionInfoMap.entrySet()) { if (e.getValue().getReplicaId() == HRegionInfo.DEFAULT_REPLICA_ID) { - checkRegionConsistency(e.getKey(), e.getValue()); + workItems.add(new WorkItemRegionConsistency(e.getKey(), e.getValue())); + } + } + List> workFutures = executor.invokeAll(workItems); + for(Future f: workFutures) { + try { + f.get(); + } catch(ExecutionException e1) { + LOG.warn("Could not check region consistency " , e1.getCause()); } } boolean prevHdfsCheck = shouldCheckHdfs(); @@ -2355,6 +2365,22 @@ public class HBaseFsck extends Configured implements Closeable { } }; + class WorkItemRegionConsistency implements Callable { + private final String key; + private final HbckInfo hbi; + + WorkItemRegionConsistency(String key, HbckInfo hbi) { + this.key = key; + this.hbi = hbi; + } + + @Override + public synchronized Void call() throws Exception { + checkRegionConsistency(key, hbi); + return null; + } + } + /** * Maintain information about a particular table.