Browse Source

AMBARI-1091. 2 parallel requests for service information resulting in JS exception. (Srimanth Gunturi via yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1431656 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako 12 years ago
parent
commit
ad55ce1fd8

+ 3 - 0
CHANGES.txt

@@ -654,6 +654,9 @@ AMBARI-666 branch (unreleased changes)
 
   BUG FIXES
 
+  AMBARI-1091. 2 parallel requests for service information resulting in JS
+  exception. (Srimanth Gunturi via yusaku)
+
   AMBARI-1090. Restrict user to apply service configuration when custom box
   properties are already exposed on the management config page.
   (Jaimin Jetly via yusaku)

+ 3 - 2
ambari-web/app/app.js

@@ -24,8 +24,9 @@ module.exports = Em.Application.create({
 
   store: DS.Store.create({
     revision: 4,
-    adapter: require('data_adapter')
-    // adapter: DS.FixtureAdapter.create()
+    adapter: DS.FixtureAdapter.create({
+      simulateRemoteResponse: false
+    })
   })
 });
 

+ 0 - 97
ambari-web/app/data_adapter.js

@@ -1,97 +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
- *
- *     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.
- */
-
-/**
- * The data adapter that performs data exchange with Ambari Server's REST interface and other backend servers.
- *
- * To allow for mixture of mock data via Fixture and actual data exchange with backend servers while we iteratively
- * integrate, we are composing an instance of the fixture adapter.
- * The idea is to conditionally use the fixture adapter for model types that have not been integrated yet,
- * and to use a custom, modified implementation of DS.RESTAdapter for model types that have been integrated.
- */
-
-module.exports = DS.Adapter.create({
-  fixtureAdapter: DS.FixtureAdapter.create(),
-  restAdapter: DS.RESTAdapter.extend({
-    buildURL: function (record, suffix) {
-      if (/((ftp|http|https):\/\/)?(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i.test(record)) {
-        return record;
-      }
-      return this._super(record, suffix);
-    },
-    ajax: function (url, type, hash) {
-      hash.url = url;
-      hash.type = type;
-      hash.dataType = 'jsonp';
-      hash.contentType = 'application/javascript; charset=utf-8';
-      hash.context = this;
-      hash.jsonp = 'jsonp';
-      if (hash.data && type !== 'GET') {
-        hash.data = JSON.stringify(hash.data);
-      }
-      jQuery.ajax(hash);
-    }
-  }).create(),
-  isRestType: function (type) {
-    return type.url != null;
-  },
-  find: function (store, type, id) {
-    if (this.isRestType(type)) {
-      return this.restAdapter.find(store, type, id);
-    } else {
-      return this.fixtureAdapter.find(store, type, id);
-    }
-  },
-  findMany: function (store, type, ids) {
-    if (this.isRestType(type)) {
-      return this.restAdapter.findMany(store, type, ids);
-    } else {
-      return this.fixtureAdapter.findMany(store, type, ids);
-    }
-  },
-  findAll: function (store, type) {
-    if (this.isRestType(type)) {
-      return this.restAdapter.findAll(store, type);
-    } else {
-      return this.fixtureAdapter.findAll(store, type);
-    }
-  },
-  findQuery: function (store, type, query, array) {
-    if (this.isRestType(type)) {
-      return this.restAdapter.findQuery(store, type, query, array);
-    } else {
-      return this.fixtureAdapter.findQuery(store, type, query, array);
-    }
-  },
-  createRecord: function (store, type, record) {
-    if (this.isRestType(type)) {
-      return this.restAdapter.createRecord(store, type, record);
-    } else {
-      return this.fixtureAdapter.createRecord(store, type, record);
-    }
-  },
-  updateRecord: function (store, type, record) {
-    if (this.isRestType(type)) {
-      return this.restAdapter.updateRecord(store, type, record);
-    } else {
-      return this.fixtureAdapter.updateRecord(store, type, record);
-    }
-  }
-});
-
-

+ 6 - 0
ambari-web/app/mappers/service_mapper.js

@@ -144,6 +144,12 @@ App.servicesMapper = App.QuickDataMapper.create({
     }
 
     if (json.items) {
+      try{
+        App.store.commit();
+      }catch (e) {
+        console.log("Error committing store before Service mapper maps");
+        console.log(e);
+      }
       var result = [];
       json.items.forEach(function (item) {
         var finalConfig = jQuery.extend({}, this.config);

+ 21 - 28
ambari-web/app/models/host.js

@@ -111,38 +111,31 @@ App.Host = DS.Model.extend({
     if (this.get('loadFifteen') != null) return this.get('loadFifteen').toFixed(2);
   }.property('loadOne', 'loadFive', 'loadFifteen'),
 
-  updateHostStatus: function(){
+  healthClass: function(){
+    var healthStatus = this.get('healthStatus');
     /**
      * Do nothing until load
      */
-    if(!this.get('isLoaded')){
-      return;
-    }
-
-    var status;
-
-    var masterComponents = this.get('components').filterProperty('isMaster', true);
-    var masterComponentsRunning = masterComponents
-                                            .everyProperty('workStatus', App.Component.Status.started);
-
-    if(this.get('isNotHeartBeating')){
-      status = 'DEAD-YELLOW';
-    } else if(masterComponentsRunning){
-      status = 'LIVE';
-    } else if(masterComponents.length > 0 && !masterComponentsRunning){
-      status = 'DEAD';
-    } else{
-      status = 'DEAD-ORANGE';
+    if (!this.get('isLoaded') || this.get('isSaving')) {
+    } else {
+      var status;
+      var masterComponents = this.get('components').filterProperty('isMaster', true);
+      var masterComponentsRunning = masterComponents.everyProperty('workStatus', App.Component.Status.started);
+      if (this.get('isNotHeartBeating')) {
+        status = 'DEAD-YELLOW';
+      } else if (masterComponentsRunning) {
+        status = 'LIVE';
+      } else if (masterComponents.length > 0 && !masterComponentsRunning) {
+        status = 'DEAD';
+      } else {
+        status = 'DEAD-ORANGE';
+      }
+      if (status) {
+        healthStatus = status;
+      }
     }
-
-    if(status){
-      this.set('healthStatus', status);
-    }
-  }.observes('components.@each.workStatus'),
-
-  healthClass: function(){
-    return 'health-status-' + this.get('healthStatus');
-  }.property('healthStatus')
+    return 'health-status-' + healthStatus;
+  }.property('healthStatus', 'components.@each.workStatus')
 });
 
 App.Host.FIXTURES = [];