Repository: ambari Updated Branches: refs/heads/trunk b69f06e00 -> 97e811974
AMBARI-6415 Allow enabling MM for host components from UI. (ababiichuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/97e81197 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/97e81197 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/97e81197 Branch: refs/heads/trunk Commit: 97e81197454788d13a20a732a178aca4aa6b4ab7 Parents: b69f06e Author: aBabiichuk <[email protected]> Authored: Tue Jul 8 16:32:00 2014 +0300 Committer: aBabiichuk <[email protected]> Committed: Tue Jul 8 16:32:00 2014 +0300 ---------------------------------------------------------------------- .../highAvailability/rollback_controller.js | 3 +- .../admin/highAvailability/step5_controller.js | 3 +- ambari-web/app/controllers/main/admin/user.js | 2 +- ambari-web/app/controllers/main/host/details.js | 43 +++++ .../main/service/reassign/step4_controller.js | 3 +- .../app/controllers/wizard/step8_controller.js | 2 +- .../main/host/details/host_component.hbs | 14 +- ambari-web/app/utils/ajax/ajax.js | 180 ++++++------------- .../app/utils/batch_scheduled_requests.js | 4 +- ambari-web/app/utils/config.js | 3 +- ambari-web/app/utils/helper.js | 10 ++ .../main/host/details/host_component_view.js | 8 - .../host/details/host_component_view_test.js | 43 ----- 13 files changed, 132 insertions(+), 186 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/97e81197/ambari-web/app/controllers/main/admin/highAvailability/rollback_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/highAvailability/rollback_controller.js b/ambari-web/app/controllers/main/admin/highAvailability/rollback_controller.js index 1050c9c..f6af166 100644 --- a/ambari-web/app/controllers/main/admin/highAvailability/rollback_controller.js +++ b/ambari-web/app/controllers/main/admin/highAvailability/rollback_controller.js @@ -393,11 +393,12 @@ App.HighAvailabilityRollbackController = App.HighAvailabilityProgressPageControl } for (var i = 0; i < hostName.length; i++) { App.ajax.send({ - name: 'admin.high_availability.maintenance_mode', + name: 'common.host.host_component.passive', sender: this, data: { hostName: hostName[i], componentName: componentName, + passive_state: "ON", taskNum: hostName.length, callback: 'checkBeforeDelete' }, http://git-wip-us.apache.org/repos/asf/ambari/blob/97e81197/ambari-web/app/controllers/main/admin/highAvailability/step5_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/highAvailability/step5_controller.js b/ambari-web/app/controllers/main/admin/highAvailability/step5_controller.js index 6802835..3f37ce6 100644 --- a/ambari-web/app/controllers/main/admin/highAvailability/step5_controller.js +++ b/ambari-web/app/controllers/main/admin/highAvailability/step5_controller.js @@ -62,10 +62,11 @@ App.HighAvailabilityWizardStep5Controller = App.HighAvailabilityProgressPageCont disableSNameNode: function () { var hostName = this.get('content.masterComponentHosts').findProperty('component', 'SECONDARY_NAMENODE').hostName; App.ajax.send({ - name: 'admin.high_availability.maintenance_mode', + name: 'common.host.host_component.passive', sender: this, data: { hostName: hostName, + passive_state: "ON", componentName: 'SECONDARY_NAMENODE' }, success: 'onTaskCompleted', http://git-wip-us.apache.org/repos/asf/ambari/blob/97e81197/ambari-web/app/controllers/main/admin/user.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/user.js b/ambari-web/app/controllers/main/admin/user.js index 292e170..aacc544 100644 --- a/ambari-web/app/controllers/main/admin/user.js +++ b/ambari-web/app/controllers/main/admin/user.js @@ -46,7 +46,7 @@ App.MainAdminUserController = Em.Controller.extend({ onPrimary: function () { App.ajax.send({ - name: 'admin.user.delete', + name: 'common.delete.user', sender: self, data: { user: event.context.get("userName"), http://git-wip-us.apache.org/repos/asf/ambari/blob/97e81197/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 9a45a93..740af84 100644 --- a/ambari-web/app/controllers/main/host/details.js +++ b/ambari-web/app/controllers/main/host/details.js @@ -1221,6 +1221,40 @@ App.MainHostDetailsController = Em.Controller.extend({ }, /** + * Send request to get passive state for hostComponent + * @param {object} component - hostComponentn object + * @param {string} state + * @param {string} message + * @method hostPassiveModeRequest + */ + updateComponentPassiveState: function (component, state, message) { + App.ajax.send({ + name: 'common.host.host_component.passive', + sender: this, + data: { + hostName: this.get('content.hostName'), + componentName: component.get('componentName'), + component: component, + passive_state: state, + context: message + }, + success: 'updateHostComponent' + }); + }, + + /** + * Success callback for receiving hostComponent passive state + * @param {object} data + * @param {object} opt + * @param {object} params + * @method updateHost + */ + updateHostComponent: function (data, opt, params) { + params.component.set('passiveState', params.passive_state) + batchUtils.infoPassiveState(params.passive_state); + }, + + /** * Show confirmation popup for action "start all components" * @method doStartAllComponents */ @@ -1514,5 +1548,14 @@ App.MainHostDetailsController = Em.Controller.extend({ batchUtils.restartHostComponents(components, Em.I18n.t('rollingrestart.context.allClientsOnSelectedHost').format(self.get('content.hostName')), "HOST"); }); } + }, + + toggleMaintenanceMode: function(event) { + var self = this; + var state = event.context.get('passiveState') === "ON" ? "OFF" : "ON"; + var message = Em.I18n.t('passiveState.turn' + state.toCapital() +'For').format(event.context.get('displayName')); + return App.showConfirmationPopup(function () { + self.updateComponentPassiveState(event.context, state, message); + }); } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/97e81197/ambari-web/app/controllers/main/service/reassign/step4_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/reassign/step4_controller.js b/ambari-web/app/controllers/main/service/reassign/step4_controller.js index b809f05..ed30f75 100644 --- a/ambari-web/app/controllers/main/service/reassign/step4_controller.js +++ b/ambari-web/app/controllers/main/service/reassign/step4_controller.js @@ -147,10 +147,11 @@ App.ReassignMasterWizardStep4Controller = App.HighAvailabilityProgressPageContro var hostName = this.get('content.reassignHosts.source'); for (var i = 0; i < hostComponents.length; i++) { App.ajax.send({ - name: 'reassign.maintenance_mode', + name: 'common.host.host_component.passive', sender: this, data: { hostName: hostName, + passive_state: "ON", componentName: hostComponents[i] }, success: 'onComponentsTasksSuccess', http://git-wip-us.apache.org/repos/asf/ambari/blob/97e81197/ambari-web/app/controllers/wizard/step8_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js index d4ef1e0..fb0be3b 100644 --- a/ambari-web/app/controllers/wizard/step8_controller.js +++ b/ambari-web/app/controllers/wizard/step8_controller.js @@ -938,7 +938,7 @@ App.WizardStep8Controller = Em.Controller.extend({ deleteClusters: function (clusterNames) { clusterNames.forEach(function (clusterName, index) { App.ajax.send({ - name: 'wizard.step8.delete_cluster', + name: 'common.delete.cluster', sender: this, data: { name: clusterName, http://git-wip-us.apache.org/repos/asf/ambari/blob/97e81197/ambari-web/app/templates/main/host/details/host_component.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/host/details/host_component.hbs b/ambari-web/app/templates/main/host/details/host_component.hbs index 889e57b..444b6f9 100644 --- a/ambari-web/app/templates/main/host/details/host_component.hbs +++ b/ambari-web/app/templates/main/host/details/host_component.hbs @@ -37,9 +37,9 @@ {{#if component.staleConfigs}} <span class="text-warning icon-refresh"></span> {{/if}} - {{#if component.service.isInPassive}} + {{#unless component.isActive}} <span class="icon-medkit"></span> - {{/if}} + {{/unless}} </div> <div class="span5 pull-right"> {{#if App.isAdmin}} @@ -100,6 +100,16 @@ </a> </li> {{/if}} + <li {{bindAttr class="view.noActionAvailable"}}> + <a href="javascript:void(null)" + data-toggle="modal" {{action "toggleMaintenanceMode" view.content target="controller"}}> + {{#if view.isActive}} + {{t passiveState.turnOn}} + {{else}} + {{t passiveState.turnOff}} + {{/if}} + </a> + </li> {{/unless}} {{#if view.isInit}} <li {{bindAttr class="view."}}> http://git-wip-us.apache.org/repos/asf/ambari/blob/97e81197/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 bbb21bf..b84702a 100644 --- a/ambari-web/app/utils/ajax/ajax.js +++ b/ambari-web/app/utils/ajax/ajax.js @@ -147,15 +147,70 @@ var urls = { } }, + 'common.service.passive': { + 'real': '/clusters/{clusterName}/services/{serviceName}', + 'mock': '', + 'format': function (data) { + return { + type: 'PUT', + data: JSON.stringify({ + RequestInfo: { + "context": data.requestInfo + }, + Body: { + ServiceInfo: { + maintenance_state: data.passive_state + } + } + }) + }; + } + }, + + 'common.host.host_component.passive': { + 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}', + 'mock': '', + 'type': 'PUT', + 'format': function(data) { + return { + data: JSON.stringify({ + RequestInfo: { + "context": data.context + }, + Body: { + HostRoles: { + maintenance_state: data.passive_state + } + } + }) + }; + } + }, + 'common.delete.host': { 'real': '/clusters/{clusterName}/hosts/{hostName}', 'type': 'DELETE' }, - 'common.delete.host_component': { 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}', 'type': 'DELETE' }, + 'common.delete.user': { + 'real': '/users/{user}', + 'type': 'DELETE' + }, + 'common.delete.config_group': { + 'real': '/clusters/{clusterName}/config_groups/{id}', + 'type': 'DELETE' + }, + 'common.delete.cluster': { + 'real': '/clusters/{name}', + 'type': 'DELETE' + }, + 'common.delete.request_schedule': { + 'real': '/clusters/{clusterName}/request_schedules/{request_schedule_id}', + 'type': 'DELETE' + }, 'alerts.get_by_service': { 'real': '/clusters/{clusterName}/services/{serviceName}?fields=alerts', @@ -196,25 +251,6 @@ var urls = { }; } }, - 'service.item.passive': { - 'real': '/clusters/{clusterName}/services/{serviceName}', - 'mock': '', - 'format': function (data) { - return { - type: 'PUT', - data: JSON.stringify({ - RequestInfo: { - "context": data.requestInfo - }, - Body: { - ServiceInfo: { - maintenance_state: data.passive_state - } - } - }) - }; - } - }, 'service.load_config_groups': { 'real': '/clusters/{clusterName}/config_groups?ConfigGroup/tag={serviceName}&fields=*', 'mock': '/data/configurations/config_group.json' @@ -239,22 +275,6 @@ var urls = { } } }, - 'reassign.maintenance_mode': { - 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}', - 'mock': '', - 'type': 'PUT', - 'format': function () { - return { - data: JSON.stringify( - { - "HostRoles": { - "maintenance_state": "ON" - } - } - ) - } - } - }, 'reassign.load_configs': { 'real': '/clusters/{clusterName}/configurations?{urlParams}', 'mock': '' @@ -279,26 +299,6 @@ var urls = { } }, - 'host_component.passive': { - 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}', - 'mock': '', - 'type': 'PUT', - 'format': function(data) { - return { - data: JSON.stringify({ - RequestInfo: { - "context": data.requestInfo - }, - Body: { - HostRoles: { - maintenance_state: data.passive_state - } - } - }) - }; - } - }, - 'config.cluster_configuration.put': { 'real': '/clusters/{cluster}', 'mock': '', @@ -354,11 +354,6 @@ var urls = { } } }, - 'config_groups.delete_config_group': { - 'real': '/clusters/{clusterName}/config_groups/{id}', - 'mock': '', - 'type': 'DELETE' - }, 'config.on_site': { 'real': '/clusters/{clusterName}/configurations?{params}', 'mock': '/data/configurations/cluster_level_configs.json?{params}', @@ -437,26 +432,6 @@ var urls = { } } }, - 'host.host_component.recommission_slave' : { - 'real' : '/clusters/{clusterName}/requests', - 'mock' : '', - 'format' : function(data) { - return { - type : 'POST', - data : JSON.stringify({ - RequestInfo: { - context: data.context, - command: data.command, - parameters: { - slave_type: data.slaveType, - included_hosts: data.hostName - } - }, - "Requests/resource_filters": [{"service_name" : data.serviceName, "component_name" : data.componentName}] - }) - } - } - }, 'host.host_component.refresh_configs': { 'real':'/clusters/{clusterName}/requests', @@ -855,20 +830,6 @@ var urls = { } } }, - 'admin.high_availability.maintenance_mode': { - 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}', - 'mock': '', - 'type': 'PUT', - 'format': function () { - return { - data: JSON.stringify({ - "HostRoles": { - "state": "DISABLED" - } - }) - } - } - }, 'admin.high_availability.load_configs': { 'real': '/clusters/{clusterName}/configurations?(type=core-site&tag={coreSiteTag})|(type=hdfs-site&tag={hdfsSiteTag})', 'mock': '' @@ -967,16 +928,6 @@ var urls = { } }, - 'admin.user.delete': { - 'real': '/users/{user}', - 'mock': '/data/users/users.json', - 'format': function() { - return { - type: 'DELETE' - } - } - }, - 'admin.user.edit': { 'real': '/users/{user}', 'mock':'/data/users/users.json', @@ -1031,15 +982,6 @@ var urls = { } }, - 'wizard.step8.delete_cluster': { - 'real': '/clusters/{name}', - 'mock': '', - 'format': function() { - return { - type: 'DELETE' - }; - } - }, 'wizard.step8.existing_cluster_names': { 'real': '/clusters', 'mock': '', @@ -1354,15 +1296,6 @@ var urls = { } } }, - 'request_schedule.delete': { - 'real': '/clusters/{clusterName}/request_schedules/{request_schedule_id}', - 'mock': '', - 'format' : function() { - return { - type : 'DELETE' - } - } - }, 'request_schedule.get': { 'real': '/clusters/{clusterName}/request_schedules/{request_schedule_id}', 'mock': '' @@ -1414,7 +1347,6 @@ var urls = { 'apiPrefix': '' }, - 'mirroring.create_new_dataset': { 'real': '/proxy?url=http://{falconServer}:15000/api/entities/submitAndSchedule/feed?user.name=ambari-qa', 'mock': '/data/mirroring/succeeded.json', http://git-wip-us.apache.org/repos/asf/ambari/blob/97e81197/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 8b969b0..c165a8e 100644 --- a/ambari-web/app/utils/batch_scheduled_requests.js +++ b/ambari-web/app/utils/batch_scheduled_requests.js @@ -267,7 +267,7 @@ module.exports = { turnOnOffPassiveRequest: function(state, message, serviceName, callback) { App.ajax.send({ - 'name': 'service.item.passive', + 'name': 'common.service.passive', 'sender': { 'successCallback': callback || defaultSuccessCallback, 'errorCallback': defaultErrorCallback @@ -551,7 +551,7 @@ module.exports = { if (requestScheduleId != null && !isNaN(requestScheduleId) && requestScheduleId > -1) { errorCallback = errorCallback || defaultErrorCallback; App.ajax.send({ - name : 'request_schedule.delete', + name : 'common.delete.request_schedule', sender : { successCallbackFunction : function(data) { successCallback(data); http://git-wip-us.apache.org/repos/asf/ambari/blob/97e81197/ambari-web/app/utils/config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js index cd6e901..4073cc8 100644 --- a/ambari-web/app/utils/config.js +++ b/ambari-web/app/utils/config.js @@ -19,7 +19,6 @@ var App = require('app'); var stringUtils = require('utils/string_utils'); -var categotyConfigs = require('data/service_configs'); var configGroupsByTag = []; App.config = Em.Object.create({ @@ -1460,7 +1459,7 @@ App.config = Em.Object.create({ deleteConfigGroup: function (configGroup, successCallback, errorCallback) { var sendData = { - name: 'config_groups.delete_config_group', + name: 'common.delete.config_group', sender: this, data: { id: configGroup.get('id') http://git-wip-us.apache.org/repos/asf/ambari/blob/97e81197/ambari-web/app/utils/helper.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/helper.js b/ambari-web/app/utils/helper.js index 61f7804..1072f08 100644 --- a/ambari-web/app/utils/helper.js +++ b/ambari-web/app/utils/helper.js @@ -67,6 +67,16 @@ String.prototype.capitalize = function () { }; /** + * Capitalize the first letter of string. + * And set to lowercase other part of string + * @method toCapital + * @return {string} + */ +String.prototype.toCapital = function () { + return this.charAt(0).toUpperCase() + this.slice(1).toLowerCase(); +}; + +/** * Finds the value in an object where this string is a key. * Optionally, the index of the key can be provided where the * value of the nth key in the hierarchy is returned. http://git-wip-us.apache.org/repos/asf/ambari/blob/97e81197/ambari-web/app/views/main/host/details/host_component_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/host/details/host_component_view.js b/ambari-web/app/views/main/host/details/host_component_view.js index 217ae30..39020d2 100644 --- a/ambari-web/app/views/main/host/details/host_component_view.js +++ b/ambari-web/app/views/main/host/details/host_component_view.js @@ -185,14 +185,6 @@ App.HostComponentView = Em.View.extend({ }.property('content.passiveState'), /** - * For PASSIVE <code>passiveState</code> of host or service - * @type {bool} - */ - isImplied: function() { - return (this.get('parentView.content.passiveState') === 'ON' || this.get('content.service.passiveState') === 'ON'); - }.property('parentView.content.passiveState', 'content.service.passiveState'), - - /** * Shows whether we need to show Delete button * @type {bool} */ http://git-wip-us.apache.org/repos/asf/ambari/blob/97e81197/ambari-web/test/views/main/host/details/host_component_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/host/details/host_component_view_test.js b/ambari-web/test/views/main/host/details/host_component_view_test.js index 8d9988c..c6225e3 100644 --- a/ambari-web/test/views/main/host/details/host_component_view_test.js +++ b/ambari-web/test/views/main/host/details/host_component_view_test.js @@ -187,49 +187,6 @@ describe('App.HostComponentView', function() { }); - describe('#isImplied', function() { - - var tests = Em.A([ - { - content: {service: {passiveState: 'ON'}}, - parentView: {content: {passiveState: 'ON'}}, - m: 'service in ON, host in ON', - e: true - }, - { - content: {service: {passiveState: 'ON', serviceName:'SERVICE_NAME'}}, - parentView: {content: {passiveState: 'OFF'}}, - m: 'service in ON, host in OFF', - e: true - }, - { - content: {service: {passiveState: 'OFF', serviceName:'SERVICE_NAME'}}, - parentView: {content: {passiveState: 'ON'}}, - m: 'service in OFF, host in ON', - e: true - }, - { - content: {service: {passiveState: 'OFF'}}, - parentView: {content: {passiveState: 'OFF'}}, - m: 'service in OFF, host in OFF', - e: false - } - ]); - - tests.forEach(function(test) { - it(test.m, function() { - hostComponentView = App.HostComponentView.create({ - startBlinking: function(){}, - doBlinking: function(){}, - parentView: test.parentView, - content: test.content - }); - expect(hostComponentView.get('isImplied')).to.equal(test.e); - }); - }); - - }); - describe('#isRestartComponentDisabled', function() { var tests = ['STARTED'];
