YARN-6310. OutputStreams in AggregatedLogFormat.LogWriter can be left open upon exceptions. Contributed by Haibo Chen
(cherry picked from commit deb9f56946
)
This commit is contained in:
parent
9ea6b24c49
commit
1a0358b59a
|
@ -485,34 +485,34 @@ public class AggregatedLogFormat {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeVersion() throws IOException {
|
private void writeVersion() throws IOException {
|
||||||
DataOutputStream out = this.writer.prepareAppendKey(-1);
|
try (DataOutputStream out = this.writer.prepareAppendKey(-1)) {
|
||||||
VERSION_KEY.write(out);
|
VERSION_KEY.write(out);
|
||||||
out.close();
|
}
|
||||||
out = this.writer.prepareAppendValue(-1);
|
try (DataOutputStream out = this.writer.prepareAppendValue(-1)) {
|
||||||
out.writeInt(VERSION);
|
out.writeInt(VERSION);
|
||||||
out.close();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeApplicationOwner(String user) throws IOException {
|
public void writeApplicationOwner(String user) throws IOException {
|
||||||
DataOutputStream out = this.writer.prepareAppendKey(-1);
|
try (DataOutputStream out = this.writer.prepareAppendKey(-1)) {
|
||||||
APPLICATION_OWNER_KEY.write(out);
|
APPLICATION_OWNER_KEY.write(out);
|
||||||
out.close();
|
}
|
||||||
out = this.writer.prepareAppendValue(-1);
|
try (DataOutputStream out = this.writer.prepareAppendValue(-1)) {
|
||||||
out.writeUTF(user);
|
out.writeUTF(user);
|
||||||
out.close();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeApplicationACLs(Map<ApplicationAccessType, String> appAcls)
|
public void writeApplicationACLs(Map<ApplicationAccessType, String> appAcls)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
DataOutputStream out = this.writer.prepareAppendKey(-1);
|
try (DataOutputStream out = this.writer.prepareAppendKey(-1)) {
|
||||||
APPLICATION_ACL_KEY.write(out);
|
APPLICATION_ACL_KEY.write(out);
|
||||||
out.close();
|
}
|
||||||
out = this.writer.prepareAppendValue(-1);
|
try (DataOutputStream out = this.writer.prepareAppendValue(-1)) {
|
||||||
for (Entry<ApplicationAccessType, String> entry : appAcls.entrySet()) {
|
for (Entry<ApplicationAccessType, String> entry : appAcls.entrySet()) {
|
||||||
out.writeUTF(entry.getKey().toString());
|
out.writeUTF(entry.getKey().toString());
|
||||||
out.writeUTF(entry.getValue());
|
out.writeUTF(entry.getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
out.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void append(LogKey logKey, LogValue logValue) throws IOException {
|
public void append(LogKey logKey, LogValue logValue) throws IOException {
|
||||||
|
@ -521,12 +521,12 @@ public class AggregatedLogFormat {
|
||||||
if (pendingUploadFiles.size() == 0) {
|
if (pendingUploadFiles.size() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DataOutputStream out = this.writer.prepareAppendKey(-1);
|
try (DataOutputStream out = this.writer.prepareAppendKey(-1)) {
|
||||||
logKey.write(out);
|
logKey.write(out);
|
||||||
out.close();
|
}
|
||||||
out = this.writer.prepareAppendValue(-1);
|
try (DataOutputStream out = this.writer.prepareAppendValue(-1)) {
|
||||||
logValue.write(out, pendingUploadFiles);
|
logValue.write(out, pendingUploadFiles);
|
||||||
out.close();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
|
|
Loading…
Reference in New Issue