wiki:How-tos/TranslatePathnamesIntoPNFS-IDs
Last modified 6 years ago Last modified on 08/05/15 22:26:56

How-To Translate Pathnames Into PNFS-IDs

The following describes how to translate the pathnames of files into their respective PNFS-IDs and vice versa.

Requirements, Constraints And Conventions

  • The usage of Chimera as file-hierarchy-provider and PostgreSQL as DBMS for the chimera-database is expected (it should be however easy to adapt to another DBMS).
  • Several POSIX-utilities are required.
  • Lines starting with “$” are entered within a POSIX-sh-compatible shell.
  • Lines starting with “#” are entered within a POSIX-sh-compatible shell, with the effective user-ID and group-ID being 0 (“root-rights”).
  • Lines starting with “(location) >” are entered within dCache’s administration interface with location as the current location.
  • Standard input is written bold, standard output normal and standard error underlined.

Introduction

Within dCache, a given file can usually be identified via one of two properties:

  • Its PNFS-ID.
  • Its pathname, which is handled by the file-hierarchy provider (for example Chimera).

Both properties are the same for each of the file’s replicas.

Its often required to “translate” pathnames into their respective PNFS-IDs or vice versa.
There are several ways to do this:

Translation Using dCache’s Administration Interface

The PnfsManager cell provides the following two commands via the administration interface:

  • pnfsidof, which translate a single pathname into its corresponding PNFS-ID.
  • pathfinder, which translate a single PNFS-ID into its corresponding pathname.

For example:
(PnfsManager) > pnfsidof /pnfs/lrz-muenchen.de/data/test
0000D7DA15B6F1BD4B52A7690AA12695116C

(PnfsManager) > pathfinder 0000D7DA15B6F1BD4B52A7690AA12695116C
/pnfs/lrz-muenchen.de/data/test


This method is however quite slow and thus inappropriate for translating many pathnames or PNFS-IDs.

The above commands are actually querying the “chimera”-database as described below.

Translation Using The “chimera”-Database

Chimera provides two functions that can be used to perform the translation:

  • path2inode, which translates a single relative pathname (searched below a directory specified by a given PNFS-ID) into its corresponding PNFS-ID.
  • inode2path, which translates a single PNFS-ID into its corresponding pathname.

These functions could be utilised via the following SQL-commands:
VALUES (path2inode('directory-pnfs-id', 'relative-pathname'));
where relative-pathname has to be replaced with a relative pathname (without any leading “/”) which is searched below the directory specified via directory-pnfs-id and
VALUES (inode2path('pnfs-id'));
where pnfs-id has to be replaced with the PNFS-ID.

This method is as fast as possible and thus especially appropriate for translating many pathnames or PNFS-IDs.

The PNFS-ID of Chimera’s file-hierarchy-root “/” is always “000000000000000000000000000000000000”.

Translating Large File-Lists

Translating large file-lists where each line holds exactly one absolute pathname or one PNFS-ID can be scripted, for example like this:
# sed -i "s|^/\(.*\)$|VALUES (path2inode('000000000000000000000000000000000000', '\1'));|" list-of-pathnames
# psql --no-align --tuples-only --username dcache --dbname chimera --file list-of-pathnames --output list-of-PNFS-IDs

# sed -i "s|\(.*\)|VALUES (inode2path('\1'));|" list-of-PNFS-IDs
# psql --no-align --tuples-only --username dcache --dbname chimera --file list-of-PNFS-IDs --output list-of-pathnames

License Of This Document

Copyright © 2009–2015, Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>.
All rights reserved.


This work is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.

This work is licensed under the Creative Commons Attribution-Share Alike 3.0 Germany License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/de/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".