ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject ambari git commit: AMBARI-13482. [CapSchedView] Mappings should be validated and invalid mappings should be disallowed. (Gaurav Nagar via yusaku)
Date Wed, 21 Oct 2015 22:24:03 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 35f639ccb -> 086633ab6


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/086633ab
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/086633ab
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/086633ab

Branch: refs/heads/branch-2.1
Commit: 086633ab60e8500c1e43a9a8a578e12d27d2a644
Parents: 35f639c
Author: Yusaku Sako <yusaku@hortonworks.com>
Authored: Wed Oct 21 15:23:00 2015 -0700
Committer: Yusaku Sako <yusaku@hortonworks.com>
Committed: Wed Oct 21 15:23:53 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/086633ab/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/086633ab/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>


Mime
View raw message