Return-Path: X-Original-To: apmail-hadoop-hdfs-commits-archive@minotaur.apache.org Delivered-To: apmail-hadoop-hdfs-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BC27F10D09 for ; Fri, 28 Feb 2014 21:07:29 +0000 (UTC) Received: (qmail 44433 invoked by uid 500); 28 Feb 2014 21:07:28 -0000 Delivered-To: apmail-hadoop-hdfs-commits-archive@hadoop.apache.org Received: (qmail 44358 invoked by uid 500); 28 Feb 2014 21:07:28 -0000 Mailing-List: contact hdfs-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hdfs-dev@hadoop.apache.org Delivered-To: mailing list hdfs-commits@hadoop.apache.org Received: (qmail 44348 invoked by uid 99); 28 Feb 2014 21:07:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Feb 2014 21:07:27 +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; Fri, 28 Feb 2014 21:07:24 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A3986238896F; Fri, 28 Feb 2014 21:07:03 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1573078 - in /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs: ./ src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/ src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/ Date: Fri, 28 Feb 2014 21:07:03 -0000 To: hdfs-commits@hadoop.apache.org From: wheat9@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140228210703.A3986238896F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: wheat9 Date: Fri Feb 28 21:07:03 2014 New Revision: 1573078 URL: http://svn.apache.org/r1573078 Log: HDFS-5956. A file size is multiplied by the replication factor in 'hdfs oiv -p FileDistribution' option. Contributed by Akira Ajisaka. Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/FileDistributionCalculator.java hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1573078&r1=1573077&r2=1573078&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Fri Feb 28 21:07:03 2014 @@ -511,6 +511,9 @@ Release 2.4.0 - UNRELEASED HDFS-5821. TestHDFSCLI fails for user names with the dash character. (Gera Shegalov via Arpit Agarwal) + HDFS-5956. A file size is multiplied by the replication factor in 'hdfs oiv + -p FileDistribution' option. (Akira Ajisaka via wheat9) + BREAKDOWN OF HDFS-5698 SUBTASKS AND RELATED JIRAS HDFS-5717. Save FSImage header in protobuf. (Haohui Mai via jing9) Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/FileDistributionCalculator.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/FileDistributionCalculator.java?rev=1573078&r1=1573077&r2=1573078&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/FileDistributionCalculator.java (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/FileDistributionCalculator.java Fri Feb 28 21:07:03 2014 @@ -123,10 +123,10 @@ final class FileDistributionCalculator { totalBlocks += f.getBlocksCount(); long fileSize = 0; for (BlockProto b : f.getBlocksList()) { - fileSize += b.getNumBytes() * f.getReplication(); + fileSize += b.getNumBytes(); } maxFileSize = Math.max(fileSize, maxFileSize); - totalSpace += fileSize; + totalSpace += fileSize * f.getReplication(); int bucket = fileSize > maxSize ? distribution.length - 1 : (int) Math .ceil((double)fileSize / steps); Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java?rev=1573078&r1=1573077&r2=1573078&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java Fri Feb 28 21:07:03 2014 @@ -28,6 +28,8 @@ import java.io.PrintWriter; import java.io.RandomAccessFile; import java.io.StringReader; import java.io.StringWriter; +import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -241,7 +243,7 @@ public class TestOfflineImageViewer { } @Test - public void testFileDistributionVisitor() throws IOException { + public void testFileDistributionCalculator() throws IOException { StringWriter output = new StringWriter(); PrintWriter o = new PrintWriter(output); new FileDistributionCalculator(new Configuration(), 0, 0, o) @@ -250,10 +252,29 @@ public class TestOfflineImageViewer { Pattern p = Pattern.compile("totalFiles = (\\d+)\n"); Matcher matcher = p.matcher(output.getBuffer()); - assertTrue(matcher.find() && matcher.groupCount() == 1); int totalFiles = Integer.parseInt(matcher.group(1)); - assertEquals(totalFiles, NUM_DIRS * FILES_PER_DIR); + assertEquals(NUM_DIRS * FILES_PER_DIR, totalFiles); + + p = Pattern.compile("totalDirectories = (\\d+)\n"); + matcher = p.matcher(output.getBuffer()); + assertTrue(matcher.find() && matcher.groupCount() == 1); + int totalDirs = Integer.parseInt(matcher.group(1)); + // totalDirs includes root directory + assertEquals(NUM_DIRS + 1, totalDirs); + + FileStatus maxFile = Collections.max(writtenFiles.values(), + new Comparator() { + @Override + public int compare(FileStatus first, FileStatus second) { + return first.getLen() < second.getLen() ? -1 : + ((first.getLen() == second.getLen()) ? 0 : 1); + } + }); + p = Pattern.compile("maxFileSize = (\\d+)\n"); + matcher = p.matcher(output.getBuffer()); + assertTrue(matcher.find() && matcher.groupCount() == 1); + assertEquals(maxFile.getLen(), Long.parseLong(matcher.group(1))); } @Test