Repository: ambari Updated Branches: refs/heads/branch-2.2 595353166 -> 4230046d5
AMBARI-14584. RU/EU - Fix calculation of hosts so that non-HDP component hosts will be excluded from 'Uninstalled', show more details on hover.(xiwang) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4230046d Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4230046d Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4230046d Branch: refs/heads/branch-2.2 Commit: 4230046d5a5f76a00e75e76dc1b341f3c70bfe53 Parents: 5953531 Author: Xi Wang <[email protected]> Authored: Thu Jan 7 17:31:06 2016 -0800 Committer: Xi Wang <[email protected]> Committed: Wed Jan 13 13:28:25 2016 -0800 ---------------------------------------------------------------------- ambari-web/app/app.js | 4 ++ ambari-web/app/messages.js | 1 + ambari-web/app/models/host_component.js | 8 +++ .../app/models/stack_service_component.js | 5 ++ .../admin/stack_upgrade/upgrade_version_box.hbs | 6 +- .../stack_upgrade/upgrade_version_box_view.js | 74 +++++++++++++++++++- .../upgrade_version_box_view_test.js | 2 + 7 files changed, 95 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/4230046d/ambari-web/app/app.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/app.js b/ambari-web/app/app.js index ccf7edb..ef1ddad 100644 --- a/ambari-web/app/app.js +++ b/ambari-web/app/app.js @@ -358,6 +358,10 @@ module.exports = Em.Application.create({ clients: function () { return App.StackServiceComponent.find().filterProperty('isClient').mapProperty('componentName') + }.property('App.router.clusterController.isLoaded'), + + nonHDP: function () { + return App.StackServiceComponent.find().filterProperty('isNonHDPComponent').mapProperty('componentName') }.property('App.router.clusterController.isLoaded') }) }); http://git-wip-us.apache.org/repos/asf/ambari/blob/4230046d/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index bec978b..528a903 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -1480,6 +1480,7 @@ Em.I18n.translations = { 'admin.stackVersions.version.hostsTooltip': 'Click to List Hosts', 'admin.stackVersions.version.emptyHostsTooltip': 'No Hosts to List', 'admin.stackVersions.version.notInstalled': "Not Installed", + 'admin.stackVersions.version.hostsInfoTooltip': "There are {0} hosts that do not need packages installed:<li>{1} Maintenance Mode</li><li>{2} Not Required</li>", 'admin.stackVersions.manageVersions': "Manage Versions", 'admin.stackVersions.manageVersions.popup.body': 'You are about to leave the <b>Cluster Management</b> interface' + ' and go to the <b>Ambari Administration</b> interface. You can return to cluster management by using the' + http://git-wip-us.apache.org/repos/asf/ambari/blob/4230046d/ambari-web/app/models/host_component.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/host_component.js b/ambari-web/app/models/host_component.js index e61822a..1be5643 100644 --- a/ambari-web/app/models/host_component.js +++ b/ambari-web/app/models/host_component.js @@ -111,6 +111,14 @@ App.HostComponent = DS.Model.extend({ return (this.get('passiveState') == 'OFF'); }.property('passiveState'), + /** + * Determine if component is a HDP component + * @returns {bool} + */ + isHDPComponent: function () { + return !App.get('components.nonHDP').contains(this.get('componentName')); + }.property('componentName', 'App.components.nonHDP'), + passiveTooltip: function () { if (!this.get('isActive')) { return Em.I18n.t('hosts.component.passive.mode'); http://git-wip-us.apache.org/repos/asf/ambari/blob/4230046d/ambari-web/app/models/stack_service_component.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/stack_service_component.js b/ambari-web/app/models/stack_service_component.js index 0a03336..18e5932 100644 --- a/ambari-web/app/models/stack_service_component.js +++ b/ambari-web/app/models/stack_service_component.js @@ -80,6 +80,11 @@ App.StackServiceComponent = DS.Model.extend({ return ['NAMENODE', 'SECONDARY_NAMENODE', 'JOBTRACKER', 'RESOURCEMANAGER', 'APP_TIMELINE_SERVER', 'OOZIE_SERVER', 'WEBHCAT_SERVER', 'HIVE_SERVER', 'HIVE_METASTORE', 'MYSQL_SERVER', 'METRICS_COLLECTOR'].contains(this.get('componentName')); }.property('componentName'), + /** @property {Boolean} isNonHDPComponent - component not belongs to HDP services **/ + isNonHDPComponent: function() { + return ['METRICS_COLLECTOR', 'METRICS_MONITOR'].contains(this.get('componentName')); + }.property('componentName'), + /** @property {Boolean} isRollinRestartAllowed - component supports rolling restart action **/ isRollinRestartAllowed: function() { return this.get('isSlave') || this.get('componentName') === 'KAFKA_BROKER'; http://git-wip-us.apache.org/repos/asf/ambari/blob/4230046d/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_version_box.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_version_box.hbs b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_version_box.hbs index 0505289..70a0738 100644 --- a/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_version_box.hbs +++ b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_version_box.hbs @@ -82,19 +82,19 @@ <div class="span4 align-center not-installed-hosts"> <div><a href="#" class="hosts-tooltip not-active" {{bindAttr data-original-title="view.content.noInitHostsTooltip" }} {{action showHosts view.versionStateMap.not_installed target="view"}}> - {{view.content.notInstalledHosts.length}}</a></div> + {{view.notInstalledHosts.length}}</a></div> <div>{{t admin.stackVersions.version.notInstalled}}</div> </div> <div class="span4 align-center installed-hosts"> <div><a href="#" class="hosts-tooltip not-active" {{bindAttr data-original-title="view.content.noInstalledHostsTooltip" }} {{action showHosts view.versionStateMap.installed target="view"}}> - {{view.content.installedHosts.length}}</a></div> + {{view.installedHosts.length}}</a></div> <div>{{t common.installed}}</div> </div> <div class="span4 align-center current-hosts"> <div><a href="#" class="hosts-tooltip not-active" {{bindAttr data-original-title="view.content.noCurrentHostsTooltip" }} {{action showHosts view.versionStateMap.current target="view"}}> - {{view.content.currentHosts.length}}</a></div> + {{view.currentHosts.length}}</a></div> <div>{{t common.current}}</div> </div> </div> http://git-wip-us.apache.org/repos/asf/ambari/blob/4230046d/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js index 2a0b170..0d15fd8 100644 --- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js +++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js @@ -236,6 +236,13 @@ App.UpgradeVersionBoxView = Em.View.extend({ App.tooltip($('.link-tooltip'), {title: Em.I18n.t('admin.stackVersions.version.linkTooltip')}); App.tooltip($('.hosts-tooltip')); App.tooltip($('.out-of-sync-badge'), {title: Em.I18n.t('hosts.host.stackVersions.status.out_of_sync')}); + Em.run.later(this, function () { + if (this.get('maintenanceHosts').length + this.get('notRequiredHosts').length) { + App.tooltip(this.$('.hosts-section'), {placement: 'bottom', title: Em.I18n.t('admin.stackVersions.version.hostsInfoTooltip').format( + this.get('maintenanceHosts').length + this.get('notRequiredHosts').length, this.get('maintenanceHosts').length, this.get('notRequiredHosts').length + )}); + } + }, 1000); }, /** @@ -349,7 +356,7 @@ App.UpgradeVersionBoxView = Em.View.extend({ showHosts: function (event) { var status = event.contexts[0]; var displayName = this.get('content.displayName'); - var hosts = this.get('content').get(status['property']); + var hosts = this.get(status['property']); var self = this; hosts.sort(); if (hosts.length) { @@ -381,5 +388,68 @@ App.UpgradeVersionBoxView = Em.View.extend({ App.router.get('mainHostController').filterByStack(displayName, state); App.router.get('mainHostController').set('showFilterConditionsFirstLoad', true); App.router.transitionTo('hosts.index'); - } + }, + + /** + * Not installed hosts should exclude 1.not required hosts 2. Maintenance Mode hosts, + * or it maybe confusing to users + * @type {Array} + */ + notInstalledHosts: function () { + var notInstalledHosts = this.get('content.notInstalledHosts') || App.get('allHostNames'); + var notRequiredHosts = this.get('notRequiredHosts'); + var maintenanceHosts = this.get('maintenanceHosts'); + if (notInstalledHosts.length && notRequiredHosts.length) { + notRequiredHosts.forEach(function(not_required) { + var index = notInstalledHosts.indexOf(not_required) + if (index > -1) { + notInstalledHosts.splice(index, 1); + } + }); + } + if (notInstalledHosts.length && maintenanceHosts.length) { + maintenanceHosts.forEach(function(mm_host) { + var index = notInstalledHosts.indexOf(mm_host) + if (index > -1) { + notInstalledHosts.splice(index, 1); + } + }); + } + return notInstalledHosts; + }.property('content.notInstalledHosts', 'notRequiredHosts', 'maintenanceHosts'), + + /** + * @type {Array} + */ + maintenanceHosts: function () { + return App.Host.find().filterProperty('passiveState', 'ON').mapProperty('hostName') || []; + }.property(''), + + /** + * Host with no HDP component is not required to install new version + * @type {Array} + */ + notRequiredHosts: function () { + var notRequiredHosts = []; + App.Host.find().forEach(function(host) { + if (!host.get('hostComponents').someProperty('isHDPComponent')) { + notRequiredHosts.push(host.get('hostName')); + } + }); + return notRequiredHosts.uniq() || []; + }.property(''), + + /** + * @type {Array} + */ + installedHosts: function () { + return this.get('content.installedHosts') || []; + }.property('content.installedHosts'), + + /** + * @type {Array} + */ + currentHosts: function () { + return this.get('content.currentHosts') || []; + }.property('content.currentHosts') }); http://git-wip-us.apache.org/repos/asf/ambari/blob/4230046d/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js index 87a11f8..ba794e7 100644 --- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js +++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js @@ -263,6 +263,7 @@ describe('App.UpgradeVersionBoxView', function () { view.set('content', Em.Object.create({ p1: [] })); + view.set('p1', []); view.showHosts({contexts: [ {'property': 'p1'} ]}); @@ -273,6 +274,7 @@ describe('App.UpgradeVersionBoxView', function () { p1: ['host1'], displayName: 'version' })); + view.set('p1', ['host1']); var popup = view.showHosts({contexts: [ {id: 1, 'property': 'p1'} ]});
