Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5C854175C6 for ; Wed, 15 Apr 2015 21:41:19 +0000 (UTC) Received: (qmail 75729 invoked by uid 500); 15 Apr 2015 21:41:13 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 75688 invoked by uid 500); 15 Apr 2015 21:41:13 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 75679 invoked by uid 99); 15 Apr 2015 21:41:13 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Apr 2015 21:41:13 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id DD87BE0921; Wed, 15 Apr 2015 21:41:12 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ndimiduk@apache.org To: commits@hbase.apache.org Message-Id: <60245be92335471fbd806e88a4d6cc49@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: hbase git commit: HBASE-12987 Pare repeated hbck output and increase verbosity in long-running tasks. Date: Wed, 15 Apr 2015 21:41:12 +0000 (UTC) Repository: hbase Updated Branches: refs/heads/branch-1 65bf10a47 -> ffd7bbfd6 HBASE-12987 Pare repeated hbck output and increase verbosity in long-running tasks. Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/ffd7bbfd Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/ffd7bbfd Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/ffd7bbfd Branch: refs/heads/branch-1 Commit: ffd7bbfd6bc6f09b11089de8508c447f3ce492c8 Parents: 65bf10a Author: Josh Elser Authored: Wed Apr 8 16:22:22 2015 -0400 Committer: Nick Dimiduk Committed: Wed Apr 15 14:36:27 2015 -0700 ---------------------------------------------------------------------- .../org/apache/hadoop/hbase/util/FSUtils.java | 55 +++++++++++++++++++- .../org/apache/hadoop/hbase/util/HBaseFsck.java | 38 +++++++++++--- 2 files changed, 85 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/ffd7bbfd/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java index d4caa1b..aa06c20 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java @@ -67,6 +67,7 @@ import org.apache.hadoop.hbase.fs.HFileSystem; import org.apache.hadoop.hbase.master.HMaster; import org.apache.hadoop.hbase.regionserver.StoreFileInfo; import org.apache.hadoop.hbase.security.AccessDeniedException; +import org.apache.hadoop.hbase.util.HBaseFsck.ErrorReporter; import org.apache.hadoop.hbase.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.protobuf.generated.FSProtos; import org.apache.hadoop.hbase.regionserver.HRegion; @@ -1543,6 +1544,28 @@ public abstract class FSUtils { public static Map getTableStoreFilePathMap(Map map, final FileSystem fs, final Path hbaseRootDir, TableName tableName) throws IOException { + return getTableStoreFilePathMap(map, fs, hbaseRootDir, tableName, null); + } + + /** + * Runs through the HBase rootdir/tablename and creates a reverse lookup map for + * table StoreFile names to the full Path. + *
+ * Example...
+ * Key = 3944417774205889744
+ * Value = hdfs://localhost:51169/user/userid/-ROOT-/70236052/info/3944417774205889744 + * + * @param map map to add values. If null, this method will create and populate one to return + * @param fs The file system to use. + * @param hbaseRootDir The root directory to scan. + * @param tableName name of the table to scan. + * @param errors ErrorReporter instance or null + * @return Map keyed by StoreFile name with a value of the full Path. + * @throws IOException When scanning the directory fails. + */ + public static Map getTableStoreFilePathMap(Map map, + final FileSystem fs, final Path hbaseRootDir, TableName tableName, ErrorReporter errors) + throws IOException { if (map == null) { map = new HashMap(); } @@ -1554,10 +1577,16 @@ public abstract class FSUtils { PathFilter familyFilter = new FamilyDirFilter(fs); FileStatus[] regionDirs = fs.listStatus(tableDir, new RegionDirFilter(fs)); for (FileStatus regionDir : regionDirs) { + if (null != errors) { + errors.progress(); + } Path dd = regionDir.getPath(); // else its a region name, now look in region for families FileStatus[] familyDirs = fs.listStatus(dd, familyFilter); for (FileStatus familyDir : familyDirs) { + if (null != errors) { + errors.progress(); + } Path family = familyDir.getPath(); if (family.getName().equals(HConstants.RECOVERED_EDITS_DIR)) { continue; @@ -1566,6 +1595,9 @@ public abstract class FSUtils { // put in map FileStatus[] familyStatus = fs.listStatus(family); for (FileStatus sfStatus : familyStatus) { + if (null != errors) { + errors.progress(); + } Path sf = sfStatus.getPath(); map.put( sf.getName(), sf); } @@ -1586,7 +1618,6 @@ public abstract class FSUtils { return result; } - /** * Runs through the HBase rootdir and creates a reverse lookup map for * table StoreFile names to the full Path. @@ -1603,6 +1634,26 @@ public abstract class FSUtils { public static Map getTableStoreFilePathMap( final FileSystem fs, final Path hbaseRootDir) throws IOException { + return getTableStoreFilePathMap(fs, hbaseRootDir, null); + } + + /** + * Runs through the HBase rootdir and creates a reverse lookup map for + * table StoreFile names to the full Path. + *
+ * Example...
+ * Key = 3944417774205889744
+ * Value = hdfs://localhost:51169/user/userid/-ROOT-/70236052/info/3944417774205889744 + * + * @param fs The file system to use. + * @param hbaseRootDir The root directory to scan. + * @param errors ErrorReporter instance or null + * @return Map keyed by StoreFile name with a value of the full Path. + * @throws IOException When scanning the directory fails. + */ + public static Map getTableStoreFilePathMap( + final FileSystem fs, final Path hbaseRootDir, ErrorReporter errors) + throws IOException { Map map = new HashMap(); // if this method looks similar to 'getTableFragmentation' that is because @@ -1611,7 +1662,7 @@ public abstract class FSUtils { // only include the directory paths to tables for (Path tableDir : FSUtils.getTableDirs(fs, hbaseRootDir)) { getTableStoreFilePathMap(map, fs, hbaseRootDir, - FSUtils.getTableName(tableDir)); + FSUtils.getTableName(tableDir), errors); } return map; } http://git-wip-us.apache.org/repos/asf/hbase/blob/ffd7bbfd/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java ---------------------------------------------------------------------- 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 65d4a42..2971643 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 @@ -648,7 +648,9 @@ public class HBaseFsck extends Configured implements Closeable { // load regiondirs and regioninfos from HDFS if (shouldCheckHdfs()) { + LOG.info("Loading region directories from HDFS"); loadHdfsRegionDirs(); + LOG.info("Loading region information from HDFS"); loadHdfsRegionInfos(); } @@ -658,6 +660,8 @@ public class HBaseFsck extends Configured implements Closeable { // fix the orphan tables fixOrphanTables(); + LOG.info("Checking and fixing region consistency"); + // Check and fix consistency checkAndFixConsistency(); @@ -978,7 +982,10 @@ public class HBaseFsck extends Configured implements Closeable { Configuration conf = getConf(); Path hbaseRoot = FSUtils.getRootDir(conf); FileSystem fs = hbaseRoot.getFileSystem(conf); - Map allFiles = FSUtils.getTableStoreFilePathMap(fs, hbaseRoot); + LOG.info("Computing mapping of all store files"); + Map allFiles = FSUtils.getTableStoreFilePathMap(fs, hbaseRoot, errors); + errors.print(""); + LOG.info("Validating mapping using HDFS state"); for (Path path: allFiles.values()) { boolean isReference = false; try { @@ -1176,6 +1183,7 @@ public class HBaseFsck extends Configured implements Closeable { } loadTableInfosForTablesWithNoRegion(); + errors.print(""); return tablesInfo; } @@ -1355,6 +1363,7 @@ public class HBaseFsck extends Configured implements Closeable { */ private void suggestFixes( SortedMap tablesInfo) throws IOException { + logParallelMerge(); for (TableInfo tInfo : tablesInfo.values()) { TableIntegrityErrorHandler handler = tInfo.new IntegrityFixSuggester(tInfo, errors); tInfo.checkRegionChain(handler); @@ -1425,9 +1434,23 @@ public class HBaseFsck extends Configured implements Closeable { return true; } + /** + * Log an appropriate message about whether or not overlapping merges are computed in parallel. + */ + private void logParallelMerge() { + if (getConf().getBoolean("hbasefsck.overlap.merge.parallel", true)) { + LOG.info("Handling overlap merges in parallel. set hbasefsck.overlap.merge.parallel to" + + " false to run serially."); + } else { + LOG.info("Handling overlap merges serially. set hbasefsck.overlap.merge.parallel to" + + " true to run in parallel."); + } + } + private SortedMap checkHdfsIntegrity(boolean fixHoles, boolean fixOverlaps) throws IOException { LOG.info("Checking HBase region split map from HDFS data..."); + logParallelMerge(); for (TableInfo tInfo : tablesInfo.values()) { TableIntegrityErrorHandler handler; if (fixHoles || fixOverlaps) { @@ -1671,6 +1694,7 @@ public class HBaseFsck extends Configured implements Closeable { LOG.warn("Could not load region dir " , e.getCause()); } } + errors.print(""); } /** @@ -2346,6 +2370,7 @@ public class HBaseFsck extends Configured implements Closeable { loadTableInfosForTablesWithNoRegion(); + logParallelMerge(); for (TableInfo tInfo : tablesInfo.values()) { TableIntegrityErrorHandler handler = tInfo.new IntegrityFixSuggester(tInfo, errors); if (!tInfo.checkRegionChain(handler)) { @@ -2963,15 +2988,11 @@ public class HBaseFsck extends Configured implements Closeable { // TODO fold this into the TableIntegrityHandler if (getConf().getBoolean("hbasefsck.overlap.merge.parallel", true)) { - LOG.info("Handling overlap merges in parallel. set hbasefsck.overlap.merge.parallel to" + - " false to run serially."); boolean ok = handleOverlapsParallel(handler, prevKey); if (!ok) { return false; } } else { - LOG.info("Handling overlap merges serially. set hbasefsck.overlap.merge.parallel to" + - " true to run in parallel."); for (Collection overlap : overlapGroups.asMap().values()) { handler.handleOverlapGroup(overlap); } @@ -3753,6 +3774,8 @@ public class HBaseFsck extends Configured implements Closeable { static class PrintingErrorReporter implements ErrorReporter { public int errorCount = 0; private int showProgress; + // How frequently calls to progress() will create output + private static final int progressThreshold = 100; Set errorTables = new HashSet(); @@ -3867,7 +3890,7 @@ public class HBaseFsck extends Configured implements Closeable { @Override public synchronized void progress() { - if (showProgress++ == 10) { + if (showProgress++ == progressThreshold) { if (!summary) { System.out.print("."); } @@ -3964,6 +3987,7 @@ public class HBaseFsck extends Configured implements Closeable { // level 2: //* FileStatus[] regionDirs = fs.listStatus(tableDir.getPath()); for (FileStatus regionDir : regionDirs) { + errors.progress(); String encodedName = regionDir.getPath().getName(); // ignore directories that aren't hexadecimal if (!encodedName.toLowerCase().matches("[0-9a-f]+")) { @@ -3991,6 +4015,7 @@ public class HBaseFsck extends Configured implements Closeable { FileStatus[] subDirs = fs.listStatus(regionDir.getPath()); Path ePath = WALSplitter.getRegionDirRecoveredEditsDir(regionDir.getPath()); for (FileStatus subDir : subDirs) { + errors.progress(); String sdName = subDir.getPath().getName(); if (!sdName.startsWith(".") && !sdName.equals(ePath.getName())) { he.hdfsOnlyEdits = false; @@ -4031,6 +4056,7 @@ public class HBaseFsck extends Configured implements Closeable { // only load entries that haven't been loaded yet. if (hbi.getHdfsHRI() == null) { try { + errors.progress(); hbck.loadHdfsRegioninfo(hbi); } catch (IOException ioe) { String msg = "Orphan region in HDFS: Unable to load .regioninfo from table "