Переглянути джерело

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

Srimanth Gunturi 9 роки тому
батько
коміт
0934a5c95f

+ 16 - 2
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;
   }

+ 32 - 0
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());
+
+  }
+
+}

+ 32 - 0
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());
+
+  }
+}

+ 2 - 3
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);
     }
   };
 

+ 13 - 0
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();
+  }
 }