Przeglądaj źródła

AMBARI-2056. Show proper error message while user tries to save configurations of partially stopped service. (srimanth)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1478207 13f79535-47bb-0310-9956-ffa450edef68
Srimanth 12 lat temu
rodzic
commit
3efcc5323b

+ 3 - 0
CHANGES.txt

@@ -825,6 +825,9 @@ Trunk (unreleased changes):
 
  BUG FIXES
 
+ AMBARI-2056. Show proper error message while user tries to save configurations 
+ of partially stopped service. (srimanth)
+
  AMBARI-2064. Legend for zoomed-in graphs do not render properly in IE9.
  (yusaku)
 

+ 78 - 11
ambari-web/app/controllers/main/service/info/configs.js

@@ -579,6 +579,52 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
     }, this);
   },
 
+  /**
+   * Determines which host components are running on each host.
+   * @return Returned in the following format:
+   * {
+   *  runningHosts: {
+   *    'hostname1': 'NameNode, DataNode, JobTracker',
+   *    'hostname2': 'DataNode',
+   *  },
+   *  runningComponentCount: 5
+   * }
+   */
+  getRunningHostComponents: function (services) {
+    var runningHosts = [];
+    var runningComponentCount = 0;
+    var hostToIndexMap = {};
+    services.forEach(function (service) {
+      var runningHostComponents = service.get('runningHostComponents');
+      if (runningHostComponents != null) {
+        runningHostComponents.forEach(function (hc) {
+          var hostName = hc.get('host.publicHostName');
+          var componentName = hc.get('displayName');
+          runningComponentCount++;
+          if (!(hostName in hostToIndexMap)) {
+            runningHosts.push({
+              name: hostName,
+              components: ""
+            });
+            hostToIndexMap[hostName] = runningHosts.length - 1;
+          }
+          var hostObj = runningHosts[hostToIndexMap[hostName]];
+          if (hostObj.components.length > 0)
+            hostObj.components += ", " + componentName;
+          else
+            hostObj.components += componentName;
+        });
+        runningHosts.sort(function (a, b) {
+          return a.name.localeCompare(b.name);
+        });
+      }
+    });
+    return {
+      runningHosts: runningHosts,
+      runningComponentCount: runningComponentCount
+    };
+  },
+  
   /**
    * open popup with appropriate message
    */
@@ -590,6 +636,8 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
     var message;
     var value;
     var flag = false;
+    var runningHosts = null;
+    var runningComponentCount = 0;
     if (App.supports.hostOverrides || 
         (this.get('content.serviceName') !== 'HDFS' && this.get('content.isStopped') === true) || 
         ((this.get('content.serviceName') === 'HDFS') && this.get('content.isStopped') === true && (!App.Service.find().someProperty('id', 'MAPREDUCE') || App.Service.find('MAPREDUCE').get('isStopped')))) {
@@ -605,13 +653,18 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
         value = result.value;
       }
     } else {
+      var rhc;
       if (this.get('content.serviceName') !== 'HDFS' || (this.get('content.serviceName') === 'HDFS' && !App.Service.find().someProperty('id', 'MAPREDUCE'))) {
+        rhc = this.getRunningHostComponents([this.get('content')]);
         header = Em.I18n.t('services.service.config.stopService');
         message = Em.I18n.t('services.service.config.msgServiceStop');
       } else {
+        rhc = this.getRunningHostComponents([this.get('content'), App.Service.find('MAPREDUCE')]);
         header = Em.I18n.t('services.service.config.stopService');
         message = Em.I18n.t('services.service.config.msgHDFSMapRServiceStop');
       }
+      runningHosts = rhc.runningHosts;
+      runningComponentCount = rhc.runningComponentCount;
     }
     
     var self = this;
