You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2014/07/10 19:48:28 UTC
git commit: AMBARI-6458. Display and support default service actions
for the new services. (Buzhor Denys via alexantonenko)
Repository: ambari
Updated Branches:
refs/heads/trunk edf653280 -> 9c75be753
AMBARI-6458. Display and support default service actions for the new services. (Buzhor Denys via alexantonenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9c75be75
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9c75be75
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9c75be75
Branch: refs/heads/trunk
Commit: 9c75be7535fb707abec484c6b85a01ef10f4c79d
Parents: edf6532
Author: Alex Antonenko <hi...@gmail.com>
Authored: Thu Jul 10 20:32:35 2014 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Thu Jul 10 20:32:35 2014 +0300
----------------------------------------------------------------------
ambari-web/app/models/service.js | 3 +-
ambari-web/app/templates/main/service/item.hbs | 2 +-
ambari-web/app/views/main/service/item.js | 155 +++++++++++++-------
3 files changed, 106 insertions(+), 54 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/9c75be75/ambari-web/app/models/service.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service.js b/ambari-web/app/models/service.js
index 567d6fd..7c3c6cd 100644
--- a/ambari-web/app/models/service.js
+++ b/ambari-web/app/models/service.js
@@ -78,7 +78,8 @@ App.Service = DS.Model.extend(App.ServiceModelMixin, {
serviceTypes: function() {
var typeServiceMap = {
GANGLIA: ['MONITORING'],
- NAGIOS: ['MONITORING']
+ NAGIOS: ['MONITORING'],
+ HDFS: ['HA_MODE']
};
return typeServiceMap[this.get('serviceName')] || [];
}.property('serviceName'),
http://git-wip-us.apache.org/repos/asf/ambari/blob/9c75be75/ambari-web/app/templates/main/service/item.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/service/item.hbs b/ambari-web/app/templates/main/service/item.hbs
index 7b904f0..a13ffd9 100644
--- a/ambari-web/app/templates/main/service/item.hbs
+++ b/ambari-web/app/templates/main/service/item.hbs
@@ -83,7 +83,7 @@
<!-- Other service actions -->
{{#each option in view.maintenance}}
- <li {{bindAttr class="option.disabled:disabled"}}>
+ <li {{bindAttr class="option.disabled:disabled option.isHidden:hidden"}}>
<a {{action "doAction" option target="controller" href=true}}><i {{bindAttr class="option.cssClass"}}></i>
{{option.label}}</a>
</li>
http://git-wip-us.apache.org/repos/asf/ambari/blob/9c75be75/ambari-web/app/views/main/service/item.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/item.js b/ambari-web/app/views/main/service/item.js
index 234059b..d685097 100644
--- a/ambari-web/app/views/main/service/item.js
+++ b/ambari-web/app/views/main/service/item.js
@@ -21,74 +21,125 @@ var batchUtils = require('utils/batch_scheduled_requests');
App.MainServiceItemView = Em.View.extend({
templateName: require('templates/main/service/item'),
+
+ serviceName: function() {
+ return this.get('controller.content.serviceName');
+ }.property('controller.content.serviceName'),
+
+ displayName: function() {
+ return this.get('controller.content.displayName');
+ }.property('controller.content.displayName'),
+
+ isPassive: function() {
+ return this.get('controller.content.passiveState') === 'ON';
+ }.property('controller.content.passiveState'),
+
+ actionMap: function() {
+ return {
+ RESTART_ALL: {
+ action: 'restartAllHostComponents',
+ context: this.get('serviceName'),
+ label: Em.I18n.t('restart.service.all'),
+ cssClass: 'icon-repeat',
+ disabled: false
+ },
+ RUN_SMOKE_TEST: {
+ action: 'runSmokeTest',
+ label: Em.I18n.t('services.service.actions.run.smoke'),
+ cssClass: 'icon-thumbs-up-alt'
+ },
+ REFRESH_CONFIGS: {
+ action: 'refreshConfigs',
+ label: Em.I18n.t('hosts.host.details.refreshConfigs'),
+ cssClass: 'icon-refresh',
+ disabled: !this.get('controller.content.isRestartRequired')
+ },
+ ROLLING_RESTART: {
+ action: 'rollingRestart',
+ context: this.get('rollingRestartComponent'),
+ label: Em.I18n.t('rollingrestart.dialog.title'),
+ cssClass: 'icon-time',
+ disabled: false
+ },
+ TOGGLE_PASSIVE: {
+ action: 'turnOnOffPassive',
+ context: this.get('isPassive') ? Em.I18n.t('passiveState.turnOffFor').format(this.get('displayName')) : Em.I18n.t('passiveState.turnOnFor').format(this.get('displayName')),
+ label: this.get('isPassive') ? Em.I18n.t('passiveState.turnOff') : Em.I18n.t('passiveState.turnOn'),
+ cssClass: 'icon-medkit',
+ disabled: false
+ },
+ TOGGLE_HA: {
+ action: App.isHaEnabled ? 'disableHighAvailability' : 'enableHighAvailability',
+ label: App.isHaEnabled ? Em.I18n.t('admin.highAvailability.button.disable') : Em.I18n.t('admin.highAvailability.button.enable'),
+ cssClass: App.isHaEnabled ? 'icon-arrow-down' : 'icon-arrow-up',
+ isHidden: (App.isHAEnabled && !App.autoRollbackHA)
+ },
+ MOVE_COMPONENT: {
+ action: 'reassignMaster',
+ context: '',
+ label: Em.I18n.t('services.service.actions.reassign.master'),
+ cssClass: 'icon-share-alt',
+ disabled: false
+ }
+ }
+ },
+ /**
+ * Create option for MOVE_COMPONENT or ROLLING_RESTART task.
+ *
+ * @param {Object} option - one of the options that return by <code>actionMap()</code>
+ * @param {Object} fields - option fields to add/rewrite
+ * @return {Object}
+ */
+ createOption: function(option, fields) {
+ return $.extend(true, {}, option, fields);
+ },
+
maintenance: function(){
+ var self = this;
var options = [];
var service = this.get('controller.content');
- var hosts = App.router.get('mainHostController.hostsCountMap')['TOTAL'];
var allMasters = this.get('controller.content.hostComponents').filterProperty('isMaster').mapProperty('componentName').uniq();
- var disabled = this.get('controller.isStopDisabled');
- var serviceName = service.get('serviceName');
- var displayName = service.get('displayName');
- var disableRefreshConfgis = !service.get('isRestartRequired');
+ var allSlaves = this.get('controller.content.hostComponents').filterProperty('isSlave').mapProperty('componentName').uniq();
+ var actionMap = this.actionMap();
if (this.get('controller.isClientsOnlyService')) {
- if (serviceName != 'TEZ') {
- options.push({action: 'runSmokeTest', cssClass: 'icon-thumbs-up-alt', 'label': Em.I18n.t('services.service.actions.run.smoke')});
+ options.push(actionMap.RUN_SMOKE_TEST);
+ options.push(actionMap.REFRESH_CONFIGS);
+ if (this.get('serviceName') === 'TEZ') {
+ options = options.without(actionMap.RUN_SMOKE_TEST);
}
- options.push({action: 'refreshConfigs', cssClass: 'icon-refresh', 'label': Em.I18n.t('hosts.host.details.refreshConfigs'), disabled: disableRefreshConfgis});
} else {
- // Restart All action
- options.push({action:'restartAllHostComponents', cssClass: 'icon-repeat', context: serviceName, 'label': Em.I18n.t('restart.service.all'), disabled: false});
- // Rolling Restart action
- var rrComponentName = batchUtils.getRollingRestartComponentName(serviceName);
- if (rrComponentName) {
- var label = Em.I18n.t('rollingrestart.dialog.title').format(App.format.role(rrComponentName));
- options.push({action:'rollingRestart', cssClass: 'icon-time', context: rrComponentName, 'label': label, disabled: false});
- }
- if (serviceName == 'FLUME') {
- options.push({action: 'refreshConfigs', cssClass: 'icon-refresh', 'label': Em.I18n.t('hosts.host.details.refreshConfigs'), disabled: disableRefreshConfgis});
+ if (this.get('serviceName') === 'FLUME') {
+ options.push(actionMap.REFRESH_CONFIGS);
}
- if (serviceName == 'HDFS') {
- if (App.isHaEnabled) {
- if (App.supports.autoRollbackHA) {
- options.push({action: 'disableHighAvailability', cssClass: 'icon-arrow-down', 'label': Em.I18n.t('admin.highAvailability.button.disable')});
- }
- } else {
- options.push({action: 'enableHighAvailability', cssClass: 'icon-arrow-up', 'label': Em.I18n.t('admin.highAvailability.button.enable')});
- }
+ options.push(actionMap.RESTART_ALL);
+ allSlaves.forEach(function(slave) {
+ options.push(self.createOption(actionMap.ROLLING_RESTART, {
+ context: slave,
+ label: actionMap.ROLLING_RESTART.label.format(App.format.role(slave))
+ }));
+ });
+ allMasters.filter(function(master) {
+ return App.get('components.reassignable').contains(master);
+ }).forEach(function(master) {
+ options.push(self.createOption(actionMap.MOVE_COMPONENT, {
+ context: master,
+ label: actionMap.MOVE_COMPONENT.label.format(App.format.role(master))
+ }));
+ });
+ if (service.get('serviceTypes').contains('HA_MODE')) {
+ options.push(actionMap.TOGGLE_HA);
}
- // Service Check and Reassign Master actions
- switch (serviceName) {
- case 'GANGLIA':
- case 'NAGIOS':
- break;
- case 'YARN':
- case 'HDFS':
- case 'MAPREDUCE':
- if (App.supports.reassignMaster && hosts > 1) {
- allMasters.forEach(function (hostComponent) {
- if (App.get('components.reassignable').contains(hostComponent)) {
- options.push({action: 'reassignMaster', context: hostComponent, cssClass: 'icon-share-alt',
- 'label': Em.I18n.t('services.service.actions.reassign.master').format(App.format.role(hostComponent)), disabled: false});
- }
- })
- }
- default:
- options.push({action: 'runSmokeTest', cssClass: 'icon-thumbs-up-alt', 'label': Em.I18n.t('services.service.actions.run.smoke'), disabled:disabled});
- }
- var requestLabel = service.get('passiveState') === "OFF" ?
- Em.I18n.t('passiveState.turnOnFor').format(displayName) :
- Em.I18n.t('passiveState.turnOffFor').format(displayName);
- var passiveLabel = service.get('passiveState') === "OFF" ?
- Em.I18n.t('passiveState.turnOn') :
- Em.I18n.t('passiveState.turnOff');
- options.push({action:'turnOnOffPassive', cssClass: 'icon-medkit', context:requestLabel, 'label':passiveLabel , disabled: false});
+ options.push(actionMap.RUN_SMOKE_TEST);
+ options.push(actionMap.TOGGLE_PASSIVE);
}
return options;
}.property('controller.content', 'controller.isStopDisabled','controller.isClientsOnlyService'),
+
isMaintenanceActive: function() {
return this.get('maintenance').length !== 0;
}.property('maintenance'),
+
hasConfigTab: function() {
return !App.get('services.noConfigTypes').concat('HCATALOG').contains('controller.content.serviceName');
}.property('controller.content.serviceName','App.services.noConfigTypes'),