incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject git commit: AMBARI-3514 Eliminate updating of immutable properties for hosts. (atkach)
Date Tue, 15 Oct 2013 12:18:35 GMT
Updated Branches:
  refs/heads/trunk 9dbf00eed -> d26023841


AMBARI-3514 Eliminate updating of immutable properties for hosts. (atkach)


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

Branch: refs/heads/trunk
Commit: d26023841a5c2022169af0809ca9166dafe2d007
Parents: 9dbf00e
Author: atkach <andrey91.07@gmail.com>
Authored: Tue Oct 15 15:18:29 2013 +0300
Committer: atkach <andrey91.07@gmail.com>
Committed: Tue Oct 15 15:18:29 2013 +0300

----------------------------------------------------------------------
 .../app/controllers/global/cluster_controller.js  | 18 ++++++++++--------
 .../app/controllers/global/update_controller.js   |  3 +--
 ambari-web/app/mappers/hosts_mapper.js            | 14 ++++++++++++++
 ambari-web/app/routes/add_host_routes.js          |  4 ++++
 ambari-web/app/routes/add_service_routes.js       |  4 ++++
 ambari-web/app/routes/reassign_master_routes.js   |  4 ++++
 6 files changed, 37 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/d2602384/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 0a2d94f..8e1860c 100644
--- a/ambari-web/app/controllers/global/cluster_controller.js
+++ b/ambari-web/app/controllers/global/cluster_controller.js
@@ -312,8 +312,7 @@ App.ClusterController = Em.Controller.extend({
       return;
     }
     var clusterUrl = this.getUrl('/data/clusters/cluster.json', '?fields=Clusters');
-    var testHostUrl =  App.get('isHadoop2Stack') ? '/data/hosts/HDP2/hosts.json':'/data/hosts/hosts.json';
-    var hostsUrl = this.getUrl(testHostUrl, '/hosts?fields=Hosts/host_name,Hosts/public_host_name,Hosts/disk_info,Hosts/cpu_count,Hosts/total_mem,Hosts/host_status,Hosts/last_heartbeat_time,Hosts/os_arch,Hosts/os_type,Hosts/ip,host_components,metrics/disk,metrics/load/load_one');
+    var hostsRealUrl = '/hosts?fields=Hosts/host_name,Hosts/public_host_name,Hosts/cpu_count,Hosts/total_mem,Hosts/host_status,Hosts/last_heartbeat_time,Hosts/os_arch,Hosts/os_type,Hosts/ip,host_components,metrics/disk,metrics/load/load_one';
     var usersUrl = App.testMode ? '/data/users/users.json' : App.apiPrefix + '/users/?fields=*';
     var racksUrl = "/data/racks/racks.json";
     var dataSetUrl = "/data/mirroring/all_datasets.json";
@@ -360,12 +359,8 @@ App.ClusterController = Em.Controller.extend({
       });
     }
     
