You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2013/06/05 19:28:18 UTC

svn commit: r1489974 - in /incubator/ambari/branches/branch-1.4.0/ambari-web/app: ./ controllers/main/service/info/ controllers/wizard/ data/ data/HDP2/ styles/ templates/common/configs/ utils/ views/common/configs/

Author: yusaku
Date: Wed Jun  5 17:28:18 2013
New Revision: 1489974

URL: http://svn.apache.org/r1489974
Log:
AMBARI-2285. Make capacity-scheduler compatible with YARN. (Andrii Tkach via yusaku)

Added:
    incubator/ambari/branches/branch-1.4.0/ambari-web/app/data/HDP2/custom_configs.js
Modified:
    incubator/ambari/branches/branch-1.4.0/ambari-web/app/config.js
    incubator/ambari/branches/branch-1.4.0/ambari-web/app/controllers/main/service/info/configs.js
    incubator/ambari/branches/branch-1.4.0/ambari-web/app/controllers/wizard/step8_controller.js
    incubator/ambari/branches/branch-1.4.0/ambari-web/app/data/custom_configs.js
    incubator/ambari/branches/branch-1.4.0/ambari-web/app/styles/application.less
    incubator/ambari/branches/branch-1.4.0/ambari-web/app/templates/common/configs/capacity_scheduler.hbs
    incubator/ambari/branches/branch-1.4.0/ambari-web/app/utils/config.js
    incubator/ambari/branches/branch-1.4.0/ambari-web/app/views/common/configs/services_config.js

