Return-Path: X-Original-To: apmail-hadoop-hdfs-issues-archive@minotaur.apache.org Delivered-To: apmail-hadoop-hdfs-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E6D4018BE0 for ; Mon, 15 Jun 2015 20:33:03 +0000 (UTC) Received: (qmail 86005 invoked by uid 500); 15 Jun 2015 20:33:03 -0000 Delivered-To: apmail-hadoop-hdfs-issues-archive@hadoop.apache.org Received: (qmail 85954 invoked by uid 500); 15 Jun 2015 20:33:03 -0000 Mailing-List: contact hdfs-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hdfs-issues@hadoop.apache.org Delivered-To: mailing list hdfs-issues@hadoop.apache.org Received: (qmail 85943 invoked by uid 99); 15 Jun 2015 20:33:03 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Jun 2015 20:33:03 +0000 Date: Mon, 15 Jun 2015 20:33:03 +0000 (UTC) From: "Tsz Wo Nicholas Sze (JIRA)" To: hdfs-issues@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HDFS-8246) Get HDFS file name based on block pool id and block id MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HDFS-8246?page=3Dcom.atlassian.= jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D14586= 649#comment-14586649 ]=20 Tsz Wo Nicholas Sze commented on HDFS-8246: ------------------------------------------- What are the more use cases? > Get HDFS file name based on block pool id and block id > ------------------------------------------------------ > > Key: HDFS-8246 > URL: https://issues.apache.org/jira/browse/HDFS-8246 > Project: Hadoop HDFS > Issue Type: New Feature > Components: HDFS, hdfs-client, namenode > Reporter: feng xu > Assignee: feng xu > Labels: BB2015-05-TBR > Attachments: HDFS-8246.0.patch > > > This feature provides HDFS shell command and C/Java API to retrieve HDFS = file name based on block pool id and block id. > 1. The Java API in class DistributedFileSystem > public String getFileName(String poolId, long blockId) throws IOException > 2. The C API in hdfs.c > char* hdfsGetFileName(hdfsFS fs, const char* poolId, int64_t blockId) > 3. The HDFS shell command=20 > hdfs dfs [generic options] -fn > This feature is useful if you have HDFS block file name in local file sys= tem and want to find out the related HDFS file name in HDFS name space (ht= tp://stackoverflow.com/questions/10881449/how-to-find-file-from-blockname-i= n-hdfs-hadoop). Each HDFS block file name in local file system contains bo= th block pool id and block id, for sample HDFS block file name /hdfs/1/hado= op/hdfs/data/current/BP-97622798-10.3.11.84-1428081035160/current/finalized= /subdir0/subdir0/blk_1073741825, the block pool id is BP-97622798-10.3.11.= 84-1428081035160 and the block id is 1073741825. The block pool id is uniq= uely related to a HDFS name node/name space, and the block id is uniquely = related to a HDFS file within a HDFS name node/name space, so the combinati= on of block pool id and a block id is uniquely related a HDFS file name.=20 > The shell command and C/Java API do not map the block pool id to name nod= e, so it=E2=80=99s user=E2=80=99s responsibility to talk to the correct nam= e node in federation environment that has multiple name nodes. The block po= ol id is used by name node to check if the user is talking with the correct= name node. > The implementation is straightforward. The client request to get HDFS fil= e name reaches the new method String getFileName(String poolId, long blockI= d) in FSNamesystem in name node through RPC, and the new method does the f= ollowings, > (1)=09Validate the block pool id. > (2)=09Create Block based on the block id. > (3)=09Get BlockInfoContiguous from Block. > (4)=09Get BlockCollection from BlockInfoContiguous. > (5)=09Get file name from BlockCollection. -- This message was sent by Atlassian JIRA (v6.3.4#6332)