Offline Image Viewer Guide


The Offline Image Viewer is a tool to dump the contents of hdfs fsimage files to a human-readable format and provide read-only WebHDFS API in order to allow offline analysis and examination of an Hadoop cluster's namespace. The tool is able to process very large image files relatively quickly. The tool handles the layout formats that were included with Hadoop versions 2.4 and up. If you want to handle older layout formats, you can use the Offline Image Viewer of Hadoop 2.3. If the tool is not able to process an image file, it will exit cleanly. The Offline Image Viewer does not require a Hadoop cluster to be running; it is entirely offline in its operation.

The Offline Image Viewer provides several output processors:

  1. Web is the default output processor. It launches a HTTP server that exposes read-only WebHDFS API. Users can investigate the namespace interactively by using HTTP REST API.
  2. XML creates an XML document of the fsimage and includes all of the information within the fsimage, similar to the lsr processor. The output of this processor is amenable to automated processing and analysis with XML tools. Due to the verbosity of the XML syntax, this processor will also generate the largest amount of output.
  3. FileDistribution is the tool for analyzing file sizes in the namespace image. In order to run the tool one should define a range of integers [0, maxSize] by specifying maxSize and a step. The range of integers is divided into segments of size step: [0, s[1], ..., s[n-1], maxSize], and the processor calculates how many files in the system fall into each segment [s[i-1], s[i]). Note that files larger than maxSize always fall into the very last segment. The output file is formatted as a tab separated two column table: Size and NumFiles. Where Size represents the start of the segment, and numFiles is the number of files form the image which size falls in this segment.


Web Processor

Web processor launches a HTTP server which exposes read-only WebHDFS API. Users can specify the address to listen by -addr option (default by localhost:5978).

   bash$ bin/hdfs oiv -i fsimage
   14/04/07 13:25:14 INFO offlineImageViewer.WebImageViewer: WebImageViewer
   started. Listening on / Press Ctrl+C to stop the viewer.

Users can access the viewer and get the information of the fsimage by the following shell command:

   bash$ bin/hdfs dfs -ls webhdfs://
   Found 2 items
   drwxrwx---   - root supergroup          0 2014-03-26 20:16 webhdfs://
   drwxr-xr-x   - root supergroup          0 2014-03-31 14:08 webhdfs://

To get the information of all the files and directories, you can simply use the following command:

   bash$ bin/hdfs dfs -ls -R webhdfs://

Users can also get JSON formatted FileStatuses via HTTP REST API.

   bash$ curl -i
   HTTP/1.1 200 OK
   Content-Type: application/json
   Content-Length: 252


The Web processor now supports the following operations:

XML Processor

XML Processor is used to dump all the contents in the fsimage. Users can specify input and output file via -i and -o command-line.

   bash$ bin/hdfs oiv -p XML -i fsimage -o fsimage.xml

This will create a file named fsimage.xml contains all the information in the fsimage. For very large image files, this process may take several minutes.

Applying the Offline Image Viewer with XML processor would result in the following output:

   <?xml version="1.0"?>
   ...remaining output omitted...


Flag Description
-i|--inputFile input file Specify the input fsimage file to process. Required.
-o|--outputFile output file Specify the output filename, if the specified output processor generates one. If the specified file already exists, it is silently overwritten. (output to stdout by default)
-p|--processor processor Specify the image processor to apply against the image file. Currently valid options are Web (default), XML and FileDistribution.
-addr address Specify the address(host:port) to listen. (localhost:5978 by default). This option is used with Web processor.
-maxSize size Specify the range [0, maxSize] of file sizes to be analyzed in bytes (128GB by default). This option is used with FileDistribution processor.
-step size Specify the granularity of the distribution in bytes (2MB by default). This option is used with FileDistribution processor.
-h|--help Display the tool usage and help information and exit.

Analyzing Results

The Offline Image Viewer makes it easy to gather large amounts of data about the hdfs namespace. This information can then be used to explore file system usage patterns or find specific files that match arbitrary criteria, along with other types of namespace analysis.