You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sm...@apache.org on 2016/07/30 01:27:29 UTC

ambari git commit: AMBARI-17966. Remove unneeded commons-httpclient dependencies from Ambari Slider View

Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 c6cdafd20 -> 5977156a0


AMBARI-17966. Remove unneeded commons-httpclient dependencies from Ambari Slider View


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

Branch: refs/heads/branch-2.4
Commit: 5977156a072a20cd3a57427db99d734a40fd946a
Parents: c6cdafd
Author: Sumit Mohanty <sm...@hortonworks.com>
Authored: Fri Jul 29 18:26:51 2016 -0700
Committer: Sumit Mohanty <sm...@hortonworks.com>
Committed: Fri Jul 29 18:26:51 2016 -0700

----------------------------------------------------------------------
 .../slider/rest/client/AmbariHttpClient.java    | 36 --------------------
 .../view/slider/rest/client/BaseHttpClient.java | 16 +++------
 .../rest/client/SliderAppMasterClient.java      |  8 -----
 3 files changed, 5 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5977156a/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/rest/client/AmbariHttpClient.java
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/rest/client/AmbariHttpClient.java b/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/rest/client/AmbariHttpClient.java
index de075df..74578c9 100644
--- a/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/rest/client/AmbariHttpClient.java
+++ b/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/rest/client/AmbariHttpClient.java
@@ -19,7 +19,6 @@
 package org.apache.ambari.view.slider.rest.client;
 
 import java.io.IOException;
-import java.io.StringReader;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -34,14 +33,10 @@ import org.apache.ambari.view.slider.clients.AmbariHostComponent;
 import org.apache.ambari.view.slider.clients.AmbariHostInfo;
 import org.apache.ambari.view.slider.clients.AmbariService;
 import org.apache.ambari.view.slider.clients.AmbariServiceInfo;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpStatus;
 
 import com.google.gson.JsonArray;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
-import com.google.gson.stream.JsonReader;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -53,22 +48,6 @@ public class AmbariHttpClient extends BaseHttpClient implements AmbariClient {
 			ViewContext viewContext) {
 		super(url, userId, password, viewContext);
 	}
