You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2014/01/04 01:33:30 UTC

git commit: AMBARI-4225. Starting/Stopping components based on restart indicator floods request history and execution queue. (yusaku)

Updated Branches:
  refs/heads/branch-1.4.3 e60a5f1a1 -> 2554b79c4


AMBARI-4225. Starting/Stopping components based on restart indicator floods request history and execution queue. (yusaku)


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

Branch: refs/heads/branch-1.4.3
Commit: 2554b79c40c3f67417c75127ee90cf881b547be7
Parents: e60a5f1
Author: Yusaku Sako <yu...@hortonworks.com>
Authored: Fri Jan 3 16:22:35 2014 -0800
Committer: Yusaku Sako <yu...@hortonworks.com>
Committed: Fri Jan 3 16:22:35 2014 -0800

----------------------------------------------------------------------
 ambari-web/app/controllers/main/host/details.js | 54 +++++++++++--------
 .../controllers/main/service/info/configs.js    | 55 ++++++++++++--------
 ambari-web/app/utils/ajax.js                    | 40 ++++++++++++++
 3 files changed, 105 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2554b79c/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 a5845c5..fe46dcc 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -1004,6 +1004,11 @@ App.MainHostDetailsController = Em.Controller.extend({
         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'),
@@ -1012,35 +1017,42 @@ App.MainHostDetailsController = Em.Controller.extend({
       body: Em.I18n.t('question.sure'),
       content: content,
       onPrimary: function () {
-        var hostComponents = this.content.get('content.hostComponents').filterProperty('staleConfigs', true);
-        hostComponents.forEach(function (item) {
-          var state = 'INSTALLED',
-              componentName = item.get('componentName'),
-              context = "Stop " + App.format.role(componentName),
-              hostName = item.get('host.hostName');
+        var hostName = this.content.get('content.hostName');
+        var hostComponents = this.content.get('content.hostComponents');
 
-          if (commandName === 'start_component') {
-            context = "Start " + App.format.role(componentName);
-            state = 'STARTED';
-            if (item.get('isClient')) {
-              //start components action includes install of clients
-              context = "Install " + App.format.role(componentName);
-              state = "INSTALLED";
-            }
-          } else if (item.get('isClient')) {
-            return false;
+        // 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.host_component.action',
+            name: 'host.stale_host_components.start_stop',
             sender: this,
             data: {
               hostName: hostName,
-              componentName: componentName,
-              context: context,
-              state: state
+              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) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/2554b79c/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 e89ee2f..58b4c99 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -1791,35 +1791,44 @@ 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).filterProperty('staleConfigs', true)
-        hostComponents.forEach(function (item) {
-          var state = 'INSTALLED',
-              componentName = item.get('componentName'),
-              context = "Stop " + App.format.role(componentName),
-              hostName = item.get('host.hostName');
-
-          if (commandName === 'start_component') {
-            context = "Start " + App.format.role(componentName);
-            state = 'STARTED';
-            if (item.get('isClient')) {
-              //start components action includes install of clients
-              context = "Install " + App.format.role(componentName);
-              state = "INSTALLED";
-            }
-          } else if (item.get('isClient')) {
-            return false;
+        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: 'host.host_component.action',
+            name: 'service.stale_host_components.start_stop',
             sender: this,
             data: {
-              hostName: hostName,
-              componentName: componentName,
-              context: context,
-              state: state
+              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) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/2554b79c/ambari-web/app/utils/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax.js b/ambari-web/app/utils/ajax.js
index 08c03ad..51c204e 100644
--- a/ambari-web/app/utils/ajax.js
+++ b/ambari-web/app/utils/ajax.js
@@ -90,6 +90,26 @@ var urls = {
       };
     }
   },
+  'service.stale_host_components.start_stop': {
+    'real': '/clusters/{clusterName}/host_components?' +
+            'HostRoles/stale_configs=true&HostRoles/component_name.in({componentNames})',
+    'mock': '/data/wizard/deploy/poll_1.json',
+    'format': function (data, opt) {
+      return {
+        type: 'PUT',
+        data: JSON.stringify({
+          RequestInfo: {
+            "context": data.requestInfo
+          },
+          Body: {
+            HostRoles: {
+              state: data.state
+            }
+          }
+        })
+      };
+    }
+  },
   'service.load_config_groups': {
     'real': '/clusters/{clusterName}/config_groups?ConfigGroup/tag={serviceName}&fields=*',
     'mock': ''
@@ -279,6 +299,26 @@ var urls = {
       }
     }
   },
+  'host.stale_host_components.start_stop': {
+    'real': '/clusters/{clusterName}/hosts/{hostName}/host_components?HostRoles/stale_configs=true&' +
+            'HostRoles/component_name.in({componentNames})',
+    'mock': '',
+    'type': 'PUT',
+    'format': function (data) {
+      return {
+        data: JSON.stringify({
+          RequestInfo: {
+            "context": data.context
+          },
+          Body: {
+            "HostRoles": {
+              "state": data.state
+            }
+          }
+        })
+      }
+    }
+  },
   'host.delete': {
     'real': '/clusters/{clusterName}/hosts/{hostName}',
     'mock': '',