ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject git commit: AMBARI-6182 Restart indicators do not appear without manual refresh when reconfiguring client-only services. (atkach)
Date Wed, 18 Jun 2014 11:45:42 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk afd5844e7 -> b19d840f2


AMBARI-6182 Restart indicators do not appear without manual refresh when reconfiguring client-only
services. (atkach)


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

Branch: refs/heads/trunk
Commit: b19d840f29873f7a9682da5615e9089416404a07
Parents: afd5844
Author: atkach <atkach@hortonworks.com>
Authored: Wed Jun 18 14:42:13 2014 +0300
Committer: atkach <atkach@hortonworks.com>
Committed: Wed Jun 18 14:42:13 2014 +0300

----------------------------------------------------------------------
 .../controllers/global/cluster_controller.js    |  17 ++--
 .../app/mappers/component_config_mapper.js      | 100 +++++++++++++------
 .../app/mappers/service_metrics_mapper.js       |   8 +-
 3 files changed, 85 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b19d840f/ambari-web/app/controllers/global/cluster_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/cluster_controller.js b/ambari-web/app/controllers/global/cluster_controller.js
index 9ec1942..699548a 100644
--- a/ambari-web/app/controllers/global/cluster_controller.js
+++ b/ambari-web/app/controllers/global/cluster_controller.js
@@ -315,19 +315,20 @@ App.ClusterController = Em.Controller.extend({
         });
 
         updater.updateServiceMetric(function () {
+
+          if (App.supports.hostOverrides) {
+            updater.updateComponentConfig(function () {
+              self.updateLoadStatus('componentConfigs');
+            });
+          } else {
+            self.updateLoadStatus('componentConfigs');
+          }
+
           updater.updateComponentsState(function () {
             self.updateLoadStatus('componentsState');
           });
           self.updateLoadStatus('serviceMetrics');
         });
