Repository: ambari
Updated Branches:
  refs/heads/trunk fe690bfdc -> 89c6f2628


AMBARI-14058. "Application Tracking URL" in Tez View broken due to RM HA 
changes in Ambari views framework. (Dipayan Bhowmick)


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

Branch: refs/heads/trunk
Commit: 89c6f26286540651ee46bcb50f618014863c5e79
Parents: fe690bf
Author: Yusaku Sako <[email protected]>
Authored: Mon Nov 30 15:51:15 2015 -0800
Committer: Yusaku Sako <[email protected]>
Committed: Mon Nov 30 15:51:15 2015 -0800

----------------------------------------------------------------------
 .../ambari/view/tez/rest/BaseProxyResource.java | 21 +++++++++++++++++++-
 .../resources/ui/scripts/init-ambari-view.js    |  3 +++
 2 files changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/89c6f262/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 3670a40..5f8fb91 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
@@ -19,6 +19,7 @@
 package org.apache.ambari.view.tez.rest;
 
 import com.google.inject.Inject;
+import org.apache.ambari.view.tez.exceptions.ProxyException;
 import org.apache.ambari.view.tez.utils.ProxyHelper;
 import org.json.simple.JSONObject;
 import org.json.simple.JSONValue;
@@ -27,7 +28,13 @@ import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
-import javax.ws.rs.core.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.HashMap;
 
 /**
@@ -50,6 +57,18 @@ public abstract class BaseProxyResource {
     String response = proxyHelper.getResponse(url, new HashMap<String, 
String>());
 
     JSONObject jsonObject = (JSONObject) JSONValue.parse(response);
+
+    // If the endpoint returns some other format apart from JSON,
+    // we will only redirect the request. This is required because UI may call
+    // the proxy endpoint to directly point to any URL of RM/ATS.
+    if (jsonObject == null) {
+      try {
+        return Response.temporaryRedirect(new URI(url)).build();
+      } catch (URISyntaxException e) {
+        throw new ProxyException("Failed to set the redirection url to : " + 
url + ".Internal Error.",
+          Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), 
e.getMessage());
+      }
+    }
     return Response.ok(jsonObject).type(MediaType.APPLICATION_JSON).build();
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/89c6f262/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js
----------------------------------------------------------------------
diff --git 
a/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js 
b/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js
index 5152fb9..c443726 100644
--- a/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js
+++ b/contrib/views/tez/src/main/resources/ui/scripts/init-ambari-view.js
@@ -164,6 +164,9 @@ function setConfigs() {
       aminfo: '%@rmproxy/proxy/__app_id__/ws/v1/tez'.fmt(resourcesPrefix),
       aminfoV2: '%@rmproxy/proxy/__app_id__/ws/v2/tez'.fmt(resourcesPrefix),
       cluster: '%@rmproxy/ws/v1/cluster'.fmt(resourcesPrefix)
+    },
+    otherNamespace: {
+      cluster: '%@rmproxy/cluster'.fmt(resourcesPrefix)
     }
   });
 

Reply via email to