Ver código fonte

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)

Xi Wang 9 anos atrás
pai
commit
6105ab5f56

+ 4 - 0
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')
   })
 });

+ 1 - 0
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' +

+ 7 - 0
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';

+ 5 - 0
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';

+ 3 - 3
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>

+ 72 - 2
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')
 });

+ 2 - 0
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'}
       ]});