This is an automated email from the ASF dual-hosted git repository.
prabhujoseph pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new 571795c YARN-10068. Fix TimelineV2Client leaking File Descriptors.
571795c is described below
commit 571795cd180d3077e8ba189b3b70e81f0d1a7044
Author: Prabhu Joseph <[email protected]>
AuthorDate: Wed Jan 8 12:00:22 2020 +0530
YARN-10068. Fix TimelineV2Client leaking File Descriptors.
Contributed by Anand Srinivasan. Reviewed by Adam Antal.
---
.../yarn/client/api/impl/TimelineV2ClientImpl.java | 40 ++++++++++++++++++----
1 file changed, 34 insertions(+), 6 deletions(-)
diff --git
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/api/impl/TimelineV2ClientImpl.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/api/impl/TimelineV2ClientImpl.java
index e086e27..6536956 100644
---
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/api/impl/TimelineV2ClientImpl.java
+++
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/api/impl/TimelineV2ClientImpl.java
@@ -57,6 +57,8 @@ import
org.apache.hadoop.yarn.security.client.TimelineDelegationTokenIdentifier;
import com.google.common.annotations.VisibleForTesting;
import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.ClientHandlerException;
+import com.sun.jersey.api.client.UniformInterfaceException;
import com.sun.jersey.core.util.MultivaluedMapImpl;
/**
@@ -313,14 +315,40 @@ public class TimelineV2ClientImpl extends
TimelineV2Client {
} catch (InterruptedException ie) {
throw (IOException) new InterruptedIOException().initCause(ie);
}
- if (resp == null || resp.getStatusInfo()
- .getStatusCode() != ClientResponse.Status.OK.getStatusCode()) {
- String msg =
- "Response from the timeline server is " + ((resp == null) ? "null"
- : "not successful," + " HTTP error code: " + resp.getStatus()
- + ", Server response:\n" + resp.getEntity(String.class));
+
+ //Close ClientResponse's input stream as we are done posting objects.
+ //ClientResponse#getEntity closes the input stream upon failure in
+ //processing HTTP response.
+ if (resp == null) {
+ String msg = "Error getting HTTP response from the timeline server.";
LOG.error(msg);
throw new YarnException(msg);
+ } else if (resp.getStatusInfo().getStatusCode()
+ == ClientResponse.Status.OK.getStatusCode()) {
+ try {
+ resp.close();
+ } catch(ClientHandlerException che) {
+ LOG.warn("Error closing the HTTP response's inputstream. ", che);
+ }
+ } else {
+ String msg = "";
+ try {
+ String stringType = resp.getEntity(String.class);
+ msg = "Server response:\n" + stringType;
+ } catch (ClientHandlerException | UniformInterfaceException chuie) {
+ msg = "Error getting entity from the HTTP response."
+ + chuie.getLocalizedMessage();
+ } catch (Throwable t) {
+ msg = "Error getting entity from the HTTP response."
+ + t.getLocalizedMessage();
+ } finally {
+ msg = "Response from the timeline server is not successful"
+ + ", HTTP error code: " + resp.getStatus()
+ + ", "
+ + msg;
+ LOG.error(msg);
+ throw new YarnException(msg);
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]