hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oz...@apache.org
Subject hadoop git commit: YARN-3217. Remove httpclient dependency from hadoop-yarn-server-web-proxy. Contributed by Brahma Reddy Battula.
Date Thu, 26 Feb 2015 15:25:33 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 f83d2e441 -> dc348f489


YARN-3217. Remove httpclient dependency from hadoop-yarn-server-web-proxy. Contributed by
Brahma Reddy Battula.

(cherry picked from commit 773b6515ac51af3484824bd6f57685a9726a1e70)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/dc348f48
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/dc348f48
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/dc348f48

Branch: refs/heads/branch-2
Commit: dc348f4894ef7b80d8ff47f1e9c5b5cec4851028
Parents: f83d2e4
Author: Tsuyoshi Ozawa <ozawa@apache.org>
Authored: Fri Feb 27 00:22:46 2015 +0900
Committer: Tsuyoshi Ozawa <ozawa@apache.org>
Committed: Fri Feb 27 00:25:12 2015 +0900

----------------------------------------------------------------------
 hadoop-yarn-project/CHANGES.txt                 |  3 ++
 .../hadoop-yarn-server-web-proxy/pom.xml        |  4 --
 .../server/webproxy/WebAppProxyServlet.java     | 46 ++++++++++----------
 3 files changed, 26 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/dc348f48/hadoop-yarn-project/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt
index e399f17..e747888 100644
--- a/hadoop-yarn-project/CHANGES.txt
+++ b/hadoop-yarn-project/CHANGES.txt
@@ -288,6 +288,9 @@ Release 2.7.0 - UNRELEASED
     YARN-2797. Add -help to yarn logs and nodes CLI command. 
     (Jagadesh Kiran N via devaraj)
 
+    YARN-3217. Remove httpclient dependency from hadoop-yarn-server-web-proxy.
+    (Brahma Reddy Battula via ozawa).
+
   OPTIMIZATIONS
 
     YARN-2990. FairScheduler's delay-scheduling always waits for node-local and 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/dc348f48/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/pom.xml
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/pom.xml
index 959f2a4..dea5f77 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/pom.xml
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/pom.xml
@@ -79,10 +79,6 @@
     </dependency>
 
     <dependency>
-      <groupId>commons-httpclient</groupId>
-      <artifactId>commons-httpclient</artifactId>
-    </dependency>
-    <dependency>
       <groupId>com.google.guava</groupId>
       <artifactId>guava</artifactId>
     </dependency>

http://git-wip-us.apache.org/repos/asf/hadoop/blob/dc348f48/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/WebAppProxyServlet.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/WebAppProxyServlet.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/WebAppProxyServlet.java
index 47f7769..fd98c80 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/WebAppProxyServlet.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/WebAppProxyServlet.java
@@ -40,13 +40,6 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.ws.rs.core.UriBuilder;
 
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HostConfiguration;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.cookie.CookiePolicy;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.params.HttpClientParams;
 import org.apache.hadoop.io.IOUtils;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationReport;
@@ -59,8 +52,15 @@ import org.apache.hadoop.yarn.util.TrackingUriPlugin;
 import org.apache.hadoop.yarn.webapp.MimeType;
 import org.apache.hadoop.yarn.webapp.hamlet.Hamlet;
 import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
+import org.apache.http.Header;
+import org.apache.http.HttpResponse;
 import org.apache.http.NameValuePair;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.params.ClientPNames;
+import org.apache.http.client.params.CookiePolicy;
 import org.apache.http.client.utils.URLEncodedUtils;
+import org.apache.http.conn.params.ConnRoutePNames;
+import org.apache.http.impl.client.DefaultHttpClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -155,23 +155,22 @@ public class WebAppProxyServlet extends HttpServlet {
   private static void proxyLink(HttpServletRequest req, 
       HttpServletResponse resp, URI link, Cookie c, String proxyHost)
       throws IOException {
-    org.apache.commons.httpclient.URI uri = 
-      new org.apache.commons.httpclient.URI(link.toString(), false);
-    HttpClientParams params = new HttpClientParams();
-    params.setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
-    params.setBooleanParameter(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, true);
-    HttpClient client = new HttpClient(params);
+    DefaultHttpClient client = new DefaultHttpClient();
+    client
+        .getParams()
+        .setParameter(ClientPNames.COOKIE_POLICY,
+            CookiePolicy.BROWSER_COMPATIBILITY)
+        .setBooleanParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true);
     // Make sure we send the request from the proxy address in the config
     // since that is what the AM filter checks against. IP aliasing or
     // similar could cause issues otherwise.
-    HostConfiguration config = new HostConfiguration();
     InetAddress localAddress = InetAddress.getByName(proxyHost);
     if (LOG.isDebugEnabled()) {
       LOG.debug("local InetAddress for proxy host: {}", localAddress);
     }
-    config.setLocalAddress(localAddress);
-    HttpMethod method = new GetMethod(uri.getEscapedURI());
-    method.setRequestHeader("Connection","close");
+    client.getParams()
+        .setParameter(ConnRoutePNames.LOCAL_ADDRESS, localAddress);
+    HttpGet httpGet = new HttpGet(link);
     @SuppressWarnings("unchecked")
     Enumeration<String> names = req.getHeaderNames();
     while(names.hasMoreElements()) {
@@ -181,30 +180,31 @@ public class WebAppProxyServlet extends HttpServlet {
         if (LOG.isDebugEnabled()) {
           LOG.debug("REQ HEADER: {} : {}", name, value);
         }
-        method.setRequestHeader(name, value);
+        httpGet.setHeader(name, value);
       }
     }
 
     String user = req.getRemoteUser();
     if (user != null && !user.isEmpty()) {
-      method.setRequestHeader("Cookie",
+      httpGet.setHeader("Cookie",
           PROXY_USER_COOKIE_NAME + "=" + URLEncoder.encode(user, "ASCII"));
     }
     OutputStream out = resp.getOutputStream();
     try {
-      resp.setStatus(client.executeMethod(config, method));
-      for(Header header : method.getResponseHeaders()) {
+      HttpResponse httpResp = client.execute(httpGet);
+      resp.setStatus(httpResp.getStatusLine().getStatusCode());
+      for (Header header : httpResp.getAllHeaders()) {
         resp.setHeader(header.getName(), header.getValue());
       }
       if (c != null) {
         resp.addCookie(c);
       }
-      InputStream in = method.getResponseBodyAsStream();
+      InputStream in = httpResp.getEntity().getContent();
       if (in != null) {
         IOUtils.copyBytes(in, out, 4096, true);
       }
     } finally {
-      method.releaseConnection();
+      httpGet.releaseConnection();
     }
   }
   


Mime
View raw message