Browse Source

AMBARI-5346. Suggest the user to put the service in Maintenance Mode before performing service-level stop, rolling restart, or restart all. (xiwang)

Xi Wang 11 years ago
parent
commit
e123825d22

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

@@ -394,7 +394,7 @@ App.MainHostController = Em.ArrayController.extend({
     });
 
     if (components.length) {
-      batchUtils.showRollingRestartPopup(components.objectAt(0).get('componentName'), false, components);
+      batchUtils.showRollingRestartPopup(components.objectAt(0).get('componentName'), service.get('displayName'), service.get('passiveState') === "ON", false, components);
     }
     else {
       App.ModalPopup.show({

+ 10 - 4
ambari-web/app/controllers/main/service/info/configs.js

@@ -1648,14 +1648,20 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
 
   restartAllStaleConfigComponents: function() {
     var self = this;
-    App.showConfirmationPopup(function () {
-      var selectedService = self.get('content.id');
-      batchUtils.restartAllServiceHostComponents(selectedService, true);
+    var serviceDisplayName = this.get('content.displayName');
+    var bodyMessage = Em.Object.create({
+      confirmMsg: Em.I18n.t('services.service.restartAll.confirmMsg').format(serviceDisplayName),
+      confirmButton: Em.I18n.t('services.service.restartAll.confirmButton'),
+      additionalWarningMsg: this.get('content.passiveState') === 'OFF' ? Em.I18n.t('services.service.restartAll.warningMsg.turnOnMM').format(serviceDisplayName): null
     });
+    App.showConfirmationFeedBackPopup(function(query) {
+      var selectedService = self.get('content.id');
+      batchUtils.restartAllServiceHostComponents(selectedService, true, query);
+    }, bodyMessage);
   },
 
   rollingRestartStaleConfigSlaveComponents: function(componentName) {
-    batchUtils.launchHostComponentRollingRestart(componentName.context, true);
+    batchUtils.launchHostComponentRollingRestart(componentName.context, this.get('content.displayName'), this.get('content.passiveState') === "ON", true);
   },
 
   showHostsShouldBeRestarted: function() {

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

@@ -91,10 +91,18 @@ App.MainServiceItemController = Em.Controller.extend({
       return;
     }
     var self = this;
+    var serviceDisplayName = this.get('content.displayName');
+    var isMaintenanceOFF = this.get('content.passiveState') === 'OFF';
+    var bodyMessage = Em.Object.create({
+      confirmMsg: serviceHealth == 'INSTALLED'? Em.I18n.t('services.service.stop.confirmMsg').format(serviceDisplayName) : Em.I18n.t('question.sure'),
+      confirmButton: serviceHealth == 'INSTALLED'? Em.I18n.t('services.service.stop.confirmButton') : Em.I18n.t('ok'),
+      additionalWarningMsg:  isMaintenanceOFF && serviceHealth == 'INSTALLED'? Em.I18n.t('services.service.stop.warningMsg.turnOnMM').format(serviceDisplayName) : null
+    });
+
     App.showConfirmationFeedBackPopup(function(query) {
       self.set('isPending', true);
       self.startStopPopupPrimary(serviceHealth, query);
-    });
+    }, bodyMessage);
   },
 
   startStopPopupPrimary: function (serviceHealth, query) {
@@ -187,9 +195,15 @@ App.MainServiceItemController = Em.Controller.extend({
   },
 
   restartAllHostComponents : function(serviceName) {
+    var serviceDisplayName = this.get('content.displayName');
+    var bodyMessage = Em.Object.create({
+      confirmMsg: Em.I18n.t('services.service.restartAll.confirmMsg').format(serviceDisplayName),
+      confirmButton: Em.I18n.t('services.service.restartAll.confirmButton'),
+      additionalWarningMsg: this.get('content.passiveState') === 'OFF' ? Em.I18n.t('services.service.restartAll.warningMsg.turnOnMM').format(serviceDisplayName): null
+     });
     App.showConfirmationFeedBackPopup(function(query) {
       batchUtils.restartAllServiceHostComponents(serviceName, false, query);
-    });
+    }, bodyMessage);
   },
 
   turnOnOffPassive: function(label) {
@@ -204,7 +218,7 @@ App.MainServiceItemController = Em.Controller.extend({
   },
 
   rollingRestart: function(hostComponentName) {
-    batchUtils.launchHostComponentRollingRestart(hostComponentName, false, this.get('content.passiveState') === "ON");
+    batchUtils.launchHostComponentRollingRestart(hostComponentName, this.get('content.displayName'), this.get('content.passiveState') === "ON", false, this.get('content.passiveState') === "ON");
   },
 
   turnOnOffPassiveRequest: function(state,message) {

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

@@ -1250,6 +1250,12 @@ Em.I18n.translations = {
   'services.service.add':'Add Service',
   'services.service.startAll':'Start All',
   'services.service.stopAll':'Stop All',
+  'services.service.stop.confirmMsg' : 'You are about to stop {0}',
+  'services.service.stop.confirmButton': 'Confirm Stop',
+  'services.service.stop.warningMsg.turnOnMM': 'This will generate alerts as the service is stopped. To suppress alerts, turn on Maintenance Mode for {0} prior to stopping',
+  'services.service.restartAll.confirmButton': 'Confirm Restart All',
+  'services.service.restartAll.confirmMsg': 'You are about to restart {0}',
+  'services.service.restartAll.warningMsg.turnOnMM': 'This will trigger alerts as the service is restarted. To suppress alerts, turn on Maintenance Mode for {0} prior to running restart all',
   'services.service.config_groups_popup.header':'Manage {0} Configuration Groups',
   'services.service.config_groups_popup.notice':'You can apply different sets of {{serviceName}} configurations to groups of hosts by managing {{serviceName}} Configuration Groups and their host membership.  Hosts belonging to a {{serviceName}} Configuration Group have the same set of configurations for {{serviceName}}. Each host belongs to one {{serviceName}} Configuration Group.',
   'services.service.config_groups_popup.rename':'Rename',
@@ -1927,7 +1933,7 @@ Em.I18n.translations = {
   'mirroring.required.invalidNumberError' : 'Enter valid number',
 
   'rollingrestart.dialog.title': 'Restart {0}s',
-  'rollingrestart.dialog.primary': 'Trigger Restart',
+  'rollingrestart.dialog.primary': 'Trigger Rolling Restart',
   'rollingrestart.notsupported.hostComponent': 'Rolling restart not supported for {0} components',
   'rollingrestart.dialog.msg.restart': 'This will restart a specified number of {0}s at a time.',
   'rollingrestart.dialog.msg.noRestartHosts': 'There are no {0}s to do rolling restarts',
@@ -1941,6 +1947,7 @@ Em.I18n.translations = {
   'rollingrestart.dialog.err.invalid.batchsize': 'Invalid restart batch size: {0}',
   'rollingrestart.dialog.err.invalid.waitTime': 'Invalid wait time between batches: {0}',
   'rollingrestart.dialog.err.invalid.toleratesize': 'Invalid failure toleration count: {0}',
+  'rollingrestart.dialog.msg.serviceNotInMM':'Note: This will trigger alerts. To suppress alerts, turn on Maintenance Mode for {0} prior to triggering a rolling restart',
   'rollingrestart.dialog.msg.staleConfigsOnly': 'Only restart {0}s with stale configs',
   'rollingrestart.rest.context': 'Rolling Restart of {0}s - batch {1} of {2}',
   'rollingrestart.context.allOnSelectedHosts':'Restart all components on the selected hosts',

+ 7 - 0
ambari-web/app/templates/common/confirmation_feedback.hbs

@@ -18,3 +18,10 @@
 <div>
   {{view.parentView.statusMessage}}
 </div>
+{{#if view.parentView.additionalWarningMsg}}
+  <br />
+  <div class='alert'>
+    {{view.parentView.additionalWarningMsg}}
+  </div>
+{{/if}}
+

+ 5 - 0
ambari-web/app/templates/common/rolling_restart_view.hbs

@@ -26,6 +26,11 @@
         {{view.maintainanceMessage}}
       </p>
     {{/if}}
+    {{#if view.suggestTurnOnMaintenanceMsg}}
+      <p>
+        {{view.suggestTurnOnMaintenanceMsg}}
+      </p>
+    {{/if}}
   </div>
   <table>
     <tr>

+ 7 - 3
ambari-web/app/utils/batch_scheduled_requests.js

@@ -230,9 +230,9 @@ module.exports = {
    *           Pre-select host-components which have stale
    *          configurations
    */
-  launchHostComponentRollingRestart: function(hostComponentName, staleConfigsOnly, skipMaintenance) {
+  launchHostComponentRollingRestart: function(hostComponentName, serviceName, isMaintenanceModeOn, staleConfigsOnly, skipMaintenance) {
     if (App.get('components.rollinRestartAllowed').contains(hostComponentName)) {
-      this.showRollingRestartPopup(hostComponentName, staleConfigsOnly, null, skipMaintenance);
+      this.showRollingRestartPopup(hostComponentName, serviceName, isMaintenanceModeOn, staleConfigsOnly, null, skipMaintenance);
     }
     else {
       this.showWarningRollingRestartPopup(hostComponentName);
@@ -246,7 +246,7 @@ module.exports = {
    * @param {App.hostComponent[]} hostComponents list of hostComponents that should be restarted (optional).
    * Using this parameter will reset hostComponentName
    */
-  showRollingRestartPopup: function(hostComponentName, staleConfigsOnly, hostComponents, skipMaintenance) {
+  showRollingRestartPopup: function(hostComponentName, serviceName, isMaintenanceModeOn, staleConfigsOnly, hostComponents, skipMaintenance) {
     hostComponents = hostComponents || [];
     var componentDisplayName = App.format.role(hostComponentName);
     if (!componentDisplayName) {
@@ -257,6 +257,8 @@ module.exports = {
       staleConfigsOnly : staleConfigsOnly,
       hostComponentName : hostComponentName,
       skipMaintenance: skipMaintenance,
+      serviceName: serviceName,
+      isServiceInMM: isMaintenanceModeOn,
       didInsertElement : function() {
         this.set('parentView.innerView', this);
         this.initialize();
@@ -270,6 +272,8 @@ module.exports = {
     App.ModalPopup.show({
       header : title,
       hostComponentName : hostComponentName,
+      serviceName: serviceName,
+      isServiceInMM: isMaintenanceModeOn,
       staleConfigsOnly : staleConfigsOnly,
       skipMaintenance: skipMaintenance,
       innerView : null,

+ 13 - 2
ambari-web/app/views/common/modal_popup.js

@@ -145,10 +145,13 @@ App.showConfirmationPopup = function (primary, body, secondary) {
  * and in case of failure provide ability to retry to launch an operation.
  *
  * @param {Function} primary - "OK" button click handler
+ * @param {Object} bodyMessage - confirmMsg:{String},
+                                 confirmButton:{String},
+                                 additionalWarningMsg:{String},
  * @param {Function} secondary - "Cancel" button click handler
  * @return {*}
  */
-App.showConfirmationFeedBackPopup = function (primary, secondary) {
+App.showConfirmationFeedBackPopup = function (primary, bodyMessage, secondary) {
   if (!primary) {
     return false;
   }
@@ -158,6 +161,9 @@ App.showConfirmationFeedBackPopup = function (primary, secondary) {
       templateName: require('templates/common/confirmation_feedback')
     }),
     query: Em.Object.create({status: "INIT"}),
+    primary: function () {
+      return bodyMessage? bodyMessage.confirmButton : Em.I18n.t('ok');
+    }.property('bodyMessage'),
     onPrimary: function () {
       this.set('query.status', "INIT");
       this.set('disablePrimary', true);
@@ -165,7 +171,12 @@ App.showConfirmationFeedBackPopup = function (primary, secondary) {
       this.set('statusMessage', Em.I18n.t('popup.confirmationFeedBack.sending'));
       primary(this.get('query'));
     },
-    statusMessage: Em.I18n.t('question.sure'),
+    statusMessage: function () {
+      return bodyMessage? bodyMessage.confirmMsg : Em.I18n.t('question.sure');
+    }.property('bodyMessage'),
+    additionalWarningMsg: function () {
+      return bodyMessage? bodyMessage.additionalWarningMsg : null;
+    }.property('bodyMessage'),
     watchStatus: function() {
       if (this.get('query.status') === "SUCCESS") {
         this.hide();

+ 24 - 0
ambari-web/app/views/common/rolling_restart_view.js

@@ -32,6 +32,19 @@ App.RollingRestartView = Em.View.extend({
    */
   hostComponentName : null,
 
+  /**
+   * Service name for components that should be restarted
+   * @type {String}
+   */
+  serviceName : null,
+
+  /**
+   * If service is in Maintenance Mode
+   * @type {bool}
+   */
+  isServiceInMM: false,
+
+
   /**
    * Restart only components with <code>staleConfigs</code>
    * @type {bool}
@@ -165,6 +178,17 @@ App.RollingRestartView = Em.View.extend({
     return hostComponents;
   }.property('nonMaintainanceHostComponents', 'staleConfigsOnly'),
 
+  /**
+   * @type {String}
+   */
+  suggestTurnOnMaintenanceMsg : function() {
+    if (!this.get('isServiceInMM')) {
+      return Em.I18n.t('rollingrestart.dialog.msg.serviceNotInMM').format(this.get('serviceName'));
+    } else {
+      return null;
+    }
+  }.property('isServiceInMM'),
+
   /**
    * @type {String}
    */