Repository: ambari Updated Branches: refs/heads/branch-2.4 b8694fd7f -> 16cd808e6
Revert "AMBARI-17186. Tez View: Improve proxy logging. (Sreenath Somarajapuram via dipayanb)" This reverts commit bb5878c04edd4b40dae6329083468d480cfdcc65. Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/16cd808e Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/16cd808e Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/16cd808e Branch: refs/heads/branch-2.4 Commit: 16cd808e63bab4b8b4e4f82b4f8ef533c5e1e1fe Parents: b8694fd Author: Aravindan Vijayan <[email protected]> Authored: Fri Jun 17 13:40:52 2016 -0700 Committer: Aravindan Vijayan <[email protected]> Committed: Fri Jun 17 13:40:52 2016 -0700 ---------------------------------------------------------------------- .../ambari/view/tez/ViewControllerImpl.java | 24 +++-------- .../tez/exceptions/ATSUrlFetchException.java | 32 ++++++++++++++ .../tez/exceptions/ActiveRMFetchException.java | 32 ++++++++++++++ .../exceptions/ConfigurationFetchException.java | 44 -------------------- .../ambari/view/tez/rest/BaseProxyResource.java | 28 +++---------- .../view/tez/rest/BaseRedirectionResource.java | 6 --- 6 files changed, 75 insertions(+), 91 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/16cd808e/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewControllerImpl.java ---------------------------------------------------------------------- diff --git a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewControllerImpl.java b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewControllerImpl.java index b15fe50..981353b 100644 --- a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewControllerImpl.java +++ b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/ViewControllerImpl.java @@ -18,19 +18,19 @@ package org.apache.ambari.view.tez; +import java.lang.String; import java.util.HashMap; import java.util.Map; import org.apache.ambari.view.ViewContext; import org.apache.ambari.view.cluster.Cluster; -import org.apache.ambari.view.tez.exceptions.ConfigurationFetchException; +import org.apache.ambari.view.tez.exceptions.ATSUrlFetchException; +import org.apache.ambari.view.tez.exceptions.ActiveRMFetchException; import org.apache.ambari.view.utils.ambari.AmbariApi; import org.apache.ambari.view.utils.ambari.AmbariApiException; import org.slf4j.LoggerFactory; import org.slf4j.Logger; -import javax.ws.rs.core.Response; - import com.google.inject.Inject; import com.google.inject.Singleton; @@ -42,8 +42,6 @@ public class ViewControllerImpl implements ViewController { private AmbariApi ambariApi; - private static final Logger LOG = LoggerFactory.getLogger(ViewControllerImpl.class); - @Inject public ViewControllerImpl(ViewContext viewContext) { this.ambariApi = new AmbariApi(viewContext); @@ -73,9 +71,7 @@ public class ViewControllerImpl implements ViewController { try { return ambariApi.getServices().getTimelineServerUrl(); } catch (AmbariApiException ex) { - String message = "Failed to find YARN Timeline Server location!"; - LOG.error(message, ex); - throw new ConfigurationFetchException(message, ex); + throw new ATSUrlFetchException(ex); } } @@ -84,21 +80,13 @@ public class ViewControllerImpl implements ViewController { try { return ambariApi.getServices().getRMUrl(); } catch (AmbariApiException ex) { - String message = "Failed to find Active ResourceManager location!"; - LOG.error(message, ex); - throw new ConfigurationFetchException(message, ex); + throw new ActiveRMFetchException(ex); } } @Override public String getYARNProtocol() { - try { - return ambariApi.getServices().getYARNProtocol(); - } catch (AmbariApiException ex) { - String message = "Failed to find YARN http/https protocol configuration value!"; - LOG.error(message, ex); - throw new ConfigurationFetchException(message, ex); - } + return ambariApi.getServices().getYARNProtocol(); } } http://git-wip-us.apache.org/repos/asf/ambari/blob/16cd808e/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/exceptions/ATSUrlFetchException.java ---------------------------------------------------------------------- diff --git a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/exceptions/ATSUrlFetchException.java b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/exceptions/ATSUrlFetchException.java new file mode 100644 index 0000000..9eb7c47 --- /dev/null +++ b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/exceptions/ATSUrlFetchException.java @@ -0,0 +1,32 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.view.tez.exceptions; + +import org.apache.ambari.view.utils.ambari.AmbariApiException; + +import javax.ws.rs.WebApplicationException; + +public class ATSUrlFetchException extends WebApplicationException { + + public ATSUrlFetchException(AmbariApiException ex) { + super(ex.toEntity()); + + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/16cd808e/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/exceptions/ActiveRMFetchException.java ---------------------------------------------------------------------- diff --git a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/exceptions/ActiveRMFetchException.java b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/exceptions/ActiveRMFetchException.java new file mode 100644 index 0000000..cb6f2eb --- /dev/null +++ b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/exceptions/ActiveRMFetchException.java @@ -0,0 +1,32 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.view.tez.exceptions; + + +import org.apache.ambari.view.utils.ambari.AmbariApiException; + +import javax.ws.rs.WebApplicationException; + +public class ActiveRMFetchException extends WebApplicationException { + + public ActiveRMFetchException(AmbariApiException ex) { + super(ex.toEntity()); + + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/16cd808e/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/exceptions/ConfigurationFetchException.java ---------------------------------------------------------------------- diff --git a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/exceptions/ConfigurationFetchException.java b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/exceptions/ConfigurationFetchException.java deleted file mode 100644 index f9f40b8..0000000 --- a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/exceptions/ConfigurationFetchException.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.view.tez.exceptions; - -import org.apache.ambari.view.utils.ambari.AmbariApiException; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.lang.Throwable; -import java.util.HashMap; -import java.util.Map; - -public class ConfigurationFetchException extends WebApplicationException { - - public ConfigurationFetchException(String message, AmbariApiException ex) { - super(toEntity(message, ex)); - } - - private static Response toEntity(String message, AmbariApiException ex) { - Map<String, Object> json = new HashMap<>(); - int status = Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(); - json.put("message", String.join(". ", message, ex.getMessage()) ); - json.put("status", status); - json.put("trace", ex.getCause()); - return Response.status(status).entity(json).type(MediaType.APPLICATION_JSON).build(); - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/16cd808e/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/rest/BaseProxyResource.java ---------------------------------------------------------------------- diff --git a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/rest/BaseProxyResource.java b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/rest/BaseProxyResource.java index 9f1581a..619f81e 100644 --- a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/rest/BaseProxyResource.java +++ b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/rest/BaseProxyResource.java @@ -34,9 +34,6 @@ import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import java.util.HashMap; -import org.slf4j.LoggerFactory; -import org.slf4j.Logger; -import javax.ws.rs.WebApplicationException; /** * Base class for the proxy resources @@ -45,8 +42,6 @@ public abstract class BaseProxyResource { private ProxyHelper proxyHelper; - private static final Logger LOG = LoggerFactory.getLogger(BaseProxyResource.class); - @Inject public BaseProxyResource(ProxyHelper proxyHelper) { this.proxyHelper = proxyHelper; @@ -59,26 +54,13 @@ public abstract class BaseProxyResource { String url = getProxyUrl(endpoint, uriInfo.getQueryParameters()); String response = proxyHelper.getResponse(url, new HashMap<String, String>()); - try { - JSONObject jsonObject = (JSONObject) JSONValue.parse(response); - - if (jsonObject == null) { - LOG.debug("Response received from URL: {} : {}", url, response); - LOG.error("Failed to parse JSON from URL: {}", url); - throw new ProxyException("Failed to parse JSON from URL : " + url + ".Internal Error.", - Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response); - } + JSONObject jsonObject = (JSONObject) JSONValue.parse(response); - LOG.debug("Proxying to URL: {}", url); - return Response.ok(jsonObject).type(MediaType.APPLICATION_JSON).build(); + if (jsonObject == null) { + throw new ProxyException("Failed to parse JSON from URL : " + url + ".Internal Error.", + Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response); } - catch(WebApplicationException e) { - LOG.debug("Response received from URL: {} : {}", url, response); - LOG.error("Proxying to URL {} failed: ", url, e); - throw new ProxyException("Failed to proxy to : " + url + ".Internal Error.", - Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e.getMessage()); - } - + return Response.ok(jsonObject).type(MediaType.APPLICATION_JSON).build(); } public abstract String getProxyUrl(String endpoint, MultivaluedMap<String, String> queryParams); http://git-wip-us.apache.org/repos/asf/ambari/blob/16cd808e/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/rest/BaseRedirectionResource.java ---------------------------------------------------------------------- diff --git a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/rest/BaseRedirectionResource.java b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/rest/BaseRedirectionResource.java index 0250bce..97ee01d 100644 --- a/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/rest/BaseRedirectionResource.java +++ b/contrib/views/tez/src/main/java/org/apache/ambari/view/tez/rest/BaseRedirectionResource.java @@ -29,8 +29,6 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import java.net.URI; import java.net.URISyntaxException; -import org.slf4j.LoggerFactory; -import org.slf4j.Logger; /** * Base class for resources which will redirect the call to the active URL by fetching the current active URL. @@ -38,17 +36,13 @@ import org.slf4j.Logger; */ public abstract class BaseRedirectionResource { - private static final Logger LOG = LoggerFactory.getLogger(BaseRedirectionResource.class); - @Path("/{endpoint:.+}") @GET public Response getData(@Context UriInfo uriInfo, @PathParam("endpoint") String endpoint) { String url = getProxyUrl(endpoint, uriInfo.getQueryParameters()); try { - LOG.debug("Redirecting to URL: {}", url); return Response.temporaryRedirect(new URI(url)).build(); } catch (URISyntaxException e) { - LOG.error("Redirecting to URL {} failed: ", url, e); throw new ProxyException("Failed to set the redirection url to : " + url + ".Internal Error.", Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e.getMessage()); }