Modified: incubator/ambari/branches/branch-1.4.0/ambari-web/app/config.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-web/app/config.js?rev=1489974&r1=1489973&r2=1489974&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-web/app/config.js (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-web/app/config.js Wed Jun  5 17:28:18 2013
@@ -47,7 +47,7 @@ App.supports = {
   secureCluster: false,
   reassignMaster: false,
   stackUpgrade: false,
-  capacitySchedulerUi: true,
+  capacitySchedulerUi: false,
   startStopAllServices: false,
   hiveOozieExtraDatabases: true,
   multipleHBaseMasters: false,

Modified: incubator/ambari/branches/branch-1.4.0/ambari-web/app/controllers/main/service/info/configs.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-web/app/controllers/main/service/info/configs.js?rev=1489974&r1=1489973&r2=1489974&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-web/app/controllers/main/service/info/configs.js (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-web/app/controllers/main/service/info/configs.js Wed Jun  5 17:28:18 2013
@@ -29,10 +29,18 @@ App.MainServiceInfoConfigsController = E
   uiConfigs: [],
   customConfig: [],
   isApplyingChanges: false,
-  serviceConfigs: App.config.get('preDefinedServiceConfigs'),
-  configs: App.config.get('preDefinedConfigProperties'),
-  configMapping: App.config.get('configMapping'),
-  customConfigs: require('data/custom_configs'),
+  serviceConfigs: function(){
+    return App.config.get('preDefinedServiceConfigs');
+  }.property('App.config.preDefinedServiceConfigs'),
+  configs: function(){
+    return App.config.get('preDefinedConfigProperties');
+  }.property('App.config.preDefinedConfigProperties'),
+  configMapping: function(){
+    return App.config.get('configMapping');
+  }.property('App.config.configMapping'),
+  customConfigs: function(){
+    return App.config.get('preDefinedCustomConfigs');
+  }.property('App.config.preDefinedCustomConfigs'),
   
   /**
    * During page load time, we get the host overrides from the server.

Modified: incubator/ambari/branches/branch-1.4.0/ambari-web/app/controllers/wizard/step8_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-web/app/controllers/wizard/step8_controller.js?rev=1489974&r1=1489973&r2=1489974&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-web/app/controllers/wizard/step8_controller.js (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-web/app/controllers/wizard/step8_controller.js Wed Jun  5 17:28:18 2013
@@ -1284,15 +1284,11 @@ App.WizardStep8Controller = Em.Controlle
     }
     if (selectedServices.someProperty('serviceName', 'MAPREDUCE2')) {
       this.applyConfigurationToSite(this.createMrSiteObj());
-      if (App.supports.capacitySchedulerUi) {
-        this.applyConfigurationToSite(this.createMapredQueueAcls());
-      }
+      this.applyConfigurationToSite(this.createMapredQueueAcls());
     }
     if (selectedServices.someProperty('serviceName', 'YARN')) {
       this.applyConfigurationToSite(this.createYarnSiteObj());
-      if (App.supports.capacitySchedulerUi) {
-        this.applyConfigurationToSite(this.createCapacityScheduler());
-      }
+      this.applyConfigurationToSite(this.createCapacityScheduler());
     }
     if (selectedServices.someProperty('serviceName', 'HBASE')) {
       this.applyConfigurationToSite(this.createHbaseSiteObj());

Added: incubator/ambari/branches/branch-1.4.0/ambari-web/app/data/HDP2/custom_configs.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-web/app/data/HDP2/custom_configs.js?rev=1489974&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-web/app/data/HDP2/custom_configs.js (added)
+++ incubator/ambari/branches/branch-1.4.0/ambari-web/app/data/HDP2/custom_configs.js Wed Jun  5 17:28:18 2013
@@ -0,0 +1,127 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+module.exports =
+  [
+    {
+      "id": "site property",
+      "name": "yarn.scheduler.capacity.root.<queue-name>.capacity",
+      "displayName": "Capacity",
+      "value": '',
+      "defaultValue": '',
+      "description": "Percentage of the number of slots in the cluster that are made to be available for jobs in this queue. The sum of capacities for all queues should be less than or equal 100.",
+      "isVisible": true,
+      "isRequired": true,
+      "serviceName": "",
+      "category": "CapacityScheduler",
+      "unit": "%",
+      "isQueue": true,
+      "filename": 'capacity-scheduler.xml',
+      "inTable": true,
+      "index": 1
+    },
+    {
+      "id": "site property",
+      "name": "yarn.scheduler.capacity.root.<queue-name>.maximum-capacity",
+      "displayName": "Max Capacity",
+      "value": '',
+      "defaultValue": '100',
+      "displayType": "int",
+      "description": "Defines a limit beyond which a queue cannot use the capacity of the cluster." +
+        "This provides a means to limit how much excess capacity a queue can use. By default, there is no limit." +
+        "The Max Capacity of a queue can only be greater than or equal to its minimum capacity. " +
+        "This property could be to curtail certain jobs which are long running in nature from occupying more than a certain " +
+        "percentage of the cluster, which in the absence of pre-emption, could lead to capacity guarantees of other queues being affected. " +
+        "One important thing to note is that maximum-capacity is a percentage , so based on the cluster's capacity it would change. " +
+        "So if large no of nodes or racks get added to the cluster, Max Capacity in absolute terms would increase accordingly. ",
+      "isVisible": true,
+      "isRequired": true,
+      "serviceName": "YARN",
+      "category": "CapacityScheduler",
+      "unit": "%",
+      "valueRange": [0, 100],
+      "isQueue": true,
+      "filename": 'capacity-scheduler.xml',
+      "inTable": true,
+      "index": 2
+    },
+    {
+      "id": "site property",
+      "name": "yarn.scheduler.capacity.root.<queue-name>.user-limit-factor",
+      "displayName": "User Limit Factor",
+      "value": '',
+      "defaultValue": '1',
+      "displayType": "int",
+      "description": "The multiple of the queue capacity which can be configured to allow a single user to acquire more slots. " +
+        "By default this is set to 1 which ensure that a single user can never take more than the queue's configured capacity " +
+        "irrespective of how idle the cluster is.",
+      "isVisible": true,
+      "isRequired": true,
+      "serviceName": "YARN",
+      "category": "CapacityScheduler",
+      "isQueue": true,
+      "filename": 'capacity-scheduler.xml',
+      "inTable": true,
+      "index": 7
+    },
+    {
+      "id": "site property",
+      "name": "yarn.scheduler.capacity.root.<queue-name>.state",
+      "displayName": "State",
+      "value": '',
+      "defaultValue": 'RUNNING',
+      "description": "state",
+      "isVisible": true,
+      "isRequired": true,
+      "serviceName": "YARN",
+      "category": "CapacityScheduler",
+      "isQueue": true,
+      "filename": 'capacity-scheduler.xml',
+      "inTable": true,
+      "index": 8
+    },
+    {
+      "id": "site property",
+      "name": "yarn.scheduler.capacity.root.<queue-name>.acl_submit_jobs",
+      "displayName": "",
+      "value": '',
+      "defaultValue": '*',
+      "description": "",
+      "isVisible": false,
+      "isRequired": true,
+      "serviceName": "YARN",
+      "category": "CapacityScheduler",
+      "isQueue": true,
+      "filename": 'capacity-scheduler.xml'
+    },
+    {
+      "id": "site property",
+      "name": "yarn.scheduler.capacity.root.<queue-name>.acl_administer_jobs",
+      "displayName": "",
+      "value": '',
+      "defaultValue": '*',
+      "description": "",
+      "isVisible": false,
+      "isRequired": true,
+      "serviceName": "YARN",
+      "category": "CapacityScheduler",
+      "isQueue": true,
+      "filename": 'capacity-scheduler.xml'
+    }
+  ]

Modified: incubator/ambari/branches/branch-1.4.0/ambari-web/app/data/custom_configs.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-web/app/data/custom_configs.js?rev=1489974&r1=1489973&r2=1489974&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-web/app/data/custom_configs.js (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-web/app/data/custom_configs.js Wed Jun  5 17:28:18 2013
@@ -24,7 +24,7 @@ module.exports =
       "name": "mapred.capacity-scheduler.queue.<queue-name>.capacity",
       "displayName": "Capacity",
       "value": '',
-      "defaultValue": '',
+      "defaultValue": '100',
       "description": "Percentage of the number of slots in the cluster that are made to be available for jobs in this queue. The sum of capacities for all queues should be less than or equal 100.",
       "isVisible": true,
       "isRequired": true,
@@ -33,6 +33,7 @@ module.exports =
       "unit": "%",
       "isQueue": true,
       "filename": 'capacity-scheduler.xml',
+      "inTable": true,
       "index": 1
     },
     {
@@ -40,7 +41,7 @@ module.exports =
       "name": "mapred.capacity-scheduler.queue.<queue-name>.maximum-capacity",
       "displayName": "Max Capacity",
       "value": '',
-      "defaultValue": 100,
+      "defaultValue": '100',
       "displayType": "int",
       "description": "Defines a limit beyond which a queue cannot use the capacity of the cluster." +
         "This provides a means to limit how much excess capacity a queue can use. By default, there is no limit." +
@@ -57,6 +58,7 @@ module.exports =
       "valueRange": [0, 100],
       "isQueue": true,
       "filename": 'capacity-scheduler.xml',
+      "inTable": true,
       "index": 2
     },
     {
@@ -64,7 +66,7 @@ module.exports =
       "name": "mapred.capacity-scheduler.queue.<queue-name>.minimum-user-limit-percent",
       "displayName": "Min User Limit",
       "value": '',
-      "defaultValue": 100,
+      "defaultValue": '100',
       "displayType": "int",
       "description": "Each queue enforces a limit on the percentage of resources allocated to a user at any given time, " +
         "if there is competition for them. This user limit can vary between a minimum and maximum value. " +
@@ -81,6 +83,7 @@ module.exports =
       "valueRange": [1, 100],
       "isQueue": true,
       "filename": 'capacity-scheduler.xml',
+      "inTable": true,
       "index": 9
     },
     {
@@ -88,7 +91,7 @@ module.exports =
       "name": "mapred.capacity-scheduler.queue.<queue-name>.user-limit-factor",
       "displayName": "User Limit Factor",
       "value": '',
-      "defaultValue": 1,
+      "defaultValue": '1',
       "displayType": "int",
       "description": "The multiple of the queue capacity which can be configured to allow a single user to acquire more slots. " +
         "By default this is set to 1 which ensure that a single user can never take more than the queue's configured capacity " +
@@ -99,6 +102,7 @@ module.exports =
       "category": "CapacityScheduler",
       "isQueue": true,
       "filename": 'capacity-scheduler.xml',
+      "inTable": true,
       "index": 8
     },
     {
@@ -106,7 +110,7 @@ module.exports =
       "name": "mapred.capacity-scheduler.queue.<queue-name>.supports-priority",
       "displayName": "Supports Priority",
       "value": 'false',
-      "defaultValue": false,
+      "defaultValue": 'false',
       "displayType": "checkbox",
       "description": "If true, priorities of jobs will be taken into account in scheduling decisions.",
       "isVisible": true,
@@ -115,6 +119,7 @@ module.exports =
       "category": "CapacityScheduler",
       "isQueue": true,
       "filename": 'capacity-scheduler.xml',
+      "inTable": true,
       "index": 7
     },
     {
@@ -122,37 +127,35 @@ module.exports =
       "name": "mapred.queue.<queue-name>.acl-submit-job",
       "displayName": "",
       "value": '',
-      "defaultValue": '',
+      "defaultValue": '*',
       "description": "",
       "isVisible": false,
       "isRequired": true,
       "serviceName": "MAPREDUCE",
       "category": "CapacityScheduler",
       "isQueue": true,
-      "filename": 'mapred-queue-acls.xml',
-      "index": 13
+      "filename": 'mapred-queue-acls.xml'
     },
     {
       "id": "site property",
       "name": "mapred.queue.<queue-name>.acl-administer-jobs",
       "displayName": "",
       "value": '',
-      "defaultValue": '',
+      "defaultValue": '*',
       "description": "",
       "isVisible": false,
       "isRequired": true,
       "serviceName": "MAPREDUCE",
       "category": "CapacityScheduler",
       "isQueue": true,
-      "filename": 'mapred-queue-acls.xml',
-      "index": 14
+      "filename": 'mapred-queue-acls.xml'
     },
     {
       "id": "site property",
       "name": "mapred.capacity-scheduler.queue.<queue-name>.maximum-initialized-active-tasks",
       "displayName": "Max initialized active tasks",
       "value": '',
-      "defaultValue": 200000,
+      "defaultValue": '200000',
       "displayType": "int",
       "description": "The maximum number of tasks, across all jobs in the queue, which can be initialized concurrently. " +
         "Once the queue's jobs exceed this limit they will be queued on disk.",
@@ -169,7 +172,7 @@ module.exports =
       "name": "mapred.capacity-scheduler.queue.<queue-name>.maximum-initialized-active-tasks-per-user",
       "displayName": "Max initialized active tasks per user",
       "value": '',
-      "defaultValue": 100000,
+      "defaultValue": '100000',
       "displayType": "int",
       "description": "The maximum number of tasks per-user, across all the of the user's jobs in the queue, which " +
         "can be initialized concurrently. Once the user's jobs exceed this limit they will be queued on disk.",
@@ -186,7 +189,7 @@ module.exports =
       "name": "mapred.capacity-scheduler.queue.<queue-name>.init-accept-jobs-factor",
       "displayName": "Init accept jobs factor",
       "value": '',
-      "defaultValue": 10,
+      "defaultValue": '10',
       "displayType": "int",
       "description": "The multiple of (maximum-system-jobs * queue-capacity) used to determine the number of " +
         "jobs which are accepted by the scheduler. The default value is 10. If number of jobs submitted to " +

Modified: incubator/ambari/branches/branch-1.4.0/ambari-web/app/styles/application.less
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-web/app/styles/application.less?rev=1489974&r1=1489973&r2=1489974&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-web/app/styles/application.less (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-web/app/styles/application.less Wed Jun  5 17:28:18 2013
@@ -616,8 +616,8 @@ h1 {
     }
     form.form-horizontal {
       margin-left: 20px;
-      .control-label {
-        text-align: left;
+      .control-label-span {
+        word-wrap: break-word;
       }
     }
     table tr, svg {

Modified: incubator/ambari/branches/branch-1.4.0/ambari-web/app/templates/common/configs/capacity_scheduler.hbs
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-web/app/templates/common/configs/capacity_scheduler.hbs?rev=1489974&r1=1489973&r2=1489974&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-web/app/templates/common/configs/capacity_scheduler.hbs (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-web/app/templates/common/configs/capacity_scheduler.hbs Wed Jun  5 17:28:18 2013
@@ -35,14 +35,9 @@
             <table class="table table-bordered table-striped">
                 <thead>
                 <tr>
-                    <th>{{t services.mapReduce.config.queue.name}}</th>
-                    <th>{{t common.users}}</th>
-                    <th>{{t services.mapReduce.config.queue.groups}}</th>
-                    <th>{{t services.mapReduce.config.queue.capacity}}</th>
-                    <th>{{t services.mapReduce.config.queue.maxCapacity}}</th>
-                    <th>{{t services.mapReduce.config.queue.minUserLimit}}</th>
-                    <th>{{t services.mapReduce.config.queue.userLimitFactor}}</th>
-                    <th>{{t services.mapReduce.config.queue.supportsPriority}}</th>
+                    {{#each header in view.tableHeaders}}
+                      <th>{{header}}</th>
+                    {{/each}}
                 </tr>
                 </thead>
                 <tbody>
@@ -51,13 +46,9 @@
                       <td><a href="javascript:void(0)">
                           <i {{bindAttr style="queue.color"}} class="marker"></i>{{queue.name}}</a>
                       </td>
-                      <td>{{queue.users}}</td>
-                      <td>{{queue.groups}}</td>
-                      <td>{{queue.capacity}}&#37;</td>
-                      <td>{{queue.maxCapacity}}&#37;</td>
-                      <td>{{queue.minUserLimit}}&#37;</td>
-                      <td>{{queue.userLimitFactor}}</td>
-                      <td>{{queue.supportsPriority}}</td>
+                      {{#each config in queue.configs}}
+                        <td>{{config.value}}</td>
+                      {{/each}}
                   </tr>
                   {{/each}}
                 </tbody>

Modified: incubator/ambari/branches/branch-1.4.0/ambari-web/app/utils/config.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-web/app/utils/config.js?rev=1489974&r1=1489973&r2=1489974&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-web/app/utils/config.js (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-web/app/utils/config.js Wed Jun  5 17:28:18 2013
@@ -25,6 +25,10 @@ var globalPropertyToServicesMap = null;
 
 App.config = Em.Object.create({
 
+  isHDP2: function(){
+    return (stringUtils.compareVersions(App.get('currentStackVersionNumber'), "2.0") === 1 ||
+      stringUtils.compareVersions(App.get('currentStackVersionNumber'), "2.0") === 0)
+  }.property('App.currentStackVersionNumber'),
   preDefinedServiceConfigs: function(){
     var configs = this.get('preDefinedConfigProperties');
     var services = [];
@@ -35,30 +39,36 @@ App.config = Em.Object.create({
     return services;
   }.property('preDefinedConfigProperties'),
   configMapping: function() {
-      if (stringUtils.compareVersions(App.get('currentStackVersionNumber'), "2.0") === 1 ||
-        stringUtils.compareVersions(App.get('currentStackVersionNumber'), "2.0") === 0) {
+      if (this.get('isHDP2')) {
         return require('data/HDP2/config_mapping');
       }
     return require('data/config_mapping');
-  }.property('App.currentStackVersionNumber'),
+  }.property('isHDP2'),
   preDefinedConfigProperties: function() {
-    if (stringUtils.compareVersions(App.get('currentStackVersionNumber'), "2.0") === 1 ||
-      stringUtils.compareVersions(App.get('currentStackVersionNumber'), "2.0") === 0) {
+    if (this.get('isHDP2')) {
       return require('data/HDP2/config_properties').configProperties;
     }
     return require('data/config_properties').configProperties;
-  }.property('App.currentStackVersionNumber'),
-  preDefinedCustomConfigs: require('data/custom_configs'),
+  }.property('isHDP2'),
+  preDefinedCustomConfigs: function () {
+    if (this.get('isHDP2')) {
+      return require('data/HDP2/custom_configs');
+    }
+    return require('data/custom_configs');
+  }.property('isHDP2'),
   //categories which contain custom configs
   categoriesWithCustom: ['CapacityScheduler'],
   //configs with these filenames go to appropriate category not in Advanced
   customFileNames: function() {
     if (App.supports.capacitySchedulerUi) {
+      if(this.get('isHDP2')){
+        return ['capacity-scheduler.xml'];
+      }
       return ['capacity-scheduler.xml', 'mapred-queue-acls.xml'];
     } else {
       return [];
     }
-  }.property(''),
+  }.property('isHDP2'),
   /**
    * Cache of loaded configurations. This is useful in not loading
    * same configuration multiple times. It is populated in multiple
@@ -127,6 +137,20 @@ App.config = Em.Object.create({
       config.isRequired = true;
     }
   },
+  capacitySchedulerFilter: function () {
+    var yarnRegex = /^yarn\.scheduler\.capacity\.root\.(?!unfunded)([a-z]([\_\-a-z0-9]{0,50}))\.(acl_administer_jobs|acl_submit_jobs|state|user-limit-factor|maximum-capacity|capacity)$/i;
+    var self = this;
+    if(this.get('isHDP2')){
+      return function (_config) {
+        return (yarnRegex.test(_config.name));
+      }
+    } else {
+      return function (_config) {
+        return (_config.name.indexOf('mapred.capacity-scheduler.queue.') !== -1) ||
+          (/^mapred\.queue\.[a-z]([\_\-a-z0-9]{0,50})\.(acl-administer-jobs|acl-submit-job)$/i.test(_config.name));
+      }
+    }
+  }.property('isHDP2'),
   /**
    * return:
    *   configs,
@@ -309,64 +333,11 @@ App.config = Em.Object.create({
   addCustomConfigs: function (configs) {
     var preDefinedCustomConfigs = $.extend(true, [], this.get('preDefinedCustomConfigs'));
     var stored = configs.filter(function (_config) {
-      if (this.get('categoriesWithCustom').contains(_config.category)) return true;
+      return this.get('categoriesWithCustom').contains(_config.category);
     }, this);
-    var queueProperties = stored.filter(function (_config) {
-      if ((_config.name.indexOf('mapred.capacity-scheduler.queue.') !== -1) ||
-        (/mapred.queue.[a-z]([\_\-a-z0-9]{0,50}).acl-administer-jobs/i.test(_config.name)) ||
-        (/mapred.queue.[a-z]([\_\-a-z0-9]{0,50}).acl-submit-job/i.test(_config.name))) {
-        return true;
-      }
-    });
+    var queueProperties = stored.filter(this.get('capacitySchedulerFilter'));
     if (queueProperties.length) {
       queueProperties.setEach('isQueue', true);
-    } else {
-      queueProperties = preDefinedCustomConfigs.filterProperty('isQueue');
-      queueProperties.forEach(function (customConfig) {
-        this.setDefaultQueue(customConfig, 'default');
-        configs.push(customConfig);
-      }, this);
-    }
-  },
-  /**
-   * set values to properties of queue
-   * @param customConfig
-   * @param queueName
-   */
-  setDefaultQueue: function (customConfig, queueName) {
-    customConfig.name = customConfig.name.replace(/<queue-name>/, queueName);
-    //default values of queue
-    switch (customConfig.name) {
-      case 'mapred.capacity-scheduler.queue.' + queueName + '.capacity':
-        customConfig.value = '100';
-        break;
-      case 'mapred.capacity-scheduler.queue.' + queueName + '.maximum-capacity':
-        customConfig.value = '100';
-        break;
-      case 'mapred.capacity-scheduler.queue.' + queueName + '.minimum-user-limit-percent':
-        customConfig.value = '100';
-        break;
-      case 'mapred.capacity-scheduler.queue.' + queueName + '.user-limit-factor':
-        customConfig.value = '1';
-        break;
-      case 'mapred.capacity-scheduler.queue.' + queueName + '.maximum-initialized-active-tasks':
-        customConfig.value = '200000';
-        break;
-      case 'mapred.capacity-scheduler.queue.' + queueName + '.maximum-initialized-active-tasks-per-user':
-        customConfig.value = '100000';
-        break;
-      case 'mapred.capacity-scheduler.queue.' + queueName + '.init-accept-jobs-factor':
-        customConfig.value = '10';
-        break;
-      case 'mapred.capacity-scheduler.queue.' + queueName + '.supports-priority':
-        customConfig.value = 'false';
-        break;
-      case 'mapred.queue.' + queueName + '.acl-submit-job':
-        customConfig.value = '*';
-        break;
-      case 'mapred.queue.' + queueName + '.acl-administer-jobs':
-        customConfig.value = '*';
-        break;
     }
   },
 

Modified: incubator/ambari/branches/branch-1.4.0/ambari-web/app/views/common/configs/services_config.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.4.0/ambari-web/app/views/common/configs/services_config.js?rev=1489974&r1=1489973&r2=1489974&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.4.0/ambari-web/app/views/common/configs/services_config.js (original)
+++ incubator/ambari/branches/branch-1.4.0/ambari-web/app/views/common/configs/services_config.js Wed Jun  5 17:28:18 2013
@@ -512,7 +512,9 @@ App.ServiceConfigCapacityScheduler = App
   category: null,
   service: null,
   serviceConfigs: null,
-  customConfigs: require('data/custom_configs'),
+  customConfigs: function(){
+    return App.config.get('preDefinedCustomConfigs');
+  }.property('App.config.preDefinedCustomConfigs'),
   /**
    * configs filtered by capacity-scheduler category
    */
@@ -533,14 +535,20 @@ App.ServiceConfigCapacityScheduler = App
     this.createEmptyQueue(this.get('customConfigs').filterProperty('isQueue'));
   },
   //list of fields which will be populated by default in a new queue
-  fieldsToPopulate: [
-    "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"
-  ],
+  fieldsToPopulate: function(){
+    if(App.config.get('isHDP2')){
+      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.config.isHDP2'),
   /**
    * create empty queue
    * take some queue then copy it and set all config values to null
@@ -555,7 +563,7 @@ App.ServiceConfigCapacityScheduler = App
     customConfigs.forEach(function(config){
       var newConfig = $.extend({}, config);
       if(fieldsToPopulate.contains(config.name)){
-        App.config.setDefaultQueue(newConfig, emptyQueue.name);
+        newConfig.value = config.defaultValue;
       }
       newConfig = App.ServiceConfigProperty.create(newConfig);
       newConfig.validate();
@@ -563,82 +571,91 @@ App.ServiceConfigCapacityScheduler = App
     });
     this.set('emptyQueue', emptyQueue);
   },
-  queues: function(){
-    var configs = this.get('categoryConfigs').filterProperty('isQueue', true);
+  deriveQueueNames: function(configs){
     var queueNames = [];
-    var queues = [];
     configs.mapProperty('name').forEach(function(name){
-      var queueName = /^mapred\.capacity-scheduler\.queue\.(.*?)\./.exec(name);
+      var queueName;
+      if(App.config.get('isHDP2')){
+        queueName = /^yarn\.scheduler\.capacity\.root\.(.*?)\./.exec(name);
+      } else {
+        queueName = /^mapred\.capacity-scheduler\.queue\.(.*?)\./.exec(name);
+      }
       if(queueName){
         queueNames.push(queueName[1]);
       }
     });
-    queueNames = queueNames.uniq();
+    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.filterConfigsByQueue(queueName, configs)
+        configs: this.groupConfigsByQueue(queueName, configs)
       })
     }, this);
     return queues;
   }.property('queueObserver'),
   /**
-   * filter configs by queue
+   * group configs by queue
    * @param queueName
    * @param configs
    */
-  filterConfigsByQueue: function (queueName, configs) {
-    var customConfigs = this.get('customConfigs');
+  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.name.replace('queue.' + queueName, 'queue.<queue-name>'));
-      if ((config.name.indexOf('mapred.capacity-scheduler.queue.' + queueName) !== -1) ||
-        (config.name.indexOf('mapred.queue.' + queueName) !== -1)) {
-        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('index', customConfig.index);
-        }
+      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);
       }
     });
