AMBARI-13482. [CapSchedView] Mappings should be validated and invalid mappings should be disallowed. (Gaurav Nagar via yusaku)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/383aac0f Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/383aac0f Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/383aac0f Branch: refs/heads/branch-dev-patch-upgrade Commit: 383aac0f581e833614b4307635d263e90ad90171 Parents: 844b1e9 Author: Yusaku Sako <yus...@hortonworks.com> Authored: Wed Oct 21 15:23:00 2015 -0700 Committer: Yusaku Sako <yus...@hortonworks.com> Committed: Wed Oct 21 15:23:29 2015 -0700 ---------------------------------------------------------------------- .../main/resources/ui/app/controllers/queues.js | 36 ++++++++++++++++++-- .../ui/app/templates/schedulerPanel.hbs | 2 +- 2 files changed, 35 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/383aac0f/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/queues.js ---------------------------------------------------------------------- diff --git a/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/queues.js b/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/queues.js index 429832f..416ff43 100644 --- a/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/queues.js +++ b/contrib/views/capacity-scheduler/src/main/resources/ui/app/controllers/queues.js @@ -336,7 +336,7 @@ App.QueuesController = Ember.ArrayController.extend({ * check if can save configs * @type {bool} */ - canNotSave: cmp.any('hasOverCapacity', 'hasUncompetedAddings','hasNotValid','hasNotValidLabels'), + canNotSave: cmp.any('hasOverCapacity', 'hasUncompetedAddings','hasNotValid','hasNotValidLabels','hasInvalidQueueMappings'), /** * List of not valid queues. @@ -384,5 +384,37 @@ App.QueuesController = Ember.ArrayController.extend({ * True if uncompetedAddings is not empty. * @type {Boolean} */ - hasUncompetedAddings:cmp.notEmpty('uncompetedAddings.[]') + hasUncompetedAddings:cmp.notEmpty('uncompetedAddings.[]'), + + /** + * True if queue_mapping is not valid + * @type {Boolean} + */ + hasInvalidQueueMappings : function() { + var mappings = this.get('scheduler.queue_mappings') || '', + queues = this.get('content.content'), + hasInvalidMapping = false; + + if(mappings == '' || mappings == 'u:%user:%primary_group' || mappings == 'u:%user:%user') { + return false; + } + + mappings.split(',').forEach(function(item) { + // item should be in format [u or g]:[name]:[queue_name] + var mapping= item.split(":"); + + if(mapping.length!=3 || (mapping[0] != 'u'&& mapping[0] != 'g')) { + hasInvalidMapping = true; + }else{ + hasInvalidMapping = queues.filter(function(queue){ + return !queue.get("queues"); //get all leaf queues + }).map(function(queue){ + return queue.get("name"); + }).indexOf(mapping[2]) == -1; + } + + }) + + return hasInvalidMapping; + }.property('scheduler.queue_mappings','content.length','content.@each.capacity') }); http://git-wip-us.apache.org/repos/asf/ambari/blob/383aac0f/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/schedulerPanel.hbs ---------------------------------------------------------------------- diff --git a/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/schedulerPanel.hbs b/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/schedulerPanel.hbs index 388bc60..4419aa0 100644 --- a/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/schedulerPanel.hbs +++ b/contrib/views/capacity-scheduler/src/main/resources/ui/app/templates/schedulerPanel.hbs @@ -126,7 +126,7 @@ }} {{#if isOperator}} <div class="col-xs-7 control-value"> - {{expandable-input value=scheduler.queue_mappings class="input-sm form-control input-expand"}} + {{expandable-input value=scheduler.queue_mappings classNameBindings="hasInvalidQueueMappings:list-group-item-danger" class="input-sm form-control input-expand"}} {{#if schedulerDirtyFilelds.queue_mappings}} <div class="btn-group btn-group-xs" > <a {{action 'rollbackProp' 'queue_mappings' scheduler}} href="#" class="btn btn-default btn-warning"><i class="fa fa-undo"></i></a>