incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject git commit: AMBARI-3727. Need ability to restart host_components in bulk (on services and hosts) (alexantonenko)
Date Wed, 13 Nov 2013 00:09:55 GMT
Updated Branches:
  refs/heads/trunk 6f7d033d7 -> a9f5a470a


AMBARI-3727. Need ability to restart host_components in bulk (on services and hosts) (alexantonenko)


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

Branch: refs/heads/trunk
Commit: a9f5a470a846e598f60d3150c3f539d227df8503
Parents: 6f7d033
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Tue Nov 12 22:01:07 2013 +0200
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Tue Nov 12 22:01:07 2013 +0200

----------------------------------------------------------------------
 ambari-web/app/controllers/main/host/details.js | 44 +++++++++++++++++--
 .../controllers/main/service/info/configs.js    | 45 ++++++++++++++++++--
 ambari-web/app/messages.js                      |  2 +
 ambari-web/app/styles/application.less          |  2 +-
 ambari-web/app/templates/main/host/summary.hbs  |  9 +++-
 .../app/templates/main/service/info/configs.hbs | 21 ++++++---
 ambari-web/app/utils/ajax.js                    | 38 +++++++++++++++++
 ambari-web/app/views/main/host/summary.js       | 20 +++++++++
 .../app/views/main/service/info/configs.js      | 20 +++++++++
 9 files changed, 185 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a9f5a470/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 b901653..13fb3e8 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -867,9 +867,47 @@ App.MainHostDetailsController = Em.Controller.extend({
     })
   },
 
