Repository: ambari Updated Branches: refs/heads/trunk 64b4727cb -> 065906814
AMBARI-6373 Add operation level info to most PUT requests issued by UI part 1. (ababiichuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/06590681 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/06590681 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/06590681 Branch: refs/heads/trunk Commit: 065906814385d674d8612c372406a60989264123 Parents: 64b4727 Author: aBabiichuk <[email protected]> Authored: Thu Jul 3 14:41:21 2014 +0300 Committer: aBabiichuk <[email protected]> Committed: Thu Jul 3 14:44:25 2014 +0300 ---------------------------------------------------------------------- .../highAvailability/progress_controller.js | 63 +-- .../highAvailability/rollback_controller.js | 49 +-- .../admin/highAvailability/step5_controller.js | 14 +- .../admin/highAvailability/step7_controller.js | 4 +- .../admin/highAvailability/step9_controller.js | 14 +- ambari-web/app/controllers/main/host/details.js | 206 +++------- ambari-web/app/controllers/main/service.js | 26 +- .../controllers/main/service/add_controller.js | 35 +- ambari-web/app/controllers/main/service/item.js | 4 +- .../main/service/reassign/step4_controller.js | 47 ++- .../main/service/reassign/step6_controller.js | 9 +- .../wizard/stack_upgrade/step3_controller.js | 9 +- ambari-web/app/utils/ajax/ajax.js | 406 +++++-------------- 13 files changed, 284 insertions(+), 602 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/06590681/ambari-web/app/controllers/main/admin/highAvailability/progress_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/highAvailability/progress_controller.js b/ambari-web/app/controllers/main/admin/highAvailability/progress_controller.js index b234cb8..39a17d7 100644 --- a/ambari-web/app/controllers/main/admin/highAvailability/progress_controller.js +++ b/ambari-web/app/controllers/main/admin/highAvailability/progress_controller.js @@ -260,7 +260,7 @@ App.HighAvailabilityProgressPageController = App.HighAvailabilityWizardControlle installedComponents = data.items; }, - createComponent: function (componentName, hostName) { + createComponent: function (componentName, hostName, serviceName) { var hostNames = (Array.isArray(hostName)) ? hostName : [hostName]; this.checkInstalledComponents(componentName, hostNames).forEach(function (host, index, array) { @@ -271,6 +271,7 @@ App.HighAvailabilityProgressPageController = App.HighAvailabilityWizardControlle data: { hostName: host.hostName, componentName: host.componentName, + serviceName: serviceName, taskNum: array.length }, success: 'onCreateComponent', @@ -284,11 +285,11 @@ App.HighAvailabilityProgressPageController = App.HighAvailabilityWizardControlle }, onCreateComponent: function () { - console.warn('func: onCreateComponent'); var hostName = arguments[2].hostName; var componentName = arguments[2].componentName; var taskNum = arguments[2].taskNum; - this.installComponent(componentName, hostName, taskNum); + var serviceName = arguments[2].serviceName; + this.updateComponent(componentName, hostName, serviceName, "Install", taskNum); }, onCreateComponentError: function (error) { @@ -299,62 +300,24 @@ App.HighAvailabilityProgressPageController = App.HighAvailabilityWizardControlle } }, - installComponent: function (componentName, hostName, taskNum) { - console.warn('func: installComponent'); + updateComponent: function (componentName, hostName, serviceName, context, taskNum) { if (!(hostName instanceof Array)) { hostName = [hostName]; } + var state = context.toLowerCase() == "start" ? "STARTED" : "INSTALLED"; for (var i = 0; i < hostName.length; i++) { App.ajax.send({ - name: 'admin.high_availability.install_component', + name: 'common.host_component.update', sender: this, data: { + context: context + " " + App.format.role(componentName), hostName: hostName[i], + serviceName: serviceName, componentName: componentName, - displayName: App.format.role(componentName), - taskNum: taskNum || hostName.length - }, - success: 'startPolling', - error: 'onTaskError' - }); - } - }, - - startComponent: function (componentName, hostName) { - console.warn('func: startComponent'); - if (!(hostName instanceof Array)) { - hostName = [hostName]; - } - for (var i = 0; i < hostName.length; i++) { - App.ajax.send({ - name: 'admin.high_availability.start_component', - sender: this, - data: { - hostName: hostName[i], - componentName: componentName, - displayName: App.format.role(componentName), - taskNum: hostName.length - }, - success: 'startPolling', - error: 'onTaskError' - }); - } - }, - - stopComponent: function (componentName, hostName) { - console.warn('func: stopComponent'); - if (!(hostName instanceof Array)) { - hostName = [hostName]; - } - for (var i = 0; i < hostName.length; i++) { - App.ajax.send({ - name: 'admin.high_availability.stop_component', - sender: this, - data: { - hostName: hostName[i], - componentName: componentName, - displayName: App.format.role(componentName), - taskNum: hostName.length + taskNum: taskNum || hostName.length, + HostRoles: { + state: state + } }, success: 'startPolling', error: 'onTaskError' http://git-wip-us.apache.org/repos/asf/ambari/blob/06590681/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 0a024a9..5b1ad66 100644 --- a/ambari-web/app/controllers/main/admin/highAvailability/rollback_controller.js +++ b/ambari-web/app/controllers/main/admin/highAvailability/rollback_controller.js @@ -208,7 +208,13 @@ App.HighAvailabilityRollbackController = App.HighAvailabilityProgressPageControl stopAllServices: function(){ console.warn('func: stopAllServices'); App.ajax.send({ - name: 'admin.high_availability.stop_all_services', + name: 'common.services.update', + data: { + context: "Stop all services", + "ServiceInfo": { + "state": "INSTALLED" + } + }, sender: this, success: 'startPolling', error: 'onTaskError' @@ -232,7 +238,7 @@ App.HighAvailabilityRollbackController = App.HighAvailabilityProgressPageControl stopFailoverControllers: function(){ console.warn('func: stopFailoverControllers'); var hostNames = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').mapProperty('hostName'); - this.stopComponent('ZKFC', hostNames); + this.updateComponent('ZKFC', hostNames, "HDFS", "Stop"); }, deleteFailoverControllers: function(){ console.warn('func: deleteFailoverControllers'); @@ -242,12 +248,12 @@ App.HighAvailabilityRollbackController = App.HighAvailabilityProgressPageControl stopStandbyNameNode: function(){ console.warn('func: stopStandbyNameNode'); var hostName = this.get('content.masterComponentHosts').findProperty('isAddNameNode', true).hostName; - this.stopComponent('NAMENODE', hostName); + this.updateComponent('NAMENODE', hostName, "HDFS", "Stop"); }, stopNameNode: function(){ console.warn('func: stopNameNode'); - var hostNames = this.get('content.masterComponentHosts').findProperty('isCurNameNode').hostName; - this.stopComponent('NAMENODE', hostNames); + var hostName = this.get('content.masterComponentHosts').findProperty('isCurNameNode').hostName; + this.updateComponent('NAMENODE', hostName, "HDFS", "Stop"); }, restoreHDFSConfigs: function(){ console.warn('func: restoreHDFSConfigs'); @@ -256,12 +262,12 @@ App.HighAvailabilityRollbackController = App.HighAvailabilityProgressPageControl enableSecondaryNameNode: function(){ console.warn('func: enableSecondaryNameNode'); var hostName = this.get('content.masterComponentHosts').findProperty('component', 'SECONDARY_NAMENODE').hostName; - this.installComponent('SECONDARY_NAMENODE', hostName, hostName.length); + this.updateComponent('SECONDARY_NAMENODE', hostName, "HDFS", "Install", hostName.length); }, stopJournalNodes: function(){ console.warn('func: stopJournalNodes'); var hostNames = this.get('content.masterComponentHosts').filterProperty('component', 'JOURNALNODE').mapProperty('hostName'); - this.stopComponent('JOURNALNODE', hostNames); + this.updateComponent('JOURNALNODE', hostNames, "HDFS", "Stop"); }, deleteJournalNodes: function(){ console.warn('func: deleteJournalNodes'); @@ -276,7 +282,13 @@ App.HighAvailabilityRollbackController = App.HighAvailabilityProgressPageControl startAllServices: function(){ console.warn('func: startAllServices'); App.ajax.send({ - name: 'admin.high_availability.start_all_services', + name: 'common.services.update', + data: { + context: "Start all services", + "ServiceInfo": { + "state": "STARTED" + } + }, sender: this, success: 'startPolling', error: 'onTaskError' @@ -298,27 +310,6 @@ App.HighAvailabilityRollbackController = App.HighAvailabilityProgressPageControl }); }, - stopComponent: function (componentName, hostName) { - console.warn('func: stopComponent'); - if (!(hostName instanceof Array)) { - hostName = [hostName]; - } - for (var i = 0; i < hostName.length; i++) { - App.ajax.send({ - name: 'admin.high_availability.stop_component', - sender: this, - data: { - hostName: hostName[i], - componentName: componentName, - displayName: App.format.role(componentName), - taskNum: hostName.length - }, - success: 'startPolling', - error: 'onTaskError' - }); - } - }, - onDeletedHDFSClient: function () { console.warn('func: onDeletedHDFSClient'); var deletedHdfsClients = this.get('deletedHdfsClients'); http://git-wip-us.apache.org/repos/asf/ambari/blob/06590681/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 e46306f..6802835 100644 --- a/ambari-web/app/controllers/main/admin/highAvailability/step5_controller.js +++ b/ambari-web/app/controllers/main/admin/highAvailability/step5_controller.js @@ -31,7 +31,13 @@ App.HighAvailabilityWizardStep5Controller = App.HighAvailabilityProgressPageCont stopAllServices: function () { App.ajax.send({ - name: 'admin.high_availability.stop_all_services', + name: 'common.services.update', + data: { + context: "Stop all services", + "ServiceInfo": { + "state": "INSTALLED" + } + }, sender: this, success: 'startPolling', error: 'onTaskError' @@ -40,17 +46,17 @@ App.HighAvailabilityWizardStep5Controller = App.HighAvailabilityProgressPageCont installNameNode: function () { var hostName = this.get('content.masterComponentHosts').findProperty('isAddNameNode').hostName; - this.createComponent('NAMENODE', hostName); + this.createComponent('NAMENODE', hostName, "HDFS"); }, installJournalNodes: function () { var hostNames = this.get('content.masterComponentHosts').filterProperty('component', 'JOURNALNODE').mapProperty('hostName'); - this.createComponent('JOURNALNODE', hostNames); + this.createComponent('JOURNALNODE', hostNames, "HDFS"); }, startJournalNodes: function () { var hostNames = this.get('content.masterComponentHosts').filterProperty('component', 'JOURNALNODE').mapProperty('hostName'); - this.startComponent('JOURNALNODE', hostNames); + this.updateComponent('JOURNALNODE', hostNames, "HDFS", "Start"); }, disableSNameNode: function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/06590681/ambari-web/app/controllers/main/admin/highAvailability/step7_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/highAvailability/step7_controller.js b/ambari-web/app/controllers/main/admin/highAvailability/step7_controller.js index 5d515ba..429ab3e 100644 --- a/ambari-web/app/controllers/main/admin/highAvailability/step7_controller.js +++ b/ambari-web/app/controllers/main/admin/highAvailability/step7_controller.js @@ -28,12 +28,12 @@ App.HighAvailabilityWizardStep7Controller = App.HighAvailabilityProgressPageCont startZooKeeperServers: function () { var hostNames = this.get('content.masterComponentHosts').filterProperty('component', 'ZOOKEEPER_SERVER').mapProperty('hostName'); - this.startComponent('ZOOKEEPER_SERVER', hostNames); + this.updateComponent('ZOOKEEPER_SERVER', hostNames, "ZOOKEEPER", "Start"); }, startNameNode: function () { var hostName = this.get('content.masterComponentHosts').findProperty('isCurNameNode').hostName; - this.startComponent('NAMENODE', hostName); + this.updateComponent('NAMENODE', hostName, "HDFS", "Start"); } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/06590681/ambari-web/app/controllers/main/admin/highAvailability/step9_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/highAvailability/step9_controller.js b/ambari-web/app/controllers/main/admin/highAvailability/step9_controller.js index 309bc6a..bd53b01 100644 --- a/ambari-web/app/controllers/main/admin/highAvailability/step9_controller.js +++ b/ambari-web/app/controllers/main/admin/highAvailability/step9_controller.js @@ -37,17 +37,17 @@ App.HighAvailabilityWizardStep9Controller = App.HighAvailabilityProgressPageCont startSecondNameNode: function () { var hostName = this.get('content.masterComponentHosts').findProperty('isAddNameNode', true).hostName; - this.startComponent('NAMENODE', hostName); + this.updateComponent('NAMENODE', hostName, "HDFS", "Start"); }, installZKFC: function () { var hostName = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').mapProperty('hostName'); - this.createComponent('ZKFC', hostName); + this.createComponent('ZKFC', hostName, "HDFS"); }, startZKFC: function () { var hostName = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').mapProperty('hostName'); - this.startComponent('ZKFC', hostName); + this.updateComponent('ZKFC', hostName, "HDFS", "Start"); }, reconfigureHBase: function () { @@ -78,7 +78,13 @@ App.HighAvailabilityWizardStep9Controller = App.HighAvailabilityProgressPageCont startAllServices: function () { App.ajax.send({ - name: 'admin.high_availability.start_all_services', + name: 'common.services.update', + data: { + context: "Start all services", + "ServiceInfo": { + "state": "STARTED" + } + }, sender: this, success: 'startPolling', error: 'onTaskError' http://git-wip-us.apache.org/repos/asf/ambari/blob/06590681/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 5ab7592..2988ded 100644 --- a/ambari-web/app/controllers/main/host/details.js +++ b/ambari-web/app/controllers/main/host/details.js @@ -76,20 +76,6 @@ App.MainHostDetailsController = Em.Controller.extend({ }.property('serviceActiveComponents'), /** - * Default error-callback for ajax-requests in current page - * @param {object} request - * @param {object} ajaxOptions - * @param {string} error - * @param {object} opt - * @param {object} params - * @method ajaxErrorCallback - */ - ajaxErrorCallback: function (request, ajaxOptions, error, opt, params) { - console.log('error on change component host status'); - App.ajax.defaultErrorHandler(request, opt.url, opt.method); - }, - - /** * send command to server to start selected host component * @param {object} event * @method startComponent @@ -99,101 +85,85 @@ App.MainHostDetailsController = Em.Controller.extend({ return App.showConfirmationPopup(function () { var component = event.context; var context = Em.I18n.t('requestInfo.startHostComponent') + " " + component.get('displayName'); - self.sendStartComponentCommand(component, context); + self.sendComponentCommand(component, context, App.HostComponentStatus.started); }); }, /** - * PUTs a command to server to start a component. If no + * send command to server to stop selected host component + * @param {object} event + * @method startComponent + */ + stopComponent: function (event) { + var self = this; + return App.showConfirmationPopup(function () { + var component = event.context; + var context = Em.I18n.t('requestInfo.stopHostComponent') + " " + component.get('displayName'); + self.sendComponentCommand(component, context, App.HostComponentStatus.stopped); + }); + }, + /** + * PUTs a command to server to start/stop a component. If no * specific component is provided, all components are started. * @param {object} component When <code>null</code> all startable components are started. - * @param {string} context Context under which this command is beign sent. + * @param {String} context Context under which this command is beign sent. + * @param {String} state - desired state of component can be 'STARTED' or 'STOPPED' * @method sendStartComponentCommand */ - sendStartComponentCommand: function (component, context) { - var dataToSend = this.getDataToSend('STARTED', context, component); + sendComponentCommand: function (component, context, state) { var data = { hostName: this.get('content.hostName'), - component: component + context: context, + component: component, + HostRoles: { + state: state + } }; - this.setComponentToData(data, dataToSend, component); + if (Array.isArray(component)) { + data.query = "HostRoles/component_name.in(" + component.mapProperty('componentName').join(',') + ")"; + } else { + data.componentName = component.get('componentName'); + data.serviceName = component.get('service.serviceName'); + } App.ajax.send({ - name: (Array.isArray(component)) ? 'host.host_components.stop' : 'host.host_component.stop', + name: (Array.isArray(component)) ? 'common.host_components.update' : 'common.host_component.update', sender: this, data: data, - success: 'startComponentSuccessCallback', + success: 'sendComponentCommandSuccessCallback', error: 'ajaxErrorCallback' }); }, - /** - * construct meta data for query - * @param {String} state - * @param {String} context - * @param {String|Array} component - componentName or Array of components - * @return {Object} request info - * @method getDataToSend creates request info to start/stop component(s) - */ - getDataToSend: function (state, context, component) { - var operationLevel = { - "cluster_name": App.get('clusterName'), - "host_name": this.get("content.hostName") - }; - - if (Array.isArray(component)) { - operationLevel["level"] = "HOST"; - } else if(component){ - operationLevel["level"] = "HOST_COMPONENT", - operationLevel["hostcomponent_name"] = component.get("componentName"), - operationLevel["service_name"] = component.get("service.serviceName") - } - return { - RequestInfo: { - "context": context, - "operation_level": operationLevel - }, - Body: { - HostRoles: { - state: state - } - } - } - }, /** - * set additional data to query info depending on component - * @param data - * @param dataToSend - * @param component - * @return {Boolean} + * Success callback for stop/start host component request + * @param {object} data + * @param {object} opt + * @param {object} params + * @method stopComponentSuccessCallback */ - setComponentToData: function (data, dataToSend, component) { - if (!dataToSend || !component || !data) return false; - - if (Array.isArray(component)) { - dataToSend.RequestInfo.query = "HostRoles/component_name.in(" + component.mapProperty('componentName').join(',') + ")"; - } else { - data.componentName = component.get('componentName'); + sendComponentCommandSuccessCallback: function (data, opt, params) { + var running = (params.HostRoles.state === App.HostComponentStatus.stopped) ? App.HostComponentStatus.stopping : App.HostComponentStatus.starting; + console.log('Send request for '+running+' successfully'); + params.component.set('workStatus', running); + if (App.get('testMode')) { + this.mimicWorkStatusChange(params.component, running, params.HostRoles.state); } - data.data = JSON.stringify(dataToSend); - return true; + this.showBackgroundOperationsPopup(); }, /** - * Success callback for start component(s) request - * @param {object} data + * Default error-callback for ajax-requests in current page + * @param {object} request + * @param {object} ajaxOptions + * @param {string} error * @param {object} opt * @param {object} params - * @method startComponentSuccessCallback + * @method ajaxErrorCallback */ - startComponentSuccessCallback: function (data, opt, params) { - console.log('Send request for STARTING successfully'); - params.component.set('workStatus', 'STARTING'); - if (App.testMode) { - this.mimicWorkStatusChange(params.component, App.HostComponentStatus.starting, App.HostComponentStatus.started); - } - this.showBackgroundOperationsPopup(); + ajaxErrorCallback: function (request, ajaxOptions, error, opt, params) { + console.log('error on change component host status'); + App.ajax.defaultErrorHandler(request, opt.url, opt.method); }, - /** * mimic status transition in test mode * @param entity @@ -383,59 +353,6 @@ App.MainHostDetailsController = Em.Controller.extend({ }, /** - * Send command to server to stop selected host component - * @param {object} event - * @method stopComponent - */ - stopComponent: function (event) { - var self = this; - return App.showConfirmationPopup(function () { - var component = event.context; - var context = Em.I18n.t('requestInfo.stopHostComponent') + " " + component.get('displayName'); - self.sendStopComponentCommand(component, context); - }); - }, - - /** - * PUTs a command to server to stop a component. If no - * specific component is provided, all components are stopped. - * @param {object} component When <code>null</code> all components are stopped. - * @param {object} context Context under which this command is beign sent. - * @method sendStopComponentCommand - */ - sendStopComponentCommand: function (component, context) { - var dataToSend = this.getDataToSend('INSTALLED', context, component); - var data = { - hostName: this.get('content.hostName'), - component: component - }; - this.setComponentToData(data, dataToSend, component); - App.ajax.send({ - name: (Array.isArray(component)) ? 'host.host_components.stop' : 'host.host_component.stop', - sender: this, - data: data, - success: 'stopComponentSuccessCallback', - error: 'ajaxErrorCallback' - }); - }, - - /** - * Success callback for stop host component request - * @param {object} data - * @param {object} opt - * @param {object} params - * @method stopComponentSuccessCallback - */ - stopComponentSuccessCallback: function (data, opt, params) { - console.log('Send request for STOPPING successfully'); - params.component.set('workStatus', 'STOPPING'); - if (App.testMode) { - this.mimicWorkStatusChange(params.component, App.HostComponentStatus.stopping, App.HostComponentStatus.stopped); - } - this.showBackgroundOperationsPopup(); - }, - - /** * Send command to server to restart selected components * @param {object} event * @method restartComponent @@ -864,22 +781,17 @@ App.MainHostDetailsController = Em.Controller.extend({ this.hide(); App.ajax.send({ - name: 'host.host_component.install', + name: 'common.host_component.update', sender: self, data: { hostName: self.get('content.hostName'), + serviceName: component.get('service.serviceName'), componentName: componentName, component: component, - data: JSON.stringify({ - RequestInfo: { - "context": Em.I18n.t('requestInfo.installHostComponent') + " " + displayName - }, - Body: { - HostRoles: { - state: 'INSTALLED' - } - } - }) + context: Em.I18n.t('requestInfo.installHostComponent') + " " + displayName, + HostRoles: { + state: 'INSTALLED' + } }, success: 'installComponentSuccessCallback', error: 'ajaxErrorCallback' @@ -1304,7 +1216,7 @@ App.MainHostDetailsController = Em.Controller.extend({ var componentsLength = Em.isNone(components) ? 0 : components.get('length'); if (componentsLength > 0) { return App.showConfirmationPopup(function () { - self.sendStartComponentCommand(components, Em.I18n.t('hosts.host.maintainance.startAllComponents.context')); + self.sendComponentCommand(components, Em.I18n.t('hosts.host.maintainance.startAllComponents.context'), App.HostComponentStatus.started); }); } }, @@ -1319,7 +1231,7 @@ App.MainHostDetailsController = Em.Controller.extend({ var componentsLength = Em.isNone(components) ? 0 : components.get('length'); if (componentsLength > 0) { return App.showConfirmationPopup(function () { - self.sendStopComponentCommand(components, Em.I18n.t('hosts.host.maintainance.stopAllComponents.context')); + self.sendComponentCommand(components, Em.I18n.t('hosts.host.maintainance.stopAllComponents.context'), App.HostComponentStatus.stopped); }); } }, http://git-wip-us.apache.org/repos/asf/ambari/blob/06590681/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 414ad40..fba94b1 100644 --- a/ambari-web/app/controllers/main/service.js +++ b/ambari-web/app/controllers/main/service.js @@ -98,7 +98,7 @@ App.MainServiceController = Em.ArrayController.extend({ } var self = this; App.showConfirmationFeedBackPopup(function(query) { - self.allServicesCall('startAllService', query); + self.allServicesCall('STARTED', query); }); }, @@ -111,29 +111,21 @@ App.MainServiceController = Em.ArrayController.extend({ } var self = this; App.showConfirmationFeedBackPopup(function(query) { - self.allServicesCall('stopAllService', query); + self.allServicesCall('INSTALLED', query); }); }, allServicesCall: function(state, query) { - var data; - if (state == 'stopAllService') { - data = '{"RequestInfo": {"context" :"' + - App.BackgroundOperationsController.CommandContexts.STOP_ALL_SERVICES + - '", "operation_level": {"level": "CLUSTER","cluster_name" : "' + App.get('clusterName') + - '"}}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}'; - } else { - data = '{"RequestInfo": {"context" :"' + - App.BackgroundOperationsController.CommandContexts.START_ALL_SERVICES + - '", "operation_level": {"level": "CLUSTER","cluster_name" : "' + App.get('clusterName') + - '"}}, "Body": {"ServiceInfo": {"state": "STARTED"}}}'; - } - + var context = (state == 'INSTALLED') ? App.BackgroundOperationsController.CommandContexts.STOP_ALL_SERVICES : + App.BackgroundOperationsController.CommandContexts.START_ALL_SERVICES App.ajax.send({ - name: 'service.start_stop', + name: 'common.services.update', sender: this, data: { - data: data, + context: context, + ServiceInfo: { + state: state + }, query: query }, success: 'allServicesCallSuccessCallback', http://git-wip-us.apache.org/repos/asf/ambari/blob/06590681/ambari-web/app/controllers/main/service/add_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/add_controller.js b/ambari-web/app/controllers/main/service/add_controller.js index 41ea6b1..ce3a9aa 100644 --- a/ambari-web/app/controllers/main/service/add_controller.js +++ b/ambari-web/app/controllers/main/service/add_controller.js @@ -410,27 +410,22 @@ App.AddServiceController = App.WizardController.extend({ * on host where some components require this * @method installAdditionalClients */ - installAdditionalClients: function() { - this.get('content.additionalClients').forEach(function(c){ - App.ajax.send({ - name: 'host.host_component.install', - sender: this, - data: { - hostName: c.hostName, - componentName: c.componentName, - data: JSON.stringify({ - RequestInfo: { - "context": Em.I18n.t('requestInfo.installHostComponent') + " " + c.hostName - }, - Body: { - HostRoles: { - state: 'INSTALLED' - } - } - }) + installAdditionalClients: function () { + this.get('content.additionalClients').forEach(function (c) { + App.ajax.send({ + name: 'common.host_component.update', + sender: this, + data: { + hostName: c.hostName, + componentName: c.componentName, + serviceName: c.componentName.slice(0, -7), + context: Em.I18n.t('requestInfo.installHostComponent') + " " + c.hostName, + HostRoles: { + state: 'INSTALLED' } - }); - }, this); + } + }); + }, this); }, /** http://git-wip-us.apache.org/repos/asf/ambari/blob/06590681/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 f1dafda..a1bbf30 100644 --- a/ambari-web/app/controllers/main/service/item.js +++ b/ambari-web/app/controllers/main/service/item.js @@ -114,7 +114,7 @@ App.MainServiceItemController = Em.Controller.extend({ } var data = { - 'requestInfo': requestInfo, + 'context': requestInfo, 'serviceName': this.get('content.serviceName').toUpperCase(), 'ServiceInfo': { 'state': serviceHealth @@ -125,7 +125,7 @@ App.MainServiceItemController = Em.Controller.extend({ data.ServiceInfo.maintenance_state = turnOnMM; } App.ajax.send({ - 'name': 'service.item.start_stop', + 'name': 'common.service.update', 'sender': this, 'success': 'startStopPopupSuccessCallback', 'error': 'startStopPopupErrorCallback', http://git-wip-us.apache.org/repos/asf/ambari/blob/06590681/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 8c29fe4..5087c9b 100644 --- a/ambari-web/app/controllers/main/service/reassign/step4_controller.js +++ b/ambari-web/app/controllers/main/service/reassign/step4_controller.js @@ -100,17 +100,28 @@ App.ReassignMasterWizardStep4Controller = App.HighAvailabilityProgressPageContro if(this.get('restartYarnMRComponents')) { var list = App.Service.find().mapProperty("serviceName").without("HDFS").join(','); var conf = { - name: 'reassign.stop_YMR2_services', + name: 'common.services.update', sender: this, - data: {servicesList: list}, + data: { + "context": "Stop without HDFS", + "ServiceInfo": { + "state": "INSTALLED" + }, + urlParams: "ServiceInfo/service_name.in("+list+")"}, success: 'startPolling', error: 'onTaskError' }; App.ajax.send(conf); } else { App.ajax.send({ - name: 'reassign.stop_services', + name: 'common.services.update', sender: this, + data: { + "context": "Stop all services", + "ServiceInfo": { + "state": "INSTALLED" + } + }, success: 'startPolling', error: 'onTaskError' }); @@ -122,7 +133,7 @@ App.ReassignMasterWizardStep4Controller = App.HighAvailabilityProgressPageContro var hostComponents = this.get('hostComponents'); var hostName = this.get('content.reassignHosts.target'); for (var i = 0; i < hostComponents.length; i++) { - this.createComponent(hostComponents[i], hostName); + this.createComponent(hostComponents[i], hostName, this.get('content.reassign.service_id')); } }, @@ -153,7 +164,7 @@ App.ReassignMasterWizardStep4Controller = App.HighAvailabilityProgressPageContro var hostComponents = this.get('hostComponents'); var hostName = this.get('content.reassignHosts.target'); for (var i = 0; i < hostComponents.length; i++) { - this.installComponent(hostComponents[i], hostName, hostComponents.length); + this.updateComponent(hostComponents[i], hostName, this.get('content.reassign.service_id'), "Install", hostComponents.length); } }, @@ -324,30 +335,42 @@ App.ReassignMasterWizardStep4Controller = App.HighAvailabilityProgressPageContro }, startZooKeeperServers: function () { - var hostNames = this.get('content.masterComponentHosts').filterProperty('component', 'ZOOKEEPER_SERVER').mapProperty('hostName'); - this.startComponent('ZOOKEEPER_SERVER', hostNames); + var components = this.get('content.masterComponentHosts').filterProperty('component', 'ZOOKEEPER_SERVER'); + this.updateComponent('ZOOKEEPER_SERVER', components.mapProperty('hostName'), "ZOOKEEPER", "Start"); }, startNameNode: function () { - var hostName = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE').mapProperty('hostName').without(this.get('content.reassignHosts.target')); - this.startComponent('NAMENODE', hostName); + var components = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE'); + this.updateComponent('NAMENODE', components.mapProperty('hostName').without(this.get('content.reassignHosts.target')), "HDFS", "Start"); }, startServices: function () { if(this.get('restartYarnMRComponents')) { var list = App.Service.find().mapProperty("serviceName").without("HDFS").join(','); var conf = { - name: 'reassign.start_YMR2_services', + name: 'common.services.update', sender: this, - data: {servicesList: list}, + data: { + "context": "Start without HDFS", + "ServiceInfo": { + "state": "STARTED" + }, + urlParams: "ServiceInfo/service_name.in("+list+")"}, success: 'startPolling', error: 'onTaskError' }; App.ajax.send(conf); } else { App.ajax.send({ - name: 'reassign.start_services', + name: 'common.services.update', sender: this, + data: { + "context": "Start all services", + "ServiceInfo": { + "state": "STARTED" + }, + urlParams: "params/run_smoke_test=true" + }, success: 'startPolling', error: 'onTaskError' }); http://git-wip-us.apache.org/repos/asf/ambari/blob/06590681/ambari-web/app/controllers/main/service/reassign/step6_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service/reassign/step6_controller.js b/ambari-web/app/controllers/main/service/reassign/step6_controller.js index 612b793..ddc2024 100644 --- a/ambari-web/app/controllers/main/service/reassign/step6_controller.js +++ b/ambari-web/app/controllers/main/service/reassign/step6_controller.js @@ -81,8 +81,15 @@ App.ReassignMasterWizardStep6Controller = App.HighAvailabilityProgressPageContro startServices: function () { App.ajax.send({ - name: 'reassign.start_services', + name: 'common.services.update', sender: this, + data: { + "context": "Start all services", + "ServiceInfo": { + "state": "STARTED" + }, + urlParams: "params/run_smoke_test=true" + }, success: 'startPolling', error: 'onTaskError' }); http://git-wip-us.apache.org/repos/asf/ambari/blob/06590681/ambari-web/app/controllers/wizard/stack_upgrade/step3_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard/stack_upgrade/step3_controller.js b/ambari-web/app/controllers/wizard/stack_upgrade/step3_controller.js index c948b1f..d67850a 100644 --- a/ambari-web/app/controllers/wizard/stack_upgrade/step3_controller.js +++ b/ambari-web/app/controllers/wizard/stack_upgrade/step3_controller.js @@ -153,12 +153,15 @@ App.StackUpgradeStep3Controller = Em.Controller.extend({ }); } else { - var data = '{"RequestInfo": {"context": "'+ Em.I18n.t("requestInfo.stopAllServices") +'"}, "Body": {"ServiceInfo": {"state": "INSTALLED"}}}'; App.ajax.send({ - name: 'admin.stack_upgrade.stop_services', + name: 'common.services.update', sender: this, data: { - data: data + "context": Em.I18n.t("requestInfo.stopAllServices"), + "ServiceInfo": { + "state": "INSTALLED" + }, + urlParams: "ServiceInfo/state=STARTED" }, success: 'stopServicesSuccessCallback', error: 'stopServicesErrorCallback' http://git-wip-us.apache.org/repos/asf/ambari/blob/06590681/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 1439454..fb0b008 100644 --- a/ambari-web/app/utils/ajax/ajax.js +++ b/ambari-web/app/utils/ajax/ajax.js @@ -30,6 +30,100 @@ var App = require('app'); * @type {Object} */ var urls = { + + 'common.services.update' : { + 'real': '/clusters/{clusterName}/services?{urlParams}', + 'mock': '/data/wizard/deploy/poll_1.json', + 'format': function (data) { + return { + type: 'PUT', + data: JSON.stringify({ + RequestInfo: { + "context": data.context, + "operation_level": { + "level": "CLUSTER", + "cluster_name" : data.clusterName + } + }, + Body: { + ServiceInfo: data.ServiceInfo + } + }) + }; + } + }, + + 'common.service.update' : { + 'real': '/clusters/{clusterName}/services/{serviceName}', + 'mock': '/data/wizard/deploy/poll_1.json', + 'format': function (data) { + return { + type: 'PUT', + data: JSON.stringify({ + RequestInfo: { + "context": data.context, + "operation_level": { + "level": "SERVICE", + "cluster_name" : data.clusterName, + "service_name" : data.serviceName + } + }, + Body: { + ServiceInfo: data.ServiceInfo + } + }) + }; + } + }, + + 'common.host_components.update': { + 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components?{urlParams}', + 'mock': '', + 'type': 'PUT', + 'format': function (data) { + return { + data: JSON.stringify({ + RequestInfo: { + "context": data.context, + "operation_level": { + level: "HOST", + cluster_name: data.clusterName, + host_names: data.hostName + }, + query: data.query + }, + Body: { + "HostRoles": data.HostRoles + } + }) + } + } + }, + + 'common.host_component.update': { + 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}', + 'mock': '/data/wizard/deploy/poll_1.json', + 'type': 'PUT', + 'format': function (data) { + return { + data: JSON.stringify({ + RequestInfo: { + "context": data.context, + "operation_level": { + level: "HOST_COMPONENT", + cluster_name: data.clusterName, + host_name: data.hostName, + service_name: data.serviceName || null + } + }, + Body: { + "HostRoles": data.HostRoles + } + }) + } + } + }, + 'alerts.get_by_service': { 'real': '/clusters/{clusterName}/services/{serviceName}?fields=alerts', 'mock': '/data/alerts/HDP2/service_alerts.json' @@ -53,28 +147,6 @@ var urls = { 'mock': '/data/background_operations/list_on_start.json', 'testInProduction': true }, - 'service.item.start_stop': { - 'real': '/clusters/{clusterName}/services/{serviceName}', - 'mock': '/data/wizard/deploy/poll_1.json', - 'format': function (data) { - return { - type: 'PUT', - data: JSON.stringify({ - RequestInfo: { - "context": data.requestInfo, - "operation_level": { - "level": "SERVICE", - "cluster_name" : data.clusterName, - "service_name" : data.serviceName - } - }, - Body: { - ServiceInfo: data.ServiceInfo - } - }) - }; - } - }, 'service.item.smoke': { 'real': '/clusters/{clusterName}/requests', 'mock': '/data/wizard/deploy/poll_1.json', @@ -110,26 +182,6 @@ 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) { - 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': '/data/configurations/config_group.json' @@ -154,82 +206,6 @@ var urls = { } } }, - 'reassign.stop_services': { - 'real': '/clusters/{clusterName}/services', - 'mock': '', - 'format': function() { - return { - type: 'PUT', - data: JSON.stringify({ - "RequestInfo": { - "context": "Stop all services" - }, - "Body": { - "ServiceInfo": { - "state": "INSTALLED" - } - } - }) - } - } - }, - 'reassign.stop_YMR2_services': { - 'real': '/clusters/{clusterName}/services?ServiceInfo/service_name.in({servicesList})', - 'mock': '', - 'format': function() { - return { - type: 'PUT', - data: JSON.stringify({ - "RequestInfo": { - "context": "Stop without HDFS" - }, - "Body": { - "ServiceInfo": { - "state": "INSTALLED" - } - } - }) - } - } - }, - 'reassign.start_services': { - 'real': '/clusters/{clusterName}/services?params/run_smoke_test=true', - 'mock': '', - 'format': function() { - return { - type: 'PUT', - data: JSON.stringify({ - "RequestInfo": { - "context": "Start all services" - }, - "Body": { - "ServiceInfo": { - "state": "STARTED" - } - } - }) - } - } - }, - 'reassign.start_YMR2_services': { - 'real': '/clusters/{clusterName}/services/?ServiceInfo/service_name.in({servicesList})', - 'mock': '', - 'format': function() { - return { - type: 'PUT', - data: JSON.stringify({ - "RequestInfo": { - "context": "Start without HDFS" - }, - "Body": { - "ServiceInfo": { - "state": "STARTED" - } - } - }) - } - } - }, 'reassign.maintenance_mode': { 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}', 'mock': '', @@ -239,7 +215,7 @@ var urls = { data: JSON.stringify( { "HostRoles": { - "state": "DISABLED" + "maintenance_state": "ON" } } ) @@ -390,61 +366,6 @@ var urls = { } }, - 'host.host_component.stop': { - 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}', - 'mock': '/data/wizard/deploy/poll_1.json', - 'format': function(data) { - return { - type: 'PUT', - data: data.data - } - } - }, - - 'host.host_components.stop': { - 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components', - 'mock': '/data/wizard/deploy/poll_1.json', - 'format': function(data) { - return { - type: 'PUT', - data: data.data - } - } - }, - - 'host.host_component.start': { - 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}', - 'mock': '/data/wizard/deploy/poll_1.json', - 'format': function(data) { - return { - type: 'PUT', - data: data.data - } - } - }, - - 'host.host_component.install': { - 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}', - 'mock': '/data/wizard/deploy/poll_1.json', - 'format': function(data) { - return { - type: 'PUT', - data: data.data - } - } - }, - - 'host.host_component.update': { - 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}', - 'mock': '/data/wizard/deploy/poll_1.json', - 'format': function(data) { - return { - type: 'PUT', - data: data.data - } - } - }, - 'host.host_component.add_new_component': { 'real': '/clusters/{clusterName}/hosts?Hosts/host_name={hostName}', 'mock': '/data/wizard/deploy/poll_1.json', @@ -540,26 +461,6 @@ 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.host_component.refresh_configs': { 'real':'/clusters/{clusterName}/requests', @@ -755,17 +656,6 @@ var urls = { 'mock': '/data/services/metrics/hdfs/space_utilization.json', 'testInProduction': true }, - 'service.start_stop': { - 'real': '/clusters/{clusterName}/services?params/run_smoke_test=true', - 'mock': '/data/mirroring/poll/poll_6.json', - 'format': function (data) { - return { - type: 'PUT', - async: false, - data: data.data - }; - } - }, 'service.metrics.yarn.gc': { 'real': '/clusters/{clusterName}/hosts/{resourceManager}/host_components/RESOURCEMANAGER?fields=metrics/jvm/gcTimeMillis[{fromSeconds},{toSeconds},{stepSeconds}]', 'mock': '/data/services/metrics/yarn/gc.json', @@ -941,44 +831,6 @@ var urls = { }; } }, - 'admin.high_availability.stop_all_services': { - 'real': '/clusters/{clusterName}/services', - 'mock': '', - 'format': function() { - return { - type: 'PUT', - data: JSON.stringify({ - "RequestInfo": { - "context": "Stop all services" - }, - "Body": { - "ServiceInfo": { - "state": "INSTALLED" - } - } - }) - } - } - }, - 'admin.high_availability.start_all_services': { - 'real': '/clusters/{clusterName}/services', - 'mock': '', - 'format': function() { - return { - type: 'PUT', - data: JSON.stringify({ - "RequestInfo": { - "context": "Start all services" - }, - "Body": { - "ServiceInfo": { - "state": "STARTED" - } - } - }) - } - } - }, 'admin.high_availability.polling': { 'real': '/clusters/{clusterName}/requests/{requestId}?fields=tasks/*,Requests/*', 'mock': '', @@ -1015,44 +867,6 @@ var urls = { } } }, - 'admin.high_availability.install_component': { - 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}', - 'mock': '', - 'type': 'PUT', - 'format': function (data) { - return { - data: JSON.stringify({ - RequestInfo: { - "context": "Install " + data.displayName - }, - Body: { - "HostRoles": { - "state": "INSTALLED" - } - } - }) - } - } - }, - 'admin.high_availability.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" - } - } - }) - } - } - }, 'admin.high_availability.maintenance_mode': { 'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}', 'mock': '', @@ -1067,25 +881,6 @@ var urls = { } } }, - 'admin.high_availability.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" - } - } - }) - } - } - }, 'admin.high_availability.load_configs': { 'real': '/clusters/{clusterName}/configurations?(type=core-site&tag={coreSiteTag})|(type=hdfs-site&tag={hdfsSiteTag})', 'mock': '', @@ -1185,17 +980,6 @@ var urls = { }; } }, - 'admin.stack_upgrade.stop_services': { - 'real': '/clusters/{clusterName}/services?ServiceInfo/state=STARTED', - 'mock': '', - 'format': function (data) { - return { - type: 'PUT', - data: data.data - }; - } - }, - 'admin.user.create': { 'real': '/users/{user}', 'mock': '/data/users/users.json',
