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 EFB5D7CDC for ; Tue, 11 Oct 2011 02:12:58 +0000 (UTC) Received: (qmail 66786 invoked by uid 500); 11 Oct 2011 02:12:58 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 66761 invoked by uid 500); 11 Oct 2011 02:12:58 -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 66754 invoked by uid 99); 11 Oct 2011 02:12:58 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Oct 2011 02:12:58 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Oct 2011 02:12:56 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 36B98238897D for ; Tue, 11 Oct 2011 02:12:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1181484 - /hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java Date: Tue, 11 Oct 2011 02:12:35 -0000 To: commits@hbase.apache.org From: nspiegelberg@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111011021235.36B98238897D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: nspiegelberg Date: Tue Oct 11 02:12:33 2011 New Revision: 1181484 URL: http://svn.apache.org/viewvc?rev=1181484&view=rev Log: HFile CLI : print block index Summary: Added the ability for the HFile CLI to print the full block index details. Also corrected printKey functionality. Using this to debug the HFOF corruption that occurred last Thursday Test Plan: - bin/hbase org.apache.hadoop.hbase.io.hfile.HFile -f /Keywords.corrupted -b DiffCamp Revision: 207413 Reviewed By: kannan Reviewers: kannan CC: kannan Revert Plan: OK Modified: hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java Modified: hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java URL: http://svn.apache.org/viewvc/hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java?rev=1181484&r1=1181483&r2=1181484&view=diff ============================================================================== --- hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java (original) +++ hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java Tue Oct 11 02:12:33 2011 @@ -1767,12 +1767,12 @@ public class HFile { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("size=" + count); + sb.append("size=" + count).append("\n"); for (int i = 0; i < count ; i++) { - sb.append(", "); - sb.append("key=").append(Bytes.toStringBinary(blockKeys[i])). - append(", offset=").append(blockOffsets[i]). - append(", dataSize=" + blockDataSizes[i]); + sb.append("key=").append(KeyValue.keyToString(blockKeys[i])). + append("\n offset=").append(blockOffsets[i]). + append(", dataSize=" + blockDataSizes[i]). + append("\n"); } return sb.toString(); } @@ -1893,7 +1893,9 @@ public class HFile { Options options = new Options(); options.addOption("v", "verbose", false, "Verbose output; emits file and meta data delimiters"); options.addOption("p", "printkv", false, "Print key/value pairs"); + options.addOption("e", "printkey", false, "Print keys"); options.addOption("m", "printmeta", false, "Print meta data of file"); + options.addOption("b", "printblocks", false, "Print block index meta data"); options.addOption("k", "checkrow", false, "Enable row order check; looks for out-of-order keys"); options.addOption("a", "checkfamily", false, "Enable family check"); @@ -1910,15 +1912,15 @@ public class HFile { CommandLine cmd = parser.parse(options, args); boolean verbose = cmd.hasOption("v"); boolean printValue = cmd.hasOption("p"); - boolean printKey = cmd.hasOption("pk") || printValue; + boolean printKey = cmd.hasOption("e") || printValue; boolean printMeta = cmd.hasOption("m"); + boolean printBlocks = cmd.hasOption("b"); boolean checkRow = cmd.hasOption("k"); boolean checkFamily = cmd.hasOption("a"); // get configuration, file system and get list of files Configuration conf = HBaseConfiguration.create(); conf.set("fs.defaultFS", conf.get(org.apache.hadoop.hbase.HConstants.HBASE_DIR)); - FileSystem fs = FileSystem.get(conf); ArrayList files = new ArrayList(); if (cmd.hasOption("f")) { files.add(new Path(cmd.getOptionValue("f"))); @@ -1932,7 +1934,8 @@ public class HFile { String enc = HRegionInfo.encodeRegionName(rn); Path regionDir = new Path(tableDir, enc); if (verbose) System.out.println("region dir -> " + regionDir); - List regionFiles = getStoreFiles(fs, regionDir); + List regionFiles = + getStoreFiles(FileSystem.get(conf), regionDir); if (verbose) System.out.println("Number of region files found -> " + regionFiles.size()); if (verbose) { @@ -1947,6 +1950,7 @@ public class HFile { // iterate over all files found for (Path file : files) { if (verbose) System.out.println("Scanning -> " + file); + FileSystem fs = file.getFileSystem(conf); if (!fs.exists(file)) { System.err.println("ERROR, file doesnt exist: " + file); continue; @@ -2042,6 +2046,10 @@ public class HFile { System.out.println("Could not get bloom data from meta block"); } } + if (printBlocks) { + System.out.println("Block Index:"); + System.out.println(reader.blockIndex); + } reader.close(); } } catch (Exception e) {