@@ -628,6 +681,8 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
       bodyClass: Ember.View.extend({
         flag: flag,
         message: message,
+        runningHosts: runningHosts,
+        runningComponentCount: runningComponentCount,
         siteProperties: value,
         getDisplayMessage: function () {
           var displayMsg = [];
@@ -662,20 +717,32 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
           return displayMsg;
 
         }.property('siteProperties'),
+        getRunningHostsMessage: function () {
+          return Em.I18n.t('services.service.config.stopService.runningHostComponents').format(this.get('runningComponentCount'), this.get('runningHosts.length'));
+        }.property('runningComponentCount', 'runningHosts.length'), 
         template: Ember.Handlebars.compile([
           '<h5>{{view.message}}</h5>',
           '{{#unless view.flag}}',
-          '<br/>',
-          '<div class="pre-scrollable" style="max-height: 250px;">',
-          '<ul>',
-          '{{#each val in view.getDisplayMessage}}',
-          '<li>',
-          '{{val}}',
-          '</li>',
-          '{{/each}}',
-          '</ul>',
-          '</div>',
-          '{{/unless}}'
+          ' <br/>',
+          ' <div class="pre-scrollable" style="max-height: 250px;">',
+          '   <ul>',
+          '   {{#each val in view.getDisplayMessage}}',
+          '     <li>',
+          '       {{val}}',
+          '     </li>',
+          '   {{/each}}',
+          '   </ul>',
+          ' </div>',
+          '{{/unless}}',
+          '{{#if view.runningHosts}}',
+          ' <i class="icon-warning-sign"></i>  {{view.getRunningHostsMessage}}',
+          ' <table class="table-striped running-host-components-table">',
+          '   <tr><th>{{t common.host}}</th><th>{{t common.components}}</th></tr>',
+          '   {{#each host in view.runningHosts}}',
+          '     <tr><td>{{host.name}}</td><td>{{host.components}}</td></tr>',
+          '   {{/each}}',
+          ' </table>',
+          '{{/if}}'
         ].join('\n'))
       })
     });

+ 1 - 0
ambari-web/app/messages.js

@@ -746,6 +746,7 @@ Em.I18n.translations = {
   'services.service.config.failSaveConfigHostExceptions':'Failure in applying service configuration host exceptions',
   'services.service.config.addPropertyWindow.errorMessage':'This is required',
   'services.service.config.addPropertyWindow.error.derivedKey':'Cannot add a known derived property',
+  'services.service.config.stopService.runningHostComponents':'{0} components on {1} hosts are still running',
 
   'services.add.header':'Add Service Wizard',
   'services.reassign.header':'Reassign Master Wizard',

+ 4 - 0
ambari-web/app/models/service.js

@@ -29,6 +29,7 @@ App.Service = DS.Model.extend({
   quickLinks: DS.hasMany('App.QuickLinks'),
   hostComponents: DS.hasMany('App.HostComponent'),
   serviceConfigsTemplate: require('data/service_configs'),
+  runningHostComponents: null,
   isStartDisabled: function () {
     return !(this.get('healthStatus') == 'red');
   }.property('healthStatus'),
@@ -87,11 +88,14 @@ App.Service = DS.Model.extend({
   updateIsStopped: function () {
     var components = this.get('hostComponents');
     var flag = true;
+    var runningHCs = Ember.A([]);
     components.forEach(function (_component) {
       if (_component.get('workStatus') !== App.HostComponentStatus.stopped && _component.get('workStatus') !== App.HostComponentStatus.install_failed) {
         flag = false;
+        runningHCs.addObject(_component);
       }
     }, this);
+    this.set('runningHostComponents', runningHCs);
     this.set('isStopped', flag);
   },
 

+ 8 - 0
ambari-web/app/styles/application.less

@@ -645,6 +645,14 @@ h1 {
   }
 }
 
+.running-host-components-table{
+  width: 100%;
+  text-align: left;
+  tbody{
+    vertical-align: top;
+  }
+}
+
 a:focus {
   outline: none;
 }