ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akovale...@apache.org
Subject git commit: AMBARI-6431. Individual flume graph data not loading correctly. (akovalenko)
Date Wed, 09 Jul 2014 12:38:16 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 5bb59403f -> 306e4d469


AMBARI-6431. Individual flume graph data not loading correctly. (akovalenko)


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

Branch: refs/heads/trunk
Commit: 306e4d4693f35c30f21a56e205cadb3d2534f8ef
Parents: 5bb5940
Author: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Authored: Wed Jul 9 15:34:53 2014 +0300
Committer: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Committed: Wed Jul 9 15:34:53 2014 +0300

----------------------------------------------------------------------
 ambari-web/app/utils/ajax/ajax.js               |  9 ++-
 .../info/metrics/flume/flume_metric_graph.js    | 13 +++-
 .../info/metrics/flume/flume_metric_graphs.js   | 75 ++++++++++++--------
 3 files changed, 61 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/306e4d46/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 9581283..f10abb7 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -1574,8 +1574,13 @@ var urls = {
     }
   },
   'host.host_component.flume.metrics.timeseries': {
-    'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/FLUME_HANDLER?fields=metrics/flume/flume/{flumeComponent}/*/{flumeComponentMetric}[{fromSeconds},{toSeconds},{stepSeconds}]',
-    'mock': ''
+    'real': '',
+    'mock': '',
+    format: function (data) {
+      return {
+        url: data.url
+      }
+    }
   },
   'host.host_components.filtered': {
     'real': '/clusters/{clusterName}/hosts?{fields}',

http://git-wip-us.apache.org/repos/asf/ambari/blob/306e4d46/ambari-web/app/views/main/service/info/metrics/flume/flume_metric_graph.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/info/metrics/flume/flume_metric_graph.js b/ambari-web/app/views/main/service/info/metrics/flume/flume_metric_graph.js
index 56a1c7f..f138f40 100644
--- a/ambari-web/app/views/main/service/info/metrics/flume/flume_metric_graph.js
+++ b/ambari-web/app/views/main/service/info/metrics/flume/flume_metric_graph.js
@@ -33,6 +33,7 @@ App.ChartServiceFlumeMetricGraph = App.ChartLinearTimeView.extend({
   metricType: null,
   metricName: null,
   hostName: null,
+  metricItems: null,
 
   id: function(){
     return "service-metrics-flume-metric-graph-" + this.get('metricType') + '-' + this.get('metricName');
@@ -46,9 +47,15 @@ App.ChartServiceFlumeMetricGraph = App.ChartLinearTimeView.extend({
 
   getDataForAjaxRequest: function() {
     var data = this._super();
-    data.flumeComponentMetric = this.get('metricName');
-    data.flumeComponent = this.get('metricType');
-    data.hostName = this.get('hostName');
+
+    var urlFields = '';
+    this.get('metricItems').forEach(function (metricItem, index) {
+      urlFields += index === 0 ? '' : ',';
+      urlFields += 'metrics/flume/flume/' + this.get('metricType') + '/' + metricItem + '/'
+ this.get('metricName') +
+          '[' + data.fromSeconds + ',' + data.toSeconds + ',' + data.stepSeconds + ']'
+    }, this);
+
+    data.url = App.get('apiPrefix') + '/clusters/' + App.get('clusterName') + '/hosts/' +
this.get('hostName') + '/host_components/FLUME_HANDLER?fields=' + urlFields;
     return data;
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/306e4d46/ambari-web/app/views/main/service/info/metrics/flume/flume_metric_graphs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/info/metrics/flume/flume_metric_graphs.js b/ambari-web/app/views/main/service/info/metrics/flume/flume_metric_graphs.js
index bb38638..b677567 100644
--- a/ambari-web/app/views/main/service/info/metrics/flume/flume_metric_graphs.js
+++ b/ambari-web/app/views/main/service/info/metrics/flume/flume_metric_graphs.js
@@ -20,43 +20,18 @@ require('views/main/service/service');
 
 App.MainServiceInfoFlumeGraphsView = App.MainServiceInfoSummaryMetricGraphsView.extend({
 
-  serviceMetricGraphs: function() {
+  serviceMetricGraphs: [],
+
+  loadMetrics: function () {
     var graphRows = [];
     var viewData = this.get('viewData');
     if (viewData != null) {
       var metricType = viewData.metricType;
       var hostName = viewData.agent.get('hostName');
-      var metricNamesGatherer = {
-        success: function(data) {
-          var metricNames = {};
-          if (data != null && data.metrics != null && data.metrics.flume
!= null && data.metrics.flume.flume != null && data.metrics.flume.flume[metricType]
!= null) {
-            for ( var name in data.metrics.flume.flume[metricType]) {
-              for ( var metricName in data.metrics.flume.flume[metricType][name]) {
-                metricNames[metricName] = name;
-              }
-            }
-          }
-          // Now that we have collected all metric names, we create
-          // views for each of them and store them 4 in a row.
-          graphRows.push([]);
-          var graphs = graphRows[0];
-          for (var metricName in metricNames) {
-            if (graphs.length > 3) {
-              graphRows.push([]);
-              graphs = graphRows[graphRows.length - 1];
-            }
-            graphs.push(App.ChartServiceFlumeMetricGraph.extend({
-              metricType: metricType,
-              metricName: metricName,
-              hostName: hostName
-            }));
-          }
-        }
-      };
       App.ajax.send({
         'name': 'host.host_component.flume.metrics',
-        'sender': metricNamesGatherer,
-        'success': 'success',
+        'sender': this,
+        'success': 'onLoadMetricsSuccess',
         'data': {
           async: false,
           hostName: hostName,
@@ -65,6 +40,44 @@ App.MainServiceInfoFlumeGraphsView = App.MainServiceInfoSummaryMetricGraphsView.
       });
     }
     return graphRows;
-  }.property('viewData', 'metricType')
+  }.observes('viewData', 'metricType'),
+
+  onLoadMetricsSuccess: function (data) {
+    var graphRows = [];
+    var viewData = this.get('viewData');
+    var metricType = viewData.metricType;
+    var hostName = viewData.agent.get('hostName');
+    var metricNames = {};
+    var metricItems = [];
+    if (data != null && data.metrics != null && data.metrics.flume != null
&& data.metrics.flume.flume != null && data.metrics.flume.flume[metricType]
!= null) {
+      for (var name in data.metrics.flume.flume[metricType]) {
+        for (var metricName in data.metrics.flume.flume[metricType][name]) {
+          metricNames[metricName] = name;
+        }
+        metricItems.push(name);
+      }
+    }
+    // Now that we have collected all metric names, we create
+    // views for each of them and store them 4 in a row.
+    graphRows.push([]);
+    var graphs = graphRows[0];
+    for (var metricName in metricNames) {
+      if (graphs.length > 3) {
+        graphRows.push([]);
+        graphs = graphRows[graphRows.length - 1];
+      }
+      graphs.push(App.ChartServiceFlumeMetricGraph.extend({
+        metricType: metricType,
+        metricName: metricName,
+        hostName: hostName,
+        metricItems: metricItems
+      }));
+    }
+    this.set('serviceMetricGraphs', graphRows);
+  },
+
+  didInsertElement: function () {
+    this.loadMetrics();
+  }
 
 });


Mime
View raw message