-
-        if (App.supports.hostOverrides) {
-          updater.updateComponentConfig(function () {
-            self.updateLoadStatus('componentConfigs');
-          });
-        } else {
-          self.updateLoadStatus('componentConfigs');
-        }
       });
     });
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/b19d840f/ambari-web/app/mappers/component_config_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/component_config_mapper.js b/ambari-web/app/mappers/component_config_mapper.js
index 5dae2e1..ef880df 100644
--- a/ambari-web/app/mappers/component_config_mapper.js
+++ b/ambari-web/app/mappers/component_config_mapper.js
@@ -21,48 +21,92 @@ App.componentConfigMapper = App.QuickDataMapper.create({
   model: App.HostComponent,
   config: {
     id: 'id',
-    work_status: 'state',
-    passive_state: 'maintenance_state',
-    component_name: 'component_name',
-    host_name: 'host_name',
-    $ha_status: 'none',
+    work_status: 'HostRoles.state',
+    passive_state: 'HostRoles.maintenance_state',
+    component_name: 'HostRoles.component_name',
+    host_name: 'HostRoles.host_name',
+    $ha_status: '',
     $display_name_advanced: '',
-    stale_configs: 'stale_configs',
-    host_id: 'host_name',
-    service_id: 'service_name'
+    stale_configs: 'HostRoles.stale_configs',
+    host_id: 'HostRoles.host_name',
+    service_id: 'HostRoles.service_name'
   },
   map: function (json) {
     console.time('App.componentConfigMapper execution time');
     var hostComponents = [];
     var serviceToHostComponentIdMap = {};
-    var restartRequiredServices = [];
+    var cacheServices = App.cache['services'];
+    var componentsWithStaleConfigs = {};
+    var loadedServiceComponentsMap = this.buildServiceComponentMap(cacheServices);
+
     json.items.forEach(function (item) {
       item.host_components.forEach(function (host_component) {
-        host_component = host_component.HostRoles;
-        restartRequiredServices.push(host_component.service_name);
-        host_component.id = host_component.component_name + '_' + host_component.host_name;
+        var serviceName = host_component.HostRoles.service_name;
+        host_component.id = host_component.HostRoles.component_name + '_' + host_component.HostRoles.host_name;
         hostComponents.push(this.parseIt(host_component, this.get('config')));
-        if (!serviceToHostComponentIdMap[host_component.service_name]) {
-          serviceToHostComponentIdMap[host_component.service_name] = [];
+
+        componentsWithStaleConfigs[host_component.id] = true;
+
+        if (!serviceToHostComponentIdMap[serviceName]) {
+          serviceToHostComponentIdMap[serviceName] = [];
         }
-        serviceToHostComponentIdMap[host_component.service_name].push(host_component.id);
+        serviceToHostComponentIdMap[serviceName].push(host_component.id);
       }, this);
     }, this);
-    restartRequiredServices = restartRequiredServices.uniq();
-    var restartRequired = App.cache['restartRequiredServices'].concat(restartRequiredServices).uniq();
+
+    //reset(only for slave and client components) staleConfigs property to false before load
to model
+    this.get('model').find().forEach(function (hostComponent) {
+      if (!componentsWithStaleConfigs[hostComponent.get('id')] && !hostComponent.get('isMaster'))
{
+        hostComponent.set('staleConfigs', false);
+      }
+    });
     App.store.loadMany(this.get('model'), hostComponents);
-    restartRequired.forEach(function(serviceName) {
-      var service = App.cache['services'].findProperty('ServiceInfo.service_name', serviceName);
-      if (service) {
-        service.host_components = [];
-        for (var n in serviceToHostComponentIdMap[serviceName]) {
-          if (serviceToHostComponentIdMap[serviceName].hasOwnProperty(n)) {
-            service.host_components.pushObject(serviceToHostComponentIdMap[serviceName][n]);
+
+    this.addNewHostComponents(loadedServiceComponentsMap, serviceToHostComponentIdMap, cacheServices);
+    console.timeEnd('App.componentConfigMapper execution time');
+  },
+
+  /**
+   * build map that include loaded host-components to avoid duplicate loading
+   * @param cacheServices
+   * @return {Object}
+   */
+  buildServiceComponentMap: function (cacheServices) {
+    var loadedServiceComponentsMap = {};
+
+    cacheServices.forEach(function (cacheService) {
+      var componentsMap = {};
+
+      cacheService.host_components.forEach(function (componentId) {
+        componentsMap[componentId] = true;
+      });
+      loadedServiceComponentsMap[cacheService.ServiceInfo.service_name] = componentsMap;
+    });
+    return loadedServiceComponentsMap;
+  },
+
+  /**
+   * add only new host-components to every service
+   * to update service - host-component relations in model
+   * @param loadedServiceComponentsMap
+   * @param serviceToHostComponentIdMap
+   * @param cacheServices
+   * @return {boolean}
+   */
+  addNewHostComponents: function (loadedServiceComponentsMap, serviceToHostComponentIdMap,
cacheServices) {
+    if (!loadedServiceComponentsMap || !serviceToHostComponentIdMap || !cacheServices) return
false;
+
+    for (var serviceName in serviceToHostComponentIdMap) {
+      var loadedService = cacheServices.findProperty('ServiceInfo.service_name', serviceName);
+
+      if (serviceToHostComponentIdMap[serviceName] && loadedService) {
+        serviceToHostComponentIdMap[serviceName].forEach(function (componentId) {
+          if (!loadedServiceComponentsMap[serviceName][componentId]) {
+            loadedService.host_components.push(componentId)
           }
-        }
+        });
       }
-    }, this);
-    App.cache['restartRequiredServices'] = restartRequiredServices;
-    console.timeEnd('App.componentConfigMapper execution time');
+    }
+    return true;
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/b19d840f/ambari-web/app/mappers/service_metrics_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/service_metrics_mapper.js b/ambari-web/app/mappers/service_metrics_mapper.js
index 34bb124..8312d3a 100644
--- a/ambari-web/app/mappers/service_metrics_mapper.js
+++ b/ambari-web/app/mappers/service_metrics_mapper.js
@@ -178,6 +178,7 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({
       var services = App.cache['services'];
       var previousComponentStatuses = App.cache['previousComponentStatuses'];
       var previousComponentPassiveStates = App.cache['previousComponentPassiveStates'];
+      var result = [];
       /**
        * services contains constructed service-components structure from components array
        */
@@ -205,8 +206,6 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({
       //load master components to model
       App.store.loadMany(this.get('model3'), hostComponents);
 
-      var result = [];
-
       //parse service metrics from components
       services.forEach(function (item) {
         var finalJson = [];
@@ -266,7 +265,8 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({
       result = misc.sortByOrder(App.Service.servicesSortOrder, result);
 
       //load services to model
-      if (previousResponse.length !== result.length) {
+      App.store.loadMany(this.get('model'), result);
+      /*if (previousResponse.length !== result.length) {
         App.store.loadMany(this.get('model'), result);
       } else {
         result.forEach(function (serviceJson) {
@@ -283,7 +283,7 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({
         }, this)
       }
 
-      previousResponse = result;
+      previousResponse = result;*/
     }
     console.timeEnd('App.serviceMetricsMapper execution time');
   },


Mime
View raw message