Search in sources :

Example 1 with PositionTrackingInputStream

use of org.apache.hadoop.hdfs.server.namenode.FSEditLogLoader.PositionTrackingInputStream in project hadoop by apache.

the class OfflineImageViewer method go.

/**
   * Process image file.
   */
public void go() throws IOException {
    DataInputStream in = null;
    PositionTrackingInputStream tracker = null;
    ImageLoader fsip = null;
    boolean done = false;
    try {
        tracker = new PositionTrackingInputStream(new BufferedInputStream(new FileInputStream(new File(inputFile))));
        in = new DataInputStream(tracker);
        int imageVersionFile = findImageVersion(in);
        fsip = ImageLoader.LoaderFactory.getLoader(imageVersionFile);
        if (fsip == null)
            throw new IOException("No image processor to read version " + imageVersionFile + " is available.");
        fsip.loadImage(in, processor, skipBlocks);
        done = true;
    } finally {
        if (!done) {
            if (tracker != null) {
                LOG.error("image loading failed at offset " + tracker.getPos());
            } else {
                LOG.error("Failed to load image file.");
            }
        }
        IOUtils.cleanup(LOG, in, tracker);
    }
}
Also used : PositionTrackingInputStream(org.apache.hadoop.hdfs.server.namenode.FSEditLogLoader.PositionTrackingInputStream) BufferedInputStream(java.io.BufferedInputStream) IOException(java.io.IOException) DataInputStream(java.io.DataInputStream) File(java.io.File) FileInputStream(java.io.FileInputStream)

Aggregations

BufferedInputStream (java.io.BufferedInputStream)1 DataInputStream (java.io.DataInputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 PositionTrackingInputStream (org.apache.hadoop.hdfs.server.namenode.FSEditLogLoader.PositionTrackingInputStream)1