incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srima...@apache.org
Subject git commit: AMBARI-3699. App.ServiceConfig needs 'configsValidator' validating across service values. (onechiporenko, srimanth via srimanth)
Date Wed, 06 Nov 2013 02:39:41 GMT
Updated Branches:
  refs/heads/trunk b5d956052 -> a4cba0e17


AMBARI-3699. App.ServiceConfig needs 'configsValidator' validating across service values. (onechiporenko, srimanth via srimanth)


Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/a4cba0e1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/a4cba0e1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/a4cba0e1

Branch: refs/heads/trunk
Commit: a4cba0e17a55911ba4acf8cdbe00c0ce9d89faf1
Parents: b5d9560
Author: Srimanth Gunturi <sgunturi@hortonworks.com>
Authored: Tue Nov 5 18:27:02 2013 -0800
Committer: Srimanth Gunturi <sgunturi@hortonworks.com>
Committed: Tue Nov 5 18:39:24 2013 -0800

----------------------------------------------------------------------
 ambari-web/app/assets/test/tests.js             |   2 +-
 .../controllers/global/cluster_controller.js    |   2 +-
 .../app/controllers/global/update_controller.js |   2 +-
 .../controllers/main/service/info/configs.js    |  90 ++++++
 ambari-web/app/data/HDP2/site_properties.js     |  13 +
 ambari-web/app/data/service_configs.js          |   6 +-
 ambari-web/app/models/service_config.js         |  28 +-
 .../templates/common/configs/service_config.hbs |   3 +-
 ambari-web/app/utils/config.js                  |  15 +-
 .../defaults_providers/defaultsProvider.js      |  37 +++
 .../yarn_defaults_provider.js                   | 288 ++++++++++++++++++
 .../validators/mapreduce2_configs_validator.js  |  69 +++++
 .../validators/service_configs_validator.js     |  68 +++++
 .../validators/yarn_configs_validator.js        |  48 +++
 .../defaults_providers/defaultsProvider.js      |  37 ---
 .../yarn_defaults_provider.js                   | 288 ------------------
 .../yarn_defaults_provider_test.js              | 295 +++++++++++++++++++
 .../yarn_defaults_provider_test.js              | 295 -------------------
 18 files changed, 955 insertions(+), 631 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a4cba0e1/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index 37edd6a..7e07585 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -61,7 +61,7 @@ require('test/mappers/runs_mapper_test');
 require('test/mappers/service_mapper_test');
 require('test/mappers/status_mapper_test');
 require('test/mappers/users_mapper_test');
