YARN-3882. AggregatedLogFormat should close aclScanner and ownerScanner

after create them. Contributed by zhihai xu
This commit is contained in:
Xuan 2015-07-04 21:51:58 -07:00
parent 2eae130ab9
commit 688617d6d7
2 changed files with 49 additions and 37 deletions

View File

@ -589,6 +589,9 @@ Release 2.8.0 - UNRELEASED
YARN-3875. FSSchedulerNode#reserveResource() doesn't print Application Id YARN-3875. FSSchedulerNode#reserveResource() doesn't print Application Id
properly in log. (Bibin A Chundatt via devaraj) properly in log. (Bibin A Chundatt via devaraj)
YARN-3882. AggregatedLogFormat should close aclScanner and ownerScanner
after create them. (zhihai xu via xgong)
Release 2.7.2 - UNRELEASED Release 2.7.2 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -489,7 +489,9 @@ public class AggregatedLogFormat {
* @throws IOException * @throws IOException
*/ */
public String getApplicationOwner() throws IOException { public String getApplicationOwner() throws IOException {
TFile.Reader.Scanner ownerScanner = reader.createScanner(); TFile.Reader.Scanner ownerScanner = null;
try {
ownerScanner = reader.createScanner();
LogKey key = new LogKey(); LogKey key = new LogKey();
while (!ownerScanner.atEnd()) { while (!ownerScanner.atEnd()) {
TFile.Reader.Scanner.Entry entry = ownerScanner.entry(); TFile.Reader.Scanner.Entry entry = ownerScanner.entry();
@ -501,6 +503,9 @@ public class AggregatedLogFormat {
ownerScanner.advance(); ownerScanner.advance();
} }
return null; return null;
} finally {
IOUtils.cleanup(LOG, ownerScanner);
}
} }
/** /**
@ -513,7 +518,9 @@ public class AggregatedLogFormat {
public Map<ApplicationAccessType, String> getApplicationAcls() public Map<ApplicationAccessType, String> getApplicationAcls()
throws IOException { throws IOException {
// TODO Seek directly to the key once a comparator is specified. // TODO Seek directly to the key once a comparator is specified.
TFile.Reader.Scanner aclScanner = reader.createScanner(); TFile.Reader.Scanner aclScanner = null;
try {
aclScanner = reader.createScanner();
LogKey key = new LogKey(); LogKey key = new LogKey();
Map<ApplicationAccessType, String> acls = Map<ApplicationAccessType, String> acls =
new HashMap<ApplicationAccessType, String>(); new HashMap<ApplicationAccessType, String>();
@ -538,11 +545,13 @@ public class AggregatedLogFormat {
} }
acls.put(ApplicationAccessType.valueOf(appAccessOp), aclString); acls.put(ApplicationAccessType.valueOf(appAccessOp), aclString);
} }
} }
aclScanner.advance(); aclScanner.advance();
} }
return acls; return acls;
} finally {
IOUtils.cleanup(LOG, aclScanner);
}
} }
/** /**