-  restartComponents: function() {
-    App.showConfirmationPopup(function() {
-
+  restartComponents: function(e) {
+    var staleComponents = this.get('content.hostComponents').filterProperty('staleConfigs',
true);
+    var commandName = "stop_component";
+    if(e.context) {
+      if(!staleComponents.findProperty('workStatus','INSTALLED')){
+        return;
+      }
+    }else {
+      commandName = "start_component";
+      if(!staleComponents.findProperty('workStatus','STARTED')){
+        return;
+      }
+    };
+    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 hostComponents = this.content.get('content.hostComponents').filterProperty('staleConfigs',
true);
+        hostComponents.forEach(function(item){
+          var componentName = item.get('componentName');
+          var hostName = item.get('host.hostName');
+          App.ajax.send({
+            name: 'config.stale.'+commandName,
+            sender: this,
+            data: {
+              hostName: hostName,
+              componentName: componentName,
+              displayName: App.format.role(componentName)
+            }
+          });
+        })
+        this.hide();
+        App.router.get('backgroundOperationsController').showPopup();
+      },
+      onSecondary: function () {
+        this.hide();
+      }
     });
   },
   /**

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a9f5a470/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 abea470..1cf098a 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -1633,11 +1633,50 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
     this.loadStep();
   },
 
-  restartComponents: function() {
-    App.showConfirmationPopup(function() {
-
+  restartComponents: function(e) {
+    var commandName = "stop_component";
+    if(e.context) {
+      if(this.get('content.healthStatus') != 'green'){
+        return;
+      }
+    }else {
+      commandName = "start_component";
+      if(this.get('content.healthStatus') != 'red'){
+        return;
+      }
+    };
+    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 selectedService = this.content.get('content.id');
+        var hostComponents = App.HostComponent.find().filterProperty('service.id', selectedService).filterProperty('staleConfigs',
true)
+        hostComponents.forEach(function(item){
+          var componentName = item.get('componentName');
+          var hostName = item.get('host.hostName');
+          App.ajax.send({
+            name: 'config.stale.'+commandName,
+            sender: this,
+            data: {
+              hostName: hostName,
+              componentName: componentName,
+              displayName: App.format.role(componentName)
+            }
+          });
+        })
+        this.hide();
+        App.router.get('backgroundOperationsController').showPopup();
+      },
+      onSecondary: function () {
+        this.hide();
+      }
     });
   },
+
   showHostsShouldBeRestarted: function() {
     var hosts = [];
     for(var hostName in this.get('content.restartRequiredHostsAndComponents')) {

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a9f5a470/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 8523f86..170310b 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1298,6 +1298,8 @@ Em.I18n.translations = {
   'hosts.host.details.hostActions':'Host Actions...',
   'hosts.host.details.needToRestart':'Host needs {0} components 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.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/incubator-ambari/blob/a9f5a470/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index 7ea9c63..8b00c90 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -4770,7 +4770,7 @@ i.icon-asterisks {
   .accordion-heading {
     background-color: #f0f0f0;
     a:hover {
-      text-decoration: none;;
+      text-decoration: none;
     }
   }
   .accordion-body {

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a9f5a470/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 94908df..31bb5f3 100644
--- a/ambari-web/app/templates/main/host/summary.hbs
+++ b/ambari-web/app/templates/main/host/summary.hbs
@@ -30,9 +30,14 @@
           {{#if view.needToRestartComponentsCount}}
               <div class="alert alert-warning clearfix">
                 <i class="icon-refresh"></i> {{view.needToRestartMessage}}
-                <button class="btn btn-warning restart-components pull-right" {{action
restartComponents target="controller"}}>
-                  {{t hosts.host.details.needToRestart.button}}
+                <br/>
+                <button {{bindAttr class=":btn :btn-warning :restart-components :pull-left
view.stopComponentsIsDisabled:disabled" }} {{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 :btn-warning :restart-components :pull-left
view.startComponentsIsDisabled:disabled" }} {{action restartComponents target="controller"}}>
+                  {{t hosts.host.details.needToRestart.startButton}}
+                 </button>
               </div>
           {{/if}}
 

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a9f5a470/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 04aa3a5..a47b358 100644
--- a/ambari-web/app/templates/main/service/info/configs.hbs
+++ b/ambari-web/app/templates/main/service/info/configs.hbs
@@ -20,14 +20,21 @@
   {{#if dataIsLoaded}}
     {{#if App.supports.hostOverrides}}
       {{#if controller.content.isRestartRequired}}
-        <div>
-          <div class="alert alert-warning clearfix">
-            <i class="icon-refresh"></i> {{{view.needToRestartMessage}}} <a
href="#" {{action showComponentsShouldBeRestarted target="controller"}}>{{view.componentsCount}}
{{t common.components}}</a> {{t on}} <a href="#" {{action showHostsShouldBeRestarted
target="controller"}}>{{view.hostsCount}} {{t dashboard.services.hosts}}</a> {{t
services.service.config.restartService.needToRestartEnd}}
-            <button class="btn btn-warning restart-components pull-right" {{action restartComponents
target="controller"}}>
-              {{t hosts.host.details.needToRestart.button}}
-            </button>
+        {{#if App.isAdmin}}
+          <div>
+            <div class="alert alert-warning clearfix">
+              <i class="icon-refresh"></i> {{{view.needToRestartMessage}}} <a
href="#" {{action showComponentsShouldBeRestarted target="controller"}}>{{view.componentsCount}}
{{t common.components}}</a> {{t on}} <a href="#" {{action showHostsShouldBeRestarted
target="controller"}}>{{view.hostsCount}} {{t dashboard.services.hosts}}</a> {{t
services.service.config.restartService.needToRestartEnd}}
+
+              <button {{bindAttr class=":btn :btn-warning :restart-components :pull-right
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 :btn-warning :restart-components :pull-right
view.stopComponentsIsDisabled:disabled" }} {{action restartComponents view.isStopCommand target="controller"}}>
+                {{t hosts.host.details.needToRestart.stopButton}}
+              </button>
+            </div>
           </div>
-        </div>
+        {{/if}}
       {{/if}}
     {{/if}}
     <div class="clearfix"></div>

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a9f5a470/ambari-web/app/utils/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax.js b/ambari-web/app/utils/ajax.js
index f2c47bd..8f7df69 100644
--- a/ambari-web/app/utils/ajax.js
+++ b/ambari-web/app/utils/ajax.js
@@ -228,6 +228,44 @@ var urls = {
       };
     }
   },
+  'config.stale.stop_component': {
+    'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
+    'mock': '',
+    'type': 'PUT',
+    'format': function (data) {
+      return {
+        data: JSON.stringify({
+          RequestInfo: {
+            "context": "Stop " + data.displayName
+          },
+          Body: {
+            "HostRoles": {
+              "state": "INSTALLED"
+            }
+          }
+        })
+      }
+    }
+  },
+  'config.stale.start_component': {
+    'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}',
+    'mock': '',
+    'type': 'PUT',
+    'format': function (data) {
+      return {
+        data: JSON.stringify({
+          RequestInfo: {
+            "context": "Start " + data.displayName
+          },
+          Body: {
+            "HostRoles": {
+              "state": "STARTED"
+            }
+          }
+        })
+      }
+    }
+  },
   'service.metrics.flume.channel_fill_percent': {
     'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_SERVER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelFillPercentage[{fromSeconds},{toSeconds},{stepSeconds}]',
     'mock': '/data/services/metrics/flume/channelFillPct.json',

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a9f5a470/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 2a31886..a0c1ac4 100644
--- a/ambari-web/app/views/main/host/summary.js
+++ b/ambari-web/app/views/main/host/summary.js
@@ -22,6 +22,8 @@ var uiEffects = require('utils/ui_effects');
 App.MainHostSummaryView = Em.View.extend({
   templateName: require('templates/main/host/summary'),
 
+  isStopCommand:true,
+
   content: function () {
     return App.router.get('mainHostDetailsController.content');
   }.property('App.router.mainHostDetailsController.content'),
@@ -36,6 +38,24 @@ App.MainHostSummaryView = Em.View.extend({
     return this.get('sortedComponents').filterProperty('staleConfigs', true).length;
   }.property('sortedComponents.@each.staleConfigs'),
 
+  stopComponentsIsDisabled: function () {
+    var staleComponents = this.get('sortedComponents').filterProperty('staleConfigs', true);
+    if(!staleComponents.findProperty('workStatus','INSTALLED')){
+      return true;
+    }else{
+      return false;
+    }
+  }.property('sortedComponents.@each.workStatus'),
+
+  startComponentsIsDisabled:function () {
+    var staleComponents = this.get('sortedComponents').filterProperty('staleConfigs', true);
+    if(!staleComponents.findProperty('workStatus','STARTED')){
+      return true;
+    }else{
+      return false;
+    }
+  }.property('sortedComponents.@each.workStatus'),
+
   needToRestartMessage: function() {
     return Em.I18n.t('hosts.host.details.needToRestart').format(this.get('needToRestartComponentsCount'));
   }.property('needToRestartComponentsCount'),

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a9f5a470/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 a7abdff..0e7ee89 100644
--- a/ambari-web/app/views/main/service/info/configs.js
+++ b/ambari-web/app/views/main/service/info/configs.js
@@ -27,6 +27,26 @@ App.MainServiceInfoConfigsView = Em.View.extend({
 
   componentsCount: null,
   hostsCount: null,
+  isStopCommand:true,
+
+
+  stopComponentsIsDisabled: function () {
+    var controller = this.get('controller');
+    if(controller.get('content.healthStatus') == 'green'){
+      return false;
+    }else{
+      return true;
+    }
+  }.property('controller.content.healthStatus'),
+
+  startComponentsIsDisabled:function () {
+    var controller = this.get('controller');
+    if(controller.get('content.healthStatus') == 'red'){
+      return false;
+    }else{
+      return true;
+    }
+  }.property('controller.content.healthStatus'),
 
   calculateCounts: function() {
     var hc = this.get('controller.content.restartRequiredHostsAndComponents');


Mime
View raw message