-    //each queue consists of 10 properties if less then add missing properties
-    if(queue.length < 10){
-      this.addMissingProperties(queue, queueName);
+    if(queue.length < customConfigs.length){
+      this.addMissingProperties(queue, customConfigs);
     }
     return queue;
   },
   /**
-   * add missing properties to queue
+   * add missing properties to queue when they don't come from server
    * @param queue
-   * @param queueName
+   * @param customConfigs
    */
-  addMissingProperties: function(queue, queueName){
-    var customConfigs = this.get('customConfigs');
+  addMissingProperties: function(queue, customConfigs){
     customConfigs.forEach(function(_config){
-      var serviceConfigProperty = $.extend({}, _config);
-      serviceConfigProperty.name = serviceConfigProperty.name.replace(/<queue-name>/, queueName);
-      if(!queue.someProperty('name', serviceConfigProperty.name)){
-        App.config.setDefaultQueue(serviceConfigProperty, queueName);
-        serviceConfigProperty = App.ServiceConfigProperty.create(serviceConfigProperty);
+      var serviceConfigProperty;
+      if(!queue.someProperty('name', _config.name)){
+        _config.value = _config.defaultValue;
+        serviceConfigProperty = App.ServiceConfigProperty.create(_config);
         serviceConfigProperty.validate();
         queue.push(serviceConfigProperty);
       }
     }, this);
   },
   /**
-   * format table content from queues
+   * convert queues to table content
    */
   tableContent: function(){
     var result = [];
     this.get('queues').forEach(function(queue){
-      var usersAndGroups = queue.configs.findProperty('name', 'mapred.queue.' + queue.name + '.acl-submit-job').get('value');
+      var usersAndGroups = queue.configs.findProperty('name', this.getUserAndGroupNames(queue.name)[0]).get('value');
       usersAndGroups = (usersAndGroups) ? usersAndGroups.split(' ') : [''];
       if(usersAndGroups.length == 1){
         usersAndGroups.push('');
@@ -646,23 +663,70 @@ App.ServiceConfigCapacityScheduler = App
       var queueObject = {
         name: queue.name,
         color: 'background-color:' + queue.color + ';',
-        users: usersAndGroups[0],
-        groups: usersAndGroups[1],
-        capacity: queue.configs.findProperty('name', 'mapred.capacity-scheduler.queue.' + queue.name + '.capacity').get('value'),
-        maxCapacity: queue.configs.findProperty('name', 'mapred.capacity-scheduler.queue.' + queue.name + '.maximum-capacity').get('value'),
-        minUserLimit: queue.configs.findProperty('name', 'mapred.capacity-scheduler.queue.' + queue.name + '.minimum-user-limit-percent').get('value'),
-        userLimitFactor: queue.configs.findProperty('name', 'mapred.capacity-scheduler.queue.' + queue.name + '.user-limit-factor').get('value'),
-        supportsPriority: queue.configs.findProperty('name', 'mapred.capacity-scheduler.queue.' + queue.name + '.supports-priority').get('value')
+        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: [],
+  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.config.get('isHDP2')){
+      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++) {
@@ -683,7 +747,9 @@ App.ServiceConfigCapacityScheduler = App
     var adminConfig;
     queue.name = queue.configs.findProperty('name', 'queueName').get('value');
     queue.configs.forEach(function(config){
-      if(config.name == 'mapred.queue.<queue-name>.acl-administer-jobs'){
+      var adminName = this.getUserAndGroupNames()[1];
+      var submitName = this.getUserAndGroupNames()[0];
+      if(config.name == adminName){
         if(config.type == 'USERS'){
           admin[0] = config.value;
         }
@@ -694,7 +760,7 @@ App.ServiceConfigCapacityScheduler = App
           adminConfig = config;
         }
       }
-      if(config.name == 'mapred.queue.<queue-name>.acl-submit-job'){
+      if(config.name == submitName){
         if(config.type == 'USERS'){
           submit[0] = config.value;
         }
@@ -710,7 +776,7 @@ App.ServiceConfigCapacityScheduler = App
       if(config.isQueue){
         serviceConfigs.push(config);
       }
-    });
+    }, this);
     adminConfig.set('value', admin.join(' '));
     submitConfig.set('value', submit.join(' '));
     this.set('queueObserver', new Date().getTime());
@@ -744,22 +810,23 @@ App.ServiceConfigCapacityScheduler = App
       var configName = _config.get('name');
       var admin = [];
       var submit = [];
+      //comparison executes including 'queue.<queue-name>' to avoid false matches
+      var queueNamePrefix = App.config.get('isHDP2') ? 'root.' : 'queue.';
       if(configNames.contains(_config.get('name'))){
-        if(configName == 'mapred.queue.' + queue.name + '.acl-submit-job'){
+        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 == 'mapred.queue.' + queue.name + '.acl-administer-jobs'){
+        } 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());
         }
-        //comparison executes including 'queue.<queue-name>' to avoid false matches
-        _config.set('name', configName.replace('queue.' + queue.name, 'queue.' + queue.configs.findProperty('name', 'queueName').get('value')));
+        _config.set('name', configName.replace(queueNamePrefix + queue.name, queueNamePrefix + queue.configs.findProperty('name', 'queueName').get('value')));
       }
-    });
+    }, this);
     this.set('queueObserver', new Date().getTime());
   },
   pieChart: App.ChartPieView.extend({
@@ -776,9 +843,12 @@ App.ServiceConfigCapacityScheduler = App
       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: parseInt(queue.configs.findProperty('name', 'mapred.capacity-scheduler.queue.' + queue.name + '.capacity').get('value')),
+          value: value,
           color: queue.color
         })
       });
