HADOOP-14902. LoadGenerator#genFile write close timing is incorrectly calculated. Contributed by Hanisha Koneru

(cherry picked from commit 6f789fe05766a61b12ca10df3f26ee354eac84aa)

Conflicts:
	hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/loadGenerator/LoadGenerator.java
This commit is contained in:
Jason Lowe 2017-09-28 16:38:30 -05:00
parent ba5656d5e0
commit 949525b81a

View File

@ -322,6 +322,7 @@ private void list() throws IOException {
private void genFile(Path file, long fileSize) throws IOException {
long startTimestamp = Time.monotonicNow();
FSDataOutputStream out = null;
boolean isOutClosed = false;
try {
out = fc.create(file,
EnumSet.of(CreateFlag.CREATE, CreateFlag.OVERWRITE),
@ -337,11 +338,15 @@ private void genFile(Path file, long fileSize) throws IOException {
i -= s;
}
startTimestamp = Time.monotonicNow();
executionTime[WRITE_CLOSE] += (Time.monotonicNow() - startTimestamp);
startTime = Time.monotonicNow();
out.close();
executionTime[WRITE_CLOSE] += (Time.monotonicNow() - startTime);
numOfOps[WRITE_CLOSE]++;
isOutClosed = true;
} finally {
IOUtils.cleanup(LOG, out);
if (!isOutClosed && out != null) {
out.close();
}
}
}
}