HDFS-2330. In NNStorage and FSImagePreTransactionalStorageInspector, IOExceptions of stream closures can mask root exceptions. Contributed by Uma Maheswara Rao G

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1172219 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tsz-wo Sze 2011-09-18 08:30:47 +00:00
parent e56579b9da
commit e34d2c075d
3 changed files with 18 additions and 5 deletions

View File

@ -31,6 +31,10 @@ Trunk (unreleased changes)
HDFS-2337. DFSClient shouldn't keep multiple RPC proxy references (atm) HDFS-2337. DFSClient shouldn't keep multiple RPC proxy references (atm)
HDFS-362. FSEditLog should not writes long and short as UTF8, and should
not use ArrayWritable for writing non-array items. (Uma Maheswara Rao G
via szetszwo)
BUG FIXES BUG FIXES
HDFS-2287. TestParallelRead has a small off-by-one bug. (todd) HDFS-2287. TestParallelRead has a small off-by-one bug. (todd)
@ -49,9 +53,9 @@ Trunk (unreleased changes)
HDFS-2333. Change DFSOutputStream back to package private, otherwise, HDFS-2333. Change DFSOutputStream back to package private, otherwise,
there are two SC_START_IN_CTOR findbugs warnings. (szetszwo) there are two SC_START_IN_CTOR findbugs warnings. (szetszwo)
HDFS-362. FSEditLog should not writes long and short as UTF8, and should HDFS-2330. In NNStorage and FSImagePreTransactionalStorageInspector,
not use ArrayWritable for writing non-array items. (Uma Maheswara Rao G IOExceptions of stream closures can mask root exceptions. (Uma Maheswara
via szetszwo) Rao G via szetszwo)
Release 0.23.0 - Unreleased Release 0.23.0 - Unreleased

View File

@ -36,6 +36,7 @@
import org.apache.hadoop.hdfs.server.common.Storage.StorageDirectory; import org.apache.hadoop.hdfs.server.common.Storage.StorageDirectory;
import org.apache.hadoop.hdfs.server.namenode.NNStorage.NameNodeDirType; import org.apache.hadoop.hdfs.server.namenode.NNStorage.NameNodeDirType;
import org.apache.hadoop.hdfs.server.namenode.NNStorage.NameNodeFile; import org.apache.hadoop.hdfs.server.namenode.NNStorage.NameNodeFile;
import org.apache.hadoop.io.IOUtils;
/** /**
* Inspects a FSImage storage directory in the "old" (pre-HDFS-1073) format. * Inspects a FSImage storage directory in the "old" (pre-HDFS-1073) format.
@ -130,8 +131,10 @@ static long readCheckpointTime(StorageDirectory sd) throws IOException {
DataInputStream in = new DataInputStream(new FileInputStream(timeFile)); DataInputStream in = new DataInputStream(new FileInputStream(timeFile));
try { try {
timeStamp = in.readLong(); timeStamp = in.readLong();
} finally {
in.close(); in.close();
in = null;
} finally {
IOUtils.cleanup(LOG, in);
} }
} }
return timeStamp; return timeStamp;

View File

@ -173,10 +173,12 @@ public boolean isPreUpgradableLayout(StorageDirectory sd) throws IOException {
try { try {
oldFile.seek(0); oldFile.seek(0);
int oldVersion = oldFile.readInt(); int oldVersion = oldFile.readInt();
oldFile.close();
oldFile = null;
if (oldVersion < LAST_PRE_UPGRADE_LAYOUT_VERSION) if (oldVersion < LAST_PRE_UPGRADE_LAYOUT_VERSION)
return false; return false;
} finally { } finally {
oldFile.close(); IOUtils.cleanup(LOG, oldFile);
} }
return true; return true;
} }
@ -392,6 +394,8 @@ static long readTransactionIdFile(StorageDirectory sd) throws IOException {
BufferedReader br = new BufferedReader(new FileReader(txidFile)); BufferedReader br = new BufferedReader(new FileReader(txidFile));
try { try {
txid = Long.valueOf(br.readLine()); txid = Long.valueOf(br.readLine());
br.close();
br = null;
} finally { } finally {
IOUtils.cleanup(LOG, br); IOUtils.cleanup(LOG, br);
} }
@ -413,6 +417,8 @@ void writeTransactionIdFile(StorageDirectory sd, long txid) throws IOException {
try { try {
fos.write(String.valueOf(txid).getBytes()); fos.write(String.valueOf(txid).getBytes());
fos.write('\n'); fos.write('\n');
fos.close();
fos = null;
} finally { } finally {
IOUtils.cleanup(LOG, fos); IOUtils.cleanup(LOG, fos);
} }