You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sr...@apache.org on 2015/10/27 22:03:44 UTC

ambari git commit: AMBARI-13515. When both RM are standby, Tez view can not be seen (DIPAYAN BHOWMICK via srimanth)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 795ddda1a -> 1d50022db


AMBARI-13515. When both RM are standby, Tez view can not be seen (DIPAYAN BHOWMICK via srimanth)


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

Branch: refs/heads/branch-2.1
Commit: 1d50022db3bd26e38670392d41b7fd9fe6166d4c
Parents: 795ddda
Author: Srimanth Gunturi <sg...@hortonworks.com>
Authored: Tue Oct 27 14:03:13 2015 -0700
Committer: Srimanth Gunturi <sg...@hortonworks.com>
Committed: Tue Oct 27 14:03:19 2015 -0700

----------------------------------------------------------------------
 .../ambari/view/tez/ViewControllerImpl.java     | 18 +++++++++--
 .../tez/exceptions/ATSUrlFetchException.java    | 32 ++++++++++++++++++++
 .../tez/exceptions/ActiveRMFetchException.java  | 32 ++++++++++++++++++++
 .../resources/ui/scripts/init-ambari-view.js    |  5 ++-
 .../view/utils/ambari/AmbariApiException.java   | 13 ++++++++
 5 files changed, 95 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1d50022d/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 ba98ade..3fad9e9 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
@@ -24,7 +24,10 @@ import java.util.Map;
 
 import org.apache.ambari.view.ViewContext;
 import org.apache.ambari.view.cluster.Cluster;
+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;
 
@@ -54,10 +57,21 @@ public class ViewControllerImpl implements ViewController {
    */
   @Override
   public ViewStatus getViewStatus() {
+
     ViewStatus status = new ViewStatus();
     Map<String, String> parameters = new HashMap<String, String>();
-    parameters.put(ViewController.PARAM_YARN_ATS_URL, ambariApi.getServices().getTimelineServerUrl());
-    parameters.put(ViewController.PARAM_YARN_RESOURCEMANAGER_URL, ambariApi.getServices().getRMUrl());
+    try {
+      parameters.put(ViewController.PARAM_YARN_ATS_URL, ambariApi.getServices().getTimelineServerUrl());
+    } catch (AmbariApiException ex) {
+      throw new ATSUrlFetchException(ex);
+    }
+
+    try {
+      parameters.put(ViewController.PARAM_YARN_RESOURCEMANAGER_URL, ambariApi.getServices().getRMUrl());
+    } catch (AmbariApiException ex) {
+      throw new ActiveRMFetchException(ex);
+    }
+
     status.setParameters(parameters);
     return status;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/1d50022d/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/1d50022d/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/1d50022d/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 bd2e9a6..ec8cdd8 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
@@ -180,9 +180,8 @@ App.Helpers.ambari = (function () {
      * @method getInstanceParametersErrorCallback
      */
     getInstanceParametersErrorCallback: function (request, ajaxOptions, error) {
-      var message = 'Ambari instance parameter fetch failed: ' + error;
-      App.Helpers.ErrorBar.getInstance().show(message);
-      Ember.assert(message);
+      var json = request.responseJSON;
+      App.Helpers.ErrorBar.getInstance().show(json.message, json.trace);
     }
   };
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/1d50022d/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/AmbariApiException.java
----------------------------------------------------------------------
diff --git a/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/AmbariApiException.java b/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/AmbariApiException.java
index 4ecc515..244220b 100644
--- a/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/AmbariApiException.java
+++ b/contrib/views/utils/src/main/java/org/apache/ambari/view/utils/ambari/AmbariApiException.java
@@ -18,6 +18,10 @@
 
 package org.apache.ambari.view.utils.ambari;
 
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.util.HashMap;
+
 /**
  * Exception during work with Ambari API
  */
@@ -29,4 +33,13 @@ public class AmbariApiException extends RuntimeException {
   public AmbariApiException(String message, Throwable cause) {
     super(message, cause);
   }
+
+  public Response toEntity() {
+    HashMap<String, Object> respJson = new HashMap<>();
+    respJson.put("trace", getCause());
+    respJson.put("message", getMessage());
+    respJson.put("status", Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
+    return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
+      .entity(respJson).type(MediaType.APPLICATION_JSON).build();
+  }
 }