You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sr...@apache.org on 2014/04/19 02:12:10 UTC

git commit: AMBARI-5517. Flume service data mapper only maps first agent. (srimanth)

Repository: ambari
Updated Branches:
  refs/heads/trunk ac6c15edb -> 0740b4da1


AMBARI-5517. Flume service data mapper only maps first agent. (srimanth)


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

Branch: refs/heads/trunk
Commit: 0740b4da11a4cff2ab9b93d3197ca9ee8122270f
Parents: ac6c15e
Author: Srimanth Gunturi <sg...@hortonworks.com>
Authored: Fri Apr 18 17:04:46 2014 -0700
Committer: Srimanth Gunturi <sg...@hortonworks.com>
Committed: Fri Apr 18 17:04:51 2014 -0700

----------------------------------------------------------------------
 .../app/mappers/service_metrics_mapper.js       | 35 +++++++------
 ambari-web/app/models/service/flume.js          | 53 +++-----------------
 .../app/views/main/service/services/flume.js    |  2 +-
 3 files changed, 29 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0740b4da/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 832da08..db23683 100644
--- a/ambari-web/app/mappers/service_metrics_mapper.js
+++ b/ambari-web/app/mappers/service_metrics_mapper.js
@@ -136,10 +136,12 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({
     nimbus_uptime: 'restApiComponent.metrics.api.cluster.summary.["nimbus.uptime"]'
   },
   flumeAgentConfig: {
-    id: 'HostComponentProcess.name',
     name: 'HostComponentProcess.name',
     status: 'HostComponentProcess.status',
-    host_id: 'HostComponentProcess.host_name'
+    host_id: 'HostComponentProcess.host_name',
+    channels_count: 'HostComponentProcess.channels_count',
+    sources_count: 'HostComponentProcess.sources_count',
+    sinks_count: 'HostComponentProcess.sinks_count'
   },
 
   model3: App.HostComponent,
@@ -224,8 +226,7 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({
           finalJson.rand = Math.random();
           result.push(finalJson);
           App.store.load(App.FlumeService, finalJson);
-          var agentsJson = this.flumeAgentMapper(item);
-          App.store.loadMany(App.FlumeAgent, agentsJson);
+          App.store.loadMany(App.FlumeAgent, finalJson.agentJsons);
         } else if (item && item.ServiceInfo && item.ServiceInfo.service_name == "YARN") {
           finalJson = this.yarnMapper(item);
           finalJson.rand = Math.random();
@@ -572,20 +573,24 @@ App.serviceMetricsMapper = App.QuickDataMapper.create({
    * data into the JSON object.
    */
   flumeMapper: function (item) {
-    var finalJson = this.parseIt(item, this.config);
-    finalJson.agents = item.components[0].host_components[0].processes.mapProperty('HostComponentProcess.name');
+    var self = this;
+    var finalJson = self.parseIt(item, self.config);
+    var flumeHandlers = item.components[0].host_components;
+    finalJson.agents = [];
+    finalJson.agentJsons = [];
+    flumeHandlers.forEach(function(flumeHandler){
+      var hostName = flumeHandler.HostRoles.host_name;
+      flumeHandler.processes.forEach(function(process){
+        var agentJson = self.parseIt(process, self.flumeAgentConfig);
+        var agentId = agentJson.name + "-" + hostName;
+        finalJson.agents.push(agentId);
+        agentJson.id = agentId;
+        finalJson.agentJsons.push(agentJson);
+      });
+    });
     return finalJson;
   },
 
-  flumeAgentMapper: function (item) {
-    var dataToParse = item.components[0].host_components[0].processes;
-    var result = [];
-    dataToParse.forEach(function(dataItem){
-      result.push(this.parseIt(dataItem, this.flumeAgentConfig));
-    }, this);
-    return result;
-  },
-
   /**
    * Storm mapper
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/0740b4da/ambari-web/app/models/service/flume.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service/flume.js b/ambari-web/app/models/service/flume.js
index 68a83e2..2d79a37 100644
--- a/ambari-web/app/models/service/flume.js
+++ b/ambari-web/app/models/service/flume.js
@@ -23,6 +23,11 @@ App.FlumeService = App.Service.extend({
 });
 
 App.FlumeAgent = DS.Model.extend({
+  /**
+   * ID of a flume agent will be of the format
+   * '<agent-name>-<host-name>'
+   */
+  id: DS.attr('string'),
   name: DS.attr('string'),
   /**
    * Status of agent. One of 'STARTED', 'INSTALLED', 'UNKNOWN'.
@@ -30,51 +35,9 @@ App.FlumeAgent = DS.Model.extend({
   status: DS.attr('string'),
   host: DS.belongsTo('App.Host'),
 
-  /**
-   * A comma separated list of channels.
-   */
-  channels: DS.attr('string'),
-
-  /**
-   * A comma separated list of sources.
-   */
-  sources: DS.attr('string'),
-
-  /**
-   * A comma separated list of sinks.
-   */
-  sinks: DS.attr('string'),
-
-  hostName: function () {
-    return this.get('host.hostName');
-  }.property('host.hostName'),
-
-  channelsCount: function() {
-    var channels = this.get('channels');
-    if (!channels) {
-      return 0;
-    } else {
-      return channels.split(',').length;
-    }
-  }.property('channels'),
-
-  sourcesCount: function() {
-    var sources = this.get('sources');
-    if (!sources) {
-      return 0;
-    } else {
-      return sources.split(',').length;
-    }
-  }.property('sources'),
-
-  sinksCount: function() {
-    var sinks = this.get('sinks');
-    if (!sinks) {
-      return 0;
-    } else {
-      return sinks.split(',').length;
-    }
-  }.property('sinks'),
+  channelsCount: DS.attr('number'),
+  sourcesCount: DS.attr('number'),
+  sinksCount: DS.attr('number'),
 
   healthClass : function() {
     switch (this.get('status')) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/0740b4da/ambari-web/app/views/main/service/services/flume.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/services/flume.js b/ambari-web/app/views/main/service/services/flume.js
index f700116..659549b 100644
--- a/ambari-web/app/views/main/service/services/flume.js
+++ b/ambari-web/app/views/main/service/services/flume.js
@@ -139,7 +139,7 @@ App.MainDashboardServiceFlumeView = App.TableView.extend({
       return  metricType + ' - ' + hostName;
     };
     var gangliaUrlTpl = App.router.get('clusterController.gangliaUrl') + '/?r=hour&cs=&ce=&m=load_one&s=by+name&c=HDPFlumeServer&h={0}&host_regex=&max_graphs=0&tab=m&vn=&sh=1&z=small&hc=4';
-    var agentHostMock = 'localhost'; // @todo change to agent hostname
+    var agentHostMock = agent.get('host.hostName');
     var mockMetricData = [
       {
         header: 'sinkName',