Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 8A9AF200B50 for ; Fri, 29 Jul 2016 13:48:27 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 893B3160A79; Fri, 29 Jul 2016 11:48:27 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D125F160A61 for ; Fri, 29 Jul 2016 13:48:26 +0200 (CEST) Received: (qmail 81262 invoked by uid 500); 29 Jul 2016 11:48:21 -0000 Mailing-List: contact hdfs-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list hdfs-issues@hadoop.apache.org Received: (qmail 80888 invoked by uid 99); 29 Jul 2016 11:48:20 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Jul 2016 11:48:20 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id AFAEF2C0D60 for ; Fri, 29 Jul 2016 11:48:20 +0000 (UTC) Date: Fri, 29 Jul 2016 11:48:20 +0000 (UTC) From: "Yiqun Lin (JIRA)" To: hdfs-issues@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (HDFS-10691) FileDistribution fails in hdfs oiv command due to ArrayIndexOutOfBoundsException MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 29 Jul 2016 11:48:27 -0000 [ https://issues.apache.org/jira/browse/HDFS-10691?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Yiqun Lin updated HDFS-10691: ----------------------------- Attachment: HDFS-10691-branch-2.7.patch > FileDistribution fails in hdfs oiv command due to ArrayIndexOutOfBoundsException > -------------------------------------------------------------------------------- > > Key: HDFS-10691 > URL: https://issues.apache.org/jira/browse/HDFS-10691 > Project: Hadoop HDFS > Issue Type: Bug > Affects Versions: 2.7.1 > Reporter: Yiqun Lin > Assignee: Yiqun Lin > Fix For: 2.8.0, 3.0.0-alpha2 > > Attachments: HDFS-10691-branch-2.7.patch, HDFS-10691.001.patch, HDFS-10691.002.patch, HDFS-10691.003.patch > > > I use hdfs oiv -p FileDistribution command to do a file analyse. But the {{ArrayIndexOutOfBoundsException}} happened and lead the process terminated. The stack infos: > {code} > Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 103 > at org.apache.hadoop.hdfs.tools.offlineImageViewer.FileDistributionCalculator.run(FileDistributionCalculator.java:243) > at org.apache.hadoop.hdfs.tools.offlineImageViewer.FileDistributionCalculator.visit(FileDistributionCalculator.java:176) > at org.apache.hadoop.hdfs.tools.offlineImageViewer.OfflineImageViewerPB.run(OfflineImageViewerPB.java:176) > at org.apache.hadoop.hdfs.tools.offlineImageViewer.OfflineImageViewerPB.main(OfflineImageViewerPB.java:129) > {code} > I looked into the code and I found the exception was threw in increasing count of {{distribution}}. And the reason for the exception is that the bucket number was more than the distribution's length. > Here are my steps: > 1).The input command params: > {code} > hdfs oiv -p FileDistribution -maxSize 104857600 -step 1024000 > {code} > The {{numIntervals}} in code should be 104857600/1024000 =102(real value:102.4), so the {{distribution}}'s length should be {{numIntervals}} + 1 = 103. > 2).The {{ArrayIndexOutOfBoundsException}} will happens when the file size is in range ((maxSize/step)*step, maxSize]. For example, if the size of one file is 104800000, and it's in range of size as mentioned before. And the bucket number is calculated as 104800000/1024000=102.3, then in code we do the {{Math.ceil}} of this, so the final value should be 103. But the {{distribution}}'s length is also 103, it means the index is from 0 to 102. So the {{ArrayIndexOutOfBoundsException}} happens. > In a word, the exception will happens when {{maxSize}} can not be divided by {{step}} and meanwhile the size of file is in range ((maxSize/step)*step, maxSize]. The related logic should be changed from > {code} > int bucket = fileSize > maxSize ? distribution.length - 1 : (int) Math > .ceil((double)fileSize / steps); > {code} > to > {code} > int bucket = > fileSize >= maxSize || fileSize > (maxSize / steps) * steps ? > distribution.length - 1 : (int) Math.ceil((double) fileSize / steps); > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-issues-unsubscribe@hadoop.apache.org For additional commands, e-mail: hdfs-issues-help@hadoop.apache.org