You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2015/11/05 15:00:10 UTC

ambari git commit: AMBARI-13742. Flume Agent metrics graphs issues

Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 b4b7df682 -> ade07b3af


AMBARI-13742. Flume Agent metrics graphs issues


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

Branch: refs/heads/branch-2.1
Commit: ade07b3afc7fd774dee7603c02524d949af9e83f
Parents: b4b7df6
Author: Alex Antonenko <hi...@gmail.com>
Authored: Thu Nov 5 15:58:11 2015 +0200
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Thu Nov 5 16:00:05 2015 +0200

----------------------------------------------------------------------
 ambari-web/app/assets/test/tests.js             |  1 +
 ambari-web/app/styles/application.less          |  3 +
 .../flume/flume_agent_metrics_section.hbs       | 40 +++++++++++++
 .../app/templates/main/service/info/summary.hbs | 21 +------
 ambari-web/app/views.js                         |  1 +
 .../flume/flume_agent_metrics_section.js        | 45 +++++++++++++++
 .../app/views/main/service/services/flume.js    | 38 +++++-------
 .../flume/flume_agent_metrics_section_test.js   | 61 ++++++++++++++++++++
 8 files changed, 166 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ade07b3a/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index 09b782b..ad5e9ec 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -255,6 +255,7 @@ var files = ['test/init_model_test',
   'test/views/main/service/info/config_test',
   'test/views/main/service/info/summary_test',
   'test/views/main/service/info/metrics/ambari_metrics/regionserver_base_test',
+  'test/views/main/service/info/metrics/flume/flume_agent_metrics_section_test',
   'test/views/main/service/services/ranger_test',
   'test/views/main/service/widgets/create/expression_view_test',
   'test/views/main/admin/highAvailability/nameNode/step1_view_test',

http://git-wip-us.apache.org/repos/asf/ambari/blob/ade07b3a/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index 8c20e6e..b85107c 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -2584,6 +2584,9 @@ a:focus {
         margin: 3px;
       }
     }
+    .accordion-body.in {
+      overflow: visible;
+    }
   }
 }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/ade07b3a/ambari-web/app/templates/main/service/info/metrics/flume/flume_agent_metrics_section.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/service/info/metrics/flume/flume_agent_metrics_section.hbs b/ambari-web/app/templates/main/service/info/metrics/flume/flume_agent_metrics_section.hbs
