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/6105ab5f
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/6105ab5f
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/6105ab5f

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 6105ab5f56a08ba27667404aac003c6689b412fb
Parents: 7cacc40
Author: Xi Wang <[email protected]>
Authored: Thu Jan 7 17:31:06 2016 -0800
Committer: Xi Wang <[email protected]>
Committed: Wed Jan 13 13:30:13 2016 -0800

----------------------------------------------------------------------
 ambari-web/app/app.js                           |  4 ++
 ambari-web/app/messages.js                      |  1 +
 ambari-web/app/models/host_component.js         |  7 ++
 .../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, 94 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/6105ab5f/ambari-web/app/app.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/app.js b/ambari-web/app/app.js
index e80f57b..52f34ab 100644
--- a/ambari-web/app/app.js
+++ b/ambari-web/app/app.js
@@ -343,6 +343,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/6105ab5f/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 2f28a75..e93aeff 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1467,6 +1467,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/6105ab5f/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 b463c80..e63f634 100644
--- a/ambari-web/app/models/host_component.js
+++ b/ambari-web/app/models/host_component.js
@@ -114,6 +114,13 @@ App.HostComponent = DS.Model.extend({
   isActive: Em.computed.equal('passiveState', 'OFF'),
 
   passiveTooltip: Em.computed.ifThenElse('isActive', '', 
Em.I18n.t('hosts.component.passive.mode')),
+  /**
+   * 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'),
 
   statusClass: function () {
     return this.get('isActive') ? this.get('workStatus') : 'icon-medkit';

http://git-wip-us.apache.org/repos/asf/ambari/blob/6105ab5f/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 6107dca..a9b342b 100644
--- a/ambari-web/app/models/stack_service_component.js
+++ b/ambari-web/app/models/stack_service_component.js
@@ -71,6 +71,11 @@ App.StackServiceComponent = DS.Model.extend({
   isReassignable: Em.computed.existsIn('componentName', ['NAMENODE', 
'SECONDARY_NAMENODE', 'JOBTRACKER', 'RESOURCEMANAGER', 'APP_TIMELINE_SERVER', 
'OOZIE_SERVER',
     'WEBHCAT_SERVER', 'HIVE_SERVER', 'HIVE_METASTORE', 'MYSQL_SERVER', 
'METRICS_COLLECTOR', 'HISTORYSERVER']),
 
+  /** @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/6105ab5f/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/6105ab5f/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 df588fd..f8dd4f2 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
@@ -234,6 +234,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);
   },
 
   /**
@@ -362,7 +369,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) {
@@ -394,5 +401,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/6105ab5f/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 5277744..e432813 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
@@ -272,6 +272,7 @@ describe('App.UpgradeVersionBoxView', function () {
       view.set('content', Em.Object.create({
         p1: []
       }));
+      view.set('p1', []);
       view.showHosts({contexts: [
         {'property': 'p1'}
       ]});
@@ -282,6 +283,7 @@ describe('App.UpgradeVersionBoxView', function () {
         p1: ['host1'],
         displayName: 'version'
       }));
+      view.set('p1', ['host1']);
       var popup = view.showHosts({contexts: [
         {id: 1, 'property': 'p1'}
       ]});

Reply via email to