Repository: ambari Updated Branches: refs/heads/trunk 29179e766 -> 47510ed78
AMBARI-16074: Show number of PXFs Live widget on main dashboard (mithmatt) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/47510ed7 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/47510ed7 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/47510ed7 Branch: refs/heads/trunk Commit: 47510ed78590116dd3c34c89b47a43b45abb1fba Parents: 29179e7 Author: Matt <mmat...@pivotal.io> Authored: Mon Apr 25 21:12:30 2016 -0700 Committer: Matt <mmat...@pivotal.io> Committed: Mon Apr 25 21:12:30 2016 -0700 ---------------------------------------------------------------------- ambari-web/app/assets/test/tests.js | 1 + .../app/mappers/components_state_mapper.js | 5 ++ ambari-web/app/messages.js | 7 +- ambari-web/app/views.js | 1 + ambari-web/app/views/main/dashboard/widgets.js | 19 +++- .../main/dashboard/widgets/hawqsegment_live.js | 6 +- .../views/main/dashboard/widgets/pxf_live.js | 91 ++++++++++++++++++++ .../main/dashboard/widgets/pxf_live_test.js | 65 ++++++++++++++ 8 files changed, 185 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/47510ed7/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 33e7f1c..7226720 100644 --- a/ambari-web/app/assets/test/tests.js +++ b/ambari-web/app/assets/test/tests.js @@ -254,6 +254,7 @@ var files = [ 'test/views/main/dashboard/widgets/node_managers_live_test', 'test/views/main/dashboard/widgets/datanode_live_test', 'test/views/main/dashboard/widgets/hawqsegment_live_test', + 'test/views/main/dashboard/widgets/pxf_live_test', 'test/views/main/dashboard/widgets/hbase_average_load_test', 'test/views/main/dashboard/widgets/hbase_regions_in_transition_test', 'test/views/main/dashboard/widgets/namenode_rpc_test', http://git-wip-us.apache.org/repos/asf/ambari/blob/47510ed7/ambari-web/app/mappers/components_state_mapper.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mappers/components_state_mapper.js b/ambari-web/app/mappers/components_state_mapper.js index 755c0f5..96eb52b 100644 --- a/ambari-web/app/mappers/components_state_mapper.js +++ b/ambari-web/app/mappers/components_state_mapper.js @@ -65,6 +65,11 @@ App.componentsStateMapper = App.QuickDataMapper.create({ hawq_segments_installed: 'INSTALLED_PATH', hawq_segments_total: 'TOTAL_PATH' }, + 'PXF': { + pxfs_started: 'STARTED_PATH', + pxfs_installed: 'INSTALLED_PATH', + pxfs_total: 'TOTAL_PATH' + }, 'HBASE_REGIONSERVER': { region_servers_started: 'STARTED_PATH', region_servers_installed: 'INSTALLED_PATH', http://git-wip-us.apache.org/repos/asf/ambari/blob/47510ed7/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index 04041aa..8c8b9e5 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -2615,6 +2615,7 @@ Em.I18n.translations = { 'dashboard.widgets.error.invalid': 'Invalid! Enter a number between 0 - {0}', 'dashboard.widgets.error.smaller': 'Threshold 1 should be smaller than threshold 2!', 'dashboard.widgets.HawqSegmentUp': 'HAWQ Segments Live', + 'dashboard.widgets.PxfUp': 'PXFs Live', 'dashboard': { 'widgets': { @@ -2721,9 +2722,9 @@ Em.I18n.translations = { 'dashboard.services.hbase.masterStarted':'Master Started', 'dashboard.services.hbase.masterActivated':'Master Activated', - 'dashboard.services.hawq.segments.started':'started', - 'dashboard.services.hawq.segments.stopped':'stopped', - 'dashboard.services.hawq.segments.total':'in total', + 'dashboard.services.components.started':'started', + 'dashboard.services.components.stopped':'stopped', + 'dashboard.services.components.total':'in total', 'dashboard.services.hive.clients':'Hive Clients', 'dashboard.services.hive.client':'Hive Client', http://git-wip-us.apache.org/repos/asf/ambari/blob/47510ed7/ambari-web/app/views.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js index 6bb2774..8e02639 100644 --- a/ambari-web/app/views.js +++ b/ambari-web/app/views.js @@ -233,6 +233,7 @@ require('views/main/dashboard/widgets/namenode_cpu'); require('views/main/dashboard/widgets/hdfs_capacity'); require('views/main/dashboard/widgets/datanode_live'); require('views/main/dashboard/widgets/hawqsegment_live'); +require('views/main/dashboard/widgets/pxf_live'); require('views/main/dashboard/widgets/namenode_rpc'); require('views/main/dashboard/widgets/metrics_memory'); require('views/main/dashboard/widgets/metrics_network'); http://git-wip-us.apache.org/repos/asf/ambari/blob/47510ed7/ambari-web/app/views/main/dashboard/widgets.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/dashboard/widgets.js b/ambari-web/app/views/main/dashboard/widgets.js index 067607f..38181c0 100644 --- a/ambari-web/app/views/main/dashboard/widgets.js +++ b/ambari-web/app/views/main/dashboard/widgets.js @@ -129,7 +129,8 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap '17', '18', '19', '20', '23', // all yarn '21', // storm '22', // flume - '24' // hawq + '24', // hawq + '25' // pxf ]; // all in order var hiddenFull = [ ['15', 'Region In Transition'] @@ -180,6 +181,12 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap visibleFull = visibleFull.without(item); }, this); } + if (this.get('pxf_model') == null) { + var pxf = ['25']; + pxf.forEach(function (item) { + visibleFull = visibleFull.without(item); + }, this); + } var obj = this.get('initPrefObject'); obj.set('visible', visibleFull); obj.set('hidden', hiddenFull); @@ -201,6 +208,8 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap hawq_model: null, + pxf_model: null, + /** * List of visible widgets * @type {Ember.Enumerable} @@ -395,7 +404,8 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap yarn_model: ['17', '18', '19', '20', '23'], storm_model: ['21'], flume_model: ['22'], - hawq_model: ['24'] + hawq_model: ['24'], + pxf_model: ['25'] }; // check each service, find out the newly added service and already deleted service @@ -463,7 +473,8 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap '21': App.SuperVisorUpView, '22': App.FlumeAgentUpView, '23': App.YARNLinksView, - '24': App.HawqSegmentUpView + '24': App.HawqSegmentUpView, + '25': App.PxfUpView }, id); }, @@ -480,7 +491,7 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap visible: [], hidden: [], threshold: {1: [80, 90], 2: [85, 95], 3: [90, 95], 4: [80, 90], 5: [1000, 3000], 6: [], 7: [], 8: [], 9: [], 10: [], 11: [], 12: [], 13: [70, 90], 14: [150, 250], 15: [3, 10], 16: [], - 17: [70, 90], 18: [], 19: [50, 75], 20: [50, 75], 21: [85, 95], 22: [85, 95], 23: [], 24: [75, 90]} // id:[thresh1, thresh2] + 17: [70, 90], 18: [], 19: [50, 75], 20: [50, 75], 21: [85, 95], 22: [85, 95], 23: [], 24: [75, 90], 25: [75, 90]} // id:[thresh1, thresh2] }), /** http://git-wip-us.apache.org/repos/asf/ambari/blob/47510ed7/ambari-web/app/views/main/dashboard/widgets/hawqsegment_live.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/dashboard/widgets/hawqsegment_live.js b/ambari-web/app/views/main/dashboard/widgets/hawqsegment_live.js index bec98c6..04e7d66 100644 --- a/ambari-web/app/views/main/dashboard/widgets/hawqsegment_live.js +++ b/ambari-web/app/views/main/dashboard/widgets/hawqsegment_live.js @@ -38,9 +38,9 @@ App.HawqSegmentUpView = App.TextDashboardWidgetView.extend(App.EditableWithLimit hiddenInfo: function () { return [ - this.get('hawqSegmentsStarted') + ' ' + Em.I18n.t('dashboard.services.hawq.segments.started'), - this.get('hawqSegmentsInstalled') + ' ' + Em.I18n.t('dashboard.services.hawq.segments.stopped'), - this.get('hawqSegmentsTotal')+ ' ' + Em.I18n.t('dashboard.services.hawq.segments.total') + this.get('hawqSegmentsStarted') + ' ' + Em.I18n.t('dashboard.services.components.started'), + this.get('hawqSegmentsInstalled') + ' ' + Em.I18n.t('dashboard.services.components.stopped'), + this.get('hawqSegmentsTotal')+ ' ' + Em.I18n.t('dashboard.services.components.total') ]; }.property('hawqSegmentsStarted', 'hawqSegmentsInstalled', 'hawqSegmentsTotal'), http://git-wip-us.apache.org/repos/asf/ambari/blob/47510ed7/ambari-web/app/views/main/dashboard/widgets/pxf_live.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/dashboard/widgets/pxf_live.js b/ambari-web/app/views/main/dashboard/widgets/pxf_live.js new file mode 100644 index 0000000..75f5886 --- /dev/null +++ b/ambari-web/app/views/main/dashboard/widgets/pxf_live.js @@ -0,0 +1,91 @@ +/** + * 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'); + +function counterOrNA(key) { + var _key = 'model.{0}'.format(key); + return Em.computed(_key, function () { + var value = this.get(_key); + if (Em.isNone(value)) { + return Em.I18n.t('services.service.summary.notAvailable'); + } + return value; + }); +} + +App.PxfUpView = App.TextDashboardWidgetView.extend(App.EditableWithLimitWidgetMixin, { + + title: Em.I18n.t('dashboard.widgets.PxfUp'), + id: '25', + + model_type: 'pxf', + + hiddenInfo: function () { + return [ + this.get('pxfsStarted') + ' ' + Em.I18n.t('dashboard.services.components.started'), + this.get('pxfsInstalled') + ' ' + Em.I18n.t('dashboard.services.components.stopped'), + this.get('pxfsTotal')+ ' ' + Em.I18n.t('dashboard.services.components.total') + ]; + }.property('pxfsStarted', 'pxfsInstalled', 'pxfsTotal'), + + hiddenInfoClass: "hidden-info-three-line", + + thresh1: 75, + thresh2: 90, + maxValue: 100, + + pxfsStarted: counterOrNA('pxfsStarted'), + + pxfsInstalled: counterOrNA('pxfsInstalled'), + + pxfsTotal: counterOrNA('pxfsTotal'), + + /** + * @type {?number} + */ + data: function () { + if (this.get('someMetricsNA')) { + return null; + } + return (this.get('pxfsStarted') / this.get('model.pxfsTotal')).toFixed(2) * 100; + }.property('model.pxfsTotal', 'pxfsStarted', 'someMetricsNA'), + + /** + * @type {string} + */ + content: function () { + if (this.get('someMetricsNA')) { + return Em.I18n.t('services.service.summary.notAvailable'); + } + return this.get('pxfsStarted') + "/" + this.get('model.pxfsTotal'); + }.property('model.pxfsTotal', 'pxfsStarted', 'someMetricsNA'), + + hintInfo: function () { + var maxTmp = parseFloat(this.get('maxValue')); + return Em.I18n.t('dashboard.widgets.hintInfo.hint1').format(maxTmp); + }.property('maxValue'), + + /** + * @type {boolean} + */ + someMetricsNA: function() { + return Em.isNone(this.get('model.pxfsStarted')) || Em.isNone(this.get('model.pxfsTotal')); + }.property('model.pxfsStarted', 'model.pxfsTotal') + +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/47510ed7/ambari-web/test/views/main/dashboard/widgets/pxf_live_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/dashboard/widgets/pxf_live_test.js b/ambari-web/test/views/main/dashboard/widgets/pxf_live_test.js new file mode 100644 index 0000000..94f47e6 --- /dev/null +++ b/ambari-web/test/views/main/dashboard/widgets/pxf_live_test.js @@ -0,0 +1,65 @@ +/** + * 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/dashboard/widget'); +require('views/main/dashboard/widgets/text_widget'); +require('views/main/dashboard/widgets/pxf_live'); + +var view; + +function testCounterOrNa(propertyName, dependentKey) { + describe('#' + propertyName, function () { + + beforeEach(function () { + view.reopen({ + model: Em.Object.create() + }); + view.get('model').set(dependentKey, []); + }); + + it('n/a (1)', function () { + view.get('model').set(dependentKey, null); + expect(view.get(propertyName)).to.be.equal(Em.I18n.t('services.service.summary.notAvailable')); + }); + + it('n/a (2)', function () { + view.get('model').set(dependentKey, undefined); + expect(view.get(propertyName)).to.be.equal(Em.I18n.t('services.service.summary.notAvailable')); + }); + + it('value exist', function () { + view.get('model').set(dependentKey, 123); + expect(view.get(propertyName)).to.be.equal(123); + }); + + }); +} + +describe('App.PxfUpView', function() { + + beforeEach(function () { + view = App.PxfUpView.create(); + }); + + testCounterOrNa('pxfsStarted', 'pxfsStarted'); + testCounterOrNa('pxfsInstalled', 'pxfsInstalled'); + testCounterOrNa('pxfsStarted', 'pxfsStarted'); + +});