new file mode 100644
index 0000000..f8401ba
--- /dev/null
+++ b/ambari-web/app/templates/main/service/info/metrics/flume/flume_agent_metrics_section.hbs
@@ -0,0 +1,40 @@
+{{!
+* 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.
+}}
+
+<div {{bindAttr class=":accordion view.toggleIndex"}}>
+  <div class="accordion-group box">
+    <div class="accordion-heading box-header">
+      <span class="pull-left accordion-toggle metrics-header"
+            data-toggle="collapse" {{bindAttr dataParent="view.toggleIndex" href="view.toggleIndex"}}>
+        <i class="pull-left icon-caret-toggle"></i>
+        <span>{{view.header}}</span>
+      </span>
+        {{#if showTimeRangeControl}}
+          {{view view.timeRangeListView}}
+        {{/if}}
+      <div class="clearfix"></div>
+    </div>
+    <div class="accordion-body collapse in" {{bindAttr id="view.id"}}>
+      <div class="accordion-inner">
+        {{#if view.metricView}}
+          {{view view.metricView viewDataBinding="view.metricViewData"}}
+        {{/if}}
+      </div>
+    </div>
+  </div>
+</div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ade07b3a/ambari-web/app/templates/main/service/info/summary.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/service/info/summary.hbs b/ambari-web/app/templates/main/service/info/summary.hbs
index b295a3b..037ab16 100644
--- a/ambari-web/app/templates/main/service/info/summary.hbs
+++ b/ambari-web/app/templates/main/service/info/summary.hbs
@@ -152,26 +152,7 @@
   <div class="row-fluid">
     <div class="span12 metrics-collapsed-graphs">
       {{#each collapsedSection in view.collapsedSections}}
-        <div {{bindAttr class=":accordion collapsedSection.toggleIndex"}}>
-          <div class="accordion-group box">
-            <div class="accordion-heading box-header">
-              <span class="pull-left accordion-toggle metrics-header"
-                    data-toggle="collapse" {{bindAttr dataParent="collapsedSection.toggleIndex" href="collapsedSection.toggleIndex"}}>
-                <i class="pull-left icon-caret-toggle"></i>
-                <span>{{collapsedSection.header}}</span>
-              </span>
-
-              <div class="clearfix"></div>
-            </div>
-            <div class="accordion-body collapse in" {{bindAttr id="collapsedSection.id"}}>
-              <div class="accordion-inner">
-                {{#if collapsedSection.metricView}}
-                  {{view collapsedSection.metricView viewDataBinding="collapsedSection.metricViewData"}}
-                {{/if}}
-              </div>
-            </div>
-          </div>
-        </div>
+        {{view collapsedSection}}
       {{/each}}
     </div>
   </div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ade07b3a/ambari-web/app/views.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js
index e702bbc..fe9f1fb 100644
--- a/ambari-web/app/views.js
+++ b/ambari-web/app/views.js
@@ -259,6 +259,7 @@ require('views/main/service/info/metrics/ambari_metrics/regionserver_block_cache
 require('views/main/service/info/metrics/ambari_metrics/regionserver_compaction_queue_size');
 require('views/main/service/info/metrics/flume/channel_sum');
 require('views/main/service/info/metrics/flume/channel_size_mma');
+require('views/main/service/info/metrics/flume/flume_agent_metrics_section');
 require('views/main/service/info/metrics/flume/flume_incoming_sum');
 require('views/main/service/info/metrics/flume/flume_incoming_mma');
 require('views/main/service/info/metrics/flume/flume_outgoing_sum');

http://git-wip-us.apache.org/repos/asf/ambari/blob/ade07b3a/ambari-web/app/views/main/service/info/metrics/flume/flume_agent_metrics_section.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/info/metrics/flume/flume_agent_metrics_section.js b/ambari-web/app/views/main/service/info/metrics/flume/flume_agent_metrics_section.js
new file mode 100644
index 0000000..43e4422
--- /dev/null
+++ b/ambari-web/app/views/main/service/info/metrics/flume/flume_agent_metrics_section.js
@@ -0,0 +1,45 @@
+/**
+ * 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.FlumeAgentMetricsSectionView = Em.View.extend(App.TimeRangeMixin, {
+
+  templateName: require('templates/main/service/info/metrics/flume/flume_agent_metrics_section'),
+
+  index: 0,
+
+  metricTypeKey: '',
+
+  metricView: null,
+
+  metricViewData: null,
+
+  id: function () {
+    return 'metric' + this.get('index');
+  }.property('index'),
+
+  toggleIndex: function () {
+    return '#' + this.get('id');
+  }.property('id'),
+
+  header: function () {
+    var metricType = Em.I18n.t('services.service.info.metrics.flume.' + this.get('metricTypeKey')).format(Em.I18n.t('common.metrics'));
+    return metricType + ' - ' + this.get('metricViewData.agent.hostName');
+  }.property('metricTypeKey', 'metricViewData.agent.hostName')
+
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/ade07b3a/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 f0283e9..9a150bd 100644
--- a/ambari-web/app/views/main/service/services/flume.js
+++ b/ambari-web/app/views/main/service/services/flume.js
@@ -18,6 +18,7 @@
 var App = require('app');
 var date = require('utils/date/date');
 var sort = require('views/common/sort_view');
+require('views/main/service/info/metrics/flume/flume_agent_metrics_section');
 
 App.MainDashboardServiceFlumeView = App.TableView.extend(App.MainDashboardServiceViewWrapper, {
   templateName: require('templates/main/service/services/flume'),
@@ -148,43 +149,32 @@ App.MainDashboardServiceFlumeView = App.TableView.extend(App.MainDashboardServic
    * @method setFlumeAgentMetric
    * @param {object} agent - DS.model of agent
    */
-  setAgentMetrics: function(host) {
-    var getMetricTitle = function(metricTypeKey, hostName) {
-      var metricType = Em.I18n.t('services.service.info.metrics.flume.' + metricTypeKey).format(Em.I18n.t('common.metrics'));
-      return  metricType + ' - ' + hostName;
-    };
-    var agentHostMock = host.get('hostName');
+  setAgentMetrics: function (host) {
     var mockMetricData = [
       {
         header: 'channelName',
-        metricView: App.MainServiceInfoFlumeGraphsView.extend(),
-        metricViewData: {
-          agent: host,
-          metricType: 'CHANNEL'
-        }
+        metricType: 'CHANNEL'
       },
       {
         header: 'sinkName',
-        metricView: App.MainServiceInfoFlumeGraphsView.extend(),
-        metricViewData: {
-          agent: host,
-          metricType: 'SINK'
-        }
+        metricType: 'SINK'
       },
       {
         header: 'sourceName',
+        metricType: 'SOURCE'
+      }
+    ];
+    var metricViews = mockMetricData.map(function (mockData, index) {
+      return App.FlumeAgentMetricsSectionView.extend({
+        index: index,
+        metricTypeKey: mockData.header,
         metricView: App.MainServiceInfoFlumeGraphsView.extend(),
         metricViewData: {
           agent: host,
-          metricType: 'SOURCE'
+          metricType: mockData.metricType
         }
-      }
-    ];
-    mockMetricData.forEach(function(mockData, index) {
-      mockData.header = getMetricTitle(mockData.header, agentHostMock);
-      mockData.id = 'metric' + index;
-      mockData.toggleIndex = '#' + mockData.id;
+      });
     });
-    this.set('parentView.collapsedSections', mockMetricData);
+    this.set('parentView.collapsedSections', metricViews);
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/ade07b3a/ambari-web/test/views/main/service/info/metrics/flume/flume_agent_metrics_section_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/service/info/metrics/flume/flume_agent_metrics_section_test.js b/ambari-web/test/views/main/service/info/metrics/flume/flume_agent_metrics_section_test.js
new file mode 100644
index 0000000..110273b
--- /dev/null
+++ b/ambari-web/test/views/main/service/info/metrics/flume/flume_agent_metrics_section_test.js
@@ -0,0 +1,61 @@
+/**
+ * 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');
+require('views/main/service/info/metrics/flume/flume_agent_metrics_section');
+
+describe('App.FlumeAgentMetricsSectionView', function () {
+
+  var view;
+
+  beforeEach(function () {
+    view = App.FlumeAgentMetricsSectionView.create();
+  });
+
+  describe('#id', function () {
+    it('should be set depending on index', function () {
+      view.set('index', 1);
+      expect(view.get('id')).to.equal('metric1');
+    });
+  });
+
+  describe('#toggleIndex', function () {
+    it('should be set depending on id', function () {
+      view.reopen({
+        id: 'metric1'
+      });
+      expect(view.get('toggleIndex')).to.equal('#metric1');
+    });
+  });
+
+  describe('#header', function () {
+    it('should be set depending on metric type and host name', function () {
+      view.setProperties({
+        metricTypeKey: 'sinkName',
+        metricViewData: {
+          agent: {
+            hostName: 'h0'
+          }
+        }
+      });
+      expect(view.get('header')).to.equal(Em.I18n.t('services.service.info.metrics.flume.sinkName').
+        format(Em.I18n.t('common.metrics')) + ' - h0');
+    });
+  });
+
+});