I'm uploading the patch. Please also note that the tests depend on 2 external fsimage files. These are not present in the patch file, because the patch can't carry binary files. Instead, I am attaching the files to this issue. When we commit this patch, we also need to commit these files at src/test/org/apache/hadoop/hdfs/tools/offlineImageViewer.
For the backport, I started with the current trunk version of the code. I took the docs from the current branch-0.22, because they were in the old XML format, but they were more complete than the original docs from the
Then, there were a few minor adjustments required to make the code work with branch-1:
- I've included LayoutVersion, because ImageLoaderCurrent needs it to determine what to parse.
- FSImageSerialization class is not available in branch-1. The original implementation of this code used the read methods in FSImage instead.
- ImageLoaderCurrent needed some new methods in CompressionCodecFactory, so I included those.
- TestOfflineImageViewer depended on a special testing flag not present in branch-1 to force generation of delegation tokens. I've included a minimal port of this flag so that we can maintain the same level of testing coverage.
- The trunk version of the code uses FSEditLogLoader#PositionTrackingInputStream so that oiv can report the byte offset where a failure occurred in the event of a corrupted fsimage. This class is not present in branch-1, and porting it would have swept in a lot of unrelated code changes. Instead, I have provided a minimal version as a nested class of OfflineImageViewer.
All new tests pass, and I have manually tested on fsimage files from a deployed branch-1-based cluster.