YARN-2484. FileSystemRMStateStore#readFile/writeFile should close FSData(In|Out)putStream in final block. Contributed by Tsuyoshi OZAWA
This commit is contained in:
parent
469ea3dcef
commit
78b048393a
|
@ -334,6 +334,9 @@ Release 2.6.0 - UNRELEASED
|
||||||
|
|
||||||
YARN-2541. Fixed ResourceManagerRest.apt.vm table syntax error. (jianhe)
|
YARN-2541. Fixed ResourceManagerRest.apt.vm table syntax error. (jianhe)
|
||||||
|
|
||||||
|
YARN-2484. FileSystemRMStateStore#readFile/writeFile should close
|
||||||
|
FSData(In|Out)putStream in final block (Tsuyoshi OZAWA via jlowe)
|
||||||
|
|
||||||
Release 2.5.1 - 2014-09-05
|
Release 2.5.1 - 2014-09-05
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.apache.hadoop.fs.FileSystem;
|
||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.fs.PathFilter;
|
import org.apache.hadoop.fs.PathFilter;
|
||||||
import org.apache.hadoop.io.DataInputByteBuffer;
|
import org.apache.hadoop.io.DataInputByteBuffer;
|
||||||
|
import org.apache.hadoop.io.IOUtils;
|
||||||
import org.apache.hadoop.security.Credentials;
|
import org.apache.hadoop.security.Credentials;
|
||||||
import org.apache.hadoop.security.token.delegation.DelegationKey;
|
import org.apache.hadoop.security.token.delegation.DelegationKey;
|
||||||
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
|
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
|
||||||
|
@ -573,12 +574,16 @@ public class FileSystemRMStateStore extends RMStateStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] readFile(Path inputPath, long len) throws Exception {
|
private byte[] readFile(Path inputPath, long len) throws Exception {
|
||||||
FSDataInputStream fsIn = fs.open(inputPath);
|
FSDataInputStream fsIn = null;
|
||||||
// state data will not be that "long"
|
try {
|
||||||
byte[] data = new byte[(int)len];
|
fsIn = fs.open(inputPath);
|
||||||
fsIn.readFully(data);
|
// state data will not be that "long"
|
||||||
fsIn.close();
|
byte[] data = new byte[(int) len];
|
||||||
return data;
|
fsIn.readFully(data);
|
||||||
|
return data;
|
||||||
|
} finally {
|
||||||
|
IOUtils.cleanup(LOG, fsIn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -592,10 +597,15 @@ public class FileSystemRMStateStore extends RMStateStore {
|
||||||
FSDataOutputStream fsOut = null;
|
FSDataOutputStream fsOut = null;
|
||||||
// This file will be overwritten when app/attempt finishes for saving the
|
// This file will be overwritten when app/attempt finishes for saving the
|
||||||
// final status.
|
// final status.
|
||||||
fsOut = fs.create(tempPath, true);
|
try {
|
||||||
fsOut.write(data);
|
fsOut = fs.create(tempPath, true);
|
||||||
fsOut.close();
|
fsOut.write(data);
|
||||||
fs.rename(tempPath, outputPath);
|
fsOut.close();
|
||||||
|
fsOut = null;
|
||||||
|
fs.rename(tempPath, outputPath);
|
||||||
|
} finally {
|
||||||
|
IOUtils.cleanup(LOG, fsOut);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue