You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sr...@apache.org on 2014/01/16 07:45:47 UTC

git commit: AMBARI-4309. Connect stale-config restarts to rolling restart dialog. (srimanth)

Updated Branches:
  refs/heads/trunk e7c4533ca -> 067b1b60c


AMBARI-4309. Connect stale-config restarts to rolling restart dialog. (srimanth)


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

Branch: refs/heads/trunk
Commit: 067b1b60ca6d88ff1f99cd3f267334b889119ac9
Parents: e7c4533
Author: Srimanth Gunturi <sg...@hortonworks.com>
Authored: Wed Jan 15 18:09:55 2014 -0800
Committer: Srimanth Gunturi <sg...@hortonworks.com>
Committed: Wed Jan 15 18:13:00 2014 -0800

----------------------------------------------------------------------
 ambari-web/app/controllers/main/host/details.js | 76 ++------------------
 .../controllers/main/service/info/configs.js    | 63 ++--------------
 ambari-web/app/controllers/main/service/item.js |  2 +-
 ambari-web/app/messages.js                      |  4 +-
 ambari-web/app/models/host.js                   |  8 ++-
 ambari-web/app/templates/main/host/summary.hbs  |  9 +--
 .../app/templates/main/service/info/configs.hbs | 19 +++--
 .../app/utils/batch_scheduled_requests.js       | 40 ++++++-----
 ambari-web/app/views/main/host/summary.js       | 18 -----
 .../app/views/main/service/info/configs.js      | 37 +++++-----
 10 files changed, 74 insertions(+), 202 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/067b1b60/ambari-web/app/controllers/main/host/details.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/details.js b/ambari-web/app/controllers/main/host/details.js
index 2304a47..6cb99c0 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -17,6 +17,7 @@
  */
 
 var App = require('app');
+var batchUtils = require('utils/batch_scheduled_requests');
 
 App.MainHostDetailsController = Em.Controller.extend({
   name: 'mainHostDetailsController',
@@ -991,78 +992,11 @@ App.MainHostDetailsController = Em.Controller.extend({
     })
   },
 
-  restartComponents: function(e) {
-    var staleComponents = this.get('content.hostComponents').filterProperty('staleConfigs', true);
-    var commandName = "stop_component";
-    if(e.context) {
-      if(!staleComponents.findProperty('workStatus','STARTED')){
-        return;
-      }
-    } else {
-      commandName = "start_component";
-      if(!staleComponents.findProperty('workStatus','INSTALLED')){
-        return;
-      }
-    }
-
-    var nonClientRequestInfo = commandName == 'start_component' ? 'Start Components' : 'Stop Components';
-    var clientRequestInfo = 'Update Clients';
-    var desiredState = commandName == 'start_component' ? 'STARTED' : 'INSTALLED';
-
-    var content = this;
-    return App.ModalPopup.show({
-      primary: Em.I18n.t('ok'),
-      secondary: Em.I18n.t('common.cancel'),
-      header: Em.I18n.t('popup.confirmation.commonHeader'),
-      body: Em.I18n.t('question.sure'),
-      content: content,
-      onPrimary: function () {
-        var hostName = this.content.get('content.hostName');
-        var hostComponents = this.content.get('content.hostComponents');
-
-        // the action is to either 1) start stale components for the host or 2) stop stale components for the host
-        // start is done through two API calls:
-        //  * call to start non-client components
-        //  * call to update clients
-        // stop is done through one API call:
-        //  * call to stop non-client components
-
-        var nonClientComponentNames = hostComponents.filterProperty('isClient', false).mapProperty('componentName').uniq();
-        var clientComponentNames = hostComponents.filterProperty('isClient', true).mapProperty('componentName').uniq();
-
-        App.ajax.send({
-          name: 'host.stale_host_components.start_stop',
-          sender: this,
-          data: {
-            hostName: hostName,
-            context: nonClientRequestInfo,
-            componentNames: nonClientComponentNames,
-            state: desiredState
-          }
-        });
-
-        if (desiredState == 'STARTED') {
-          App.ajax.send({
-            name: 'host.stale_host_components.start_stop',
-            sender: this,
-            data: {
-              hostName: hostName,
-              context: clientRequestInfo,
-              componentNames: clientComponentNames,
-              state: 'INSTALLED'
-            }
-          });
-        }
-        this.hide();
-        // load data (if we need to show this background operations popup) from persist
-        App.router.get('applicationController').dataLoading().done(function (initValue) {
-          if (initValue) {
-            App.router.get('backgroundOperationsController').showPopup();
-          }
-        });
-      }
-    });
+  restartAllStaleConfigComponents: function() {
+    var staleComponents = this.get('content.componentsWithStaleConfigs');
+    batchUtils.restartHostComponents(staleComponents);
   },
+
   /**
    * open Reassign Master Wizard with selected component
    * @param event

http://git-wip-us.apache.org/repos/asf/ambari/blob/067b1b60/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 b235de2..b0d5d4f 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -18,6 +18,7 @@
 
 var App = require('app');
 require('controllers/wizard/slave_component_groups_controller');
+var batchUtils = require('utils/batch_scheduled_requests');
 
 App.MainServiceInfoConfigsController = Em.Controller.extend({
   name: 'mainServiceInfoConfigsController',
@@ -1751,18 +1752,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
     this.loadStep();
   },
 
-  restartComponents: function(e) {
-    var commandName = "stop_component";
-    if (e.context) {
-      if (!this.get('content.hostComponents').filterProperty('staleConfigs').findProperty('workStatus', 'STARTED')) {
-        return;
-      }
-    } else {
-      commandName = "start_component";
-      if (!this.get('content.hostComponents').filterProperty('staleConfigs').findProperty('workStatus', 'INSTALLED')) {
-        return;
-      }
-    }
+  restartAllStaleConfigComponents: function() {
     var content = this;
     return App.ModalPopup.show({
       primary: Em.I18n.t('ok'),
@@ -1772,55 +1762,16 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
       content: content,
       onPrimary: function () {
         var selectedService = this.content.get('content.id');
-        var hostComponents = App.HostComponent.find().filterProperty('service.id', selectedService);
-        var desiredState = commandName == 'start_component' ? 'STARTED' : 'INSTALLED';
-        var nonClientRequestInfo = commandName == 'start_component' ? 'Start Components' : 'Stop Components';
-        var clientRequestInfo = 'Update Clients';
-
-        // the action is to either 1) start stale components for the service or 2) stop stale components for the service
-        // start is done through two API calls:
-        //  * first call to start non-client components
-        //  * second call to update clients
-        // stop is done through one API call:
-        //  * call to stop non-client components
-
-        var nonClientComponentNames = hostComponents.filterProperty('isClient', false).mapProperty('componentName').uniq();
-        var clientComponentNames = hostComponents.filterProperty('isClient', true).mapProperty('componentName').uniq();
-
-        // start/stop stale non-client host components for the service
-        App.ajax.send({
-          name: 'service.stale_host_components.start_stop',
-          sender: this,
-          data: {
-            componentNames: nonClientComponentNames.join(','),
-            requestInfo: nonClientRequestInfo,
-            state: desiredState
-          }
-        });
-
-        // start only: update stale client host components for the service
-        if (desiredState == 'STARTED') {
-          App.ajax.send({
-            name: 'service.stale_host_components.start_stop',
-            sender: this,
-            data: {
-              componentNames: clientComponentNames.join(','),
-              requestInfo: clientRequestInfo,
-              state: 'INSTALLED'
-            }
-          });
-        }
         this.hide();
-        // load data (if we need to show this background operations popup) from persist
-        App.router.get('applicationController').dataLoading().done(function (initValue) {
-          if (initValue) {
-            App.router.get('backgroundOperationsController').showPopup();
-          }
-        });
+        batchUtils.restartAllServiceHostComponents(selectedService, true);
       }
     });
   },
 
+  rollingRestartStaleConfigSlaveComponents: function(componentName) {
+    batchUtils.launchHostComponentRollingRestart(componentName.context, true);
+  },
+
   showHostsShouldBeRestarted: function() {
     var hosts = [];
     for(var hostName in this.get('content.restartRequiredHostsAndComponents')) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/067b1b60/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 92d160d..2efd2c1 100644
--- a/ambari-web/app/controllers/main/service/item.js
+++ b/ambari-web/app/controllers/main/service/item.js
@@ -188,7 +188,7 @@ App.MainServiceItemController = Em.Controller.extend({
   },
 
   restartAllHostComponents : function(serviceName) {
-    batchUtils.doPostRestartAllServiceComponents(serviceName);
+    batchUtils.restartAllServiceHostComponents(serviceName, false);
   },
 
   rollingRestart: function(hostComponentName) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/067b1b60/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 90130db..5c0fc0d 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1376,9 +1376,7 @@ Em.I18n.translations = {
 
   'hosts.host.details.hostActions':'Host Actions',
   'hosts.host.details.needToRestart':'Host needs {0} {1} restarted',
-  'hosts.host.details.needToRestart.button':'Restart components',
-  'hosts.host.details.needToRestart.stopButton':'Stop Components',
-  'hosts.host.details.needToRestart.startButton':'Start Components',
+  'hosts.host.details.needToRestart.button':'Restart',
   'hosts.host.details.deleteHost':'Delete Host',
   'hosts.host.details.startAllComponents':'Start All Components',
   'hosts.host.details.stopAllComponents':'Stop All Components',

http://git-wip-us.apache.org/repos/asf/ambari/blob/067b1b60/ambari-web/app/models/host.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/host.js b/ambari-web/app/models/host.js
index 53475b0..63bfc42 100644
--- a/ambari-web/app/models/host.js
+++ b/ambari-web/app/models/host.js
@@ -74,13 +74,17 @@ App.Host = DS.Model.extend({
     return 0;
   }.property('memTotal', 'memFree'),
 
+  componentsWithStaleConfigs: function () {
+    return this.get('hostComponents').filterProperty('staleConfigs', true);
+  }.property('hostComponents.@each.staleConfigs'),
+
   /**
    * Get count of host components with stale configs
    * @returns {Number}
    */
   componentsWithStaleConfigsCount: function() {
-    return this.get('hostComponents').filterProperty('staleConfigs', true).length;
-  }.property('hostComponents.@each.staleConfigs'),
+    return this.get('componentsWithStaleConfigs').length;
+  }.property('componentsWithStaleConfigs.length'),
 
   /**
    * Get count of host components in maintenance mode

http://git-wip-us.apache.org/repos/asf/ambari/blob/067b1b60/ambari-web/app/templates/main/host/summary.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host/summary.hbs b/ambari-web/app/templates/main/host/summary.hbs
index d3dc8d7..4cd7158 100644
--- a/ambari-web/app/templates/main/host/summary.hbs
+++ b/ambari-web/app/templates/main/host/summary.hbs
@@ -30,13 +30,8 @@
           {{#if view.content.componentsWithStaleConfigsCount}}
               <div class="alert alert-warning clearfix">
                 <i class="icon-refresh"></i> {{view.needToRestartMessage}}
-                <br/>
-                <button {{bindAttr class=":btn :restart-components :pull-left view.stopComponentsIsDisabled::btn-danger" disabled="view.stopComponentsIsDisabled"}} {{action restartComponents view.isStopCommand target="controller"}}>
-                  {{t hosts.host.details.needToRestart.stopButton}}
-                </button>
-                 <span class="restart-components  pull-left">&nbsp</span>
-                 <button {{bindAttr class=":btn :restart-components :pull-left view.startComponentsIsDisabled::btn-success" disabled="view.startComponentsIsDisabled"}} {{action restartComponents target="controller"}}>
-                  {{t hosts.host.details.needToRestart.startButton}}
+                 <button {{bindAttr class=":btn :restart-components :pull-right :btn-warning"}} {{action restartAllStaleConfigComponents target="controller"}}>
+                  {{t hosts.host.details.needToRestart.button}}
                  </button>
               </div>
           {{/if}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/067b1b60/ambari-web/app/templates/main/service/info/configs.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/service/info/configs.hbs b/ambari-web/app/templates/main/service/info/configs.hbs
index b07acf5..9463505 100644
--- a/ambari-web/app/templates/main/service/info/configs.hbs
+++ b/ambari-web/app/templates/main/service/info/configs.hbs
@@ -24,14 +24,19 @@
           <div>
             <div class="alert alert-warning clearfix">
               <i class="icon-refresh"></i> {{{view.needToRestartMessage}}} {{t services.service.config.restartService.needToRestart}}  <a href="#" {{action showComponentsShouldBeRestarted target="controller"}}>{{view.componentsCount}} {{pluralize view.componentsCount singular="t:common.component" plural="t:common.components"}}</a> {{t on}} <a href="#" {{action showHostsShouldBeRestarted target="controller"}}>{{view.hostsCount}} {{pluralize view.hostsCount singular="t:common.host" plural="t:common.hosts"}}</a>
-
-              <button {{bindAttr class=":btn :restart-components :pull-right view.startComponentsIsDisabled::btn-success view.startComponentsIsDisabled:disabled" }} {{action restartComponents target="controller"}}>
-                {{t hosts.host.details.needToRestart.startButton}}
-              </button>
               <span class="restart-components pull-right">&nbsp</span>
-              <button {{bindAttr class=":btn :restart-components :pull-right view.stopComponentsIsDisabled::btn-danger view.stopComponentsIsDisabled:disabled" }} {{action restartComponents view.isStopCommand target="controller"}}>
-                {{t hosts.host.details.needToRestart.stopButton}}
-              </button>
+              <div class="btn-group pull-right">
+                <button type="button" class="btn btn-default dropdown-toggle btn-warning" data-toggle="dropdown">
+                  {{t hosts.host.details.needToRestart.button}}
+                  <span class="caret"></span>
+                </button>
+                <ul class="dropdown-menu">
+                  <li><a href="#" {{action restartAllStaleConfigComponents target="controller"}}>{{t restart.service.all}}</a></li>
+                  {{#if view.rollingRestartSlaveComponentName}}
+                    <li><a href="#" {{action rollingRestartStaleConfigSlaveComponents view.rollingRestartSlaveComponentName target="controller"}}>{{view.rollingRestartActionName}}</a></li>
+                  {{/if}}
+                </ul>
+              </div>
             </div>
           </div>
         {{/if}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/067b1b60/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 e3bdb53..4212f86 100644
--- a/ambari-web/app/utils/batch_scheduled_requests.js
+++ b/ambari-web/app/utils/batch_scheduled_requests.js
@@ -49,30 +49,38 @@ module.exports = {
     return rollingRestartComponent;
   },
 
-  doPostRestartAllServiceComponents : function(serviceName) {
-    var allHostComponents = App.HostComponent.find();
+  restartAllServiceHostComponents : function(serviceName, staleConfigsOnly) {
+    var service = App.Service.find(serviceName);
+    if (service) {
+      var hostComponents = service.get('hostComponents')
+      if (staleConfigsOnly) {
+        hostComponents = hostComponents.filterProperty('staleConfigs', true);
+      }
+      this.restartHostComponents(hostComponents);
+    }
+  },
+
+  restartHostComponents : function(hostComponentsList) {
     var componentToHostsMap = {};
-    var componentCount = 0;
-    allHostComponents.forEach(function(hc) {
-      if (serviceName == hc.get('service.serviceName')) {
-        var componentName = hc.get('componentName');
-        if (!componentToHostsMap[componentName]) {
-          componentToHostsMap[componentName] = [];
-          componentCount++;
-        }
-        componentToHostsMap[componentName].push(hc.get('host.hostName'));
+    var componentToServiceMap = {};
+    hostComponentsList.forEach(function(hc) {
+      var componentName = hc.get('componentName');
+      if (!componentToHostsMap[componentName]) {
+        componentToHostsMap[componentName] = [];
       }
+      componentToHostsMap[componentName].push(hc.get('host.hostName'));
+      componentToServiceMap[componentName] = hc.get('service.serviceName');
     });
     for ( var componentName in componentToHostsMap) {
       var hosts = componentToHostsMap[componentName].join(",");
       var data = {
-        serviceName : serviceName,
+        serviceName : componentToServiceMap[componentName],
         componentName : componentName,
         hosts : hosts
       }
       var sender = {
         successFunction : function() {
-          App.router.get('applicationController').dataLoading().done(function (initValue) {
+          App.router.get('applicationController').dataLoading().done(function(initValue) {
             if (initValue) {
               App.router.get('backgroundOperationsController').showPopup();
             }
@@ -96,7 +104,7 @@ module.exports = {
    * Makes a REST call to the server requesting the rolling restart of the
    * provided host components.
    */
-  doPostBatchRollingRestartRequest : function(restartHostComponents, batchSize, intervalTimeSeconds, tolerateSize, successCallback, errorCallback) {
+  _doPostBatchRollingRestartRequest : function(restartHostComponents, batchSize, intervalTimeSeconds, tolerateSize, successCallback, errorCallback) {
     var clusterName = App.get('clusterName');
     var data = {
       restartHostComponents : restartHostComponents,
@@ -175,9 +183,9 @@ module.exports = {
           var batchSize = this.get('innerView.batchSize');
           var waitTime = this.get('innerView.interBatchWaitTimeSeconds');
           var tolerateSize = this.get('innerView.tolerateSize');
-          self.doPostBatchRollingRestartRequest(restartComponents, batchSize, waitTime, tolerateSize, function() {
+          self._doPostBatchRollingRestartRequest(restartComponents, batchSize, waitTime, tolerateSize, function() {
             dialog.hide();
-            App.router.get('applicationController').dataLoading().done(function (initValue) {
+            App.router.get('applicationController').dataLoading().done(function(initValue) {
               if (initValue) {
                 App.router.get('backgroundOperationsController').showPopup();
               }

http://git-wip-us.apache.org/repos/asf/ambari/blob/067b1b60/ambari-web/app/views/main/host/summary.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/summary.js b/ambari-web/app/views/main/host/summary.js
index 67f8595..15bc0ad 100644
--- a/ambari-web/app/views/main/host/summary.js
+++ b/ambari-web/app/views/main/host/summary.js
@@ -34,24 +34,6 @@ App.MainHostSummaryView = Em.View.extend({
     window.open(gangliaMobileUrl);
   },
 
-  stopComponentsIsDisabled: function () {
-    var staleComponents = this.get('content.hostComponents').filterProperty('staleConfigs', true);
-    if(!staleComponents.findProperty('workStatus','STARTED')){
-      return true;
-    } else {
-      return false;
-    }
-  }.property('content.hostComponents.@each.workStatus', 'content.hostComponents.@each.staleConfigs'),
-
-  startComponentsIsDisabled:function () {
-    var staleComponents = this.get('content.hostComponents').filterProperty('staleConfigs', true);
-    if(!staleComponents.findProperty('workStatus','INSTALLED')){
-      return true;
-    } else {
-      return false;
-    }
-  }.property('content.hostComponents.@each.workStatus', 'content.hostComponents.@each.staleConfigs'),
-
   needToRestartMessage: function() {
     var componentsCount, word;
     componentsCount = this.get('content.componentsWithStaleConfigsCount');

http://git-wip-us.apache.org/repos/asf/ambari/blob/067b1b60/ambari-web/app/views/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/info/configs.js b/ambari-web/app/views/main/service/info/configs.js
index 02d2fe8..4af04c3 100644
--- a/ambari-web/app/views/main/service/info/configs.js
+++ b/ambari-web/app/views/main/service/info/configs.js
@@ -17,6 +17,7 @@
  */
 
 var App = require('app');
+var batchUtils = require('utils/batch_scheduled_requests');
 
 App.MainServiceInfoConfigsView = Em.View.extend({
   templateName: require('templates/main/service/info/configs'),
@@ -29,26 +30,7 @@ App.MainServiceInfoConfigsView = Em.View.extend({
   hostsCount: null,
   isStopCommand:true,
 
-
-  stopComponentsIsDisabled: function () {
-    var staleComponents = this.get('controller.content.hostComponents').filterProperty('staleConfigs', true);
-    if (!staleComponents.findProperty('workStatus', 'STARTED')) {
-      return true;
-    } else {
-      return false;
-    }
-  }.property('controller.content.hostComponents.@each.workStatus', 'controller.content.hostComponents.@each.staleConfigs'),
-
-  startComponentsIsDisabled: function () {
-    var staleComponents = this.get('controller.content.hostComponents').filterProperty('staleConfigs', true);
-    if (!staleComponents.findProperty('workStatus', 'INSTALLED')) {
-      return true;
-    } else {
-      return false;
-    }
-  }.property('controller.content.hostComponents.@each.workStatus', 'controller.content.hostComponents.@each.staleConfigs'),
-
-  calculateCounts: function() {
+  updateComponentInformation: function() {
     var hc = this.get('controller.content.restartRequiredHostsAndComponents');
     var hostsCount = 0;
     var componentsCount = 0;
@@ -58,5 +40,18 @@ App.MainServiceInfoConfigsView = Em.View.extend({
     }
     this.set('componentsCount', componentsCount);
     this.set('hostsCount', hostsCount);
-  }.observes('controller.content.restartRequiredHostsAndComponents')
+  }.observes('controller.content.restartRequiredHostsAndComponents'),
+
+  rollingRestartSlaveComponentName : function() {
+    return batchUtils.getRollingRestartComponentName(this.get('controller.content.serviceName'));
+  }.property('controller.content.serviceName'),
+
+  rollingRestartActionName : function() {
+    var label = null;
+    var componentName = this.get('rollingRestartSlaveComponentName');
+    if (componentName) {
+      label = Em.I18n.t('rollingrestart.dialog.title').format(App.format.role(componentName));
+    }
+    return label;
+  }.property('rollingRestartSlaveComponentName')
 });