-	
-    @SuppressWarnings("deprecation")
-    private RuntimeException createRuntimeException(HttpException httpException) {
-      String message = httpException.getMessage();
-      try {
-        JsonElement jsonElement = new JsonParser().parse(new JsonReader(new StringReader(httpException.getMessage())));
-        if (jsonElement != null && jsonElement.getAsJsonObject().has("message")) {
-          message = jsonElement.getAsJsonObject().get("message").getAsString();
-        }
-      } catch (Throwable t) {
-      }
-      if (httpException.getReasonCode() != HttpStatus.SC_OK) {
-        message = httpException.getReasonCode() + " " + httpException.getReason() + ": " + message;
-      }
-      return new RuntimeException(message, httpException);
-    }
 
     /**
      * Provides the first cluster defined on this Ambari server.
@@ -91,9 +70,6 @@ public class AmbariHttpClient extends BaseHttpClient implements AmbariClient {
                 cluster.setVersion(clusterObj.get("version").getAsString());
                 return cluster;
             }
-        } catch (HttpException e) {
-            logger.warn("Unable to determine Ambari clusters", e);
-            throw createRuntimeException(e);
         } catch (IOException e) {
             logger.warn("Unable to determine Ambari clusters", e);
             throw new RuntimeException(e.getMessage(), e);
@@ -119,8 +95,6 @@ public class AmbariHttpClient extends BaseHttpClient implements AmbariClient {
             }
           }
         }
-      } catch (HttpException e) {
-        logger.warn("Unable to determine Ambari clusters", e);
       } catch (IOException e) {
         logger.warn("Unable to determine Ambari clusters", e);
       }
@@ -177,10 +151,6 @@ public class AmbariHttpClient extends BaseHttpClient implements AmbariClient {
 			  logger.warn("Unable to determine Ambari cluster details - "
 			      + clusterInfo.getName(), e);
 			  throw new RuntimeException(e.getMessage(), e);
-			} catch (HttpException e) {
-				logger.warn("Unable to determine Ambari cluster details - "
-				    + clusterInfo.getName(), e);
-				throw createRuntimeException(e);
 			} catch (IOException e) {
 				logger.warn("Unable to determine Ambari cluster details - "
 				    + clusterInfo.getName(), e);
@@ -212,9 +182,6 @@ public class AmbariHttpClient extends BaseHttpClient implements AmbariClient {
 				    return properties;
 				  }
 				}
-			} catch (HttpException e) {
-				logger.warn("Unable to determine Ambari clusters", e);
-				throw createRuntimeException(e);
 			} catch (IOException e) {
 				logger.warn("Unable to determine Ambari clusters", e);
 				throw new RuntimeException(e.getMessage(), e);
@@ -255,9 +222,6 @@ public class AmbariHttpClient extends BaseHttpClient implements AmbariClient {
             }
             svc.setComponentsToHostComponentsMap(componentsToHostComponentsMap);
             return svc;
-        } catch (HttpException e) {
-            logger.warn("Unable to determine Ambari clusters", e);
-            throw createRuntimeException(e);
         } catch (IOException e) {
             logger.warn("Unable to determine Ambari clusters", e);
             throw new RuntimeException(e.getMessage(), e);

http://git-wip-us.apache.org/repos/asf/ambari/blob/5977156a/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/rest/client/BaseHttpClient.java
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/rest/client/BaseHttpClient.java b/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/rest/client/BaseHttpClient.java
index ce30a10..bfc4d3a 100644
--- a/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/rest/client/BaseHttpClient.java
+++ b/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/rest/client/BaseHttpClient.java
@@ -27,7 +27,6 @@ import java.util.Map;
 import org.apache.ambari.view.URLStreamProvider;
 import org.apache.ambari.view.ViewContext;
 import org.apache.ambari.view.utils.ambari.AmbariApi;
-import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.io.IOUtils;
 
 import com.google.gson.JsonElement;
@@ -111,12 +110,11 @@ public class BaseHttpClient {
 		this.password = password;
 	}
 
-	public JsonElement doGetJson(String path) throws HttpException, IOException {
+	public JsonElement doGetJson(String path) throws IOException {
 		return doGetJson(getUrl(), path);
 	}
 
-	public JsonElement doGetJson(String url, String path) throws HttpException,
-			IOException {
+	public JsonElement doGetJson(String url, String path) throws IOException {
 		InputStream inputStream = null;
 		try {
 			Map<String, String> headers = new HashMap<String, String>();
@@ -129,16 +127,14 @@ public class BaseHttpClient {
 			}
 		} catch (IOException e) {
 			logger.error("Error while reading from url " + url + path, e);
-			HttpException httpException = new HttpException(
-					e.getLocalizedMessage());
-			throw httpException;
+			throw e;
 		}
 		JsonElement jsonElement = new JsonParser().parse(new JsonReader(
 				new InputStreamReader(inputStream)));
 		return jsonElement;
 	}
 
-	public String doGet(String path) throws HttpException, IOException {
+	public String doGet(String path) throws IOException {
 		String response = null;
 		try {
 			InputStream inputStream = null;
@@ -154,9 +150,7 @@ public class BaseHttpClient {
 			response = IOUtils.toString(inputStream);
 		} catch (IOException e) {
 			logger.error("Error while reading from url " + getUrl() + path, e);
-			HttpException httpException = new HttpException(
-					e.getLocalizedMessage());
-			throw httpException;
+			throw e;
 		}
 		return response;
 	}

http://git-wip-us.apache.org/repos/asf/ambari/blob/5977156a/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/rest/client/SliderAppMasterClient.java
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/rest/client/SliderAppMasterClient.java b/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/rest/client/SliderAppMasterClient.java
index 708a214..0a2540c 100644
--- a/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/rest/client/SliderAppMasterClient.java
+++ b/contrib/views/slider/src/main/java/org/apache/ambari/view/slider/rest/client/SliderAppMasterClient.java
@@ -34,7 +34,6 @@ import org.apache.ambari.view.slider.MetricsHolder;
 import org.apache.ambari.view.slider.SliderAppType;
 import org.apache.ambari.view.slider.SliderAppTypeComponent;
 import org.apache.ambari.view.slider.TemporalInfo;
-import org.apache.commons.httpclient.HttpException;
 import org.apache.ambari.view.slider.SliderAppsViewController;
 
 import com.google.gson.JsonElement;
@@ -77,9 +76,6 @@ public class SliderAppMasterClient extends BaseHttpClient {
           return data;
         }
       }
-    } catch (HttpException e) {
-      logger.warn("Unable to determine Ambari clusters", e);
-      throw new RuntimeException(e.getMessage(), e);
     } catch (IOException e) {
       logger.warn("Unable to determine Ambari clusters", e);
       throw new RuntimeException(e.getMessage(), e);
@@ -112,8 +108,6 @@ public class SliderAppMasterClient extends BaseHttpClient {
           }
         }
       }
-    } catch (HttpException e) {
-      logger.warn("Unable to determine quicklinks from " + providerUrl, e);
     } catch (IOException e) {
       logger.warn("Unable to determine quicklinks from " + providerUrl, e);
     }
@@ -150,8 +144,6 @@ public class SliderAppMasterClient extends BaseHttpClient {
           }
         }
       }
-    } catch (HttpException e) {
-      logger.warn("Unable to determine quicklinks from " + providerUrl, e);
     } catch (IOException e) {
       logger.warn("Unable to determine quicklinks from " + providerUrl, e);
     }