hadoop-hdfs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Harsh J <ha...@cloudera.com>
Subject Re: How to obtain block information of a HDFS file?
Date Thu, 28 Jul 2011 14:10:19 GMT

What version of Hadoop are you using?

On Thu, Jul 28, 2011 at 6:03 PM, Florin P <florinpico@yahoo.com> wrote:
> Hello!
>   I would like to know how to obtain for a file (via Java API) the following information
>  - how many blocks occupies in the HDFS

Is this request per file? or overall? [If overall, I think metrics are
your best bet]

>   -which are the machines where the blocks were replicated

If this request is per-file, then FileSystem#getBlockLocations(…) API
can help you. Just request it over the entire size of the file
(FileStatus information can be got via FileSystem#getFileStatus(…))

Harsh J

View raw message