ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject git commit: AMBARI-6276 Prompt to put Service in Maintenance Mode when doing Rolling Restart / Service Stop. (ababiichuk)
Date Wed, 25 Jun 2014 18:57:09 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 4173376b9 -> 9a8cdf910


AMBARI-6276 Prompt to put Service in Maintenance Mode when doing Rolling Restart / Service
Stop. (ababiichuk)


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

Branch: refs/heads/trunk
Commit: 9a8cdf910ff8ecc72a9f1d2acf3e933611060172
Parents: 4173376
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Wed Jun 25 21:40:04 2014 +0300
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Wed Jun 25 21:40:26 2014 +0300

----------------------------------------------------------------------
 ambari-web/app/controllers/main/service/item.js | 56 +++++++++-----------
 .../templates/common/confirmation_feedback.hbs  |  3 ++
 .../templates/common/rolling_restart_view.hbs   | 10 ++++
 ambari-web/app/utils/ajax/ajax.js               |  4 +-
 .../app/utils/batch_scheduled_requests.js       | 26 ++++++++-
 ambari-web/app/views/common/modal_popup.js      |  9 +++-
 .../app/views/common/rolling_restart_view.js    |  6 +++
 7 files changed, 79 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9a8cdf91/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 2066ab1..5c591b1 100644
