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);
}
}
Aggregations