-require('test/utils/defaults_providers/yarn_defaults_provider_test');
+require('test/utils/configs/defaults_providers/yarn_defaults_provider_test');
 require('test/utils/config_test');
 require('test/utils/date_test');
 require('test/utils/config_test');

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a4cba0e1/ambari-web/app/controllers/global/cluster_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/cluster_controller.js b/ambari-web/app/controllers/global/cluster_controller.js
index dc9386e..009ef1e 100644
--- a/ambari-web/app/controllers/global/cluster_controller.js
+++ b/ambari-web/app/controllers/global/cluster_controller.js
@@ -320,7 +320,7 @@ App.ClusterController = Em.Controller.extend({
     }
     var clusterUrl = this.getUrl('/data/clusters/cluster.json', '?fields=Clusters');
     var hostsRealUrl = '/hosts?fields=Hosts/host_name,Hosts/public_host_name,Hosts/cpu_count,Hosts/total_mem,' +
-      'Hosts/host_status,Hosts/last_heartbeat_time,Hosts/os_arch,Hosts/os_type,Hosts/ip,host_components,' +
+      'Hosts/host_status,Hosts/last_heartbeat_time,Hosts/os_arch,Hosts/os_type,Hosts/ip,host_components,Hosts/disk_info,' +
       'metrics/disk,metrics/load/load_one,metrics/cpu/cpu_system,metrics/cpu/cpu_user,metrics/memory/mem_total,metrics/memory/mem_free';
     var usersUrl = App.testMode ? '/data/users/users.json' : App.apiPrefix + '/users/?fields=*';
     var racksUrl = "/data/racks/racks.json";

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a4cba0e1/ambari-web/app/controllers/global/update_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/update_controller.js b/ambari-web/app/controllers/global/update_controller.js
index addc0c7..fc50f10 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -56,7 +56,7 @@ App.UpdateController = Em.Controller.extend({
 
   updateHost:function(callback) {
     var testUrl = App.get('isHadoop2Stack') ? '/data/hosts/HDP2/hosts.json' : '/data/hosts/hosts.json';
-    var hostsUrl = this.getUrl(testUrl, '/hosts?fields=Hosts/host_name,Hosts/last_heartbeat_time,' +
+    var hostsUrl = this.getUrl(testUrl, '/hosts?fields=Hosts/host_name,Hosts/last_heartbeat_time,Hosts/disk_info,' +
       'metrics/disk,metrics/load/load_one,metrics/cpu/cpu_system,metrics/cpu/cpu_user,metrics/memory/mem_total,metrics/memory/mem_free');
     App.HttpClient.get(hostsUrl, App.hostsMapper, {
       complete: callback

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a4cba0e1/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index 67a5758..f6fa803 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -30,6 +30,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
   globalConfigs: [],
   uiConfigs: [],
   customConfig: [],
+  serviceConfigsData: require('data/service_configs'),
   isApplyingChanges: false,
   serviceConfigs: function () {
     return App.config.get('preDefinedServiceConfigs');
@@ -430,12 +431,82 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
   },
 
   /**
+   * Get info about hosts and host components to configDefaultsProviders
+   * @returns {{masterComponentHosts: Array, slaveComponentHosts: Array, hosts: {}}}
+   */
+  getInfoForDefaults: function() {
+
+    var slaveComponentHosts = [];
+    var slaves = App.HostComponent.find().filterProperty('isSlave', true).map(function(item) {
+      return Em.Object.create({
+        host: item.get('host.hostName'),
+        componentName: item.get('componentName')
+      });
+    });
+    slaves.forEach(function(slave) {
+      var s = slaveComponentHosts.findProperty('componentName', slave.componentName);
+      if (s) {
+        s.hosts.push({hostName: slave.host});
+      }
+      else {
+        slaveComponentHosts.push({
+          componentName: slave.get('componentName'),
+          hosts: [{hostName: slave.host}]
+        });
+      }
+    });
+
+    var masterComponentHosts = App.HostComponent.find().filterProperty('isMaster', true).map(function(item) {
+      return {
+        component: item.get('componentName'),
+        serviceId: item.get('service.serviceName'),
+        host: item.get('host.hostName')
+      }
+    });
+    var hosts = {};
+    App.Host.find().map(function(host) {
+      hosts[host.get('hostName')] = {
+        name: host.get('hostName'),
+        cpu: host.get('cpu'),
+        memory: host.get('memory'),
+        disk_info: host.get('diskInfo')
+      };
+    });
+
+    return {
+      masterComponentHosts: masterComponentHosts,
+      slaveComponentHosts: slaveComponentHosts,
+      hosts: hosts
+    };
+  },
+
+  /**
    * Load child components to service config object
    * @param configs
    * @param componentConfig
    * @param restartData
    */
   loadComponentConfigs: function (configs, componentConfig, restartData) {
+
+    var localDB = this.getInfoForDefaults();
+    var recommendedDefaults = {};
+    var s = this.get('serviceConfigsData').findProperty('serviceName', this.get('content.serviceName'));
+
+    var defaults = [];
+    if (s.defaultsProviders) {
+      s.defaultsProviders.forEach(function(defaultsProvider) {
+        var d = defaultsProvider.getDefaults(localDB);
+        defaults.push(d);
+        for (var name in d) {
+          recommendedDefaults[name] = d[name];
+        }
+      });
+    }
+    if (s.configsValidator) {
+      s.configsValidator.set('recommendedDefaults', recommendedDefaults);
+    }
+
+
     configs.forEach(function (_serviceConfigProperty) {
       console.log("config", _serviceConfigProperty);
       if (!_serviceConfigProperty) return;
@@ -464,6 +535,25 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
         serviceConfigProperty.set('restartRequiredMessage', message);
       }
       if (serviceConfigProperty.get('serviceName') === this.get('content.serviceName')) {
+
+        defaults.forEach(function(defaults) {
+          for(var name in defaults) {
+            if (serviceConfigProperty.name == name) {
+              serviceConfigProperty.set('value', defaults[name]);
+              serviceConfigProperty.set('defaultValue', defaults[name]);
+            }
+          }
+        });
+
+        if (s.configsValidator) {
+          var validators = s.configsValidator.get('configValidators');
+          for (var validatorName in validators) {
+            if (serviceConfigProperty.name == validatorName) {
+              serviceConfigProperty.set('serviceValidator', s.configsValidator);
+            }
+          }
+        }
+
         // serviceConfigProperty.serviceConfig = componentConfig;
         if (App.get('isAdmin')) {
           serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isReconfigurable'));

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a4cba0e1/ambari-web/app/data/HDP2/site_properties.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/data/HDP2/site_properties.js b/ambari-web/app/data/HDP2/site_properties.js
index f362220..8697c5f 100644
--- a/ambari-web/app/data/HDP2/site_properties.js
+++ b/ambari-web/app/data/HDP2/site_properties.js
@@ -201,6 +201,7 @@ module.exports =
       "id": "site property",
       "name": "yarn.scheduler.minimum-allocation-mb",
       "displayName": "yarn.scheduler.minimum-allocation-mb",
+      "displayType": "int",
       "value": "",
       "defaultValue": "",
       "serviceName": "YARN",
@@ -210,6 +211,7 @@ module.exports =
       "id": "site property",
       "name": "yarn.scheduler.maximum-allocation-mb",
       "displayName": "yarn.scheduler.maximum-allocation-mb",
+      "displayType": "int",
       "value": "",
       "defaultValue": "",
       "serviceName": "YARN",
@@ -219,6 +221,7 @@ module.exports =
       "id": "site property",
       "name": "yarn.nodemanager.resource.memory-mb",
       "displayName": "yarn.nodemanager.resource.memory-mb",
+      "displayType": "int",
       "value": "",
       "defaultValue": "",
       "serviceName": "YARN",
@@ -356,6 +359,16 @@ module.exports =
       "value": "",
       "defaultValue": ""
     },
+    {
+      "id": "site property",
+      "name": "yarn.app.mapreduce.am.resource.mb",
+      "displayName": "yarn.app.mapreduce.am.resource.mb",
+      "value": "",
+      "defaultValue": "",
+      "displayType": "int",
+      "category": "Advanced",
+      "serviceName": "MAPREDUCE2"
+    },
 
   /**********************************************oozie-site***************************************/
     {

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a4cba0e1/ambari-web/app/data/service_configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/data/service_configs.js b/ambari-web/app/data/service_configs.js
index b7857b1..6858b9b 100644
--- a/ambari-web/app/data/service_configs.js
+++ b/ambari-web/app/data/service_configs.js
@@ -18,7 +18,9 @@
 
 var App = require('app');
 require('models/service_config');
-require('utils/defaults_providers/yarn_defaults_provider');
+require('utils/configs/defaults_providers/yarn_defaults_provider');
+require('utils/configs/validators/yarn_configs_validator');
+require('utils/configs/validators/mapreduce2_configs_validator');
 
 module.exports = [
   {
@@ -66,6 +68,7 @@ module.exports = [
   {
     serviceName: 'YARN',
     displayName: 'YARN',
+    configsValidator: App.YARNConfigsValidator,
     defaultsProviders: [App.YARNDefaultsProvider],
     filename: 'yarn-site',
     configCategories: [
@@ -84,6 +87,7 @@ module.exports = [
     serviceName: 'MAPREDUCE2',
     displayName: 'MapReduce 2',
     filename: 'mapred-site',
+    configsValidator: App.MapReduce2ConfigsValidator,
     defaultsProviders: [App.YARNDefaultsProvider],
     configCategories: [
       App.ServiceConfigCategory.create({ name: 'HistoryServer', displayName : 'History Server', hostComponentNames : ['HISTORYSERVER']}),

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a4cba0e1/ambari-web/app/models/service_config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service_config.js b/ambari-web/app/models/service_config.js
index 0d1677b..774e7c9 100644
--- a/ambari-web/app/models/service_config.js
+++ b/ambari-web/app/models/service_config.js
@@ -147,6 +147,7 @@ App.ServiceConfigProperty = Ember.Object.extend({
   isVisible: true,
   isSecureConfig: false,
   errorMessage: '',
+  warnMessage: '',
   serviceConfig: null, // points to the parent App.ServiceConfig object
   filename: '',
   isOriginalSCP : true, // if true, then this is original SCP instance and its value is not overridden value.
@@ -156,11 +157,13 @@ App.ServiceConfigProperty = Ember.Object.extend({
   isUserProperty: null, // This property was added by user. Hence they get removal actions etc.
   isOverridable: true,
   error: false,
+  warn: false,
   overrideErrorTrigger: 0, //Trigger for overrridable property error
   isRestartRequired: false,
   restartRequiredMessage: 'Restart required',
   index: null, //sequence number in category
   editDone: false, //Text field: on focusOut: true, on focusIn: false
+  serviceValidator: null,
 
   /**
    * On Overridable property error message, change overrideErrorTrigger value to recount number of errors service have
@@ -486,6 +489,7 @@ App.ServiceConfigProperty = Ember.Object.extend({
     var values = [];//value split by "," to check UNIX users, groups list
 
     var isError = false;
+    var isWarn = false;
 
     if (typeof value === 'string' && value.length === 0) {
       if (this.get('isRequired')) {
@@ -619,13 +623,29 @@ App.ServiceConfigProperty = Ember.Object.extend({
         }
       }
     }
+    
+    var serviceValidator = this.get('serviceValidator');
+    if (serviceValidator!=null) {
+      var validationIssue = serviceValidator.validateConfig(this);
+      if (validationIssue) {
+    	this.set('warnMessage', validationIssue);
+    	isWarn = true;
+      }
+    }
 
-    if (!isError) {
-      this.set('errorMessage', '');
-      this.set('error', false);
+    if (!isWarn || isError) { // Errors get priority
+        this.set('warnMessage', '');
+        this.set('warn', false);
     } else {
-      this.set('error', true);
+        this.set('warn', true);
     }
+    
+    if (!isError) {
+        this.set('errorMessage', '');
+        this.set('error', false);
+      } else {
+        this.set('error', true);
+      }
   }.observes('value', 'retypedPassword')
 
 });

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a4cba0e1/ambari-web/app/templates/common/configs/service_config.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/configs/service_config.hbs b/ambari-web/app/templates/common/configs/service_config.hbs
index 7cec9c1..5199bd4 100644
--- a/ambari-web/app/templates/common/configs/service_config.hbs
+++ b/ambari-web/app/templates/common/configs/service_config.hbs
@@ -106,7 +106,7 @@
                           </span>
                           <div class="controls">
                             {{! Here serviceConfigBinding should ideally be serviceConfigPropertyBinding }}
-                              <div {{bindAttr class="errorMessage:error: :control-group"}}>
+                              <div {{bindAttr class="errorMessage:error: warnMessage:warning: :control-group"}}>
                                 {{view viewClass serviceConfigBinding="this" categoryConfigsAllBinding="view.categoryConfigsAll" }}
                                 {{#if view.canEdit}}
 	                                {{#if isPropertyOverridable}}
@@ -124,6 +124,7 @@
 	                                {{/if}}
                                 {{/if}}
                                   <span class="help-inline">{{errorMessage}}</span>
+                                  <span class="help-inline">{{warnMessage}}</span>
                               </div>
                             {{#if this.isOverridden}}
                               {{view App.ServiceConfigView.SCPOverriddenRowsView serviceConfigPropertyBinding="this"}}

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a4cba0e1/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index 71d961e..3a81b60 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -501,11 +501,12 @@ App.config = Em.Object.create({
       serviceConfig.set('showConfig', service.showConfig);
 
       // Use calculated default values for some configs
-
-      if (!storedConfigs && service.defaultsProviders)  {
+      var recommendedDefaults = {};
+      if (!storedConfigs && service.defaultsProviders) {
         service.defaultsProviders.forEach(function(defaultsProvider) {
           var defaults = defaultsProvider.getDefaults(localDB);
           for(var name in defaults) {
+        	recommendedDefaults[name] = defaults[name];
             var config = configsByService.findProperty('name', name);
             if (config) {
               config.set('value', defaults[name]);
@@ -514,6 +515,16 @@ App.config = Em.Object.create({
           }
         });
       }
+      if (service.configsValidator) {
+    	service.configsValidator.set('recommendedDefaults', recommendedDefaults);
+    	var validators = service.configsValidator.get('configValidators');
+    	for (var validatorName in validators) {
+        var c = configsByService.findProperty('name', validatorName);
+          if (c) {
+            c.set('serviceValidator', service.configsValidator);
+          }
+        }
+      }
 
       serviceConfig.set('configs', configsByService);
       renderedServiceConfigs.push(serviceConfig);

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a4cba0e1/ambari-web/app/utils/configs/defaults_providers/defaultsProvider.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/configs/defaults_providers/defaultsProvider.js b/ambari-web/app/utils/configs/defaults_providers/defaultsProvider.js
new file mode 100644
index 0000000..1eaad12
--- /dev/null
+++ b/ambari-web/app/utils/configs/defaults_providers/defaultsProvider.js
@@ -0,0 +1,37 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+
+App.DefaultsProvider = Em.Object.extend({
+
+  /**
+   * Look at cluster setup, the provided properties, and provide an object where keys are property-names, and values are the recommended defaults
+   * @param {App.ServiceConfigProperty} serviceConfigProperty
+   */
+  getDefaults: function(serviceConfigProperty) {
+
+  },
+
+  /**
+   * Cluster info used to calculate properties values
+   * Should be redeclared in the child providers
+   */
+  getClusterData: function() {
+
+  }
+});

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a4cba0e1/ambari-web/app/utils/configs/defaults_providers/yarn_defaults_provider.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/configs/defaults_providers/yarn_defaults_provider.js b/ambari-web/app/utils/configs/defaults_providers/yarn_defaults_provider.js
new file mode 100644
index 0000000..070de87
--- /dev/null
+++ b/ambari-web/app/utils/configs/defaults_providers/yarn_defaults_provider.js
@@ -0,0 +1,288 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+require('utils/configs/defaults_providers/defaultsProvider');
+
+App.YARNDefaultsProvider = App.DefaultsProvider.create({
+
+  /**
+   * List of the configs that should be calculated
+   */
+  configsTemplate: {
+    'yarn.nodemanager.resource.memory-mb': null,
+    'yarn.scheduler.minimum-allocation-mb': null,
+    'yarn.scheduler.maximum-allocation-mb': null,
+    'mapreduce.map.memory.mb': null,
+    'mapreduce.reduce.memory.mb': null,
+    'mapreduce.map.java.opts': null,
+    'mapreduce.reduce.java.opts': null,
+    'mapreduce.task.io.sort.mb': null,
+    'yarn.app.mapreduce.am.resource.mb': null,
+    'yarn.app.mapreduce.am.command-opts': null
+  },
+
+  /**
+   * Information about ram, disk count, cpu count and hbase availability
+   * Example:
+   * {
+   *   disk: 12,
+   *   ram: 48 * 1024, // MB
+   *   cpu: 12,
+   *   hBaseInstalled: false
+   * }
+   */
+  clusterData: null,
+
+  /**
+   * Reserved for system memory
+   *
+   * Value in MB!
+   */
+  reservedRam: null,
+
+  /**
+   * Reserved for HBase memory
+   *
+   * Value in MB!
+   */
+  hBaseRam: null,
+
+  GB: 1024,
+  /**
+   *  Minimum container size (in RAM).
+   *  This value is dependent on the amount of RAM available, as in smaller memory nodes the minimum container size should also be smaller
+   *
+   *  Value in MB!
+   */
+  recommendedMinimumContainerSize: function () {
+    if (!this.clusterDataIsValid()) return null;
+    var ram = this.get('clusterData.ram');
+    switch (true) {
+      case (ram <=4 ):
+        return 256;
+      case (ram <= 8):
+        return 512;
+      case (ram <= 24):
+        return 1024;
+      default:
+        return 2048;
+    }
+  }.property('clusterData.ram'),
+
+  /**
+   * Maximum number of containers allowed per node
+   * max (2*cores,min (1.8*DISKS,(Total available RAM) / MIN_CONTAINER_SIZE)))
+   * min (2*CORES, 1.8*DISKS, (Total available RAM) / MIN_CONTAINER_SIZE)
+   */
+  containers: function () {
+    if (!this.clusterDataIsValid()) return null;
+    var cpu = this.get('clusterData.cpu');
+    var disk = this.get('clusterData.disk');
+    var ram = this.get('clusterData.ram');
+    var containerSize = this.get('recommendedMinimumContainerSize');
+    cpu *= 2;
+    disk = Math.ceil(disk * 1.8);
+    ram = (ram - this.get('reservedRam'));
+    if (this.get('clusterData.hBaseInstalled')) {
+      ram -= this.get('hBaseRam')
+    }
+    ram *= this.get('GB');
+    ram /= containerSize;
+    return Math.round(Math.max(cpu, Math.min(disk, ram)));
+  }.property('clusterData.cpu', 'clusterData.ram', 'clusterData.hBaseInstalled', 'clusterData.disk', 'reservedRam', 'hBaseRam', 'recommendedMinimumContainerSize'),
+
+  /**
+   * amount of RAM per container
+   * RAM-per-container = abs(MIN_CONTAINER_SIZE, (Total Available RAM) / containers))
+   *
+   * Value in MB!
+   */
+  ramPerContainer: function () {
+    var containers = this.get('containers');
+    var ram = this.get('clusterData.ram');
+    ram = (ram - this.get('reservedRam'));
+    if (this.get('clusterData.hBaseInstalled')) {
+      ram -= this.get('hBaseRam')
+    }
+    ram *= this.get('GB');
+    var container_ram = Math.abs(ram / containers);
+    return container_ram > this.get('GB') ? container_ram / (512 * 512) : container_ram;
+  }.property('recommendedMinimumContainerSize', 'containers', 'clusterData.ram', 'clusterData.hBaseInstalled', 'hBaseRam', 'reservedRam'),
+
+  mapMemory: function () {
+    return this.get('ramPerContainer');
+  }.property('ramPerContainer'),
+
+  reduceMemory: function () {
+    var ramPerContainer = this.get('ramPerContainer');
+    return ramPerContainer <= 2048 ? 2 * ramPerContainer : ramPerContainer;
+  }.property('ramPerContainer'),
+
+  amMemory: function () {
+    return Math.max(this.get('mapMemory'), this.get('reduceMemory'));
+  }.property('mapMemory', 'reduceMemory'),
+
+  /**
+   * Reserved for HBase and system memory is based on total available memory
+   */
+
+
+
+  reservedStackRecommendations: function () {
+    var memory = this.get('clusterData.ram');
+    var reservedStack = { 4: 1, 8: 2, 16: 2, 24: 4, 48: 6, 64: 8, 72: 8, 96: 12,
+      128: 24, 256: 32, 512: 64};
+
+    if (memory in reservedStack) {
+      this.set('reservedRam', reservedStack[memory]);
+    }
+    if (memory <= 4)
+      this.set('reservedRam', 1);
+    else if (memory >= 512)
+      this.set('reservedRam', 64);
+    else
+      this.set('reservedRam', 1);
+  }.observes('clusterData.ram'),
+
+  hbaseMemRecommendations: function () {
+    var memory = this.get('clusterData.ram');
+    var reservedHBase = {4:1, 8:1, 16:2, 24:4, 48:8, 64:8, 72:8, 96:16,
+      128:24, 256:32, 512:64};
+
+    if (memory in reservedHBase) {
+      this.set('reservedRam', reservedHBase[memory]);
+    }
+    if (memory <= 4)
+      this.set('hBaseRam', 1);
+    else if (memory >= 512)
+      this.set('hBaseRam', 64);
+    else
+      this.set('hBaseRam', 2);
+
+  }.observes('clusterData.ram'),
+
+  /**
+   * Provide an object where keys are property-names and values are the recommended defaults
+   * @param {object} localDB Object with information about hosts and master/slave components
+   * Example:
+   *  <code>
+   *    {
+   *       "hosts": {
+   *           "host1": {
+   *               "name": "host1",
+   *               "cpu": 1,
+   *               "memory": "6123683.00",
+   *               "disk_info": [{
+   *                   ....
+   *               },...]
+   *           },...
+   *       },
+   *       "masterComponentHosts": [{
+   *           "component": "NAMENODE",
+   *           "hostName": "host1",
+   *           "serviceId": "HDFS"
+   *       },...],
+   *       "slaveComponentHosts": [{
+   *           "componentName": "DATANODE",
+   *           "hosts": [{
+   *               "hostName": "host2"
+   *           }]
+   *       },...]
+   *   }
+   *  </code>
+   * @return {object}
+   */
+  getDefaults: function (localDB) {
+    this._super();
+    this.getClusterData(localDB);
+    var configs = {};
+    jQuery.extend(configs, this.get('configsTemplate'));
+    configs['yarn.nodemanager.resource.memory-mb'] = Math.round(this.get('containers') * this.get('ramPerContainer'));
+    configs['yarn.scheduler.minimum-allocation-mb'] = Math.round(this.get('ramPerContainer'));
+    configs['yarn.scheduler.maximum-allocation-mb'] = Math.round(this.get('containers') * this.get('ramPerContainer'));
+    configs['yarn.app.mapreduce.am.resource.mb'] = Math.round(this.get('amMemory'));
+    configs['yarn.app.mapreduce.am.command-opts'] = "-Xmx" + Math.round(0.8 * this.get('amMemory')) + "m";
+    configs['mapreduce.map.memory.mb'] = Math.round(this.get('mapMemory'));
+    configs['mapreduce.reduce.memory.mb'] = Math.round(this.get('reduceMemory'));
+    configs['mapreduce.map.java.opts'] = "-Xmx" + Math.round(0.8 * this.get('mapMemory')) + "m";
+    configs['mapreduce.reduce.java.opts'] = "-Xmx" + Math.round(0.8 * this.get('reduceMemory')) + "m";
+    configs['mapreduce.task.io.sort.mb'] = Math.round(0.4 * this.get('mapMemory'));
+    return configs;
+  },
+
+  /**
+   * Calculate needed cluster data (like disk count, cpu count, ram (in MB!) and hbase availability)
+   * @param {object} localDB Object with information about hosts and master/slave components
+   */
+  getClusterData: function (localDB) {
+    this._super();
+    var components = ['NODEMANAGER'];
+    var hosts = [];
+    if (!localDB.hosts || !(localDB.masterComponentHosts || localDB.slaveComponentHosts)) return;
+    var hBaseInstalled = !!localDB.masterComponentHosts.filterProperty('component', 'HBASE_MASTER').length;
+    components.forEach(function (component) {
+      var mc = localDB.masterComponentHosts.findProperty('component', component);
+      if (mc) {
+        if (!hosts.contains(mc.hostName)) {
+          hosts.push(mc.hostName);
+        }
+      }
+      else {
+        var sc = localDB.slaveComponentHosts.findProperty('componentName', component);
+        if (sc) {
+          sc.hosts.map(function (host) {
+            if (!hosts.contains(host.hostName)) {
+              hosts.push(host.hostName);
+            }
+          });
+        }
+      }
+    });
+    var clusterData = {
+      cpu: 0,
+      disk: 0,
+      ram: 0,
+      hBaseInstalled: hBaseInstalled
+    };
+    var host = hosts[0] && localDB.hosts[hosts[0]];
+    if (host) {
+      clusterData.cpu = parseInt(host.cpu);
+      var length = 0;
+      host.disk_info.forEach(function(disk) {
+        //invalid mountpoints
+        if (!(disk.mountpoint.startsWith('/home/') || disk.mountpoint.startsWith('/homes/') || 
+        		disk.mountpoint.startsWith('/dev/') || disk.mountpoint.startsWith('/tmp/'))) {
+          length++;
+        }
+      },this);
+      clusterData.disk = length;
+      clusterData.ram = Math.round(parseFloat(host.memory) / (1024 * 1024));
+    }
+    this.set('clusterData', clusterData);
+  },
+
+  /**
+   * Verify <code>clusterData</code> - check if all properties are defined
+   */
+  clusterDataIsValid: function () {
+    if (!this.get('clusterData')) return false;
+    if (this.get('clusterData.ram') == null || this.get('clusterData.cpu') == null || this.get('clusterData.disk') == null || this.get('clusterData.hBaseInstalled') == null) return false;
+    return true;
+  }
+
+});

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a4cba0e1/ambari-web/app/utils/configs/validators/mapreduce2_configs_validator.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/configs/validators/mapreduce2_configs_validator.js b/ambari-web/app/utils/configs/validators/mapreduce2_configs_validator.js
new file mode 100644
index 0000000..d2f30d2
--- /dev/null
+++ b/ambari-web/app/utils/configs/validators/mapreduce2_configs_validator.js
@@ -0,0 +1,69 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+require('utils/configs/validators/service_configs_validator');
+
+App.MapReduce2ConfigsValidator = App.ServiceConfigsValidator.create({
+
+  /**
+   * List of the configs that should be validated
+   */
+  configValidators: {
+    'mapreduce.map.java.opts': 'mapreduceMapJavaOpts',
+    'mapreduce.reduce.java.opts': 'mapreduceReduceJavaOpts',
+    'mapreduce.task.io.sort.mb': 'mapreduceTaskIoSortMb',
+    'mapreduce.map.memory.mb': 'mapreduceMapMemoryMb',
+    'mapreduce.reduce.memory.mb': 'mapreduceReduceMemoryMb',
+    'yarn.app.mapreduce.am.resource.mb': 'yarnAppMapreduceAmResourceMb',
+    'yarn.app.mapreduce.am.command-opts': 'yarnAppMapreduceAmCommandOpts'
+  },
+
+  /**
+   * List of the real configProperty objects
+   */
+  configProperties: [],
+
+  mapreduceMapJavaOpts: function(config) {
+    return this.validatorLessThenDefaultValue(config);
+  },
+
+  mapreduceReduceJavaOpts: function(config) {
+	return this.validatorLessThenDefaultValue(config);
+  },
+
+  mapreduceTaskIoSortMb: function(config) {
+    return this.validatorLessThenDefaultValue(config);
+  },
+
+  mapreduceMapMemoryMb: function(config) {
+    return this.validatorLessThenDefaultValue(config);
+  },
+
+  mapreduceReduceMemoryMb: function(config) {
+    return this.validatorLessThenDefaultValue(config);
+  },
+
+  yarnAppMapreduceAmResourceMb: function(config) {
+    return this.validatorLessThenDefaultValue(config);
+  },
+
+  yarnAppMapreduceAmCommandOpts: function(config) {
+    return this.validatorLessThenDefaultValue(config);
+  }
+
+});

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a4cba0e1/ambari-web/app/utils/configs/validators/service_configs_validator.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/configs/validators/service_configs_validator.js b/ambari-web/app/utils/configs/validators/service_configs_validator.js
new file mode 100644
index 0000000..c9e2a90
--- /dev/null
+++ b/ambari-web/app/utils/configs/validators/service_configs_validator.js
@@ -0,0 +1,68 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+
+App.ServiceConfigsValidator = Em.Object.extend({
+
+  /**
+   * Defaults recommended for various properties. This is to be used 
+   * by this validator to validate a property. Generally this value should be 
+   * set to values given by the defaults provider of the service.
+   * 
+   * The key is the property name, and the value is the recommended default.
+   */
+  recommendedDefaults: {},
+  
+  /**
+   * Per property validators where key is config name and value 
+   * is the validation function. This field is expected to be
+   * overridden by extending classes.
+   */
+  configValidators: {},
+  
+  /**
+   * Validate the given config property with the available  
+   * {@param recommendedDefaults}. This can do cross-property
+   * validations also. 
+   * 
+   * @param config  {App.ServiceConfigProperty}
+   * @return {string}  No validation issues when <code>null</code> returned.
+   */
+  validateConfig: function(config) {
+    var validatorFunction = this.get('configValidators')[config.get('name')];
+    if (validatorFunction) {
+      return this[validatorFunction](config);
+    }
+    return null;
+  },
+  
+  /**
+   * Check if provided <code>config.value</code> is less than <code>recommendedDefaults</code>
+   * @param {object} config - configProperty name
+   */
+  validatorLessThenDefaultValue: function(config) {
+    var defaultValue = this.recommendedDefaults[config.get('name')];
+    var currentValue = parseInt(config.get('value').toString().replace( /\D+/g, ''));
+    defaultValue = parseInt(defaultValue.toString().replace( /\D+/g, ''));
+    if (defaultValue && currentValue &&  currentValue < defaultValue) {
+      return "Value is less than the recommended default of "+defaultValue;
+    }
+    return null;
+  }
+
+});

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a4cba0e1/ambari-web/app/utils/configs/validators/yarn_configs_validator.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/configs/validators/yarn_configs_validator.js b/ambari-web/app/utils/configs/validators/yarn_configs_validator.js
new file mode 100644
index 0000000..dda3f10
--- /dev/null
+++ b/ambari-web/app/utils/configs/validators/yarn_configs_validator.js
@@ -0,0 +1,48 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+require('utils/configs/validators/service_configs_validator');
+
+App.YARNConfigsValidator = App.ServiceConfigsValidator.create({
+  /**
+   * List of the configs that should be validated
+   */
+  configValidators: {
+    'yarn.nodemanager.resource.memory-mb': 'yarnNodemanagerResourceMemoryMb',
+    'yarn.scheduler.minimum-allocation-mb': 'yarnSchedulerMinimumAllocationMb',
+    'yarn.scheduler.maximum-allocation-mb': 'yarnSchedulerMaximumAllocationMb'
+  },
+
+  /**
+   * List of the real configProperty objects
+   */
+  configProperties: [],
+
+  yarnNodemanagerResourceMemoryMb: function(config) {
+    return this.validatorLessThenDefaultValue(config);
+  },
+
+  yarnSchedulerMinimumAllocationMb: function(config) {
+    return this.validatorLessThenDefaultValue(config);
+  },
+
+  yarnSchedulerMaximumAllocationMb: function(config) {
+    return this.validatorLessThenDefaultValue(config);
+  }
+
+});

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a4cba0e1/ambari-web/app/utils/defaults_providers/defaultsProvider.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/defaults_providers/defaultsProvider.js b/ambari-web/app/utils/defaults_providers/defaultsProvider.js
deleted file mode 100644
index 1eaad12..0000000
--- a/ambari-web/app/utils/defaults_providers/defaultsProvider.js
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * 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.
- */
-
-var App = require('app');
-
-App.DefaultsProvider = Em.Object.extend({
-
-  /**
-   * Look at cluster setup, the provided properties, and provide an object where keys are property-names, and values are the recommended defaults
-   * @param {App.ServiceConfigProperty} serviceConfigProperty
-   */
-  getDefaults: function(serviceConfigProperty) {
-
-  },
-
-  /**
-   * Cluster info used to calculate properties values
-   * Should be redeclared in the child providers
-   */
-  getClusterData: function() {
-
-  }
-});

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a4cba0e1/ambari-web/app/utils/defaults_providers/yarn_defaults_provider.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/defaults_providers/yarn_defaults_provider.js b/ambari-web/app/utils/defaults_providers/yarn_defaults_provider.js
deleted file mode 100644
index 4b10e97..0000000
--- a/ambari-web/app/utils/defaults_providers/yarn_defaults_provider.js
+++ /dev/null
@@ -1,288 +0,0 @@
-/**
- * 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.
- */
-
-var App = require('app');
-require('utils/defaults_providers/defaultsProvider');
-
-App.YARNDefaultsProvider = App.DefaultsProvider.create({
-
-  /**
-   * List of the configs that should be calculated
-   */
-  configsTemplate: {
-    'yarn.nodemanager.resource.memory-mb': null,
-    'yarn.scheduler.minimum-allocation-mb': null,
-    'yarn.scheduler.maximum-allocation-mb': null,
-    'mapreduce.map.memory.mb': null,
-    'mapreduce.reduce.memory.mb': null,
-    'mapreduce.map.java.opts': null,
-    'mapreduce.reduce.java.opts': null,
-    'mapreduce.task.io.sort.mb': null,
-    'yarn.app.mapreduce.am.resource.mb': null,
-    'yarn.app.mapreduce.am.command-opts': null
-  },
-
-  /**
-   * Information about ram, disk count, cpu count and hbase availability
-   * Example:
-   * {
-   *   disk: 12,
-   *   ram: 48 * 1024, // MB
-   *   cpu: 12,
-   *   hBaseInstalled: false
-   * }
-   */
-  clusterData: null,
-
-  /**
-   * Reserved for system memory
-   *
-   * Value in MB!
-   */
-  reservedRam: null,
-
-  /**
-   * Reserved for HBase memory
-   *
-   * Value in MB!
-   */
-  hBaseRam: null,
-
-  GB: 1024,
-  /**
-   *  Minimum container size (in RAM).
-   *  This value is dependent on the amount of RAM available, as in smaller memory nodes the minimum container size should also be smaller
-   *
-   *  Value in MB!
-   */
-  recommendedMinimumContainerSize: function () {
-    if (!this.clusterDataIsValid()) return null;
-    var ram = this.get('clusterData.ram');
-    switch (true) {
-      case (ram <=4 ):
-        return 256;
-      case (ram <= 8):
-        return 512;
-      case (ram <= 24):
-        return 1024;
-      default:
-        return 2048;
-    }
-  }.property('clusterData.ram'),
-
-  /**
-   * Maximum number of containers allowed per node
-   * max (2*cores,min (1.8*DISKS,(Total available RAM) / MIN_CONTAINER_SIZE)))
-   * min (2*CORES, 1.8*DISKS, (Total available RAM) / MIN_CONTAINER_SIZE)
-   */
-  containers: function () {
-    if (!this.clusterDataIsValid()) return null;
-    var cpu = this.get('clusterData.cpu');
-    var disk = this.get('clusterData.disk');
-    var ram = this.get('clusterData.ram');
-    var containerSize = this.get('recommendedMinimumContainerSize');
-    cpu *= 2;
-    disk = Math.ceil(disk * 1.8);
-    ram = (ram - this.get('reservedRam'));
-    if (this.get('clusterData.hBaseInstalled')) {
-      ram -= this.get('hBaseRam')
-    }
-    ram *= this.get('GB');
-    ram /= containerSize;
-    return Math.round(Math.max(cpu, Math.min(disk, ram)));
-  }.property('clusterData.cpu', 'clusterData.ram', 'clusterData.hBaseInstalled', 'clusterData.disk', 'reservedRam', 'hBaseRam', 'recommendedMinimumContainerSize'),
-
-  /**
-   * amount of RAM per container
-   * RAM-per-container = abs(MIN_CONTAINER_SIZE, (Total Available RAM) / containers))
-   *
-   * Value in MB!
-   */
-  ramPerContainer: function () {
-    var containers = this.get('containers');
-    var ram = this.get('clusterData.ram');
-    ram = (ram - this.get('reservedRam'));
-    if (this.get('clusterData.hBaseInstalled')) {
-      ram -= this.get('hBaseRam')
-    }
-    ram *= this.get('GB');
-    var container_ram = Math.abs(ram / containers);
-    return container_ram > this.get('GB') ? container_ram / (512 * 512) : container_ram;
-  }.property('recommendedMinimumContainerSize', 'containers', 'clusterData.ram', 'clusterData.hBaseInstalled', 'hBaseRam', 'reservedRam'),
-
-  mapMemory: function () {
-    return this.get('ramPerContainer');
-  }.property('ramPerContainer'),
-
-  reduceMemory: function () {
-    var ramPerContainer = this.get('ramPerContainer');
-    return ramPerContainer <= 2048 ? 2 * ramPerContainer : ramPerContainer;
-  }.property('ramPerContainer'),
-
-  amMemory: function () {
-    return Math.max(this.get('mapMemory'), this.get('reduceMemory'));
-  }.property('mapMemory', 'reduceMemory'),
-
-  /**
-   * Reserved for HBase and system memory is based on total available memory
-   */
-
-
-
-  reservedStackRecommendations: function () {
-    var memory = this.get('clusterData.ram');
-    var reservedStack = { 4: 1, 8: 2, 16: 2, 24: 4, 48: 6, 64: 8, 72: 8, 96: 12,
-      128: 24, 256: 32, 512: 64};
-
-    if (memory in reservedStack) {
-      this.set('reservedRam', reservedStack[memory]);
-    }
-    if (memory <= 4)
-      this.set('reservedRam', 1);
-    else if (memory >= 512)
-      this.set('reservedRam', 64);
-    else
-      this.set('reservedRam', 1);
-  }.observes('clusterData.ram'),
-
-  hbaseMemRecommendations: function () {
-    var memory = this.get('clusterData.ram');
-    var reservedHBase = {4:1, 8:1, 16:2, 24:4, 48:8, 64:8, 72:8, 96:16,
-      128:24, 256:32, 512:64};
-
-    if (memory in reservedHBase) {
-      this.set('reservedRam', reservedHBase[memory]);
-    }
-    if (memory <= 4)
-      this.set('hBaseRam', 1);
-    else if (memory >= 512)
-      this.set('hBaseRam', 64);
-    else
-      this.set('hBaseRam', 2);
-
-  }.observes('clusterData.ram'),
-
-  /**
-   * Provide an object where keys are property-names and values are the recommended defaults
-   * @param {object} localDB Object with information about hosts and master/slave components
-   * Example:
-   *  <code>
-   *    {
-   *       "hosts": {
-   *           "host1": {
-   *               "name": "host1",
-   *               "cpu": 1,
-   *               "memory": "6123683.00",
-   *               "disk_info": [{
-   *                   ....
-   *               },...]
-   *           },...
-   *       },
-   *       "masterComponentHosts": [{
-   *           "component": "NAMENODE",
-   *           "hostName": "host1",
-   *           "serviceId": "HDFS"
-   *       },...],
-   *       "slaveComponentHosts": [{
-   *           "componentName": "DATANODE",
-   *           "hosts": [{
-   *               "hostName": "host2"
-   *           }]
-   *       },...]
-   *   }
-   *  </code>
-   * @return {object}
-   */
-  getDefaults: function (localDB) {
-    this._super();
-    this.getClusterData(localDB);
-    var configs = {};
-    jQuery.extend(configs, this.get('configsTemplate'));
-    configs['yarn.nodemanager.resource.memory-mb'] = Math.round(this.get('containers') * this.get('ramPerContainer'));
-    configs['yarn.scheduler.minimum-allocation-mb'] = Math.round(this.get('ramPerContainer'));
-    configs['yarn.scheduler.maximum-allocation-mb'] = Math.round(this.get('containers') * this.get('ramPerContainer'));
-    configs['yarn.app.mapreduce.am.resource.mb'] = Math.round(this.get('amMemory'));
-    configs['yarn.app.mapreduce.am.command-opts'] = "-Xmx" + Math.round(0.8 * this.get('amMemory')) + "m";
-    configs['mapreduce.map.memory.mb'] = Math.round(this.get('mapMemory'));
-    configs['mapreduce.reduce.memory.mb'] = Math.round(this.get('reduceMemory'));
-    configs['mapreduce.map.java.opts'] = "-Xmx" + Math.round(0.8 * this.get('mapMemory')) + "m";
-    configs['mapreduce.reduce.java.opts'] = "-Xmx" + Math.round(0.8 * this.get('reduceMemory')) + "m";
-    configs['mapreduce.task.io.sort.mb'] = Math.round(0.4 * this.get('mapMemory'));
-    return configs;
-  },
-
-  /**
-   * Calculate needed cluster data (like disk count, cpu count, ram (in MB!) and hbase availability)
-   * @param {object} localDB Object with information about hosts and master/slave components
-   */
-  getClusterData: function (localDB) {
-    this._super();
-    var components = ['NODEMANAGER'];
-    var hosts = [];
-    if (!localDB.hosts || !(localDB.masterComponentHosts || localDB.slaveComponentHosts)) return;
-    var hBaseInstalled = !!localDB.masterComponentHosts.filterProperty('component', 'HBASE_MASTER').length;
-    components.forEach(function (component) {
-      var mc = localDB.masterComponentHosts.findProperty('component', component);
-      if (mc) {
-        if (!hosts.contains(mc.hostName)) {
-          hosts.push(mc.hostName);
-        }
-      }
-      else {
-        var sc = localDB.slaveComponentHosts.findProperty('componentName', component);
-        if (sc) {
-          sc.hosts.map(function (host) {
-            if (!hosts.contains(host.hostName)) {
-              hosts.push(host.hostName);
-            }
-          });
-        }
-      }
-    });
-    var clusterData = {
-      cpu: 0,
-      disk: 0,
-      ram: 0,
-      hBaseInstalled: hBaseInstalled
-    };
-    var host = hosts[0] && localDB.hosts[hosts[0]];
-    if (host) {
-      clusterData.cpu = parseInt(host.cpu);
-      var length = 0;
-      host.disk_info.forEach(function(disk) {
-        //invalid mountpoints
-        if (!(disk.mountpoint.startsWith('/home/') || disk.mountpoint.startsWith('/homes/') || 
-        		disk.mountpoint.startsWith('/dev/') || disk.mountpoint.startsWith('/tmp/'))) {
-          length++;
-        }
-      },this);
-      clusterData.disk = length;
-      clusterData.ram = Math.round(parseFloat(host.memory) / (1024 * 1024));
-    }
-    this.set('clusterData', clusterData);
-  },
-
-  /**
-   * Verify <code>clusterData</code> - check if all properties are defined
-   */
-  clusterDataIsValid: function () {
-    if (!this.get('clusterData')) return false;
-    if (this.get('clusterData.ram') == null || this.get('clusterData.cpu') == null || this.get('clusterData.disk') == null || this.get('clusterData.hBaseInstalled') == null) return false;
-    return true;
-  }
-
-});

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a4cba0e1/ambari-web/test/utils/configs/defaults_providers/yarn_defaults_provider_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/configs/defaults_providers/yarn_defaults_provider_test.js b/ambari-web/test/utils/configs/defaults_providers/yarn_defaults_provider_test.js
new file mode 100644
index 0000000..c8e36f0
--- /dev/null
+++ b/ambari-web/test/utils/configs/defaults_providers/yarn_defaults_provider_test.js
@@ -0,0 +1,295 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+require('utils/configs/defaults_providers/defaultsProvider');
+require('utils/configs/defaults_providers/yarn_defaults_provider');
+
+describe('YARNDefaultsProvider', function() {
+
+  describe('#clusterDataIsValid', function() {
+    var tests = [
+      {clusterData: {disk: 12,ram: 48 * 1024,cpu: 12,hBaseInstalled: false},e: true},
+      {clusterData: {disk: null,ram: 48 * 1024,cpu: 12,hBaseInstalled: false},e: false},
+      {clusterData: {disk: 12,ram: null,cpu: 12,hBaseInstalled: false},e: false},
+      {clusterData: {disk: 12,ram: 48 * 1024,cpu: null,hBaseInstalled: false},e: false},
+      {clusterData: {disk: 12,ram: 48 * 1024,cpu: 12,hBaseInstalled: null},e: false},
+      {clusterData: {disk: 12,ram: 48 * 1024,cpu: 12},e: false},
+      {clusterData: {disk: 12,ram: 48 * 1024,hBaseInstalled: true},e: false},
+      {clusterData: {disk: 12,cpu: 12,hBaseInstalled: true},e: false},
+      {clusterData: {ram: 48 * 1024,cpu: 12,hBaseInstalled: false},e: false}
+    ];
+    tests.forEach(function(test) {
+      it((test.e?'valid':'invalid') + ' clusterData', function() {
+        App.YARNDefaultsProvider.set('clusterData', test.clusterData);
+        expect(App.YARNDefaultsProvider.clusterDataIsValid()).to.equal(test.e);
+      });
+    });
+  });
+
+  describe('#reservedMemoryRecommendations', function() {
+    var tests = [
+      {ram: null, e: {os: 1, hbase: 1}},
+      {ram: 2, e: {os: 1, hbase: 1}},
+      {ram: 4, e: {os: 1, hbase: 1}},
+      {ram: 6, e: {os: 2, hbase: 1}},
+      {ram: 8, e: {os: 2, hbase: 1}},
+      {ram: 12, e: {os: 2, hbase: 2}},
+      {ram: 16, e: {os: 2, hbase: 2}},
+      {ram: 20, e: {os: 4, hbase: 4}},
+      {ram: 24, e: {os: 4, hbase: 4}},
+      {ram: 36, e: {os: 6, hbase: 8}},
+      {ram: 48, e: {os: 6, hbase: 8}},
+      {ram: 56, e: {os: 8, hbase: 8}},
+      {ram: 64, e: {os: 8, hbase: 8}},
+      {ram: 68, e: {os: 8, hbase: 8}},
+      {ram: 72, e: {os: 8, hbase: 8}},
+      {ram: 84, e: {os: 12, hbase: 16}},
+      {ram: 96, e: {os: 12, hbase: 16}},
+      {ram: 112, e: {os: 24, hbase: 24}},
+      {ram: 128, e: {os: 24, hbase: 24}},
+      {ram: 196, e: {os: 32, hbase: 32}},
+      {ram: 256, e: {os: 32, hbase: 32}},
+      {ram: 384, e: {os: 64, hbase: 64}},
+      {ram: 512, e: {os: 64, hbase: 64}},
+      {ram: 756, e: {os: 64, hbase: 64}}
+    ];
+    App.YARNDefaultsProvider.set('clusterData');
+    tests.forEach(function(test) {
+      it('ram: ' + test.ram + ' GB', function() {
+        App.YARNDefaultsProvider.set('clusterData', {
+          disk: 12,
+          ram: test.ram * 1024,
+          cpu: 12,
+          hBaseInstalled: false
+        });
+        expect(App.YARNDefaultsProvider.get('reservedRam')).to.equal(test.e.os * 1024);
+        expect(App.YARNDefaultsProvider.get('hBaseRam')).to.equal(test.e.hbase * 1024);
+      });
+    });
+  });
+
+  describe('#recommendedMinimumContainerSize', function() {
+    it('No clusterData', function() {
+      App.YARNDefaultsProvider.set('clusterData', null);
+      expect(App.YARNDefaultsProvider.get('recommendedMinimumContainerSize')).to.equal(null);
+    });
+    it('No clusterData.ram', function() {
+      App.YARNDefaultsProvider.set('clusterData', {});
+      expect(App.YARNDefaultsProvider.get('recommendedMinimumContainerSize')).to.equal(null);
+    });
+
+    var tests = [
+      {ram: 3, e: 256},
+      {ram: 4, e: 512},
+      {ram: 6, e: 512},
+      {ram: 8, e: 1024},
+      {ram: 12, e: 1024},
+      {ram: 24, e: 2048}
+    ];
+
+    tests.forEach(function(test) {
+      it('ram: ' + test.ram + ' GB', function() {
+        App.YARNDefaultsProvider.set('clusterData', {
+          disk: 12,
+          ram: test.ram * 1024,
+          cpu: 12,
+          hBaseInstalled: false
+        });
+        expect(App.YARNDefaultsProvider.get('recommendedMinimumContainerSize')).to.equal(test.e);
+      });
+    });
+
+  });
+
+  describe('#containers', function() {
+    it('No clusterData', function() {
+      App.YARNDefaultsProvider.set('clusterData', null);
+      expect(App.YARNDefaultsProvider.get('containers')).to.equal(null);
+    });
+    it('Some clusterData metric is null', function() {
+      App.YARNDefaultsProvider.set('clusterData', {disk: null, cpu: 1, ram: 1});
+      expect(App.YARNDefaultsProvider.get('containers')).to.equal(null);
+      App.YARNDefaultsProvider.set('clusterData', {disk: 1, cpu: null, ram: 1});
+      expect(App.YARNDefaultsProvider.get('containers')).to.equal(null);
+      App.YARNDefaultsProvider.set('clusterData', {disk:1, cpu: 1, ram: null});
+      expect(App.YARNDefaultsProvider.get('containers')).to.equal(null);
+    });
+
+    var tests = [
+      {
+        clusterData: {
+          disk: 12,
+          ram: 48 * 1024,
+          cpu: 12,
+          hBaseInstalled: false
+        },
+        e: 21
+      },
+      {
+        clusterData: {
+          disk: 12,
+          ram: 48 * 1024,
+          cpu: 12,
+          hBaseInstalled: true
+        },
+        e: 17
+      }
+    ];
+
+    tests.forEach(function(test) {
+      it((test.hBaseInstalled?'With':'Without') + ' hBase', function() {
+        App.YARNDefaultsProvider.set('clusterData', test.clusterData);
+        expect(App.YARNDefaultsProvider.get('containers')).to.equal(test.e);
+      });
+    });
+
+  });
+
+  describe('#ramPerContainer', function() {
+    it('No clusterData', function() {
+      App.YARNDefaultsProvider.set('clusterData', null);
+      expect(App.YARNDefaultsProvider.get('ramPerContainer')).to.equal(null);
+    });
+    var tests = [
+      {
+        clusterData: {
+          disk: 12,
+          ram: 48 * 1024,
+          cpu: 12,
+          hBaseInstalled: false
+        },
+        e: 2048
+      },
+      {
+        clusterData: {
+          disk: 12,
+          ram: 16 * 1024,
+          cpu: 12,
+          hBaseInstalled: true
+        },
+        e: 1024
+      }
+    ];
+
+    tests.forEach(function(test) {
+      it((test.hBaseInstalled?'With':'Without') + ' hBase', function() {
+        App.YARNDefaultsProvider.set('clusterData', test.clusterData);
+        expect(App.YARNDefaultsProvider.get('ramPerContainer')).to.equal(test.e);
+      });
+    });
+  });
+
+  describe('#getDefaults', function() {
+    var tests = [
+      {
+        localDB: {},
+        m: 'Empty localDB',
+        e: null
+      },
+      {
+        localDB: {
+          "masterComponentHosts": []
+        },
+        m: 'localDB without hosts',
+        e: null
+      },
+      {
+        localDB: {
+          "hosts": {}
+        },
+        m: 'localDB without masterComponentHosts amd slaveComponentHosts',
+        e: null
+      },
+      {
+        localDB: {
+          "hosts": {
+            "host1": {"name": "host1","cpu": 8,"memory": "25165824.00","disk_info": [{},{},{},{},{},{},{},{}]},
+            "host2": {"name": "host2","cpu": 4,"memory": "25165824.00","disk_info": [{},{},{},{}]}
+          },
+          "masterComponentHosts": [
+            {"component": "RESOURCEMANAGER","hostName": "host1","serviceId": "HDFS"}
+          ],
+          "slaveComponentHosts": [
+            {
+              "componentName": "NODEMANAGER",
+              "hosts": [{"hostName": "host2"}]
+            }
+          ]
+        },
+        m: 'Without HBase',
+        e: {
+          'mapreduce.map.java.opts': 1638,
+          'mapreduce.map.memory.mb': 2048,
+          'mapreduce.reduce.java.opts': 3277,
+          'mapreduce.reduce.memory.mb': 4096,
+          'yarn.app.mapreduce.am.command-opts': 3277,
+          'yarn.app.mapreduce.am.resource.mb': 4096,
+          'yarn.nodemanager.resource.memory-mb': 43008,
+          'yarn.scheduler.maximum-allocation-mb': 43008,
+          'yarn.scheduler.minimum-allocation-mb': 2048
+        }
+      },
+      {
+        localDB: {
+          "hosts": {
+            "host1": {"name": "host1","cpu": 8,"memory": "25165824.00","disk_info": [{},{},{},{},{},{},{},{}]},
+            "host2": {"name": "host2","cpu": 4,"memory": "12582912.00","disk_info": [{},{},{},{}]}
+          },
+          "masterComponentHosts": [
+            {"component": "RESOURCEMANAGER","hostName": "host1","serviceId": "HDFS"},
+            {"component": "HBASE_MASTER","hostName": "host1","serviceId": "HDFS"}
+          ],
+          "slaveComponentHosts": [
+            {
+              "componentName": "NODEMANAGER",
+              "hosts": [{"hostName": "host2"}]
+            }
+          ]
+        },
+        m: 'With HBase',
+        e: {
+          'mapreduce.map.java.opts': 1638,
+          'mapreduce.map.memory.mb': 2048,
+          'mapreduce.reduce.java.opts': 3277,
+          'mapreduce.reduce.memory.mb': 4096,
+          'yarn.app.mapreduce.am.command-opts': 3277,
+          'yarn.app.mapreduce.am.resource.mb': 4096,
+          'yarn.nodemanager.resource.memory-mb': 22528,
+          'yarn.scheduler.maximum-allocation-mb': 22528,
+          'yarn.scheduler.minimum-allocation-mb': 2048
+        }
+      }
+    ];
+    tests.forEach(function(test) {
+      it(test.m, function() {
+        App.YARNDefaultsProvider.set('clusterData', null);
+        var configs = App.YARNDefaultsProvider.getDefaults(test.localDB);
+
+        for(var config in configs) {
+          if (test.e) {
+            expect(configs[config]).to.equal(test.e[config]);
+          }
+          else {
+            expect(configs[config] == 0 || configs[config] == null).to.equal(true);
+          }
+        }
+      });
+    });
+  });
+
+});

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/a4cba0e1/ambari-web/test/utils/defaults_providers/yarn_defaults_provider_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/defaults_providers/yarn_defaults_provider_test.js b/ambari-web/test/utils/defaults_providers/yarn_defaults_provider_test.js
deleted file mode 100644
index 4f1efef..0000000
--- a/ambari-web/test/utils/defaults_providers/yarn_defaults_provider_test.js
+++ /dev/null
@@ -1,295 +0,0 @@
-/**
- * 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.
- */
-
-var App = require('app');
-require('utils/defaults_providers/defaultsProvider');
-require('utils/defaults_providers/yarn_defaults_provider');
-
-describe('YARNDefaultsProvider', function() {
-
-  describe('#clusterDataIsValid', function() {
-    var tests = [
-      {clusterData: {disk: 12,ram: 48 * 1024,cpu: 12,hBaseInstalled: false},e: true},
-      {clusterData: {disk: null,ram: 48 * 1024,cpu: 12,hBaseInstalled: false},e: false},
-      {clusterData: {disk: 12,ram: null,cpu: 12,hBaseInstalled: false},e: false},
-      {clusterData: {disk: 12,ram: 48 * 1024,cpu: null,hBaseInstalled: false},e: false},
-      {clusterData: {disk: 12,ram: 48 * 1024,cpu: 12,hBaseInstalled: null},e: false},
-      {clusterData: {disk: 12,ram: 48 * 1024,cpu: 12},e: false},
-      {clusterData: {disk: 12,ram: 48 * 1024,hBaseInstalled: true},e: false},
-      {clusterData: {disk: 12,cpu: 12,hBaseInstalled: true},e: false},
-      {clusterData: {ram: 48 * 1024,cpu: 12,hBaseInstalled: false},e: false}
-    ];
-    tests.forEach(function(test) {
-      it((test.e?'valid':'invalid') + ' clusterData', function() {
-        App.YARNDefaultsProvider.set('clusterData', test.clusterData);
-        expect(App.YARNDefaultsProvider.clusterDataIsValid()).to.equal(test.e);
-      });
-    });
-  });
-
-  describe('#reservedMemoryRecommendations', function() {
-    var tests = [
-      {ram: null, e: {os: 1, hbase: 1}},
-      {ram: 2, e: {os: 1, hbase: 1}},
-      {ram: 4, e: {os: 1, hbase: 1}},
-      {ram: 6, e: {os: 2, hbase: 1}},
-      {ram: 8, e: {os: 2, hbase: 1}},
-      {ram: 12, e: {os: 2, hbase: 2}},
-      {ram: 16, e: {os: 2, hbase: 2}},
-      {ram: 20, e: {os: 4, hbase: 4}},
-      {ram: 24, e: {os: 4, hbase: 4}},
-      {ram: 36, e: {os: 6, hbase: 8}},
-      {ram: 48, e: {os: 6, hbase: 8}},
-      {ram: 56, e: {os: 8, hbase: 8}},
-      {ram: 64, e: {os: 8, hbase: 8}},
-      {ram: 68, e: {os: 8, hbase: 8}},
-      {ram: 72, e: {os: 8, hbase: 8}},
-      {ram: 84, e: {os: 12, hbase: 16}},
-      {ram: 96, e: {os: 12, hbase: 16}},
-      {ram: 112, e: {os: 24, hbase: 24}},
-      {ram: 128, e: {os: 24, hbase: 24}},
-      {ram: 196, e: {os: 32, hbase: 32}},
-      {ram: 256, e: {os: 32, hbase: 32}},
-      {ram: 384, e: {os: 64, hbase: 64}},
-      {ram: 512, e: {os: 64, hbase: 64}},
-      {ram: 756, e: {os: 64, hbase: 64}}
-    ];
-    App.YARNDefaultsProvider.set('clusterData');
-    tests.forEach(function(test) {
-      it('ram: ' + test.ram + ' GB', function() {
-        App.YARNDefaultsProvider.set('clusterData', {
-          disk: 12,
-          ram: test.ram * 1024,
-          cpu: 12,
-          hBaseInstalled: false
-        });
-        expect(App.YARNDefaultsProvider.get('reservedRam')).to.equal(test.e.os * 1024);
-        expect(App.YARNDefaultsProvider.get('hBaseRam')).to.equal(test.e.hbase * 1024);
-      });
-    });
-  });
-
-  describe('#recommendedMinimumContainerSize', function() {
-    it('No clusterData', function() {
-      App.YARNDefaultsProvider.set('clusterData', null);
-      expect(App.YARNDefaultsProvider.get('recommendedMinimumContainerSize')).to.equal(null);
-    });
-    it('No clusterData.ram', function() {
-      App.YARNDefaultsProvider.set('clusterData', {});
-      expect(App.YARNDefaultsProvider.get('recommendedMinimumContainerSize')).to.equal(null);
-    });
-
-    var tests = [
-      {ram: 3, e: 256},
-      {ram: 4, e: 512},
-      {ram: 6, e: 512},
-      {ram: 8, e: 1024},
-      {ram: 12, e: 1024},
-      {ram: 24, e: 2048}
-    ];
-
-    tests.forEach(function(test) {
-      it('ram: ' + test.ram + ' GB', function() {
-        App.YARNDefaultsProvider.set('clusterData', {
-          disk: 12,
-          ram: test.ram * 1024,
-          cpu: 12,
-          hBaseInstalled: false
-        });
-        expect(App.YARNDefaultsProvider.get('recommendedMinimumContainerSize')).to.equal(test.e);
-      });
-    });
-
-  });
-
-  describe('#containers', function() {
-    it('No clusterData', function() {
-      App.YARNDefaultsProvider.set('clusterData', null);
-      expect(App.YARNDefaultsProvider.get('containers')).to.equal(null);
-    });
-    it('Some clusterData metric is null', function() {
-      App.YARNDefaultsProvider.set('clusterData', {disk: null, cpu: 1, ram: 1});
-      expect(App.YARNDefaultsProvider.get('containers')).to.equal(null);
-      App.YARNDefaultsProvider.set('clusterData', {disk: 1, cpu: null, ram: 1});
-      expect(App.YARNDefaultsProvider.get('containers')).to.equal(null);
-      App.YARNDefaultsProvider.set('clusterData', {disk:1, cpu: 1, ram: null});
-      expect(App.YARNDefaultsProvider.get('containers')).to.equal(null);
-    });
-
-    var tests = [
-      {
-        clusterData: {
-          disk: 12,
-          ram: 48 * 1024,
-          cpu: 12,
-          hBaseInstalled: false
-        },
-        e: 21
-      },
-      {
-        clusterData: {
-          disk: 12,
-          ram: 48 * 1024,
-          cpu: 12,
-          hBaseInstalled: true
-        },
-        e: 17
-      }
-    ];
-
-    tests.forEach(function(test) {
-      it((test.hBaseInstalled?'With':'Without') + ' hBase', function() {
-        App.YARNDefaultsProvider.set('clusterData', test.clusterData);
-        expect(App.YARNDefaultsProvider.get('containers')).to.equal(test.e);
-      });
-    });
-
-  });
-
-  describe('#ramPerContainer', function() {
-    it('No clusterData', function() {
-      App.YARNDefaultsProvider.set('clusterData', null);
-      expect(App.YARNDefaultsProvider.get('ramPerContainer')).to.equal(null);
-    });
-    var tests = [
-      {
-        clusterData: {
-          disk: 12,
-          ram: 48 * 1024,
-          cpu: 12,
-          hBaseInstalled: false
-        },
-        e: 2048
-      },
-      {
-        clusterData: {
-          disk: 12,
-          ram: 16 * 1024,
-          cpu: 12,
-          hBaseInstalled: true
-        },
-        e: 1024
-      }
-    ];
-
-    tests.forEach(function(test) {
-      it((test.hBaseInstalled?'With':'Without') + ' hBase', function() {
-        App.YARNDefaultsProvider.set('clusterData', test.clusterData);
-        expect(App.YARNDefaultsProvider.get('ramPerContainer')).to.equal(test.e);
-      });
-    });
-  });
-
-  describe('#getDefaults', function() {
-    var tests = [
-      {
-        localDB: {},
-        m: 'Empty localDB',
-        e: null
-      },
-      {
-        localDB: {
-          "masterComponentHosts": []
-        },
-        m: 'localDB without hosts',
-        e: null
-      },
-      {
-        localDB: {
-          "hosts": {}
-        },
-        m: 'localDB without masterComponentHosts amd slaveComponentHosts',
-        e: null
-      },
-      {
-        localDB: {
-          "hosts": {
-            "host1": {"name": "host1","cpu": 8,"memory": "25165824.00","disk_info": [{},{},{},{},{},{},{},{}]},
-            "host2": {"name": "host2","cpu": 4,"memory": "25165824.00","disk_info": [{},{},{},{}]}
-          },
-          "masterComponentHosts": [
-            {"component": "RESOURCEMANAGER","hostName": "host1","serviceId": "HDFS"}
-          ],
-          "slaveComponentHosts": [
-            {
-              "componentName": "NODEMANAGER",
-              "hosts": [{"hostName": "host2"}]
-            }
-          ]
-        },
-        m: 'Without HBase',
-        e: {
-          'mapreduce.map.java.opts': 1638,
-          'mapreduce.map.memory.mb': 2048,
-          'mapreduce.reduce.java.opts': 3277,
-          'mapreduce.reduce.memory.mb': 4096,
-          'yarn.app.mapreduce.am.command-opts': 3277,
-          'yarn.app.mapreduce.am.resource.mb': 4096,
-          'yarn.nodemanager.resource.memory-mb': 43008,
-          'yarn.scheduler.maximum-allocation-mb': 43008,
-          'yarn.scheduler.minimum-allocation-mb': 2048
-        }
-      },
-      {
-        localDB: {
-          "hosts": {
-            "host1": {"name": "host1","cpu": 8,"memory": "25165824.00","disk_info": [{},{},{},{},{},{},{},{}]},
-            "host2": {"name": "host2","cpu": 4,"memory": "12582912.00","disk_info": [{},{},{},{}]}
-          },
-          "masterComponentHosts": [
-            {"component": "RESOURCEMANAGER","hostName": "host1","serviceId": "HDFS"},
-            {"component": "HBASE_MASTER","hostName": "host1","serviceId": "HDFS"}
-          ],
-          "slaveComponentHosts": [
-            {
-              "componentName": "NODEMANAGER",
-              "hosts": [{"hostName": "host2"}]
-            }
-          ]
-        },
-        m: 'With HBase',
-        e: {
-          'mapreduce.map.java.opts': 1638,
-          'mapreduce.map.memory.mb': 2048,
-          'mapreduce.reduce.java.opts': 3277,
-          'mapreduce.reduce.memory.mb': 4096,
-          'yarn.app.mapreduce.am.command-opts': 3277,
-          'yarn.app.mapreduce.am.resource.mb': 4096,
-          'yarn.nodemanager.resource.memory-mb': 22528,
-          'yarn.scheduler.maximum-allocation-mb': 22528,
-          'yarn.scheduler.minimum-allocation-mb': 2048
-        }
-      }
-    ];
-    tests.forEach(function(test) {
-      it(test.m, function() {
-        App.YARNDefaultsProvider.set('clusterData', null);
-        var configs = App.YARNDefaultsProvider.getDefaults(test.localDB);
-
-        for(var config in configs) {
-          if (test.e) {
-            expect(configs[config]).to.equal(test.e[config]);
-          }
-          else {
-            expect(configs[config] == 0 || configs[config] == null).to.equal(true);
-          }
-        }
-      });
-    });
-  });
-
-});


Mime
View raw message