|
@@ -40,11 +40,10 @@ App.ServiceConfigView = Em.View.extend({
|
|
|
supportsHostOverrides: function () {
|
|
|
switch (this.get('controller.name')) {
|
|
|
case 'wizardStep7Controller':
|
|
|
- return App.supports.hostOverridesInstaller && (this.get('controller.selectedService.serviceName') !== 'MISC');
|
|
|
+ return this.get('controller.selectedService.serviceName') !== 'MISC';
|
|
|
case 'mainServiceInfoConfigsController':
|
|
|
- return App.supports.hostOverrides;
|
|
|
case 'mainHostServiceConfigsController':
|
|
|
- return App.supports.hostOverridesHost;
|
|
|
+ return true;
|
|
|
default:
|
|
|
return false;
|
|
|
}
|
|
@@ -845,709 +844,4 @@ App.ServiceConfigTab = Ember.View.extend({
|
|
|
var serviceName = this.get('controller.selectedService.serviceName');
|
|
|
this.$('a[href="#' + serviceName + '"]').tab('show');
|
|
|
}
|
|
|
-});
|
|
|
-
|
|
|
-/**
|
|
|
- * custom view for capacity scheduler category
|
|
|
- * @type {*}
|
|
|
- */
|
|
|
-App.ServiceConfigCapacityScheduler = App.ServiceConfigsByCategoryView.extend({
|
|
|
- templateName: require('templates/common/configs/capacity_scheduler'),
|
|
|
- category: null,
|
|
|
- service: null,
|
|
|
- serviceConfigs: null,
|
|
|
- customConfigs: function(){
|
|
|
- return App.config.get('preDefinedCustomConfigs');
|
|
|
- }.property('App.config.preDefinedCustomConfigs'),
|
|
|
- /**
|
|
|
- * configs filtered by capacity-scheduler category
|
|
|
- */
|
|
|
- categoryConfigs: function () {
|
|
|
- return this.get('serviceConfigs').filterProperty('category', this.get('category.name'));
|
|
|
- }.property('queueObserver', 'serviceConfigs.@each'),
|
|
|
- /**
|
|
|
- * rewrote method to avoid incompatibility with parent
|
|
|
- */
|
|
|
- filteredCategoryConfigs: function () {
|
|
|
- return this.get('categoryConfigs');
|
|
|
- }.property(),
|
|
|
- advancedConfigs: function () {
|
|
|
- return this.get('categoryConfigs').filterProperty('isQueue', undefined) || [];
|
|
|
- }.property('categoryConfigs.@each'),
|
|
|
- didInsertElement: function () {
|
|
|
- this._super();
|
|
|
- this.createEmptyQueue(this.get('customConfigs').filterProperty('isQueue'));
|
|
|
- },
|
|
|
- //list of fields which will be populated by default in a new queue
|
|
|
- fieldsToPopulate: function(){
|
|
|
- if(App.get('isHadoop2Stack')){
|
|
|
- return ["yarn.scheduler.capacity.root.<queue-name>.user-limit-factor",
|
|
|
- "yarn.scheduler.capacity.root.<queue-name>.state"];
|
|
|
- }
|
|
|
- return [
|
|
|
- "mapred.capacity-scheduler.queue.<queue-name>.minimum-user-limit-percent",
|
|
|
- "mapred.capacity-scheduler.queue.<queue-name>.user-limit-factor",
|
|
|
- "mapred.capacity-scheduler.queue.<queue-name>.supports-priority",
|
|
|
- "mapred.capacity-scheduler.queue.<queue-name>.maximum-initialized-active-tasks",
|
|
|
- "mapred.capacity-scheduler.queue.<queue-name>.maximum-initialized-active-tasks-per-user",
|
|
|
- "mapred.capacity-scheduler.queue.<queue-name>.init-accept-jobs-factor"
|
|
|
- ];
|
|
|
- }.property('App.isHadoop2Stack'),
|
|
|
- /**
|
|
|
- * create empty queue
|
|
|
- * take some queue then copy it and set all config values to null
|
|
|
- * @param customConfigs
|
|
|
- */
|
|
|
- createEmptyQueue: function (customConfigs) {
|
|
|
- var emptyQueue = {
|
|
|
- name: '<queue-name>',
|
|
|
- configs: []
|
|
|
- };
|
|
|
- var fieldsToPopulate = this.get('fieldsToPopulate');
|
|
|
- customConfigs.forEach(function (config) {
|
|
|
- var newConfig = $.extend({}, config);
|
|
|
- if (fieldsToPopulate.contains(config.name)) {
|
|
|
- newConfig.value = config.defaultValue;
|
|
|
- }
|
|
|
- newConfig = App.ServiceConfigProperty.create(newConfig);
|
|
|
- newConfig.validate();
|
|
|
- emptyQueue.configs.push(newConfig);
|
|
|
- });
|
|
|
- this.set('emptyQueue', emptyQueue);
|
|
|
- },
|
|
|
- deriveQueueNames: function(configs){
|
|
|
- var queueNames = [];
|
|
|
- configs.mapProperty('name').forEach(function(name){
|
|
|
- var queueName;
|
|
|
- if(App.get('isHadoop2Stack')){
|
|
|
- queueName = /^yarn\.scheduler\.capacity\.root\.(.*?)\./.exec(name);
|
|
|
- } else {
|
|
|
- queueName = /^mapred\.capacity-scheduler\.queue\.(.*?)\./.exec(name);
|
|
|
- }
|
|
|
- if(queueName){
|
|
|
- queueNames.push(queueName[1]);
|
|
|
- }
|
|
|
- });
|
|
|
- return queueNames.uniq();
|
|
|
- },
|
|
|
- queues: function(){
|
|
|
- var configs = this.get('categoryConfigs').filterProperty('isQueue', true);
|
|
|
- var queueNames = this.deriveQueueNames(configs);
|
|
|
- var queues = [];
|
|
|
-
|
|
|
- queueNames.forEach(function(queueName){
|
|
|
- queues.push({
|
|
|
- name: queueName,
|
|
|
- color: this.generateColor(queueName),
|
|
|
- configs: this.groupConfigsByQueue(queueName, configs)
|
|
|
- })
|
|
|
- }, this);
|
|
|
- return queues;
|
|
|
- }.property('queueObserver'),
|
|
|
- /**
|
|
|
- * group configs by queue
|
|
|
- * @param queueName
|
|
|
- * @param configs
|
|
|
- */
|
|
|
- groupConfigsByQueue: function (queueName, configs) {
|
|
|
- var customConfigs = [];
|
|
|
- var queue = [];
|
|
|
- this.get('customConfigs').forEach(function(_config){
|
|
|
- var copy = $.extend({}, _config);
|
|
|
- copy.name = _config.name.replace('<queue-name>', queueName);
|
|
|
- customConfigs.push(copy);
|
|
|
- });
|
|
|
- configs.forEach(function (config) {
|
|
|
- var customConfig = customConfigs.findProperty('name', config.get('name'));
|
|
|
- if (customConfig) {
|
|
|
- config.set('description', customConfig.description);
|
|
|
- config.set('displayName', customConfig.displayName);
|
|
|
- config.set('isRequired', customConfig.isRequired);
|
|
|
- config.set('unit', customConfig.unit);
|
|
|
- config.set('displayType', customConfig.displayType);
|
|
|
- config.set('valueRange', customConfig.valueRange);
|
|
|
- config.set('isVisible', customConfig.isVisible);
|
|
|
- config.set('inTable', customConfig.inTable);
|
|
|
- config.set('index', customConfig.index);
|
|
|
- queue.push(config);
|
|
|
- }
|
|
|
- });
|
|
|
- if(queue.length < customConfigs.length){
|
|
|
- this.addMissingProperties(queue, customConfigs);
|
|
|
- }
|
|
|
- return queue;
|
|
|
- },
|
|
|
- /**
|
|
|
- * add missing properties to queue when they don't come from server
|
|
|
- * @param queue
|
|
|
- * @param customConfigs
|
|
|
- */
|
|
|
- addMissingProperties: function(queue, customConfigs){
|
|
|
- customConfigs.forEach(function(_config){
|
|
|
- var serviceConfigProperty;
|
|
|
- if(!queue.someProperty('name', _config.name)){
|
|
|
- _config.value = _config.defaultValue;
|
|
|
- serviceConfigProperty = App.ServiceConfigProperty.create(_config);
|
|
|
- serviceConfigProperty.validate();
|
|
|
- queue.push(serviceConfigProperty);
|
|
|
- }
|
|
|
- }, this);
|
|
|
- },
|
|
|
- /**
|
|
|
- * convert queues to table content
|
|
|
- */
|
|
|
- tableContent: function () {
|
|
|
- var result = [];
|
|
|
- this.get('queues').forEach(function (queue) {
|
|
|
- var usersAndGroups = queue.configs.findProperty('name', this.getUserAndGroupNames(queue.name)[0]).get('value');
|
|
|
- usersAndGroups = (usersAndGroups) ? usersAndGroups.split(' ') : [''];
|
|
|
- if (usersAndGroups.length == 1) {
|
|
|
- usersAndGroups.push('');
|
|
|
- }
|
|
|
- var queueObject = {
|
|
|
- name: queue.name,
|
|
|
- color: 'background-color:' + queue.color + ';',
|
|
|
- configs: this.sortByIndex(queue.configs.filterProperty('inTable'))
|
|
|
- };
|
|
|
- //push acl_submit_jobs users
|
|
|
- queueObject.configs.unshift({
|
|
|
- value: usersAndGroups[1],
|
|
|
- inTable: true,
|
|
|
- displayName: Em.I18n.t('common.users')
|
|
|
- });
|
|
|
- //push acl_submit_jobs groups
|
|
|
- queueObject.configs.unshift({
|
|
|
- value: usersAndGroups[0],
|
|
|
- inTable: true,
|
|
|
- displayName: Em.I18n.t('services.mapReduce.config.queue.groups')
|
|
|
- });
|
|
|
- result.push(queueObject);
|
|
|
- }, this);
|
|
|
- return result;
|
|
|
- }.property('queues'),
|
|
|
- /**
|
|
|
- * create headers depending on existed properties in queue
|
|
|
- */
|
|
|
- tableHeaders: function(){
|
|
|
- var headers = [
|
|
|
- Em.I18n.t('services.mapReduce.config.queue.name')
|
|
|
- ];
|
|
|
- return (this.get('tableContent').length) ?
|
|
|
- headers.concat(this.get('tableContent').objectAt(0).configs.filterProperty('inTable').mapProperty('displayName')):
|
|
|
- headers;
|
|
|
- }.property('tableContent'),
|
|
|
- queueObserver: null,
|
|
|
- /**
|
|
|
- * uses as template for adding new queue
|
|
|
- */
|
|
|
- emptyQueue: {},
|
|
|
- /**
|
|
|
- * get capacities sum of queues except of current
|
|
|
- * @param queueName
|
|
|
- * @return {Number}
|
|
|
- */
|
|
|
- getQueuesCapacitySum: function(queueName){
|
|
|
- var capacitySum = 0;
|
|
|
- this.get('queues').filter(function(queue){
|
|
|
- return queue.name !== queueName;
|
|
|
- }).forEach(function(queue){
|
|
|
- capacitySum = capacitySum + window.parseInt(queue.configs.find(function(config){
|
|
|
- return config.get('name').substr(-9, 9) === '.capacity';
|
|
|
- }).get('value'));
|
|
|
- });
|
|
|
- return capacitySum;
|
|
|
- },
|
|
|
- /**
|
|
|
- * get names of configs, for users and groups, which have different names in HDP1 and HDP2
|
|
|
- * @param queueName
|
|
|
- * @return {Array}
|
|
|
- */
|
|
|
- getUserAndGroupNames: function(queueName){
|
|
|
- queueName = queueName || '<queue-name>';
|
|
|
- if(App.get('isHadoop2Stack') && this.get('controller.selectedService')) {
|
|
|
- if (this.get('controller.selectedService.serviceName') == "YARN") {
|
|
|
- return ['yarn.scheduler.capacity.root.' + queueName + '.acl_submit_jobs',
|
|
|
- 'yarn.scheduler.capacity.root.' + queueName + '.acl_administer_jobs']
|
|
|
- }
|
|
|
- return ['mapred.queue.' + queueName + '.acl-submit-job',
|
|
|
- 'mapred.queue.' + queueName + '.acl-administer-jobs']
|
|
|
- }
|
|
|
- },
|
|
|
- generateColor: function (str) {
|
|
|
- var hash = 0;
|
|
|
- for (var i = 0; i < str.length; i++) {
|
|
|
- hash = str.charCodeAt(i) + ((hash << 5) - hash);
|
|
|
- }
|
|
|
- return '#' + Number(Math.abs(hash)).toString(16).concat('00000').substr(0, 6);
|
|
|
- },
|
|
|
- /**
|
|
|
- * add new queue
|
|
|
- * add created configs to serviceConfigs with current queue name
|
|
|
- * @param queue
|
|
|
- */
|
|
|
- addQueue: function (queue) {
|
|
|
- var serviceConfigs = this.get('serviceConfigs');
|
|
|
- var admin = [];
|
|
|
- var submit = [];
|
|
|
- var submitConfig;
|
|
|
- var adminConfig;
|
|
|
- queue.name = queue.configs.findProperty('name', 'queueName').get('value');
|
|
|
- queue.configs.forEach(function (config) {
|
|
|
- var adminName = this.getUserAndGroupNames()[1];
|
|
|
- var submitName = this.getUserAndGroupNames()[0];
|
|
|
- if(config.name == adminName){
|
|
|
- if (config.type == 'USERS') {
|
|
|
- admin[0] = config.value;
|
|
|
- }
|
|
|
- if (config.type == 'GROUPS') {
|
|
|
- admin[1] = config.value;
|
|
|
- }
|
|
|
- if (config.isQueue) {
|
|
|
- adminConfig = config;
|
|
|
- }
|
|
|
- }
|
|
|
- if(config.name == submitName){
|
|
|
- if (config.type == 'USERS') {
|
|
|
- submit[0] = config.value;
|
|
|
- }
|
|
|
- if (config.type == 'GROUPS') {
|
|
|
- submit[1] = config.value;
|
|
|
- }
|
|
|
- if (config.isQueue) {
|
|
|
- submitConfig = config;
|
|
|
- }
|
|
|
- }
|
|
|
- config.set('name', config.get('name').replace('<queue-name>', queue.name));
|
|
|
- config.set('value', config.get('value').toString());
|
|
|
- if (config.isQueue) {
|
|
|
- serviceConfigs.push(config);
|
|
|
- }
|
|
|
- }, this);
|
|
|
- adminConfig.set('value', admin.join(' '));
|
|
|
- submitConfig.set('value', submit.join(' '));
|
|
|
- this.set('queueObserver', App.dateTime());
|
|
|
- },
|
|
|
- /**
|
|
|
- * delete queue
|
|
|
- * delete configs from serviceConfigs which have current queue name
|
|
|
- * @param queue
|
|
|
- */
|
|
|
- deleteQueue: function (queue) {
|
|
|
- var serviceConfigs = this.get('serviceConfigs');
|
|
|
- var configNames = queue.configs.filterProperty('isQueue').mapProperty('name');
|
|
|
- for (var i = 0, l = serviceConfigs.length; i < l; i++) {
|
|
|
- if (configNames.contains(serviceConfigs[i].name)) {
|
|
|
- serviceConfigs.splice(i, 1);
|
|
|
- l--;
|
|
|
- i--;
|
|
|
- }
|
|
|
- }
|
|
|
- this.set('queueObserver', App.dateTime());
|
|
|
- },
|
|
|
- /**
|
|
|
- * save changes that was made to queue
|
|
|
- * edit configs from serviceConfigs which have current queue name
|
|
|
- * @param queue
|
|
|
- */
|
|
|
- editQueue: function (queue) {
|
|
|
- var serviceConfigs = this.get('serviceConfigs');
|
|
|
- var configNames = queue.configs.filterProperty('isQueue').mapProperty('name');
|
|
|
- serviceConfigs.forEach(function (_config) {
|
|
|
- var configName = _config.get('name');
|
|
|
- var admin = [];
|
|
|
- var submit = [];
|
|
|
- //comparison executes including 'queue.<queue-name>' to avoid false matches
|
|
|
- var queueNamePrefix = App.get('isHadoop2Stack') ? 'root.' : 'queue.';
|
|
|
- if (configNames.contains(_config.get('name'))) {
|
|
|
- if(configName == this.getUserAndGroupNames(queue.name)[0]){
|
|
|
- submit = queue.configs.filterProperty('name', configName);
|
|
|
- submit = submit.findProperty('type', 'USERS').get('value') + ' ' + submit.findProperty('type', 'GROUPS').get('value');
|
|
|
- _config.set('value', submit);
|
|
|
- } else if(configName == this.getUserAndGroupNames(queue.name)[1]){
|
|
|
- admin = queue.configs.filterProperty('name', configName);
|
|
|
- admin = admin.findProperty('type', 'USERS').get('value') + ' ' + admin.findProperty('type', 'GROUPS').get('value');
|
|
|
- _config.set('value', admin);
|
|
|
- } else {
|
|
|
- _config.set('value', queue.configs.findProperty('name', _config.get('name')).get('value').toString());
|
|
|
- }
|
|
|
- _config.set('name', configName.replace(queueNamePrefix + queue.name, queueNamePrefix + queue.configs.findProperty('name', 'queueName').get('value')));
|
|
|
- }
|
|
|
- }, this);
|
|
|
- this.set('queueObserver', App.dateTime());
|
|
|
- },
|
|
|
- pieChart: App.ChartPieView.extend({
|
|
|
- w: 200,
|
|
|
- h: 200,
|
|
|
- queues: null,
|
|
|
- didInsertElement: function () {
|
|
|
- this.update();
|
|
|
- },
|
|
|
- data: [{"label":"default", "value":100}],
|
|
|
- update: function () {
|
|
|
- var self = this;
|
|
|
- var data = [];
|
|
|
- var queues = this.get('queues');
|
|
|
- var capacitiesSum = 0;
|
|
|
- queues.forEach(function (queue) {
|
|
|
- var value = window.parseInt(queue.configs.find(function(_config){
|
|
|
- return _config.get('name').substr(-9, 9) === '.capacity';
|
|
|
- }).get('value'));
|
|
|
- data.push({
|
|
|
- label: queue.name,
|
|
|
- value: value,
|
|
|
- color: queue.color
|
|
|
- })
|
|
|
- });
|
|
|
-
|
|
|
- data.mapProperty('value').forEach(function (capacity) {
|
|
|
- capacitiesSum += capacity;
|
|
|
- });
|
|
|
- if (capacitiesSum < 100) {
|
|
|
- data.push({
|
|
|
- label: Em.I18n.t('common.empty'),
|
|
|
- value: (100 - capacitiesSum),
|
|
|
- color: 'transparent',
|
|
|
- isEmpty: true
|
|
|
- })
|
|
|
- }
|
|
|
- $(d3.select(this.get('selector'))[0]).children().remove();
|
|
|
- this.set('data', data);
|
|
|
- this.set('palette', new Rickshaw.Color.Palette({
|
|
|
- scheme: data.mapProperty('color')
|
|
|
- }));
|
|
|
- this.appendSvg();
|
|
|
-
|
|
|
- this.get('arcs')
|
|
|
- .on("click",function (d, i) {
|
|
|
- var event = {context: d.data.label};
|
|
|
- if (d.data.isEmpty !== true) self.get('parentView').queuePopup(event);
|
|
|
- }).on('mouseover', function (d, i) {
|
|
|
- var position = d3.svg.mouse(this);
|
|
|
- var label = $('#section_label');
|
|
|
- label.css('left', position[0] + 100);
|
|
|
- label.css('top', position[1] + 100);
|
|
|
- label.text(d.data.label);
|
|
|
- label.show();
|
|
|
- })
|
|
|
- .on('mouseout', function (d, i) {
|
|
|
- $('#section_label').hide();
|
|
|
- })
|
|
|
-
|
|
|
- }.observes('queues'),
|
|
|
- donut: d3.layout.pie().sort(null).value(function (d) {
|
|
|
- return d.value;
|
|
|
- })
|
|
|
- }),
|
|
|
- /**
|
|
|
- * open popup with chosen queue
|
|
|
- * @param event
|
|
|
- */
|
|
|
- queuePopup: function (event) {
|
|
|
- //if queueName was handed that means "Edit" mode, otherwise "Add" mode
|
|
|
- var queueName = event.context || null;
|
|
|
- var self = this;
|
|
|
- App.ModalPopup.show({
|
|
|
- didInsertElement: function () {
|
|
|
- if (queueName) {
|
|
|
- this.set('header', Em.I18n.t('services.mapReduce.config.editQueue'));
|
|
|
- this.set('secondary', Em.I18n.t('common.save'));
|
|
|
- if (self.get('queues').length > 1 && self.get('canEdit')) {
|
|
|
- this.set('delete', Em.I18n.t('common.delete'));
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- header: Em.I18n.t('services.mapReduce.config.addQueue'),
|
|
|
- secondary: Em.I18n.t('common.add'),
|
|
|
- primary: Em.I18n.t('common.cancel'),
|
|
|
- delete: null,
|
|
|
- isError: function () {
|
|
|
- if (!self.get('canEdit')) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- var content = this.get('content');
|
|
|
- var configs = content.configs.filter(function (config) {
|
|
|
- return !(config.name == self.getUserAndGroupNames(content.name)[0] ||
|
|
|
- config.name == self.getUserAndGroupNames(content.name)[1] &&
|
|
|
- config.isQueue);
|
|
|
- });
|
|
|
- return configs.someProperty('isValid', false);
|
|
|
- }.property('content.configs.@each.isValid'),
|
|
|
- onDelete: function () {
|
|
|
- var view = this;
|
|
|
- App.ModalPopup.show({
|
|
|
- header: Em.I18n.t('popup.confirmation.commonHeader'),
|
|
|
- body: Em.I18n.t('hosts.delete.popup.body'),
|
|
|
- primary: Em.I18n.t('yes'),
|
|
|
- onPrimary: function () {
|
|
|
- self.deleteQueue(view.get('content'));
|
|
|
- view.hide();
|
|
|
- this.hide();
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- onSecondary: function () {
|
|
|
- if (queueName) {
|
|
|
- self.editQueue(this.get('content'));
|
|
|
- } else {
|
|
|
- self.addQueue(this.get('content'));
|
|
|
- }
|
|
|
- this.hide();
|
|
|
- },
|
|
|
- /**
|
|
|
- * Queue properties order:
|
|
|
- * 1. Queue Name
|
|
|
- * 2. Capacity
|
|
|
- * 3. Max Capacity
|
|
|
- * 4. Users
|
|
|
- * 5. Groups
|
|
|
- * 6. Admin Users
|
|
|
- * 7. Admin Groups
|
|
|
- * 8. Support Priority
|
|
|
- * ...
|
|
|
- */
|
|
|
- content: function () {
|
|
|
- var content = (queueName) ? self.get('queues').findProperty('name', queueName) : self.get('emptyQueue');
|
|
|
- var configs = [];
|
|
|
- // copy of queue configs
|
|
|
- content.configs.forEach(function (config, index) {
|
|
|
- if(config.get('name').substr(-9, 9) === '.capacity') {
|
|
|
- //added validation function for capacity property
|
|
|
- config.reopen({
|
|
|
- validate: function () {
|
|
|
- var value = this.get('value');
|
|
|
- var isError = false;
|
|
|
- var capacitySum = self.getQueuesCapacitySum(content.name);
|
|
|
- if (value == '') {
|
|
|
- if (this.get('isRequired')) {
|
|
|
- this.set('errorMessage', 'This is required');
|
|
|
- isError = true;
|
|
|
- } else {
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!isError) {
|
|
|
- if (!validator.isValidInt(value)) {
|
|
|
- this.set('errorMessage', 'Must contain digits only');
|
|
|
- isError = true;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!isError) {
|
|
|
- if ((capacitySum + parseInt(value)) > 100) {
|
|
|
- isError = true;
|
|
|
- this.set('errorMessage', 'The sum of capacities more than 100');
|
|
|
- }
|
|
|
- if (!isError) {
|
|
|
- this.set('errorMessage', '');
|
|
|
- }
|
|
|
- }
|
|
|
- }.observes('value')
|
|
|
- });
|
|
|
- }
|
|
|
- if (config.name == 'mapred.capacity-scheduler.queue.' + content.name + '.supports-priority') {
|
|
|
- if (config.get('value') == 'true' || config.get('value') === true) {
|
|
|
- config.set('value', true);
|
|
|
- } else {
|
|
|
- config.set('value', false);
|
|
|
- }
|
|
|
- }
|
|
|
- if(config.name === 'yarn.scheduler.capacity.root.' + content.name + '.state'){
|
|
|
- config.reopen({
|
|
|
- validate: function(){
|
|
|
- var value = this.get('value');
|
|
|
- this._super();
|
|
|
- if(!this.get('errorMessage')){
|
|
|
- if(!(value === 'STOPPED' || value === 'RUNNING')){
|
|
|
- this.set('errorMessage', 'State value should be RUNNING or STOPPED');
|
|
|
- }
|
|
|
- }
|
|
|
- }.observes('value')
|
|
|
- })
|
|
|
- }
|
|
|
- configs[index] = App.ServiceConfigProperty.create(config);
|
|
|
- });
|
|
|
- content = {
|
|
|
- name: content.name,
|
|
|
- configs: configs
|
|
|
- };
|
|
|
- content = this.insertExtraConfigs(content);
|
|
|
- content.configs = self.sortByIndex(content.configs);
|
|
|
- return content;
|
|
|
- }.property(),
|
|
|
- footerClass: Ember.View.extend({
|
|
|
- classNames: ['modal-footer', 'host-checks-update'],
|
|
|
- templateName: require('templates/common/configs/queuePopup_footer')
|
|
|
- }),
|
|
|
- bodyClass: Ember.View.extend({
|
|
|
- templateName: require('templates/common/configs/queuePopup_body')
|
|
|
- }),
|
|
|
- /**
|
|
|
- * Insert extra config in popup according to queue
|
|
|
- *
|
|
|
- * the mapred.queue.default.acl-administer-jobs turns into two implicit configs:
|
|
|
- * "Admin Users" field and "Admin Groups" field
|
|
|
- * the mapred.queue.default.acl-submit-job turns into two implicit configs:
|
|
|
- * "Users" field and "Groups" field
|
|
|
- * Add implicit config that contain "Queue Name"
|
|
|
- * @param content
|
|
|
- * @return {*}
|
|
|
- */
|
|
|
- insertExtraConfigs: function (content) {
|
|
|
- var that = this;
|
|
|
- var admin = content.configs.findProperty('name', self.getUserAndGroupNames(content.name)[1]).get('value');
|
|
|
- var submit = content.configs.findProperty('name', self.getUserAndGroupNames(content.name)[0]).get('value');
|
|
|
- admin = (admin) ? admin.split(' ') : [''];
|
|
|
- submit = (submit) ? submit.split(' ') : [''];
|
|
|
- if (admin.length < 2) {
|
|
|
- admin.push('');
|
|
|
- }
|
|
|
- if (submit.length < 2) {
|
|
|
- submit.push('');
|
|
|
- }
|
|
|
- var nameField = App.ServiceConfigProperty.create({
|
|
|
- name: 'queueName',
|
|
|
- displayName: Em.I18n.t('services.mapReduce.extraConfig.queue.name'),
|
|
|
- description: Em.I18n.t('services.mapReduce.description.queue.name'),
|
|
|
- value: (content.name == '<queue-name>') ? '' : content.name,
|
|
|
- validate: function () {
|
|
|
- var queueNames = self.get('queues').mapProperty('name');
|
|
|
- var value = this.get('value');
|
|
|
- var isError = false;
|
|
|
- var regExp = /^[a-z]([\_\-a-z0-9]{0,50})\$?$/i;
|
|
|
- if (value == '') {
|
|
|
- if (this.get('isRequired')) {
|
|
|
- this.set('errorMessage', 'This is required');
|
|
|
- isError = true;
|
|
|
- } else {
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!isError) {
|
|
|
- if ((queueNames.indexOf(value) !== -1) && (value != content.name)) {
|
|
|
- this.set('errorMessage', 'Queue name is already used');
|
|
|
- isError = true;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!isError) {
|
|
|
- if (!regExp.test(value)) {
|
|
|
- this.set('errorMessage', 'Incorrect input');
|
|
|
- isError = true;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!isError) {
|
|
|
- this.set('errorMessage', '');
|
|
|
- }
|
|
|
- }.observes('value'),
|
|
|
- isRequired: true,
|
|
|
- isVisible: true,
|
|
|
- isEditable: self.get('canEdit'),
|
|
|
- index: 0
|
|
|
- });
|
|
|
- nameField.validate();
|
|
|
- content.configs.unshift(nameField);
|
|
|
-
|
|
|
- var submitUser = App.ServiceConfigProperty.create({
|
|
|
- name: self.getUserAndGroupNames(content.name)[0],
|
|
|
- displayName: Em.I18n.t('common.users'),
|
|
|
- value: submit[0],
|
|
|
- description: Em.I18n.t('services.mapReduce.description.queue.submit.user'),
|
|
|
- isRequired: true,
|
|
|
- isVisible: true,
|
|
|
- type: 'USERS',
|
|
|
- displayType: "UNIXList",
|
|
|
- isEditable: self.get('canEdit'),
|
|
|
- index: 3
|
|
|
- });
|
|
|
-
|
|
|
- var submitGroup = App.ServiceConfigProperty.create({
|
|
|
- name: self.getUserAndGroupNames(content.name)[0],
|
|
|
- displayName: Em.I18n.t('services.mapReduce.config.queue.groups'),
|
|
|
- description: Em.I18n.t('services.mapReduce.description.queue.submit.group'),
|
|
|
- value: submit[1],
|
|
|
- isRequired: true,
|
|
|
- isVisible: true,
|
|
|
- "displayType": "UNIXList",
|
|
|
- type: 'GROUPS',
|
|
|
- isEditable: self.get('canEdit'),
|
|
|
- index: 4
|
|
|
- });
|
|
|
-
|
|
|
- var adminUser = App.ServiceConfigProperty.create({
|
|
|
- name: self.getUserAndGroupNames(content.name)[1],
|
|
|
- displayName: Em.I18n.t('services.mapReduce.config.queue.adminUsers'),
|
|
|
- description: Em.I18n.t('services.mapReduce.description.queue.admin.user'),
|
|
|
- value: admin[0],
|
|
|
- isRequired: true,
|
|
|
- isVisible: true,
|
|
|
- type: 'USERS',
|
|
|
- displayType: "UNIXList",
|
|
|
- isEditable: self.get('canEdit'),
|
|
|
- index: 5
|
|
|
- });
|
|
|
-
|
|
|
- var adminGroup = App.ServiceConfigProperty.create({
|
|
|
- name: self.getUserAndGroupNames(content.name)[1],
|
|
|
- displayName: Em.I18n.t('services.mapReduce.config.queue.adminGroups'),
|
|
|
- value: admin[1],
|
|
|
- description: Em.I18n.t('services.mapReduce.description.queue.admin.group'),
|
|
|
- isRequired: true,
|
|
|
- isVisible: true,
|
|
|
- "displayType": "UNIXList",
|
|
|
- type: 'GROUPS',
|
|
|
- isEditable: self.get('canEdit'),
|
|
|
- index: 6
|
|
|
- });
|
|
|
-
|
|
|
- submitUser.reopen({
|
|
|
- validate: function () {
|
|
|
- that.userGroupValidation(this, submitGroup);
|
|
|
- }.observes('value')
|
|
|
- });
|
|
|
- submitGroup.reopen({
|
|
|
- validate: function () {
|
|
|
- that.userGroupValidation(this, submitUser);
|
|
|
- }.observes('value')
|
|
|
- });
|
|
|
- adminUser.reopen({
|
|
|
- validate: function () {
|
|
|
- that.userGroupValidation(this, adminGroup);
|
|
|
- }.observes('value')
|
|
|
- });
|
|
|
- adminGroup.reopen({
|
|
|
- validate: function () {
|
|
|
- that.userGroupValidation(this, adminUser);
|
|
|
- }.observes('value')
|
|
|
- });
|
|
|
-
|
|
|
- submitUser.validate();
|
|
|
- adminUser.validate();
|
|
|
- content.configs.push(submitUser);
|
|
|
- content.configs.push(submitGroup);
|
|
|
- content.configs.push(adminUser);
|
|
|
- content.configs.push(adminGroup);
|
|
|
-
|
|
|
- return content;
|
|
|
- },
|
|
|
- /**
|
|
|
- * Validate by follow rules:
|
|
|
- * Users can be blank. If it is blank, Groups must not be blank.
|
|
|
- * Groups can be blank. If it is blank, Users must not be blank.
|
|
|
- * @param context
|
|
|
- * @param boundConfig
|
|
|
- */
|
|
|
- userGroupValidation: function (context, boundConfig) {
|
|
|
- if (context.get('value') == '') {
|
|
|
- if (boundConfig.get('value') == '') {
|
|
|
- context._super();
|
|
|
- } else {
|
|
|
- boundConfig.validate();
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (boundConfig.get('value') == '') {
|
|
|
- boundConfig.set('errorMessage', '');
|
|
|
- }
|
|
|
- context._super();
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-});
|
|
|
+});
|