Return-Path: X-Original-To: apmail-ambari-commits-archive@www.apache.org Delivered-To: apmail-ambari-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2EB8F189EC for ; Mon, 22 Feb 2016 16:48:22 +0000 (UTC) Received: (qmail 99277 invoked by uid 500); 22 Feb 2016 16:48:22 -0000 Delivered-To: apmail-ambari-commits-archive@ambari.apache.org Received: (qmail 99146 invoked by uid 500); 22 Feb 2016 16:48:22 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 98608 invoked by uid 99); 22 Feb 2016 16:48:21 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Feb 2016 16:48:21 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 8BF2FE0362; Mon, 22 Feb 2016 16:48:21 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ncole@apache.org To: commits@ambari.apache.org Date: Mon, 22 Feb 2016 16:48:28 -0000 Message-Id: <4db908aaa285450f89a7c6a5287c7055@git.apache.org> In-Reply-To: <90cdde70f79b47228e68f3f3708e8b6a@git.apache.org> References: <90cdde70f79b47228e68f3f3708e8b6a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [08/21] ambari git commit: AMBARI-15060: Ambari should show no. of HAWQ segments live on main dashboard (mithmatt via jaoki) AMBARI-15060: Ambari should show no. of HAWQ segments live on main dashboard (mithmatt via jaoki) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/82d94401 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/82d94401 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/82d94401 Branch: refs/heads/branch-dev-patch-upgrade Commit: 82d944017eb90c380e374e6f7aeddab6004c6a84 Parents: 997749f Author: Jun Aoki Authored: Fri Feb 19 12:05:40 2016 -0800 Committer: Jun Aoki Committed: Fri Feb 19 12:05:40 2016 -0800 ---------------------------------------------------------------------- ambari-web/app/assets/test/tests.js | 1 + .../app/mappers/components_state_mapper.js | 5 + ambari-web/app/messages.js | 5 + ambari-web/app/views.js | 1 + ambari-web/app/views/main/dashboard/widgets.js | 19 +- .../main/dashboard/widgets/hawqsegment_live.js | 190 +++++++++++++++++++ .../dashboard/widgets/hawqsegment_live_test.js | 69 +++++++ 7 files changed, 286 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/82d94401/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 06c4c31..4edcc5e 100644 --- a/ambari-web/app/assets/test/tests.js +++ b/ambari-web/app/assets/test/tests.js @@ -239,6 +239,7 @@ var files = [ 'test/views/main/dashboard/widgets/uptime_text_widget_test', '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/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/82d94401/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 0f2b627..ac3e1b5 100644 --- a/ambari-web/app/mappers/components_state_mapper.js +++ b/ambari-web/app/mappers/components_state_mapper.js @@ -59,6 +59,11 @@ App.componentsStateMapper = App.QuickDataMapper.create({ node_managers_installed: 'INSTALLED_PATH', node_managers_total: 'TOTAL_PATH' }, + 'HAWQSEGMENT': { + hawq_segments_started: 'STARTED_PATH', + hawq_segments_installed: 'INSTALLED_PATH', + hawq_segments_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/82d94401/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index 1b08248..2622043 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -2527,6 +2527,7 @@ Em.I18n.translations = { 'dashboard.widgets.YARNLinks': 'YARN Links', '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': { @@ -2631,6 +2632,10 @@ 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.hive.clients':'Hive Clients', 'dashboard.services.hive.client':'Hive Client', 'dashboard.services.hive.metastore':'Hive Metastore', http://git-wip-us.apache.org/repos/asf/ambari/blob/82d94401/ambari-web/app/views.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js index 2440086..0d3e49b 100644 --- a/ambari-web/app/views.js +++ b/ambari-web/app/views.js @@ -219,6 +219,7 @@ require('views/main/dashboard/widgets/namenode_heap'); 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/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/82d94401/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 a2fb281..8a86af6 100644 --- a/ambari-web/app/views/main/dashboard/widgets.js +++ b/ambari-web/app/views/main/dashboard/widgets.js @@ -128,7 +128,8 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap '13', '12', '14', '16', //hbase '17', '18', '19', '20', '23', // all yarn '21', // storm - '22' // flume + '22', // flume + '24' // hawq ]; // all in order var hiddenFull = [ ['15', 'Region In Transition'] @@ -173,6 +174,12 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap visibleFull = visibleFull.without(item); }, this); } + if (this.get('hawq_model') == null) { + var hawq = ['24']; + hawq.forEach(function (item) { + visibleFull = visibleFull.without(item); + }, this); + } var obj = this.get('initPrefObject'); obj.set('visible', visibleFull); obj.set('hidden', hiddenFull); @@ -192,6 +199,8 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap flume_model: null, + hawq_model: null, + /** * List of visible widgets * @type {Ember.Enumerable} @@ -383,7 +392,8 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap hbase_model: ['12', '13', '14', '15', '16'], yarn_model: ['17', '18', '19', '20', '23'], storm_model: ['21'], - flume_model: ['22'] + flume_model: ['22'], + hawq_model: ['24'] }; // check each service, find out the newly added service and already deleted service @@ -450,7 +460,8 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap '20': App.YARNMemoryPieChartView, '21': App.SuperVisorUpView, '22': App.FlumeAgentUpView, - '23': App.YARNLinksView + '23': App.YARNLinksView, + '24': App.HawqSegmentUpView }, id); }, @@ -467,7 +478,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: []} // id:[thresh1, thresh2] + 17: [70, 90], 18: [], 19: [50, 75], 20: [50, 75], 21: [85, 95], 22: [85, 95], 23: [], 24: [80, 90]} // id:[thresh1, thresh2] }), /** http://git-wip-us.apache.org/repos/asf/ambari/blob/82d94401/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 new file mode 100644 index 0000000..e8d0656 --- /dev/null +++ b/ambari-web/app/views/main/dashboard/widgets/hawqsegment_live.js @@ -0,0 +1,190 @@ +/** + * 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.HawqSegmentUpView = App.TextDashboardWidgetView.extend({ + + title: Em.I18n.t('dashboard.widgets.HawqSegmentUp'), + id: '24', + + isPieChart: false, + isText: true, + isProgressBar: false, + model_type: 'hawq', + + hiddenInfo: function () { + var result = []; + result.pushObject(this.get('hawqSegmentsStarted') + ' ' + Em.I18n.t('dashboard.services.hawq.segments.started')); + result.pushObject(this.get('hawqSegmentsInstalled') + ' ' + Em.I18n.t('dashboard.services.hawq.segments.stopped')); + result.pushObject(this.get('hawqSegmentsTotal')+ ' ' + Em.I18n.t('dashboard.services.hawq.segments.total')); + return result; + }.property('hawqSegmentsStarted', 'hawqSegmentsInstalled', 'hawqSegmentsTotal'), + hiddenInfoClass: "hidden-info-three-line", + + thresh1: 40, + thresh2: 70, + maxValue: 100, + + hawqSegmentsStarted: function () { + if (Em.isNone(this.get('model.hawqSegmentsStarted'))) { + return Em.I18n.t('services.service.summary.notAvailable'); + } + return this.get('model.hawqSegmentsStarted'); + }.property('model.hawqSegmentsStarted'), + + hawqSegmentsInstalled: function () { + if (Em.isNone(this.get('model.hawqSegmentsInstalled'))) { + return Em.I18n.t('services.service.summary.notAvailable'); + } + return this.get('model.hawqSegmentsInstalled'); + }.property('model.hawqSegmentsInstalled'), + + hawqSegmentsTotal: function () { + if (Em.isNone(this.get('model.hawqSegmentsTotal'))) { + return Em.I18n.t('services.service.summary.notAvailable'); + } + return this.get('model.hawqSegmentsTotal'); + }.property('model.hawqSegmentsTotal'), + + data: function () { + if (Em.isNone(this.get('model.hawqSegmentsStarted')) || Em.isNone(this.get('model.hawqSegmentsTotal'))) { + return null; + } else { + return ((this.get('hawqSegmentsStarted') / this.get('model.hawqSegmentsTotal')).toFixed(2)) * 100; + } + }.property('model.hawqSegmentsTotal', 'hawqSegmentsStarted'), + + content: function () { + if (Em.isNone(this.get('model.hawqSegmentsStarted')) || Em.isNone(this.get('model.hawqSegmentsTotal'))) { + return Em.I18n.t('services.service.summary.notAvailable'); + } else { + return this.get('hawqSegmentsStarted') + "/" + this.get('model.hawqSegmentsTotal'); + } + }.property('model.hawqSegmentsTotal', 'hawqSegmentsStarted'), + + editWidget: function (event) { + var parent = this; + var max_tmp = parseFloat(parent.get('maxValue')); + var configObj = Ember.Object.create({ + thresh1: parent.get('thresh1') + '', + thresh2: parent.get('thresh2') + '', + hintInfo: Em.I18n.t('dashboard.widgets.hintInfo.hint1').format(max_tmp), + isThresh1Error: false, + isThresh2Error: false, + errorMessage1: "", + errorMessage2: "", + maxValue: max_tmp, + observeNewThresholdValue: function () { + var thresh1 = this.get('thresh1'); + var thresh2 = this.get('thresh2'); + if (thresh1.trim() != "") { + if (isNaN(thresh1) || thresh1 > max_tmp || thresh1 < 0){ + this.set('isThresh1Error', true); + this.set('errorMessage1', 'Invalid! Enter a number between 0 - ' + max_tmp); + } else if ( this.get('isThresh2Error') === false && parseFloat(thresh2)<= parseFloat(thresh1)) { + this.set('isThresh1Error', true); + this.set('errorMessage1', 'Threshold 1 should be smaller than threshold 2 !'); + } else { + this.set('isThresh1Error', false); + this.set('errorMessage1', ''); + } + } else { + this.set('isThresh1Error', true); + this.set('errorMessage1', 'This is required'); + } + + if (thresh2.trim() != "") { + if (isNaN(thresh2) || thresh2 > max_tmp || thresh2 < 0) { + this.set('isThresh2Error', true); + this.set('errorMessage2', 'Invalid! Enter a number between 0 - ' + max_tmp); + } else { + this.set('isThresh2Error', false); + this.set('errorMessage2', ''); + } + } else { + this.set('isThresh2Error', true); + this.set('errorMessage2', 'This is required'); + } + + // update the slider handles and color + if (this.get('isThresh1Error') === false && this.get('isThresh2Error') === false) { + $("#slider-range").slider('values', 0 , parseFloat(thresh1)); + $("#slider-range").slider('values', 1 , parseFloat(thresh2)); + } + }.observes('thresh1', 'thresh2') + + }); + + var browserVerion = this.getInternetExplorerVersion(); + App.ModalPopup.show({ + header: Em.I18n.t('dashboard.widgets.popupHeader'), + classNames: [ 'sixty-percent-width-modal-edit-widget'], + bodyClass: Ember.View.extend({ + templateName: require('templates/main/dashboard/edit_widget_popup'), + configPropertyObj: configObj + }), + primary: Em.I18n.t('common.apply'), + onPrimary: function () { + configObj.observeNewThresholdValue(); + if (!configObj.isThresh1Error && !configObj.isThresh2Error) { + parent.set('thresh1', parseFloat(configObj.get('thresh1')) ); + parent.set('thresh2', parseFloat(configObj.get('thresh2')) ); + if (!App.get('testMode')) { + var big_parent = parent.get('parentView'); + big_parent.getUserPref(big_parent.get('persistKey')); + var oldValue = big_parent.get('currentPrefObject'); + oldValue.threshold[parseInt(parent.id)] = [configObj.get('thresh1'), configObj.get('thresh2')]; + big_parent.postUserPref(big_parent.get('persistKey'),oldValue); + } + this.hide(); + } + }, + + didInsertElement: function () { + var handlers = [configObj.get('thresh1'), configObj.get('thresh2')]; + var colors = [App.healthStatusRed, App.healthStatusOrange, App.healthStatusGreen]; //color red, orange, green + + if (browserVerion == -1 || browserVerion > 9) { + configObj.set('isIE9', false); + configObj.set('isGreenOrangeRed', false); + $("#slider-range").slider({ + range: true, + min: 0, + max: max_tmp, + values: handlers, + create: function (event, ui) { + parent.updateColors(handlers, colors); + }, + slide: function (event, ui) { + parent.updateColors(ui.values, colors); + configObj.set('thresh1', ui.values[0] + ''); + configObj.set('thresh2', ui.values[1] + ''); + }, + change: function (event, ui) { + parent.updateColors(ui.values, colors); + } + }); + } else { + configObj.set('isIE9', true); + configObj.set('isGreenOrangeRed', false); + } + } + }); + } +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/82d94401/ambari-web/test/views/main/dashboard/widgets/hawqsegment_live_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/dashboard/widgets/hawqsegment_live_test.js b/ambari-web/test/views/main/dashboard/widgets/hawqsegment_live_test.js new file mode 100644 index 0000000..eb8a505 --- /dev/null +++ b/ambari-web/test/views/main/dashboard/widgets/hawqsegment_live_test.js @@ -0,0 +1,69 @@ +/** + * 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/hawqsegment_live'); + +describe('App.HawqSegmentUpView', function() { + + var tests = [ + { + data: 100, + e: { + isRed: false, + isOrange: false, + isGreen: true + } + }, + { + data: 0, + e: { + isRed: true, + isOrange: false, + isGreen: false + } + }, + { + data: 50, + e: { + isRed: false, + isOrange: true, + isGreen: false + } + } + ]; + + tests.forEach(function(test) { + describe('', function() { + var hawqSegmentUpView = App.HawqSegmentUpView.create({model_type:null, data: test.data, content: test.data.toString()}); + it('shows red', function() { + expect(hawqSegmentUpView.get('isRed')).to.equal(test.e.isRed); + }); + it('shows orange', function() { + expect(hawqSegmentUpView.get('isOrange')).to.equal(test.e.isOrange); + }); + it('shows green', function() { + expect(hawqSegmentUpView.get('isGreen')).to.equal(test.e.isGreen); + }); + }); + }); + +});