Skip to content

Commit d6978fe

Browse files
belugabehrJonathan Eagles
authored andcommitted
TEZ-4268: Buffer File Read of TEZ AM Local Resources PB File (#91)
(cherry picked from commit 7374b69)
1 parent bef8632 commit d6978fe

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

tez-dag/src/main/java/org/apache/tez/dag/app/DAGAppMaster.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121

2222

23+
import java.io.BufferedInputStream;
2324
import java.io.File;
2425
import java.io.FileInputStream;
2526
import java.io.FileNotFoundException;
@@ -608,17 +609,14 @@ public synchronized void serviceInit(final Configuration conf) throws Exception
608609

609610
if (!versionMismatch) {
610611
if (isSession) {
611-
FileInputStream sessionResourcesStream = null;
612-
try {
613-
sessionResourcesStream = new FileInputStream(
614-
new File(workingDirectory, TezConstants.TEZ_AM_LOCAL_RESOURCES_PB_FILE_NAME));
612+
try (BufferedInputStream sessionResourcesStream =
613+
new BufferedInputStream(
614+
new FileInputStream(new File(workingDirectory,
615+
TezConstants.TEZ_AM_LOCAL_RESOURCES_PB_FILE_NAME)))) {
615616
PlanLocalResourcesProto amLocalResourceProto = PlanLocalResourcesProto
616617
.parseDelimitedFrom(sessionResourcesStream);
617-
amResources.putAll(DagTypeConverters.convertFromPlanLocalResources(amLocalResourceProto));
618-
} finally {
619-
if (sessionResourcesStream != null) {
620-
sessionResourcesStream.close();
621-
}
618+
amResources.putAll(DagTypeConverters
619+
.convertFromPlanLocalResources(amLocalResourceProto));
622620
}
623621
}
624622
}

0 commit comments

Comments
 (0)