@@ -848,12 +918,9 @@ App.ServiceConfigCapacityScheduler = App
         }
         var content = this.get('content');
         var configs = content.configs.filter(function(config){
-          if((config.name == 'mapred.queue.' + content.name + '.acl-submit-job' ||
-             config.name == 'mapred.queue.' + content.name + '.acl-administer-jobs') &&
-             (config.isQueue)){
-            return false;
-          }
-          return true;
+          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'),
@@ -893,25 +960,15 @@ App.ServiceConfigCapacityScheduler = App
       content: function(){
         var content = (queueName) ? self.get('queues').findProperty('name', queueName) : self.get('emptyQueue');
         var configs = [];
-        var tableContent = self.get('tableContent');
         // copy of queue configs
         content.configs.forEach(function (config, index) {
-          if (config.name == 'mapred.capacity-scheduler.queue.' + content.name + '.capacity') {
+          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 capacities = [];
-                var capacitySum = 0;
-                if(tableContent){
-                  capacities = tableContent.mapProperty('capacity');
-                  for (var i = 0, l = capacities.length; i < l; i++) {
-                    capacitySum += parseInt(capacities[i]);
-                  }
-                  if (content.name != '<queue-name>') {
-                    capacitySum = capacitySum - parseInt(tableContent.findProperty('name', content.name).capacity);
-                  }
-                }
+                var capacitySum = self.getQueuesCapacitySum(content.name);
                 if (value == '') {
                   if (this.get('isRequired')) {
                     this.set('errorMessage', 'This is required');
@@ -945,6 +1002,19 @@ App.ServiceConfigCapacityScheduler = App
               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 = {
@@ -1000,8 +1070,8 @@ App.ServiceConfigCapacityScheduler = App
        */
       insertExtraConfigs: function(content){
         var that = this;
-        var admin = content.configs.findProperty('name', 'mapred.queue.' + content.name + '.acl-administer-jobs').get('value');
-        var submit = content.configs.findProperty('name', 'mapred.queue.' + content.name + '.acl-submit-job').get('value');
+        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){
@@ -1010,7 +1080,7 @@ App.ServiceConfigCapacityScheduler = App
         if(submit.length < 2){
           submit.push('');
         }
-        var newField = App.ServiceConfigProperty.create({
+        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'),
@@ -1049,11 +1119,11 @@ App.ServiceConfigCapacityScheduler = App
           isEditable: self.get('canEdit'),
           index: 0
         });
-        newField.validate();
-        content.configs.unshift(newField);
+        nameField.validate();
+        content.configs.unshift(nameField);
 
         var submitUser = App.ServiceConfigProperty.create({
-          name: 'mapred.queue.' + content.name + '.acl-submit-job',
+          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'),
@@ -1066,7 +1136,7 @@ App.ServiceConfigCapacityScheduler = App
         });
 
         var submitGroup = App.ServiceConfigProperty.create({
-          name: 'mapred.queue.' + content.name + '.acl-submit-job',
+          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],
@@ -1079,7 +1149,7 @@ App.ServiceConfigCapacityScheduler = App
         });
 
         var adminUser = App.ServiceConfigProperty.create({
-          name: 'mapred.queue.' + content.name + '.acl-administer-jobs',
+          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],
@@ -1092,7 +1162,7 @@ App.ServiceConfigCapacityScheduler = App
         });
 
         var adminGroup = App.ServiceConfigProperty.create({
-          name: 'mapred.queue.' + content.name + '.acl-administer-jobs',
+          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'),
@@ -1136,8 +1206,8 @@ App.ServiceConfigCapacityScheduler = App
       },
       /**
        * Validate by follow rules:
-       * Users can be blank. If this is blank, Groups must not be blank.
-       * Groups can be blank. If this is blank, Users must not be blank.
+       * 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
        */