Return-Path: X-Original-To: apmail-hadoop-hdfs-user-archive@minotaur.apache.org Delivered-To: apmail-hadoop-hdfs-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D46737674 for ; Thu, 28 Jul 2011 14:11:07 +0000 (UTC) Received: (qmail 76346 invoked by uid 500); 28 Jul 2011 14:11:07 -0000 Delivered-To: apmail-hadoop-hdfs-user-archive@hadoop.apache.org Received: (qmail 76178 invoked by uid 500); 28 Jul 2011 14:11:06 -0000 Mailing-List: contact hdfs-user-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hdfs-user@hadoop.apache.org Delivered-To: mailing list hdfs-user@hadoop.apache.org Received: (qmail 76170 invoked by uid 99); 28 Jul 2011 14:11:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Jul 2011 14:11:06 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of harsh@cloudera.com designates 209.85.213.176 as permitted sender) Received: from [209.85.213.176] (HELO mail-yx0-f176.google.com) (209.85.213.176) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Jul 2011 14:10:59 +0000 Received: by yxl11 with SMTP id 11so2187365yxl.35 for ; Thu, 28 Jul 2011 07:10:39 -0700 (PDT) Received: by 10.236.127.67 with SMTP id c43mr50047yhi.259.1311862239091; Thu, 28 Jul 2011 07:10:39 -0700 (PDT) MIME-Version: 1.0 Received: by 10.236.60.163 with HTTP; Thu, 28 Jul 2011 07:10:19 -0700 (PDT) In-Reply-To: <1311856395.8887.YahooMailClassic@web29212.mail.ird.yahoo.com> References: <1311856395.8887.YahooMailClassic@web29212.mail.ird.yahoo.com> From: Harsh J Date: Thu, 28 Jul 2011 19:40:19 +0530 Message-ID: Subject: Re: How to obtain block information of a HDFS file? To: hdfs-user@hadoop.apache.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Hello, What version of Hadoop are you using? On Thu, Jul 28, 2011 at 6:03 PM, Florin P wrote: > Hello! > =A0 I would like to know how to obtain for a file (via Java API) the foll= owing information > =A0- how many blocks occupies in the HDFS Is this request per file? or overall? [If overall, I think metrics are your best bet] > =A0 -which are the machines where the blocks were replicated If this request is per-file, then FileSystem#getBlockLocations(=85) API can help you. Just request it over the entire size of the file (FileStatus information can be got via FileSystem#getFileStatus(=85)) --=20 Harsh J