Repository: ambari
Updated Branches:
  refs/heads/trunk 4a11ff281 -> 7e50afca6


AMBARI-6038. Remove status_mapper in order to stop updating all hosts, and 
start update only displayed one via hosts_mapper. (akovalenko)


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

Branch: refs/heads/trunk
Commit: 7e50afca608119c3fd81ad18aa91a3c6ce914b86
Parents: 4a11ff2
Author: Aleksandr Kovalenko <[email protected]>
Authored: Thu Jun 5 20:14:16 2014 +0300
Committer: Aleksandr Kovalenko <[email protected]>
Committed: Thu Jun 5 20:14:16 2014 +0300

----------------------------------------------------------------------
 .../controllers/global/cluster_controller.js    |  88 +++-----------
 ambari-web/app/controllers/main.js              |   2 -
 ambari-web/app/controllers/main/host/details.js |  13 --
 ambari-web/app/controllers/main/service/item.js |   3 -
 ambari-web/app/mappers.js                       |   1 -
 ambari-web/app/mappers/status_mapper.js         | 121 -------------------
 6 files changed, 15 insertions(+), 213 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7e50afca/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 76bc5ca..e899ee8 100644
--- a/ambari-web/app/controllers/global/cluster_controller.js
+++ b/ambari-web/app/controllers/global/cluster_controller.js
@@ -25,10 +25,7 @@ App.ClusterController = Em.Controller.extend({
   ambariProperties: null,
   ambariViews: [],
   clusterDataLoadedPercent: 'width:0', // 0 to 1
-  /**
-   * Whether we need to update statuses automatically or not
-   */
-  isWorking: false,
+
   isGangliaUrlLoaded: false,
   isNagiosUrlLoaded: false,
 
@@ -234,57 +231,6 @@ App.ClusterController = Em.Controller.extend({
   }.property('App.router.updateController.isUpdated', 
'dataLoadList.serviceMetrics'),
 
   /**
-   * Send request to server to load components updated statuses
-   * @param callback Slave function, should be called to fire delayed update.
-   * @param isInitialLoad
-   * Look at <code>App.updater.run</code> for more information
-   * @return {Boolean} Whether we have errors
-   */
-  loadUpdatedStatus: function (callback, isInitialLoad) {
-    if (!this.get('clusterName')) {
-      callback();
-      return false;
-    }
-    App.set('currentServerTime', App.get('currentServerTime') + 
App.componentsUpdateInterval);
-    var testUrl = App.get('isHadoop2Stack') ? 
'/data/hosts/HDP2/hc_host_status.json' : '/data/dashboard/services.json';
-    var statusUrl = 
'/hosts?fields=Hosts/host_status,Hosts/maintenance_state,host_components/HostRoles/state,host_components/HostRoles/maintenance_state,alerts/summary&minimal_response=true';
-    if (isInitialLoad) {
-      testUrl = '/data/hosts/HDP2/hosts_init.json';
-      statusUrl = 
'/hosts?fields=Hosts/host_name,Hosts/maintenance_state,Hosts/public_host_name,Hosts/cpu_count,Hosts/ph_cpu_count,Hosts/total_mem,'
 +
-        
'Hosts/host_status,Hosts/last_heartbeat_time,Hosts/os_arch,Hosts/os_type,Hosts/ip,host_components/HostRoles/state,host_components/HostRoles/maintenance_state,'
 +
-        
'Hosts/disk_info,metrics/disk,metrics/load/load_one,metrics/cpu/cpu_system,metrics/cpu/cpu_user,'
 +
-        
'metrics/memory/mem_total,metrics/memory/mem_free,alerts/summary&minimal_response=true';
-    }
-    //desired_state property is eliminated since calculateState function is 
commented out, it become useless
-    statusUrl = this.getUrl(testUrl, statusUrl);
-
-    App.HttpClient.get(statusUrl, App.statusMapper, {
-      complete: callback
-    });
-    return true;
-  },
-
-  /**
-   * Run <code>loadUpdatedStatus</code> with delay
-   * @param delay
-   */
-  loadUpdatedStatusDelayed: function (delay) {
-    setTimeout(function () {
-      App.updater.immediateRun('loadUpdatedStatus');
-    }, delay);
-  },
-
-  /**
-   * Start polling, when <code>isWorking</code> become true
-   */
-  startPolling: function () {
-    if (!this.get('isWorking')) {
-      return false;
-    }
-    App.updater.run(this, 'loadUpdatedStatus', 'isWorking', 
App.componentsUpdateInterval); //update will not run it immediately
-    return true;
-  }.observes('isWorking'),
-  /**
    *
    *  load all data and update load status
    */
@@ -362,28 +308,24 @@ App.ClusterController = Em.Controller.extend({
       self.updateLoadStatus('stackComponents');
       updater.updateServices(function () {
         self.updateLoadStatus('services');
+        updater.updateHost(function () {
+          self.updateLoadStatus('hosts');
+        });
 
-        self.loadUpdatedStatus(function () {
-
-          updater.updateHost(function () {
-            self.updateLoadStatus('hosts');
-          });
-
-          updater.updateServiceMetric(function () {
-            updater.updateComponentsState(function () {
-              self.updateLoadStatus('componentsState');
-            });
-            self.updateLoadStatus('serviceMetrics');
+        updater.updateServiceMetric(function () {
+          updater.updateComponentsState(function () {
+            self.updateLoadStatus('componentsState');
           });
+          self.updateLoadStatus('serviceMetrics');
+        });
 
-          if (App.supports.hostOverrides) {
-            updater.updateComponentConfig(function () {
-              self.updateLoadStatus('componentConfigs');
-            });
-          } else {
+        if (App.supports.hostOverrides) {
+          updater.updateComponentConfig(function () {
             self.updateLoadStatus('componentConfigs');
-          }
-        }, true);
+          });
+        } else {
+          self.updateLoadStatus('componentConfigs');
+        }
       });
     });
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/7e50afca/ambari-web/app/controllers/main.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main.js 
b/ambari-web/app/controllers/main.js
index f024f9f..55db450 100644
--- a/ambari-web/app/controllers/main.js
+++ b/ambari-web/app/controllers/main.js
@@ -66,13 +66,11 @@ App.MainController = Em.Controller.extend({
     if (App.router.get('clusterController.isLoaded')) {
       App.router.get('updateController').set('isWorking', true);
       App.router.get('backgroundOperationsController').set('isWorking', true);
-      App.router.get('clusterController').set('isWorking', true);
     }
   }.observes('App.router.clusterController.isLoaded'),
   stopPolling: function(){
     App.router.get('updateController').set('isWorking', false);
     App.router.get('backgroundOperationsController').set('isWorking', false);
-    App.router.get('clusterController').set('isWorking', false);
   },
 
   reloadTimeOut: null,

http://git-wip-us.apache.org/repos/asf/ambari/blob/7e50afca/ambari-web/app/controllers/main/host/details.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/details.js 
b/ambari-web/app/controllers/main/host/details.js
index 430feaf..7370900 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -190,8 +190,6 @@ App.MainHostDetailsController = Em.Controller.extend({
 
     if (App.testMode) {
       this.mimicWorkStatusChange(params.component, 
App.HostComponentStatus.starting, App.HostComponentStatus.started);
-    } else {
-      App.router.get('clusterController').loadUpdatedStatusDelayed(500);
     }
     this.showBackgroundOperationsPopup();
   },
@@ -378,8 +376,6 @@ App.MainHostDetailsController = Em.Controller.extend({
 
     if (App.testMode) {
       this.mimicWorkStatusChange(params.component, 
App.HostComponentStatus.starting, App.HostComponentStatus.started);
-    } else {
-      App.router.get('clusterController').loadUpdatedStatusDelayed(500);
     }
     this.showBackgroundOperationsPopup();
   },
@@ -433,8 +429,6 @@ App.MainHostDetailsController = Em.Controller.extend({
 
     if (App.testMode) {
       this.mimicWorkStatusChange(params.component, 
App.HostComponentStatus.stopping, App.HostComponentStatus.stopped);
-    } else {
-      App.router.get('clusterController').loadUpdatedStatusDelayed(500);
     }
     this.showBackgroundOperationsPopup();
   },
@@ -630,8 +624,6 @@ App.MainHostDetailsController = Em.Controller.extend({
 
     if (App.testMode) {
       this.mimicWorkStatusChange(params.component, 
App.HostComponentStatus.installing, App.HostComponentStatus.stopped);
-    } else {
-      App.router.get('clusterController').loadUpdatedStatusDelayed(500);
     }
 
     this.showBackgroundOperationsPopup(function () {
@@ -905,8 +897,6 @@ App.MainHostDetailsController = Em.Controller.extend({
     console.log('Send request for REINSTALL COMPONENT successfully');
     if (App.testMode) {
       this.mimicWorkStatusChange(params.component, 
App.HostComponentStatus.installing, App.HostComponentStatus.stopped);
-    } else {
-      App.router.get('clusterController').loadUpdatedStatusDelayed(500);
     }
     this.showBackgroundOperationsPopup();
   },
@@ -1100,9 +1090,6 @@ App.MainHostDetailsController = Em.Controller.extend({
    */
   decommissionSuccessCallback: function (data) {
     if (data && (data.Requests || data.resources[0].RequestSchedule)) {
-      if (!App.testMode) {
-        App.router.get('clusterController').loadUpdatedStatusDelayed(500);
-      }
       this.showBackgroundOperationsPopup();
       return true;
     } else {

http://git-wip-us.apache.org/repos/asf/ambari/blob/7e50afca/ambari-web/app/controllers/main/service/item.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/item.js 
b/ambari-web/app/controllers/main/service/item.js
index dd5ff66..0341155 100644
--- a/ambari-web/app/controllers/main/service/item.js
+++ b/ambari-web/app/controllers/main/service/item.js
@@ -63,9 +63,6 @@ App.MainServiceItemController = Em.Controller.extend({
           self.get('content.hostComponents').setEach('workStatus', 
App.HostComponentStatus[config.hs]);
         }, App.testModeDelayForActions);
       }
-      else {
-        App.router.get('clusterController').loadUpdatedStatusDelayed(500);// 
@todo check working without param 500
-      }
       // load data (if we need to show this background operations popup) from 
persist
       App.router.get('applicationController').dataLoading().done(function 
(initValue) {
         if (initValue) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/7e50afca/ambari-web/app/mappers.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers.js b/ambari-web/app/mappers.js
index 1c431ae..6bde2fb 100644
--- a/ambari-web/app/mappers.js
+++ b/ambari-web/app/mappers.js
@@ -19,7 +19,6 @@
 //load all mappers
 require('mappers/server_data_mapper');
 require('mappers/stack_service_component_mapper');
-require('mappers/status_mapper');
 require('mappers/hosts_mapper');
 require('mappers/cluster_mapper');
 require('mappers/jobs_mapper');

http://git-wip-us.apache.org/repos/asf/ambari/blob/7e50afca/ambari-web/app/mappers/status_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/status_mapper.js 
b/ambari-web/app/mappers/status_mapper.js
deleted file mode 100644
index 67f3dac..0000000
--- a/ambari-web/app/mappers/status_mapper.js
+++ /dev/null
@@ -1,121 +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.
- */
-
-var App = require('app');
-
-App.statusMapper = App.QuickDataMapper.create({
-  model: App.HostComponent,
-  map: function (json) {
-    console.time('App.statusMapper execution time');
-    if (json.items) {
-      var previousComponentStatuses = App.cache['previousComponentStatuses'];
-      var previousComponentPassiveStates = 
App.cache['previousComponentPassiveStates'];
-      var hostComponentRecordsMap = App.cache['hostComponentRecordsMap'];
-      var servicesCache = App.cache['services'];
-      var addedHostComponents = [];
-      var updatedHostComponents = [];
-      var componentServiceMap = App.QuickDataMapper.componentServiceMap();
-      var currentComponentStatuses = {};
-      var currentComponentPassiveStates = {};
-      var hostComponentsOnService = {};
-
-      json.items.forEach(function (host) {
-        var hostName = host.Hosts.host_name;
-
-        var hostComponentsOnHost = [];
-        host.host_components.forEach(function (host_component) {
-          host_component.id = host_component.HostRoles.component_name + "_" + 
hostName;
-          var existedComponent = previousComponentStatuses[host_component.id];
-          var existedPassiveComponent = 
previousComponentPassiveStates[host_component.id];
-          var service = 
componentServiceMap[host_component.HostRoles.component_name];
-
-          //delete all currently existed host-components to indicate which 
need to be deleted from model
-          delete previousComponentStatuses[host_component.id];
-          delete previousComponentPassiveStates[host_component.id];
-
-          if (existedComponent || existedPassiveComponent) {
-            //update host-components, which have status changed
-            if (existedComponent !== host_component.HostRoles.state || 
existedPassiveComponent !== host_component.HostRoles.maintenance_state) {
-              updatedHostComponents.push(host_component);
-            }
-          } else {
-            addedHostComponents.push({
-              id: host_component.id,
-              component_name: host_component.HostRoles.component_name,
-              passive_state: host_component.HostRoles.maintenance_state,
-              work_status: host_component.HostRoles.state,
-              host_id: hostName,
-              service_id: service
-            });
-          }
-          currentComponentStatuses[host_component.id] = 
host_component.HostRoles.state;
-          currentComponentPassiveStates[host_component.id] = 
host_component.HostRoles.maintenance_state;
-          //host-components to host relations
-          hostComponentsOnHost.push(host_component.id);
-          //host-component to service relations
-          if (!hostComponentsOnService[service]) {
-            hostComponentsOnService[service] = {
-              host_components: []
-            };
-          }
-          
hostComponentsOnService[service].host_components.push(host_component.id);
-        }, this);
-
-      }, this);
-
-
-      for (var id in previousComponentStatuses) {
-        this.deleteRecord(hostComponentRecordsMap[id]);
-      }
-
-      updatedHostComponents.forEach(function (hostComponent) {
-        var hostComponentRecord = hostComponentRecordsMap[hostComponent.id];
-        if (hostComponentRecord) {
-          hostComponentRecord.set('workStatus', hostComponent.HostRoles.state);
-          hostComponentRecord.set('passiveState', 
hostComponent.HostRoles.maintenance_state);
-        }
-      }, this);
-
-      if (addedHostComponents.length) {
-        App.store.loadMany(this.get('model'), addedHostComponents);
-        App.HostComponent.find().forEach(function(hostComponent){
-          hostComponentRecordsMap[hostComponent.get('id')] = hostComponent;
-        });
-      }
-
-      // update services workStatus and passiveState
-      App.Service.find().forEach(function (service) {
-        var cachedServiceData = 
servicesCache.findProperty('ServiceInfo.service_name', 
service.get('serviceName'));
-        if (cachedServiceData) {
-          service.set('workStatus', cachedServiceData.ServiceInfo.state);
-          service.set('passiveState', 
cachedServiceData.ServiceInfo.passive_state);
-        }
-      }, this);
-
-      //TODO remove when App.Host model dependencies will be replaced with 
server request
-      if (!App.router.get('clusterController.isLoaded')) {
-        App.hostsMapper.map(json);
-      }
-
-      App.cache['previousComponentStatuses'] = currentComponentStatuses;
-      App.cache['previousComponentPassiveStates'] = 
currentComponentPassiveStates;
-      App.cache['hostComponentsOnService'] = hostComponentsOnService;
-
-    }
-    console.timeEnd('App.statusMapper execution time');
-  }
-});

Reply via email to