ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [08/10] git commit: AMBARI-6877. NameNode CPU metrics are missing (alexantonenko)
Date Fri, 15 Aug 2014 18:20:23 GMT
AMBARI-6877. NameNode CPU metrics are missing (alexantonenko)


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

Branch: refs/heads/branch-alerts-dev
Commit: 3394a034502c54c1cac97118c99b967885d53549
Parents: 16073e9
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Fri Aug 15 17:45:37 2014 +0300
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Fri Aug 15 14:20:00 2014 -0400

----------------------------------------------------------------------
 ambari-web/app/models/service/hdfs.js           |  1 -
 ambari-web/app/utils/ajax/ajax.js               |  4 +++
 .../main/dashboard/widgets/namenode_cpu.js      | 37 +++++++++++++++++---
 3 files changed, 37 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/3394a034/ambari-web/app/models/service/hdfs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service/hdfs.js b/ambari-web/app/models/service/hdfs.js
index f62e167..b34a4e8 100644
--- a/ambari-web/app/models/service/hdfs.js
+++ b/ambari-web/app/models/service/hdfs.js
@@ -48,7 +48,6 @@ App.HDFSService = App.Service.extend({
   dfsTotalFiles: DS.attr('number'),
   upgradeStatus: DS.attr('boolean'),
   safeModeStatus: DS.attr('string'),
-  nameNodeCpu: DS.attr('number'),
   nameNodeRpc: DS.attr('number')
 });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/3394a034/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index 4ad4572..2f6a464 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -1797,6 +1797,10 @@ var urls = {
     'real': '/clusters/{clusterName}/hosts?fields=Hosts/host_name,Hosts/public_host_name,Hosts/os_type,Hosts/ip,host_components,metrics/disk,metrics/cpu/cpu_system,metrics/cpu/cpu_user,metrics/memory/mem_total,metrics/memory/mem_free&minimal_response=true',
     'mock': ''
   },
+  'namenode.cpu_wio': {
+    'real': '/clusters/{clusterName}/hosts/{nnHost}?fields=metrics/cpu',
+    'mock': ''
+  },
 
   'custom_action.create': {
     'real': '/requests',

http://git-wip-us.apache.org/repos/asf/ambari/blob/3394a034/ambari-web/app/views/main/dashboard/widgets/namenode_cpu.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets/namenode_cpu.js b/ambari-web/app/views/main/dashboard/widgets/namenode_cpu.js
index 86cda03..6fca69e 100644
--- a/ambari-web/app/views/main/dashboard/widgets/namenode_cpu.js
+++ b/ambari-web/app/views/main/dashboard/widgets/namenode_cpu.js
@@ -25,15 +25,44 @@ App.NameNodeCpuPieChartView = App.PieChartDashboardWidgetView.extend({
 
   model_type: 'hdfs',
   widgetHtmlId: 'widget-nn-cpu',
-  modelFieldUsed: 'nameNodeCpu',
+  cpuWio: null,
+  nnHostName:"",
 
   didInsertElement: function() {
     this._super();
+    var self = this;
+    if (App.get('isHaEnabled')) {
+      this.set('nnHostName', this.get('model').get('activeNameNode.hostName'));
+    }else{
+     this.set('nnHostName', this.get('model').get('nameNode.hostName'));
+    }
+    this.getValue();
+    setInterval(function() {self.getValue()}, App.componentsUpdateInterval);
+  },
+
+  getValue: function () {
+    App.ajax.send({
+      name: 'namenode.cpu_wio',
+      sender: this,
+      data: {
+        nnHost: this.get('nnHostName')
+      },
+      success: 'updateValueSuccess',
+      error: 'updateValueError'
+    });
+  },
+
+  updateValueError: function () {
+    this.calc();
+  },
+
+  updateValueSuccess: function (response) {
+    this.set('cpuWio', response.metrics.cpu.cpu_wio);
     this.calc();
   },
 
   calcHiddenInfo: function() {
-    var value = this.get('model').get(this.get('modelFieldUsed'));
+    var value = this.get('cpuWio');
     var obj1;
     if( value == null) {
       obj1 = Em.I18n.t('services.service.summary.notAvailable');
@@ -49,11 +78,11 @@ App.NameNodeCpuPieChartView = App.PieChartDashboardWidgetView.extend({
   },
 
   calcIsPieExists: function() {
-    return (this.get('model').get(this.get('modelFieldUsed')) != null);
+    return (this.get('cpuWio') != null);
   },
 
   calcDataForPieChart: function() {
-    var value = this.get('model').get(this.get('modelFieldUsed'));
+    var value = this.get('cpuWio');
     value = value >= 100 ? 100: value;
     var percent = (value + 0).toFixed(1);
     var percent_precise = (value + 0).toFixed(2);


Mime
View raw message