--- a/ambari-web/app/controllers/main/service/item.js
+++ b/ambari-web/app/controllers/main/service/item.js
@@ -90,36 +90,46 @@ App.MainServiceItemController = Em.Controller.extend({
     var serviceDisplayName = this.get('content.displayName');
     var isMaintenanceOFF = this.get('content.passiveState') === 'OFF';
     var bodyMessage = Em.Object.create({
+      putInMaintenance: (serviceHealth == 'INSTALLED' && isMaintenanceOFF) || (serviceHealth
== 'STARTED' && !isMaintenanceOFF),
+      turnOnMmMsg: serviceHealth == 'INSTALLED' ? Em.I18n.t('passiveState.turnOnFor').format(serviceDisplayName)
: Em.I18n.t('passiveState.turnOffFor').format(serviceDisplayName),
       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
     });
 
-    return App.showConfirmationFeedBackPopup(function(query) {
+    return App.showConfirmationFeedBackPopup(function(query, runMmOperation) {
       self.set('isPending', true);
-      self.startStopPopupPrimary(serviceHealth, query);
+      self.startStopPopupPrimary(serviceHealth, query, runMmOperation);
     }, bodyMessage);
   },
 
-  startStopPopupPrimary: function (serviceHealth, query) {
+  startStopPopupPrimary: function (serviceHealth, query, runMmOperation) {
     var requestInfo = "";
+    var turnOnMM = "ON"
     if (serviceHealth == "STARTED") {
+      turnOnMM = "OFF"
       requestInfo = App.BackgroundOperationsController.CommandContexts.START_SERVICE.format(this.get('content.serviceName'));
     } else {
       requestInfo = App.BackgroundOperationsController.CommandContexts.STOP_SERVICE.format(this.get('content.serviceName'));
     }
 
+    var data = {
+      'requestInfo': requestInfo,
+      'serviceName': this.get('content.serviceName').toUpperCase(),
+      'ServiceInfo': {
+        'state': serviceHealth
+      },
+      'query': query
+    };
+    if (runMmOperation) {
+      data.ServiceInfo.maintenance_state = turnOnMM;
+    }
     App.ajax.send({
       'name': 'service.item.start_stop',
       'sender': this,
       'success': 'startStopPopupSuccessCallback',
       'error': 'startStopPopupErrorCallback',
-      'data': {
-        'requestInfo': requestInfo,
-        'serviceName': this.get('content.serviceName').toUpperCase(),
-        'state': serviceHealth,
-        'query': query
-      }
+      'data': data
     });
     this.set('isStopDisabled', true);
     this.set('isStartDisabled', true);
@@ -192,13 +202,15 @@ App.MainServiceItemController = Em.Controller.extend({
   restartAllHostComponents : function(serviceName) {
     var serviceDisplayName = this.get('content.displayName');
     var bodyMessage = Em.Object.create({
+      putInMaintenance: this.get('content.passiveState') === 'OFF',
+      turnOnMmMsg: Em.I18n.t('passiveState.turnOnFor').format(serviceDisplayName),
       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
      });
     var staleConfigsOnly = App.Service.find(serviceName).get('serviceTypes').contains('MONITORING');
-    return App.showConfirmationFeedBackPopup(function(query) {
-      batchUtils.restartAllServiceHostComponents(serviceName, staleConfigsOnly, query);
+    return App.showConfirmationFeedBackPopup(function(query, runMmOperation) {
+      batchUtils.restartAllServiceHostComponents(serviceName, staleConfigsOnly, query, runMmOperation);
     }, bodyMessage);
   },
 
@@ -207,7 +219,9 @@ App.MainServiceItemController = Em.Controller.extend({
     var state = this.get('content.passiveState') == 'OFF' ? 'ON' : 'OFF';
     var onOff = state === 'ON' ? "On" : "Off";
     return App.showConfirmationPopup(function() {
-          self.turnOnOffPassiveRequest(state, label)
+          batchUtils.turnOnOffPassiveRequest(state, label, self.get('content.serviceName').toUpperCase(),
function(data, opt, params) {
+            self.set('content.passiveState', params.passive_state);
+            batchUtils.infoPassiveState(params.passive_state);})
         },
         Em.I18n.t('hosts.passiveMode.popup').format(onOff,self.get('content.displayName'))
     );
@@ -217,24 +231,6 @@ App.MainServiceItemController = Em.Controller.extend({
     batchUtils.launchHostComponentRollingRestart(hostComponentName, this.get('content.displayName'),
this.get('content.passiveState') === "ON", false, this.get('content.passiveState') === "ON");
   },
 
-  turnOnOffPassiveRequest: function(state,message) {
-    App.ajax.send({
-      'name': 'service.item.passive',
-      'sender': this,
-      'data': {
-        'requestInfo': message,
-        'serviceName': this.get('content.serviceName').toUpperCase(),
-        'passive_state': state
-      },
-      'success':'updateService'
-    });
-  },
-
-  updateService: function(data, opt, params) {
-    this.set('content.passiveState', params.passive_state);
-    batchUtils.infoPassiveState(params.passive_state);
-  },
-
   runSmokeTestPrimary: function(query) {
     App.ajax.send({
       'name': 'service.item.smoke',

http://git-wip-us.apache.org/repos/asf/ambari/blob/9a8cdf91/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 b11fcba..bda28b8 100644
--- a/ambari-web/app/templates/common/confirmation_feedback.hbs
+++ b/ambari-web/app/templates/common/confirmation_feedback.hbs
@@ -24,4 +24,7 @@
     {{view.parentView.additionalWarningMsg}}
   </div>
 {{/if}}
+{{#if view.parentView.putInMaintenance}}
+  <label class="checkbox">{{view Ember.Checkbox checkedBinding="view.parentView.runMmOperation"}}
{{view.parentView.turnOnMmMsg}}</label>
+{{/if}}
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/9a8cdf91/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 b659906..d443376 100644
--- a/ambari-web/app/templates/common/rolling_restart_view.hbs
+++ b/ambari-web/app/templates/common/rolling_restart_view.hbs
@@ -56,6 +56,16 @@
           {{view.staleConfigsOnlyMessage}}
         </td>
       </tr>
+      <tr>
+        <td>&nbsp;</td>
+        <td colspan="2">
+          {{#unless view.isServiceInMM}}
+            {{view Ember.Checkbox checkedBinding="view.turnOnMm"}}
+            {{view.turnOnMmMsg}}
+          {{/unless}}
+        </td>
+      </tr>
+
     </table>
   {{else}}
     <div class="spinner"></div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/9a8cdf91/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index 82054a2..3343466 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -69,9 +69,7 @@ var urls = {
             }
           },
           Body: {
-            ServiceInfo: {
-              state: data.state
-            }
+            ServiceInfo: data.ServiceInfo
           }
         })
       };

http://git-wip-us.apache.org/repos/asf/ambari/blob/9a8cdf91/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 38aeb8c..cc6cd2c 100644
--- a/ambari-web/app/utils/batch_scheduled_requests.js
+++ b/ambari-web/app/utils/batch_scheduled_requests.js
@@ -69,11 +69,14 @@ module.exports = {
    * @param {String} serviceName for which service hostComponents should be restarted
    * @param {bool} staleConfigsOnly restart only hostComponents with <code>staleConfig</code>
true
    */
-  restartAllServiceHostComponents: function(serviceName, staleConfigsOnly, query) {
+  restartAllServiceHostComponents: function(serviceName, staleConfigsOnly, query, runMmOperation)
{
     var self = this;
     var context = staleConfigsOnly ? Em.I18n.t('rollingrestart.context.allWithStaleConfigsForSelectedService').format(serviceName)
: Em.I18n.t('rollingrestart.context.allForSelectedService').format(serviceName);
     var services = (serviceName === 'HIVE' && App.Service.find('HCATALOG').get('isLoaded'))
? ['HIVE', 'HCATALOG'] : [serviceName];
 
+    if (runMmOperation) {
+      this.turnOnOffPassiveRequest('ON', Em.I18n.t('passiveState.turnOnFor').format(serviceName),
serviceName);
+    }
     this.getComponentsFromServer({
       services: services,
       staleConfigs: staleConfigsOnly ? staleConfigsOnly : null,
@@ -263,6 +266,22 @@ module.exports = {
     }
     return operationLevel;
   },
+
+  turnOnOffPassiveRequest: function(state, message, serviceName, callback) {
+    App.ajax.send({
+      'name': 'service.item.passive',
+      'sender': {
+        'successCallback': callback || defaultSuccessCallback,
+        'errorCallback': defaultErrorCallback
+      },
+      'data': {
+        'requestInfo': message,
+        'serviceName': serviceName,
+        'passive_state': state
+      },
+      'success': 'successCallback'
+    });
+  },
   /**
    * Makes a REST call to the server requesting the rolling restart of the
    * provided host components.
@@ -374,6 +393,8 @@ module.exports = {
     }
     var title = Em.I18n.t('rollingrestart.dialog.title').format(componentDisplayName);
     var viewExtend = {
+      turnOnMmMsg: Em.I18n.t('passiveState.turnOnFor').format(serviceName),
+      turnOnMm: false,
       staleConfigsOnly : staleConfigsOnly,
       hostComponentName : hostComponentName,
       skipMaintenance: skipMaintenance,
@@ -431,6 +452,9 @@ module.exports = {
         var batchSize = this.get('innerView.batchSize');
         var waitTime = this.get('innerView.interBatchWaitTimeSeconds');
         var tolerateSize = this.get('innerView.tolerateSize');
+        if (this.get('innerView.turnOnMm')) {
+          self.turnOnOffPassiveRequest('ON', Em.I18n.t('passiveState.turnOnFor').format(serviceName),
serviceName);
+        }
         self._doPostBatchRollingRestartRequest(restartComponents, batchSize, waitTime, tolerateSize,
function(data, ajaxOptions, params) {
           dialog.hide();
           defaultSuccessCallback(data, ajaxOptions, params);

http://git-wip-us.apache.org/repos/asf/ambari/blob/9a8cdf91/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 550af3c..8b561a4 100644
--- a/ambari-web/app/views/common/modal_popup.js
+++ b/ambari-web/app/views/common/modal_popup.js
@@ -176,7 +176,7 @@ App.showConfirmationFeedBackPopup = function (primary, bodyMessage, secondary)
{
       this.set('disableSecondary', true);
       this.set('statusMessage', Em.I18n.t('popup.confirmationFeedBack.sending'));
       this.hide();
-      primary(this.get('query'));
+      primary(this.get('query'), this.get('runMmOperation'));
     },
     statusMessage: function () {
       return bodyMessage? bodyMessage.confirmMsg : Em.I18n.t('question.sure');
@@ -184,6 +184,13 @@ App.showConfirmationFeedBackPopup = function (primary, bodyMessage, secondary)
{
     additionalWarningMsg: function () {
       return bodyMessage? bodyMessage.additionalWarningMsg : null;
     }.property('bodyMessage'),
+    putInMaintenance: function () {
+      return bodyMessage ? bodyMessage.putInMaintenance : null;
+    }.property('bodyMessage'),
+    runMmOperation: false,
+    turnOnMmMsg: function () {
+      return bodyMessage ? bodyMessage.turnOnMmMsg : null;
+    }.property('bodyMessage'),
     watchStatus: function() {
       if (this.get('query.status') === "SUCCESS") {
         this.hide();

http://git-wip-us.apache.org/repos/asf/ambari/blob/9a8cdf91/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 c992cf0..263e28b 100644
--- a/ambari-web/app/views/common/rolling_restart_view.js
+++ b/ambari-web/app/views/common/rolling_restart_view.js
@@ -44,6 +44,12 @@ App.RollingRestartView = Em.View.extend({
    */
   isServiceInMM: false,
 
+  /**
+   * If true service will be put in Maintenance mode before rolling restart
+   * @type {bool}
+   */
+  turnOnMm: false,
+
 
   /**
    * Restart only components with <code>staleConfigs</code>


Mime
View raw message