You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ak...@apache.org on 2015/11/20 12:39:20 UTC
ambari git commit: AMBARI-13989. Implement single button to "refresh
all" for all services impacted for stale configs (akovalenko)
Repository: ambari
Updated Branches:
refs/heads/trunk ef89fb85c -> 3a65b4723
AMBARI-13989. Implement single button to "refresh all" for all services impacted for stale configs (akovalenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3a65b472
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3a65b472
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3a65b472
Branch: refs/heads/trunk
Commit: 3a65b4723fc8fc5229f9e3d90b77d7ea4fc270ef
Parents: ef89fb8
Author: Aleksandr Kovalenko <ak...@hortonworks.com>
Authored: Fri Nov 20 13:21:08 2015 +0200
Committer: Aleksandr Kovalenko <ak...@hortonworks.com>
Committed: Fri Nov 20 13:21:08 2015 +0200
----------------------------------------------------------------------
ambari-web/app/controllers/main/dashboard.js | 4 +
ambari-web/app/controllers/main/service.js | 60 +++++++++++
ambari-web/app/messages.js | 3 +
.../main/service/all_services_actions.hbs | 8 ++
.../test/controllers/main/service_test.js | 103 +++++++++++++++++++
5 files changed, 178 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/3a65b472/ambari-web/app/controllers/main/dashboard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/dashboard.js b/ambari-web/app/controllers/main/dashboard.js
index e3eb0b2..861ff2d 100644
--- a/ambari-web/app/controllers/main/dashboard.js
+++ b/ambari-web/app/controllers/main/dashboard.js
@@ -51,5 +51,9 @@ App.MainDashboardController = Em.Controller.extend({
stopAllService: function(event){
App.router.get('mainServiceController').stopAllService(event);
+ },
+
+ restartAllRequired: function(event){
+ App.router.get('mainServiceController').restartAllRequired(event);
}
});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/3a65b472/ambari-web/app/controllers/main/service.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service.js b/ambari-web/app/controllers/main/service.js
index 266f2ba..9269780 100644
--- a/ambari-web/app/controllers/main/service.js
+++ b/ambari-web/app/controllers/main/service.js
@@ -81,6 +81,14 @@ App.MainServiceController = Em.ArrayController.extend({
}.property('isStartStopAllClicked', 'content.@each.healthStatus'),
/**
+ * Should "Refresh All"-button be disabled
+ * @type {bool}
+ */
+ isRestartAllRequiredDisabled: function () {
+ return !this.get('content').someProperty('isRestartRequired');
+ }.property('content.@each.isRestartRequired'),
+
+ /**
* @type {bool}
*/
isStartStopAllClicked: function () {
@@ -289,5 +297,57 @@ App.MainServiceController = Em.ArrayController.extend({
}
App.router.get('addServiceController').setDBProperty('onClosePath', 'main.services.index');
App.router.transitionTo('main.serviceAdd');
+ },
+
+ /**
+ * Show confirmation popup and send request to restart all host components with stale_configs=true
+ */
+ restartAllRequired: function () {
+ var self = this;
+ var servicesList = [];
+ var hostComponentsToRestart = [];
+ App.HostComponent.find().filterProperty('staleConfigs').forEach(function (hostComponent) {
+ hostComponentsToRestart.push({
+ component_name: hostComponent.get('componentName'),
+ service_name: hostComponent.get('service.serviceName'),
+ hosts: hostComponent.get('hostName')
+ });
+ servicesList.push(hostComponent.get('service.displayName'));
+ });
+ return App.showConfirmationPopup(function () {
+ self.restartHostComponents(hostComponentsToRestart);
+ }, Em.I18n.t('services.service.refreshAll.confirmMsg').format(servicesList.uniq().join(', ')), null, null, Em.I18n.t('services.service.restartAll.confirmButton'));
+ },
+
+ /**
+ * Send request restart host components from hostComponentsToRestart
+ * @returns {$.ajax}
+ */
+ restartHostComponents: function (hostComponentsToRestart) {
+ App.ajax.send({
+ name: 'restart.hostComponents',
+ sender: this,
+ data: {
+ context: 'Restart all required services',
+ resource_filters: hostComponentsToRestart,
+ operation_level: {
+ level: "CLUSTER",
+ cluster_name: App.get('clusterName')
+ }
+ },
+ success: 'restartAllRequiredSuccessCallback'
+ });
+ },
+
+ /**
+ * Success callback for restartAllRequired
+ */
+ restartAllRequiredSuccessCallback: function () {
+ // load data (if we need to show this background operations popup) from persist
+ App.router.get('userSettingsController').dataLoading('show_bg').done(function (initValue) {
+ if (initValue) {
+ App.router.get('backgroundOperationsController').showPopup();
+ }
+ });
}
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/3a65b472/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 57f8555..2691a5d 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1875,8 +1875,11 @@ Em.I18n.translations = {
'services.service.add':'Add Service',
'services.service.startAll':'Start All',
'services.service.stopAll':'Stop All',
+ 'services.service.restartAllRequired':'Restart All Required',
'services.service.startAll.confirmMsg' : 'You are about to start all services',
'services.service.stopAll.confirmMsg' : 'You are about to stop all services',
+ 'services.service.refreshAll.confirmMsg': '<p>You are about to restart {0}</p>' +
+ '<div class="alert alert-warning">This will trigger alerts as the service is restarted. To suppress alerts, turn on Maintenance Mode for services listed above prior to running Restart All Required</div>',
'services.service.start.confirmMsg' : 'You are about to start {0}',
'services.service.stop.confirmMsg' : 'You are about to stop {0}',
'services.service.stop.confirmButton': 'Confirm Stop',
http://git-wip-us.apache.org/repos/asf/ambari/blob/3a65b472/ambari-web/app/templates/main/service/all_services_actions.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/service/all_services_actions.hbs b/ambari-web/app/templates/main/service/all_services_actions.hbs
index acbe692..1cc0270 100644
--- a/ambari-web/app/templates/main/service/all_services_actions.hbs
+++ b/ambari-web/app/templates/main/service/all_services_actions.hbs
@@ -46,6 +46,14 @@
{{t services.service.stopAll}}
</a>
</li>
+ <li {{bindAttr class="controller.isRestartAllRequiredDisabled:disabled" }}>
+ <a href="#" data-toggle="modal"
+ {{bindAttr class="controller.isRestartAllRequiredDisabled:disabled" }}
+ {{action "restartAllRequired" target="controller"}}>
+ <i {{bindAttr class=":icon-repeat controller.isRestartAllRequiredDisabled:disabled:enabled" }}></i>
+ {{t services.service.restartAllRequired}}
+ </a>
+ </li>
</ul>
</div>
</div>
http://git-wip-us.apache.org/repos/asf/ambari/blob/3a65b472/ambari-web/test/controllers/main/service_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service_test.js b/ambari-web/test/controllers/main/service_test.js
index b228279..f51c7eb 100644
--- a/ambari-web/test/controllers/main/service_test.js
+++ b/ambari-web/test/controllers/main/service_test.js
@@ -330,4 +330,107 @@ describe('App.MainServiceController', function () {
});
+ describe('#isRestartAllRequiredDisabled', function () {
+
+ it('should be false if there is at least one service with isRestartRequired=true', function () {
+ mainServiceController.reopen({
+ content: [
+ {isRestartRequired: false}, {isRestartRequired: false}, {isRestartRequired: true}
+ ]
+ });
+ expect(mainServiceController.get('isRestartAllRequiredDisabled')).to.be.false;
+ });
+
+ it('should be true if there is no services with isRestartRequired=true', function () {
+ mainServiceController.reopen({
+ content: [
+ {isRestartRequired: false}, {isRestartRequired: false}, {isRestartRequired: false}
+ ]
+ });
+ expect(mainServiceController.get('isRestartAllRequiredDisabled')).to.be.true;
+ });
+
+ });
+
+ describe('#restartAllRequired', function () {
+
+ beforeEach(function () {
+ sinon.spy(App, 'showConfirmationPopup');
+ sinon.spy(mainServiceController, 'restartHostComponents');
+ sinon.stub(App.HostComponent, 'find', function() {
+ return [
+ Em.Object.create({
+ componentName: 'componentName1',
+ hostName: 'hostName1',
+ service: {
+ serviceName: 'serviceName1',
+ displayName: 'displayName1'
+ },
+ staleConfigs: true
+ }),
+ Em.Object.create({
+ componentName: 'componentName2',
+ hostName: 'hostName2',
+ service: {
+ serviceName: 'serviceName2',
+ displayName: 'displayName2'
+ },
+ staleConfigs: true
+ }),
+ Em.Object.create({
+ componentName: 'componentName3',
+ hostName: 'hostName3',
+ service: {
+ serviceName: 'serviceName3',
+ displayName: 'displayName3'
+ },
+ staleConfigs: false
+ })
+ ];
+ });
+ });
+
+ afterEach(function () {
+ App.HostComponent.find.restore();
+ App.showConfirmationPopup.restore();
+ mainServiceController.restartHostComponents.restore();
+ });
+
+ it('should show confirmation popup with list of services and call restartHostComponents after confirmation', function () {
+ var popup = mainServiceController.restartAllRequired();
+ popup.onPrimary();
+ expect(App.showConfirmationPopup.args[0][1]).to.equal(Em.I18n.t('services.service.refreshAll.confirmMsg').format('displayName1, displayName2'));
+ expect(mainServiceController.restartHostComponents.calledWith([
+ {
+ component_name: 'componentName1',
+ service_name: 'serviceName1',
+ hosts: 'hostName1'
+ },
+ {
+ component_name: 'componentName2',
+ service_name: 'serviceName2',
+ hosts: 'hostName2'
+ }
+ ])).to.be.true;
+ });
+
+ });
+
+ describe('#restartHostComponents', function () {
+
+ beforeEach(function () {
+ sinon.stub(App.ajax, 'send', Em.K);
+ });
+
+ afterEach(function () {
+ App.ajax.send.restore();
+ });
+
+ it('should send ajax request', function () {
+ mainServiceController.restartHostComponents();
+ expect(App.ajax.send.calledOnce).to.be.true;
+ });
+
+ });
+
});