Permalink
Browse files

Pass digestinputstream to loader instead of DIS in FSImage.loadImage()

Summary:
With this patch, I am passing a unwrapped digestinputstream istead of
datainputstream. There is a small thing that InputStream sometimes is
passed from outside (I think for snapshot code), and hence I need to
check if the digestinputstream is not null.

Test Plan: manually, with lzo codec

Reviewers: hkuang, pritam, weiyan

Reviewed By: weiyan
  • Loading branch information...
tomasz Alex Feinberg
tomasz authored and Alex Feinberg committed Oct 4, 2012
1 parent 583d5f3 commit 20a5d4ab6df486c9c65d0373c2c6aad5b461d2c9
Showing with 7 additions and 8 deletions.
  1. +7 −8 src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSImageFormat.java
@@ -126,11 +126,11 @@ private void checkNotLoaded() {
}
}
- void load(File curFile, DataInputStream in)
- throws IOException
- {
+ void load(File curFile, DataInputStream in) throws IOException {
checkNotLoaded();
- assert curFile != null : "curFile is null";
+ DigestInputStream fin = null;
+ if (curFile == null )
+ throw new IOException("curFile is null");
long startTime = now();
@@ -142,9 +142,8 @@ void load(File curFile, DataInputStream in)
if (in == null) {
FileInputStream fis = new FileInputStream(curFile);
digester = MD5Hash.getDigester();
- DigestInputStream fin = new DigestInputStream(
- fis, digester);
- in = new DataInputStream(fin);
+ fin = new DigestInputStream(fis, digester);
+ in = new DataInputStream(fin);
}
try {
/*
@@ -195,7 +194,7 @@ void load(File curFile, DataInputStream in)
} else {
compression = FSImageCompression.createNoopCompression();
}
- in = compression.unwrapInputStream(in);
+ in = compression.unwrapInputStream(fin != null ? fin : in);
LOG.info("Loading image file " + curFile + " using " + compression);

0 comments on commit 20a5d4a

Please sign in to comment.