You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by xi...@apache.org on 2014/04/03 23:56:02 UTC

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

Repository: ambari
Updated Branches:
  refs/heads/trunk 4ba9f1e81 -> e123825d2


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


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e123825d
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e123825d
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e123825d

Branch: refs/heads/trunk
Commit: e123825d22a9ba160998251b462119c4d9682f85
Parents: 4ba9f1e
Author: Xi Wang <xi...@apache.org>
Authored: Thu Apr 3 13:43:54 2014 -0700
Committer: Xi Wang <xi...@apache.org>
Committed: Thu Apr 3 14:54:59 2014 -0700

----------------------------------------------------------------------
 ambari-web/app/controllers/main/host.js         |  2 +-
 .../controllers/main/service/info/configs.js    | 14 ++++++++----
 ambari-web/app/controllers/main/service/item.js | 20 +++++++++++++---
 ambari-web/app/messages.js                      |  9 +++++++-
 .../templates/common/confirmation_feedback.hbs  |  7 ++++++
 .../templates/common/rolling_restart_view.hbs   |  5 ++++
 .../app/utils/batch_scheduled_requests.js       | 10 +++++---
 ambari-web/app/views/common/modal_popup.js      | 15 ++++++++++--
 .../app/views/common/rolling_restart_view.js    | 24 ++++++++++++++++++++
 9 files changed, 92 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e123825d/ambari-web/app/controllers/main/host.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host.js b/ambari-web/app/controllers/main/host.js
index 57f7859..41a0e42 100644
--- a/ambari-web/app/controllers/main/host.js
+++ b/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({

http://git-wip-us.apache.org/repos/asf/ambari/blob/e123825d/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index 15d9c38..f3cf1a0 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/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() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/e123825d/ambari-web/app/controllers/main/service/item.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/item.js b/ambari-web/app/controllers/main/service/item.js
index 73ea4c74..f78a57b 100644
--- a/ambari-web/app/controllers/main/service/item.js
+++ b/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) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/e123825d/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 27b7ec3..030596b 100644
--- a/ambari-web/app/messages.js
+++ b/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',

http://git-wip-us.apache.org/repos/asf/ambari/blob/e123825d/ambari-web/app/templates/common/confirmation_feedback.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/confirmation_feedback.hbs b/ambari-web/app/templates/common/confirmation_feedback.hbs
index 72fbb66..b11fcba 100644
--- a/ambari-web/app/templates/common/confirmation_feedback.hbs
+++ b/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}}
+

http://git-wip-us.apache.org/repos/asf/ambari/blob/e123825d/ambari-web/app/templates/common/rolling_restart_view.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/rolling_restart_view.hbs b/ambari-web/app/templates/common/rolling_restart_view.hbs
index 673673e..275cc9d 100644
--- a/ambari-web/app/templates/common/rolling_restart_view.hbs
+++ b/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>

http://git-wip-us.apache.org/repos/asf/ambari/blob/e123825d/ambari-web/app/utils/batch_scheduled_requests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/batch_scheduled_requests.js b/ambari-web/app/utils/batch_scheduled_requests.js
index 53f9ebb..2c872d0 100644
--- a/ambari-web/app/utils/batch_scheduled_requests.js
+++ b/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,

http://git-wip-us.apache.org/repos/asf/ambari/blob/e123825d/ambari-web/app/views/common/modal_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/modal_popup.js b/ambari-web/app/views/common/modal_popup.js
index f8ff00f..c8ed229 100644
--- a/ambari-web/app/views/common/modal_popup.js
+++ b/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();

http://git-wip-us.apache.org/repos/asf/ambari/blob/e123825d/ambari-web/app/views/common/rolling_restart_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/rolling_restart_view.js b/ambari-web/app/views/common/rolling_restart_view.js
index edc6733..3dbbb68 100644
--- a/ambari-web/app/views/common/rolling_restart_view.js
+++ b/ambari-web/app/views/common/rolling_restart_view.js
@@ -33,6 +33,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}
    */
@@ -168,6 +181,17 @@ App.RollingRestartView = Em.View.extend({
   /**
    * @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}
+   */
   restartMessage : function() {
     return Em.I18n.t('rollingrestart.dialog.msg.restart').format(this.get('hostComponentDisplayName'))
   }.property('hostComponentDisplayName'),