Skip to content

Commit

Permalink
[AMBARI-23611] Add service groups to start/stop/restart functions (#1109
Browse files Browse the repository at this point in the history
)

* Fixed several start/stop/restart commands from the front end.

* Fixed additional unit tests.
  • Loading branch information
jgolieb committed Apr 27, 2018
1 parent 0e3c8bb commit 0b704ad
Show file tree
Hide file tree
Showing 50 changed files with 257 additions and 179 deletions.
2 changes: 1 addition & 1 deletion ambari-web/app/controllers/global/update_controller.js
Expand Up @@ -547,7 +547,7 @@ App.UpdateController = Em.Controller.extend({

updateServices: function (callback) {
var testUrl = '/data/services/HDP2/services.json';
var componentConfigUrl = this.getUrl(testUrl, '/services?fields=ServiceInfo/state,ServiceInfo/maintenance_state,components/ServiceComponentInfo/component_name&minimal_response=true');
var componentConfigUrl = this.getUrl(testUrl, '/services?fields=ServiceInfo/state,ServiceInfo/maintenance_state,components');
App.HttpClient.get(componentConfigUrl, App.serviceMapper, {
complete: callback
});
Expand Down
Expand Up @@ -28,7 +28,7 @@ App.RollbackHighAvailabilityWizardStep2Controller = App.HighAvailabilityWizardSt
sender: this,
data: {
hostName: hostName,
nameNodeId: App.HostComponent.find().findProperty('componentName', 'NAMENODE').get('compId')
nameNodeId: App.HostComponent.find().findProperty('componentName', 'NAMENODE').get('componentId')
},
success: 'checkNnCheckPointStatus'
});
Expand Down
Expand Up @@ -220,7 +220,7 @@ App.HighAvailabilityRollbackController = App.HighAvailabilityProgressPageControl

stopAllServices: function(){
App.ajax.send({
name: 'common.services.update',
name: 'common.services.update.all',
data: {
context: "Stop all services",
"ServiceInfo": {
Expand Down Expand Up @@ -345,7 +345,7 @@ App.HighAvailabilityRollbackController = App.HighAvailabilityProgressPageControl
},
startAllServices: function(){
App.ajax.send({
name: 'common.services.update',
name: 'common.services.update.all',
data: {
context: "Start all services",
"ServiceInfo": {
Expand Down Expand Up @@ -480,7 +480,7 @@ App.HighAvailabilityRollbackController = App.HighAvailabilityProgressPageControl
sender: this,
data: {
hostName: hostName[i],
componentId: App.HostComponent.find().findProperty('componentName', componentName).get('compId'),
componentId: App.HostComponent.find().findProperty('componentName', componentName).get('componentId'),
passive_state: "ON",
taskNum: hostName.length,
callback: 'checkBeforeDelete'
Expand All @@ -501,7 +501,7 @@ App.HighAvailabilityRollbackController = App.HighAvailabilityProgressPageControl
name: 'admin.high_availability.getHostComponent',
sender: this,
data: {
componentId: App.HostComponent.find().findProperty('componentName', componentName).get('compId'),
componentId: App.HostComponent.find().findProperty('componentName', componentName).get('componentId'),
hostName: hostName[i],
taskNum: hostName.length,
callback: 'deleteComponent'
Expand Down Expand Up @@ -550,7 +550,7 @@ App.HighAvailabilityRollbackController = App.HighAvailabilityProgressPageControl
name: 'common.delete.host_component',
sender: this,
data: {
componentId: App.HostComponent.find().findProperty('componentName', componentName).get('compId'),
componentId: App.HostComponent.find().findProperty('componentName', componentName).get('componentId'),
hostName: hostName[i]
},
success: 'onDeleteComplete',
Expand Down
Expand Up @@ -39,7 +39,7 @@ App.HighAvailabilityWizardStep4Controller = Em.Controller.extend({
sender: this,
data: {
hostName: hostName,
nameNodeId: App.HostComponent.find().findProperty('componentName', 'NAMENODE').get('compId')
nameNodeId: App.HostComponent.find().findProperty('componentName', 'NAMENODE').get('componentId')
},
success: 'checkNnCheckPointStatus'
});
Expand Down
Expand Up @@ -54,7 +54,7 @@ App.HighAvailabilityWizardStep5Controller = App.HighAvailabilityProgressPageCont
data: {
hostName: hostName,
passive_state: "ON",
componentId: App.HostComponent.find().findProperty('componentName', 'SECONDARY_NAMENODE').get('compId'),
componentId: App.HostComponent.find().findProperty('componentName', 'SECONDARY_NAMENODE').get('componentId'),
},
success: 'onTaskCompleted',
error: 'onTaskError'
Expand Down
Expand Up @@ -81,7 +81,7 @@ App.HighAvailabilityWizardStep6Controller = Em.Controller.extend({
sender: this,
data: {
hostName: hostName,
jnId: App.HostComponent.find().findProperty('componentName', 'JOURNALNODE').get('compId')
jnId: App.HostComponent.find().findProperty('componentName', 'JOURNALNODE').get('componentId')
},
success: 'checkJnCheckPointStatus'
});
Expand Down
Expand Up @@ -310,7 +310,7 @@ App.HighAvailabilityWizardStep9Controller = App.HighAvailabilityProgressPageCont
name: 'common.delete.host_component',
sender: this,
data: {
componentId: App.HostComponent.find().findProperty('componentName', 'SECONDARY_NAMENODE').get('compId'),
componentId: App.HostComponent.find().findProperty('componentName', 'SECONDARY_NAMENODE').get('componentId'),
hostName: hostName
},
success: 'onTaskCompleted',
Expand Down
Expand Up @@ -23,7 +23,7 @@ App.KerberosWizardStep6Controller = App.KerberosProgressPageController.extend({

stopServices: function () {
App.ajax.send({
name: 'common.services.update',
name: 'common.services.update.all',
data: {
context: "Stop services",
"ServiceInfo": {
Expand Down Expand Up @@ -60,7 +60,7 @@ App.KerberosWizardStep6Controller = App.KerberosProgressPageController.extend({
name: 'common.delete.host_component',
sender: this,
data: {
componentId: App.HostComponent.find().findProperty('componentName', 'APP_TIMELINE_SERVER').get('compId'),
componentId: App.HostComponent.find().findProperty('componentName', 'APP_TIMELINE_SERVER').get('componentId'),
hostName: App.HostComponent.find().findProperty('componentName', 'APP_TIMELINE_SERVER').get('hostName')
},
success: 'onDeleteATSSuccess',
Expand Down
12 changes: 7 additions & 5 deletions ambari-web/app/controllers/main/admin/service_auto_start.js
Expand Up @@ -112,12 +112,14 @@ App.MainAdminServiceAutoStartController = Em.Controller.extend({
},

load: function() {
const self = this;

this.loadClusterSettings().done(function (settings) {
this.set('clusterConfigs', settings);
this.set('isGeneralRecoveryEnabled', settings.recovery_enabled === 'true');
this.set('isGeneralRecoveryEnabledCached', this.get('isGeneralRecoveryEnabled'));
this.loadComponentsConfigs().then(() => {
this.set('isLoaded', true);
self.set('clusterConfigs', settings);
self.set('isGeneralRecoveryEnabled', settings.recovery_enabled === 'true');
self.set('isGeneralRecoveryEnabledCached', self.get('isGeneralRecoveryEnabled'));
self.loadComponentsConfigs().then(() => {
self.set('isLoaded', true);
});
});
},
Expand Down
Expand Up @@ -192,7 +192,7 @@ App.BulkOperationsController = Em.Controller.extend({
return batchUtils.getComponentsFromServer({
passiveState: 'OFF',
hosts: hosts.mapProperty('hostName'),
displayParams: ['host_components/HostRoles/component_name']
displayParams: ['host_components/HostRoles/component_name', 'host_components/HostRoles/service_group_name']
}, this._getComponentsFromServerForRestartCallback);
},

Expand All @@ -208,6 +208,7 @@ App.BulkOperationsController = Em.Controller.extend({
host.host_components.forEach(function (hostComponent) {
hostComponents.push(O.create({
componentName: hostComponent.HostRoles.component_name,
serviceGroupName: hostComponent.HostRoles.service_group_name,
hostName: host.Hosts.host_name
}));
})
Expand Down
14 changes: 7 additions & 7 deletions ambari-web/app/controllers/main/host/details.js
Expand Up @@ -328,9 +328,9 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow
}
};
if (Array.isArray(component)) {
data.query = "HostRoles/component_name.in(" + component.mapProperty('componentName').join(',') + ")";
data.query = "HostRoles/id.in(" + component.mapProperty('componentId').join(',') + ")";
} else {
data.componentName = component.get('componentName');
data.componentId = component.get('componentId');
data.serviceName = component.get('service.serviceName');
}
App.ajax.send({
Expand Down Expand Up @@ -422,7 +422,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow
sender: this,
data: {
host: hostName || this.get('content.hostName'),
nameNodeId: App.HostComponent.find().findProperty('componentName', 'NAMENODE').get('compId')
nameNodeId: App.HostComponent.find().findProperty('componentName', 'NAMENODE').get('componentId')
},
success: 'parseNnCheckPointTime'
});
Expand Down Expand Up @@ -608,7 +608,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow
name: (Em.isNone(componentName)) ? 'common.delete.host' : 'common.delete.host_component',
sender: this,
data: {
componentId: hostComponent ? hostComponent.get('compId') : '',
componentId: hostComponent ? hostComponent.get('componentId') : '',
hostName: this.get('content.hostName')
},
success: '_doDeleteHostComponentSuccessCallback',
Expand Down Expand Up @@ -1613,6 +1613,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow
var resource_filters = [
{
service_name: component.get('service.serviceName'),
service_group_name: component.get('service.serviceGroupName'),
component_name: component.get('componentName'),
hosts: component.get('host.hostName')
}
Expand Down Expand Up @@ -1765,7 +1766,6 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow
installComponent: function (event) {
var self = this;
var component = event.context;
var componentId = component.get('compId');
var displayName = component.get('displayName');

return App.ModalPopup.show({
Expand All @@ -1787,7 +1787,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow
data: {
hostName: self.get('content.hostName'),
serviceName: component.get('service.serviceName'),
componentId: componentId,
componentId: component.get('componentId'),
component: component,
context: Em.I18n.t('requestInfo.installHostComponent') + " " + displayName,
HostRoles: {
Expand Down Expand Up @@ -2312,7 +2312,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow
sender: this,
data: {
hostName: this.get('content.hostName'),
componentId: component.get('compId'),
componentId: component.get('componentId'),
component: component,
passive_state: state,
context: message
Expand Down
6 changes: 3 additions & 3 deletions ambari-web/app/controllers/main/service.js
Expand Up @@ -161,7 +161,7 @@ App.MainServiceController = Em.ArrayController.extend(App.SupportClientConfigsDo
var context = (state == 'INSTALLED') ? App.BackgroundOperationsController.CommandContexts.STOP_ALL_SERVICES :
App.BackgroundOperationsController.CommandContexts.START_ALL_SERVICES;
return App.ajax.send({
name: 'common.services.update',
name: 'common.services.update.all',
sender: this,
data: {
context: context,
Expand Down Expand Up @@ -200,7 +200,7 @@ App.MainServiceController = Em.ArrayController.extend(App.SupportClientConfigsDo
*/
silentStopAllServices: function () {
return App.ajax.send({
name: 'common.services.update',
name: 'common.services.update.all',
sender: this,
data: {
context: App.BackgroundOperationsController.CommandContexts.STOP_ALL_SERVICES,
Expand Down Expand Up @@ -251,7 +251,7 @@ App.MainServiceController = Em.ArrayController.extend(App.SupportClientConfigsDo
) {
this.set('shouldStart', false);
return App.ajax.send({
name: 'common.services.update',
name: 'common.services.update.all',
sender: this,
data: {
context: App.BackgroundOperationsController.CommandContexts.START_ALL_SERVICES,
Expand Down
2 changes: 1 addition & 1 deletion ambari-web/app/controllers/main/service/info/summary.js
Expand Up @@ -325,7 +325,7 @@ App.MainServiceInfoSummaryController = Em.Controller.extend({
context: context,
agentName: agent.get('name'),
host: agent.get('hostName'),
componentId: App.HostComponent.find().findProperty('componentName', 'FLUME_HANDLER').get('compId')
componentId: App.HostComponent.find().findProperty('componentName', 'FLUME_HANDLER').get('componentId')
},
success: 'commandSuccessCallback'
});
Expand Down
52 changes: 34 additions & 18 deletions ambari-web/app/controllers/main/service/item.js
Expand Up @@ -179,18 +179,27 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
* @type {String[]}
*/
sitesToLoad: function() {
var services = this.get('configDependentServiceNames'), configTypeList = [];
const services = this.get('configDependentServiceNames');
let configTypeList = [];

if (services.length) {
configTypeList = App.StackService.find().filter(function(s) {
return services.contains(s.get('serviceName'));
}).mapProperty('configTypeList').reduce(function(p, v) {
return p.concat(v);
const filteredServices = App.StackService.find().filter(function (s) {
return services.mapProperty('name').contains(s.get('serviceName'));
});

const mappedServices = filteredServices.mapProperty('configTypeList');

if (mappedServices && mappedServices.length > 0) {
configTypeList = mappedServices.reduce(function (p, v) {
return p.concat(v);
});
}
}

if (this.get('serviceConfigsMap')[this.get('content.serviceName')]) {
configTypeList = configTypeList.concat(this.get('serviceConfigsMap')[this.get('content.serviceName')]);
}
configTypeList.push('cluster-env');

return configTypeList.uniq();
}.property('content.serviceName'),

Expand Down Expand Up @@ -235,12 +244,14 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
});

self.get('configDependentServiceNames').forEach(function(serviceName) {
var configTypes = App.StackService.find(serviceName).get('configTypeList');
var configsByService = allConfigs.filter(function (c) {
return configTypes.contains(App.config.getConfigTagFromFileName(c.get('filename')));
});
if (App.config.get('preDefinedServiceConfigs').someProperty('serviceName', serviceName)) {
self.get('stepConfigs').pushObject(App.config.createServiceConfig(serviceName, [], configsByService));
var configTypes = App.StackService.find(serviceName.name).get('configTypeList');
if (configTypes) {
var configsByService = allConfigs.filter(function (c) {
return configTypes.contains(App.config.getConfigTagFromFileName(c.get('filename')));
});
if (configsByService && App.config.get('preDefinedServiceConfigs').someProperty('serviceName', serviceName)) {
self.get('stepConfigs').pushObject(App.config.createServiceConfig(serviceName, [], configsByService));
}
}
});

Expand Down Expand Up @@ -576,8 +587,10 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
},

startStopPopupPrimary: function (serviceHealth, query, components, hosts, label) {
const isStart = (serviceHealth === 'STARTED'),
serviceName = this.get('content.serviceName');
const isStart = (serviceHealth === 'STARTED');
const serviceName = this.get('content.serviceName');
const serviceGroupName = this.get('content.serviceGroupName');

if (components || hosts) {
batchUtils.getComponentsFromServer({
hosts,
Expand All @@ -598,6 +611,7 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
data: {
context,
serviceName: serviceName.toUpperCase(),
serviceGroupName: serviceGroupName,
state: serviceHealth,
query: requestQuery
},
Expand All @@ -611,6 +625,7 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
data = {
context,
serviceName: serviceName.toUpperCase(),
serviceGroupName: serviceGroupName,
ServiceInfo: {
state: serviceHealth
},
Expand Down Expand Up @@ -1059,10 +1074,11 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
runSmokeTestPrimary: function(query) {
var clusterLevelRequired = ['KERBEROS'];
var requestData = {
'serviceName': this.get('content.serviceName'),
'displayName': this.get('content.displayName'),
'actionName': this.get('content.serviceName') === 'ZOOKEEPER' ? 'ZOOKEEPER_QUORUM_SERVICE_CHECK' : this.get('content.serviceName') + '_SERVICE_CHECK',
'query': query
'serviceName': this.get('content.serviceName'),
'serviceGroupName': this.get('content.serviceGroupName'),
'displayName': this.get('content.displayName'),
'actionName': this.get('content.serviceName') === 'ZOOKEEPER' ? 'ZOOKEEPER_QUORUM_SERVICE_CHECK' : this.get('content.serviceName') + '_SERVICE_CHECK',
'query': query
};
if (clusterLevelRequired.contains(this.get('content.serviceName'))) {
requestData.operationLevel = {
Expand Down

0 comments on commit 0b704ad

Please sign in to comment.