YARN-5199. Close LogReader in NMWebServices#getLogs. Contributed by Xuan Gong.
This commit is contained in:
parent
7e09601a90
commit
2be48e7d15
|
@ -36,7 +36,7 @@ import javax.ws.rs.core.Response;
|
||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
import javax.ws.rs.core.StreamingOutput;
|
import javax.ws.rs.core.StreamingOutput;
|
||||||
import javax.ws.rs.core.UriInfo;
|
import javax.ws.rs.core.UriInfo;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.hadoop.classification.InterfaceAudience.Public;
|
import org.apache.hadoop.classification.InterfaceAudience.Public;
|
||||||
import org.apache.hadoop.classification.InterfaceStability.Unstable;
|
import org.apache.hadoop.classification.InterfaceStability.Unstable;
|
||||||
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
||||||
|
@ -241,13 +241,17 @@ public class NMWebServices {
|
||||||
@Override
|
@Override
|
||||||
public void write(OutputStream os) throws IOException,
|
public void write(OutputStream os) throws IOException,
|
||||||
WebApplicationException {
|
WebApplicationException {
|
||||||
int bufferSize = 65536;
|
try {
|
||||||
byte[] buf = new byte[bufferSize];
|
int bufferSize = 65536;
|
||||||
int len;
|
byte[] buf = new byte[bufferSize];
|
||||||
while ((len = fis.read(buf, 0, bufferSize)) > 0) {
|
int len;
|
||||||
os.write(buf, 0, len);
|
while ((len = fis.read(buf, 0, bufferSize)) > 0) {
|
||||||
|
os.write(buf, 0, len);
|
||||||
|
}
|
||||||
|
os.flush();
|
||||||
|
} finally {
|
||||||
|
IOUtils.closeQuietly(fis);
|
||||||
}
|
}
|
||||||
os.flush();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue