瀏覽代碼

AMBARI-4910. Can't restart all on a host. (onechiporenko)

Oleg Nechiporenko 11 年之前
父節點
當前提交
27854b4b04

+ 2 - 2
ambari-web/app/controllers/main/host.js

@@ -224,14 +224,14 @@ App.MainHostController = Em.ArrayController.extend({
   /**
   /**
    * Bulk restart for selected hosts
    * Bulk restart for selected hosts
    * @param {Object} operationData - data about bulk operation (action, hostComponents etc)
    * @param {Object} operationData - data about bulk operation (action, hostComponents etc)
-   * @param {Array} hosts - list of affected hosts
+   * @param {Ember.Enumerable} hosts - list of affected hosts
    */
    */
   bulkOperationForHostsRestart: function(operationData, hosts) {
   bulkOperationForHostsRestart: function(operationData, hosts) {
     var hostComponents = [];
     var hostComponents = [];
     hosts.forEach(function(host) {
     hosts.forEach(function(host) {
       hostComponents.pushObjects(host.get('hostComponents').filterProperty('passiveState','OFF').toArray());
       hostComponents.pushObjects(host.get('hostComponents').filterProperty('passiveState','OFF').toArray());
     });
     });
-    batchUtils.restartHostComponents(hostComponents);
+    batchUtils.restartHostComponents(hostComponents, Em.I18n.t('rollingrestart.context.allOnSelectedHosts'));
   },
   },
 
 
   /**
   /**

+ 7 - 4
ambari-web/app/controllers/main/host/details.js

@@ -373,9 +373,10 @@ App.MainHostDetailsController = Em.Controller.extend({
   },
   },
 
 
   restartComponent: function(event) {
   restartComponent: function(event) {
+    var self = this;
     var component = event.context;
     var component = event.context;
     App.showConfirmationPopup(function(){
     App.showConfirmationPopup(function(){
-      batchUtils.restartHostComponents([component]);
+      batchUtils.restartHostComponents([component], Em.I18n.t('rollingrestart.context.selectedComponentOnSelectedHost').format(component.get('componentName'), self.get('content.hostName')));
     });
     });
   },
   },
   /**
   /**
@@ -1031,11 +1032,12 @@ App.MainHostDetailsController = Em.Controller.extend({
   },
   },
 
 
   doRestartAllComponents: function() {
   doRestartAllComponents: function() {
+    var self = this;
     var components = this.get('content.hostComponents').filterProperty('passiveState','OFF');
     var components = this.get('content.hostComponents').filterProperty('passiveState','OFF');
     var componentsLength = components == null ? 0 : components.get('length');
     var componentsLength = components == null ? 0 : components.get('length');
     if (componentsLength > 0) {
     if (componentsLength > 0) {
       App.showConfirmationPopup(function() {
       App.showConfirmationPopup(function() {
-        batchUtils.restartHostComponents(components);
+        batchUtils.restartHostComponents(components, Em.I18n.t('rollingrestart.context.allOnSelectedHost').format(self.get('content.hostName')));
       });
       });
     }
     }
   },
   },
@@ -1212,7 +1214,7 @@ App.MainHostDetailsController = Em.Controller.extend({
 
 
   restartAllStaleConfigComponents: function() {
   restartAllStaleConfigComponents: function() {
     var staleComponents = this.get('content.componentsWithStaleConfigs');
     var staleComponents = this.get('content.componentsWithStaleConfigs');
-    batchUtils.restartHostComponents(staleComponents);
+    batchUtils.restartHostComponents(staleComponents, Em.I18n.t('rollingrestart.context.allWithStaleConfigsOnSelectedHost').format(this.get('content.hostName')));
   },
   },
 
 
   /**
   /**
@@ -1274,12 +1276,13 @@ App.MainHostDetailsController = Em.Controller.extend({
    * Restart clients host components to apply config changes
    * Restart clients host components to apply config changes
    */
    */
   refreshConfigs: function(event) {
   refreshConfigs: function(event) {
+    var self = this;
     var components = event.context.filter(function(component) {
     var components = event.context.filter(function(component) {
       return component.get('staleConfigs');
       return component.get('staleConfigs');
     });
     });
     if (components.get('length') > 0) {
     if (components.get('length') > 0) {
       App.showConfirmationPopup(function() {
       App.showConfirmationPopup(function() {
-        batchUtils.restartHostComponents(components);
+        batchUtils.restartHostComponents(components, Em.I18n.t('rollingrestart.context.allClientsOnSelectedHost').format(self.get('content.hostName')));
       });
       });
     }
     }
   }
   }

+ 1 - 1
ambari-web/app/controllers/main/service/item.js

@@ -292,7 +292,7 @@ App.MainServiceItemController = Em.Controller.extend({
     var self = this;
     var self = this;
     if (this.get('content.isClientsOnly')) {
     if (this.get('content.isClientsOnly')) {
       App.showConfirmationPopup(function() {
       App.showConfirmationPopup(function() {
-        batchUtils.restartHostComponents(self.get('content.hostComponents'));
+        batchUtils.restartHostComponents(self.get('content.hostComponents'), Em.I18n.t('rollingrestart.context.allForSelectedService').format(self.get('content.serviceName')));
       });
       });
     }
     }
   },
   },

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

@@ -1862,6 +1862,14 @@ Em.I18n.translations = {
   'rollingrestart.dialog.err.invalid.toleratesize': 'Invalid failure toleration count: {0}',
   'rollingrestart.dialog.err.invalid.toleratesize': 'Invalid failure toleration count: {0}',
   'rollingrestart.dialog.msg.staleConfigsOnly': 'Only restart {0}s with stale configs',
   'rollingrestart.dialog.msg.staleConfigsOnly': 'Only restart {0}s with stale configs',
   'rollingrestart.rest.context': 'Rolling Restart of {0}s - batch {1} of {2}',
   'rollingrestart.rest.context': 'Rolling Restart of {0}s - batch {1} of {2}',
+  'rollingrestart.context.allOnSelectedHosts':'Restart all components on the selected hosts',
+  'rollingrestart.context.allForSelectedService':'Restart all components for {0}',
+  'rollingrestart.context.allWithStaleConfigsForSelectedService':'Restart all components with Stale Configs for {0}',
+  'rollingrestart.context.allClientsOnSelectedHost':'Restart all clients on {0}',
+  'rollingrestart.context.allWithStaleConfigsOnSelectedHost':'Restart components with Stale Configs on {0}',
+  'rollingrestart.context.allOnSelectedHost':'Restart all components on {0}',
+  'rollingrestart.context.selectedComponentOnSelectedHost':'Restart {0} on {1}',
+  'rollingrestart.context.default':'Restart components',
 
 
   'rolling.command.context': 'Rolling set {0} to state "{1}" - batch {2} of {3}',
   'rolling.command.context': 'Rolling set {0} to state "{1}" - batch {2} of {3}',
   'rolling.nothingToDo.header': 'Nothing to do',
   'rolling.nothingToDo.header': 'Nothing to do',

+ 20 - 19
ambari-web/app/utils/batch_scheduled_requests.js

@@ -69,27 +69,29 @@ module.exports = {
    */
    */
   restartAllServiceHostComponents: function(serviceName, staleConfigsOnly) {
   restartAllServiceHostComponents: function(serviceName, staleConfigsOnly) {
     var service = App.Service.find(serviceName);
     var service = App.Service.find(serviceName);
+    var context = staleConfigsOnly ? Em.I18n.t('rollingrestart.context.allWithStaleConfigsForSelectedService').format(serviceName) : Em.I18n.t('rollingrestart.context.allForSelectedService').format(serviceName);
     if (service) {
     if (service) {
       var hostComponents = service.get('hostComponents');
       var hostComponents = service.get('hostComponents');
       if (staleConfigsOnly) {
       if (staleConfigsOnly) {
         hostComponents = hostComponents.filterProperty('staleConfigs', true);
         hostComponents = hostComponents.filterProperty('staleConfigs', true);
       }
       }
-      this.restartHostComponents(hostComponents);
+      this.restartHostComponents(hostComponents, context);
     }
     }
   },
   },
 
 
   /**
   /**
    * Restart list of host components
    * Restart list of host components
-   * @param {*} hostComponentsList list of host components should be restarted
+   * @param {Ember.Enumerable} hostComponentsList list of host components should be restarted
+   * @param {String} context message to show in BG popup
    */
    */
-  restartHostComponents: function(hostComponentsList) {
+  restartHostComponents: function(hostComponentsList, context) {
+    context = context || Em.I18n.t('rollingrestart.context.default');
     /**
     /**
      * Format: {
      * Format: {
      *  'DATANODE': ['host1', 'host2'],
      *  'DATANODE': ['host1', 'host2'],
      *  'NAMENODE': ['host1', 'host3']
      *  'NAMENODE': ['host1', 'host3']
      *  ...
      *  ...
      * }
      * }
-     * @type {Object}
      */
      */
     var componentToHostsMap = {};
     var componentToHostsMap = {};
     var componentServiceMap = App.QuickDataMapper.componentServiceMap();
     var componentServiceMap = App.QuickDataMapper.componentServiceMap();
@@ -110,22 +112,21 @@ module.exports = {
         });
         });
       }
       }
     }
     }
-    if (!resource_filters.length) {
-      return;
+    if (resource_filters.length) {
+      App.ajax.send({
+        name: 'restart.hostComponents',
+        sender: {
+          successCallback: defaultSuccessCallback,
+          errorCallback: defaultErrorCallback
+        },
+        data: {
+          context: context,
+          resource_filters: resource_filters
+        },
+        success: 'successCallback',
+        error: 'errorCallback'
+      });
     }
     }
-    App.ajax.send({
-      name: 'restart.hostComponents',
-      sender: {
-        successCallback: defaultSuccessCallback,
-        errorCallback: defaultErrorCallback
-      },
-      data: {
-        context: 'RESTART ' + Em.keys(componentToHostsMap).map(function(componentName) {return App.format.components[componentName];}).join(', '),
-        resource_filters: resource_filters
-      },
-      success: 'successCallback',
-      error: 'errorCallback'
-    });
   },
   },
 
 
   /**
   /**