-    App.HttpClient.get(hostsUrl, App.hostsMapper, {
-      complete:function (jqXHR, textStatus) {
-        self.updateLoadStatus('hosts');
-      }
-    }, function (jqXHR, textStatus) {
-        self.updateLoadStatus('hosts');
+    this.requestHosts(hostsRealUrl, function (jqXHR, textStatus) {
+      self.updateLoadStatus('hosts');
     });
 
     App.HttpClient.get(usersUrl, App.usersMapper, {
@@ -388,6 +383,13 @@ App.ClusterController = Em.Controller.extend({
     });
   },
 
+  requestHosts: function(realUrl, callback){
+    var testHostUrl =  App.get('isHadoop2Stack') ? '/data/hosts/HDP2/hosts.json':'/data/hosts/hosts.json';
+    var url = this.getUrl(testHostUrl, realUrl);
+    App.HttpClient.get(url, App.hostsMapper, {
+      complete: callback
+    }, callback)
+  },
 
   loadAmbariProperties: function() {
     App.ajax.send({

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/d2602384/ambari-web/app/controllers/global/update_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/update_controller.js b/ambari-web/app/controllers/global/update_controller.js
index 713cade..344fff5 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -44,9 +44,8 @@ App.UpdateController = Em.Controller.extend({
   }.observes('isWorking'),
 
   updateHost:function(callback) {
-    var self = this;
     var testUrl =  App.get('isHadoop2Stack') ? '/data/hosts/HDP2/hosts.json':'/data/hosts/hosts.json';
-      var hostsUrl = this.getUrl(testUrl, '/hosts?fields=Hosts/host_name,Hosts/public_host_name,Hosts/disk_info,Hosts/cpu_count,Hosts/total_mem,Hosts/host_status,Hosts/last_heartbeat_time,Hosts/os_arch,Hosts/os_type,Hosts/ip,host_components,metrics/disk,metrics/load/load_one');
+      var hostsUrl = this.getUrl(testUrl, '/hosts?fields=Hosts/host_name,Hosts/host_status,Hosts/last_heartbeat_time,host_components,metrics/disk,metrics/load/load_one');
       App.HttpClient.get(hostsUrl, App.hostsMapper, {
         complete: callback
       });

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/d2602384/ambari-web/app/mappers/hosts_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/hosts_mapper.js b/ambari-web/app/mappers/hosts_mapper.js
index 706281f..25f799f 100644
--- a/ambari-web/app/mappers/hosts_mapper.js
+++ b/ambari-web/app/mappers/hosts_mapper.js
@@ -16,6 +16,7 @@
  */
 
 var App = require('app');
+var cacheData = {};
 
 App.hostsMapper = App.QuickDataMapper.create({
 
@@ -56,6 +57,7 @@ App.hostsMapper = App.QuickDataMapper.create({
         var serverHostIds = {};
         result.forEach(function (host) {
           serverHostIds[host.id] = host.id;
+          cacheData[host.id] = host;
         });
         var hostsToDelete = [];
         clientHosts.forEach(function (host) {
@@ -69,6 +71,18 @@ App.hostsMapper = App.QuickDataMapper.create({
           host.deleteRecord();
         });
       }
+      //restore properties from cache instead request them from server
+      result.forEach(function (host) {
+        var cacheHost = cacheData[host.id];
+        if (cacheHost) {
+          host.ip = cacheHost.ip;
+          host.os_arch = cacheHost.os_arch;
+          host.os_type = cacheHost.os_type;
+          host.public_host_name = cacheHost.public_host_name;
+          host.memory = cacheHost.memory;
+          host.cpu = cacheHost.cpu;
+        }
+      });
       App.store.loadMany(this.get('model'), result);
     }
   },

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/d2602384/ambari-web/app/routes/add_host_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/add_host_routes.js b/ambari-web/app/routes/add_host_routes.js
index 49594f9..8ef5f1b 100644
--- a/ambari-web/app/routes/add_host_routes.js
+++ b/ambari-web/app/routes/add_host_routes.js
@@ -280,6 +280,10 @@ module.exports = Em.Route.extend({
     back: Em.Router.transitionTo('step5'),
     complete: function (router, context) {
       var addHostController = router.get('addHostController');
+      var hostsUrl = '/hosts?fields=Hosts/host_name,Hosts/public_host_name,Hosts/cpu_count,Hosts/total_mem,Hosts/host_status,Hosts/last_heartbeat_time,Hosts/os_arch,Hosts/os_type,Hosts/ip,host_components,metrics/disk,metrics/load/load_one';
+      router.get('clusterController').requestHosts(hostsUrl, function () {
+        console.log('Request for hosts, with immutable parameters')
+      });
       router.get('updateController').updateAll();
       addHostController.finish();
       $(context.currentTarget).parents("#modal").find(".close").trigger('click');

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/d2602384/ambari-web/app/routes/add_service_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/add_service_routes.js b/ambari-web/app/routes/add_service_routes.js
index 9ecd9df..abf2907 100644
--- a/ambari-web/app/routes/add_service_routes.js
+++ b/ambari-web/app/routes/add_service_routes.js
@@ -27,6 +27,10 @@ module.exports = Em.Route.extend({
       Em.run.next(function () {
         var addServiceController = router.get('addServiceController');
         App.router.get('updateController').set('isWorking', false);
+        var hostsUrl = '/hosts?fields=Hosts/host_name,Hosts/disk_info';
+        router.get('clusterController').requestHosts(hostsUrl, function () {
+          console.log('Request for hosts, with disk_info parameter');
+        });
         App.ModalPopup.show({
           classNames: ['full-width-modal'],
           header:Em.I18n.t('services.add.header'),

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/d2602384/ambari-web/app/routes/reassign_master_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/reassign_master_routes.js b/ambari-web/app/routes/reassign_master_routes.js
index 08025d1..0435ba0 100644
--- a/ambari-web/app/routes/reassign_master_routes.js
+++ b/ambari-web/app/routes/reassign_master_routes.js
@@ -24,6 +24,10 @@ module.exports = Em.Route.extend({
       Em.run.next(function () {
         var reassignMasterController = router.get('reassignMasterController');
         App.router.get('updateController').set('isWorking', false);
+        var hostsUrl = '/hosts?fields=Hosts/host_name,Hosts/disk_info';
+        router.get('clusterController').requestHosts(hostsUrl, function () {
+          console.log('Request for hosts, with disk_info parameter');
+        });
         var popup = App.ModalPopup.show({
           classNames: ['full-width-modal'],
           header:Em.I18n.t('services.reassign.header'),


Mime
View raw message