You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2016/02/02 13:40:46 UTC

[01/11] ambari git commit: AMBARI-14860. Remove assertions in loops in the tests (onechiporenko)

Repository: ambari
Updated Branches:
  refs/heads/branch-dev-patch-upgrade 77af8e54f -> 4c5d2bd0a


AMBARI-14860. Remove assertions in loops in the tests (onechiporenko)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 31477a588a1af89f8a156af4d9efb04b61508fe0
Parents: 3ab6a3a
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Mon Feb 1 15:40:09 2016 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Mon Feb 1 18:17:44 2016 +0200

----------------------------------------------------------------------
 .../global/cluster_controller_test.js           |  4 +-
 .../progress_controller_test.js                 |  4 +-
 .../admin/kerberos/step4_controller_test.js     |  7 +-
 ...anage_alert_notifications_controller_test.js | 85 +++++++++++---------
 .../main/host/add_controller_test.js            |  2 +
 .../test/controllers/wizard/step3_test.js       | 43 +++++-----
 .../test/controllers/wizard/step4_test.js       | 19 ++++-
 .../test/controllers/wizard/step5_test.js       |  7 +-
 .../test/controllers/wizard/step6_test.js       |  6 +-
 .../test/controllers/wizard/step7_test.js       | 13 +--
 .../test/controllers/wizard/step8_test.js       | 19 +++--
 .../test/controllers/wizard/step9_test.js       | 23 +++---
 ambari-web/test/controllers/wizard_test.js      |  8 +-
 ambari-web/test/mappers/service_mapper_test.js  |  8 +-
 .../common/configs/toggle_isrequired_test.js    | 12 +--
 .../kdc_credentials_controller_mixin_test.js    | 29 ++++---
 .../test/mixins/common/serverValidator_test.js  | 14 +++-
 ambari-web/test/models/cluster_states_test.js   | 20 +++--
 .../objects/service_config_property_test.js     | 38 ++++-----
 ambari-web/test/router_test.js                  | 84 +++++++++----------
 ambari-web/test/utils/ajax/ajax_queue_test.js   |  2 +-
 ambari-web/test/utils/config_test.js            | 32 ++++----
 ambari-web/test/utils/date/timezone_test.js     | 24 +++---
 ambari-web/test/utils/helper_test.js            |  6 +-
 .../test/views/common/chart/linear_time_test.js | 16 ++--
 .../common/configs/service_config_view_test.js  | 18 +++--
 .../modal_popups/cluster_check_popup_test.js    | 12 ++-
 .../manage_alert_notifications_view_test.js     | 17 ++--
 ambari-web/test/views/wizard/step3_view_test.js | 31 ++++---
 ambari-web/test/views/wizard/step9_view_test.js | 71 ++++++++++------
 30 files changed, 386 insertions(+), 288 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/global/cluster_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/global/cluster_controller_test.js b/ambari-web/test/controllers/global/cluster_controller_test.js
index a791b19..d2c6876 100644
--- a/ambari-web/test/controllers/global/cluster_controller_test.js
+++ b/ambari-web/test/controllers/global/cluster_controller_test.js
@@ -190,8 +190,8 @@ describe('App.clusterController', function () {
     controller.set('clusterName', 'tdk');
     var tests = ['test1', 'test2', 'test3'];
 
-    it('testMode = false', function () {
-      tests.forEach(function (test) {
+    tests.forEach(function (test) {
+      it(test, function () {
         expect(controller.getUrl(test, test)).to.equal(App.apiPrefix + '/clusters/' + controller.get('clusterName') + test);
       });
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/main/admin/highAvailability/progress_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/highAvailability/progress_controller_test.js b/ambari-web/test/controllers/main/admin/highAvailability/progress_controller_test.js
index f002754..0f1b18d 100644
--- a/ambari-web/test/controllers/main/admin/highAvailability/progress_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/highAvailability/progress_controller_test.js
@@ -132,8 +132,8 @@ describe('App.HighAvailabilityProgressPageController', function () {
       Date.prototype.getTime.restore();
     });
 
-    it("reconfigures configs after HA", function() {
-      tests.forEach(function(t) {
+    tests.forEach(function(t, index) {
+      it("reconfigures configs after HA #" + (index + 1), function() {
         controller.set('content', t.content);
         expect(controller.reconfigureSites(t.siteNames, t.data, t.note)).to.eql(t.result);
       });

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
index 6c4a1fb..fa78916 100644
--- a/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
@@ -49,9 +49,10 @@ describe('App.KerberosWizardStep4Controller', function() {
   describe('#createServiceConfig', function() {
     var controller = App.KerberosWizardStep4Controller.create({});
     it('should create instance of App.ServiceConfig', function() {
-      controller.createServiceConfig([], []).forEach(function(item){
-        expect(item).be.instanceof(App.ServiceConfig);
-      });
+      var configs = controller.createServiceConfig([], []);
+      expect(configs).to.have.property('length').equal(2);
+      expect(configs[0]).to.be.instanceof(App.ServiceConfig);
+      expect(configs[1]).to.be.instanceof(App.ServiceConfig);
     });
   });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js b/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
index 84caec6..19d0c1b 100644
--- a/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
+++ b/ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
@@ -102,45 +102,48 @@ describe('App.ManageAlertNotificationsController', function () {
 
   describe('#addAlertNotification()', function () {
 
+    var inputFields = Em.Object.create({
+      a: {
+        value: '',
+        defaultValue: 'a'
+      },
+      b: {
+        value: '',
+        defaultValue: 'b'
+      },
+      c: {
+        value: '',
+        defaultValue: 'c'
+      },
+      severityFilter: {
+        value: [],
+        defaultValue: ['OK', 'WARNING', 'CRITICAL', 'UNKNOWN']
+      },
+      global: {
+        value: false
+      },
+      allGroups: Em.Object.create({
+        value: 'custom'
+      })
+    });
+
     beforeEach(function () {
       sinon.stub(controller, 'showCreateEditPopup');
+      controller.set('inputFields', inputFields);
+      controller.addAlertNotification();
     });
 
     afterEach(function () {
       controller.showCreateEditPopup.restore();
     });
 
-    it("should set value for inputFields and call showCreateEditPopup", function () {
-
-      controller.set('inputFields', Em.Object.create({
-        a: {
-          value: '',
-          defaultValue: 'a'
-        },
-        b: {
-          value: '',
-          defaultValue: 'b'
-        },
-        c: {
-          value: '',
-          defaultValue: 'c'
-        },
-        severityFilter: {
-          value: [],
-          defaultValue: ['OK', 'WARNING', 'CRITICAL', 'UNKNOWN']
-        },
-        global: {
-          value: false
-        },
-        allGroups: Em.Object.create({
-          value: 'custom'
-        })
-      }));
-      controller.addAlertNotification();
-
-      Em.keys(controller.get('inputFields')).forEach(function (key) {
-        expect(controller.get('inputFields.' + key + '.value')).to.eql(controller.get('inputFields.' + key + '.defaultValue'));
+    Object.keys(inputFields).forEach(function (key) {
+      it(key, function () {
+        expect(controller.get('inputFields.' + key + '.value')).to.be.eql(controller.get('inputFields.' + key + '.defaultValue'));
       });
+    });
+
+    it("should call showCreateEditPopup", function () {
       expect(controller.showCreateEditPopup.calledOnce).to.be.true;
     });
 
@@ -664,16 +667,26 @@ describe('App.ManageAlertNotificationsController', function () {
         });
 
         cases.forEach(function (item) {
-          it(item.method, function () {
-            item.errors.forEach(function (errorName) {
-              view.set(errorName, true);
+          describe(item.method, function () {
+
+            beforeEach(function () {
+              item.errors.forEach(function (errorName) {
+                view.set(errorName, true);
+              });
+              view.set('controller.inputFields.method.value', item.method);
             });
-            view.set('controller.inputFields.method.value', item.method);
+
             item.errors.forEach(function (errorName) {
-              expect(view.get(errorName)).to.be.false;
+              it(errorName + ' is false', function () {
+                expect(view.get(errorName)).to.be.false;
+              });
+
             });
             validators.forEach(function (validatorName) {
-              expect(view.get(validatorName).calledOnce).to.equal(item.validators.contains(validatorName));
+              var called = item.validators.contains(validatorName);
+              it(validatorName + ' ' + (called ? '' : 'not') + ' called', function () {
+                expect(view.get(validatorName).calledOnce).to.equal(called);
+              });
             });
           });
         });

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/main/host/add_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/host/add_controller_test.js b/ambari-web/test/controllers/main/host/add_controller_test.js
index ed8e78b..1c78da4 100644
--- a/ambari-web/test/controllers/main/host/add_controller_test.js
+++ b/ambari-web/test/controllers/main/host/add_controller_test.js
@@ -1172,6 +1172,7 @@ describe('App.AddHostController', function () {
     });
   });
 
+  /*eslint-disable mocha-cleanup/no-assertions-in-loop*/
   describe("#loadAllPriorSteps()", function () {
     var stepsSet = {
       '1': [
@@ -1313,6 +1314,7 @@ describe('App.AddHostController', function () {
       });
     }, this);
   });
+  /*eslint-enable mocha-cleanup/no-assertions-in-loop*/
 
   describe("#clearAllSteps()", function () {
     beforeEach(function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/wizard/step3_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step3_test.js b/ambari-web/test/controllers/wizard/step3_test.js
index ee38304..438554b 100644
--- a/ambari-web/test/controllers/wizard/step3_test.js
+++ b/ambari-web/test/controllers/wizard/step3_test.js
@@ -1630,21 +1630,24 @@ describe('App.WizardStep3Controller', function () {
               c.parseHostCheckWarnings({tasks: test.tasks});
             });
 
-            it('warnings', function () {
-              c.get('warnings').forEach(function (w, i) {
-                Em.keys(test.e.warnings[i]).forEach(function (k) {
-                  expect(w[k]).to.eql(test.e.warnings[i][k]);
+            it('warnings count is valid', function () {
+              expect(c.get('warnings.length')).to.be.equal(test.e.warnings.length);
+            });
+
+            test.e.warnings.forEach(function (warning, index) {
+              Object.keys(warning).forEach(function (warningKey) {
+                it('warning #' + (index + 1) + ' key: ' + warningKey, function () {
+                  expect(c.get('warnings')[index][warningKey]).to.be.eql(warning[warningKey]);
                 });
               });
             });
 
-            it('warningsByHost', function () {
-              for (var i in test.e.warningsByHost) {
-                if (test.e.warningsByHost.hasOwnProperty(i)) {
-                  expect(c.get('warningsByHost')[i].warnings.length).to.equal(test.e.warningsByHost[i]);
-                }
-              }
+            Object.keys(test.e.warningsByHost).forEach(function (warningByHostKey, index) {
+              it ('warningsByHost #' + (index + 1), function () {
+                expect(c.get('warningsByHost')[index].warnings.length).to.equal(test.e.warningsByHost[warningByHostKey]);
+              });
             });
+
           });
         });
       });
@@ -2095,21 +2098,21 @@ describe('App.WizardStep3Controller', function () {
               beforeEach(function () {
                 c.parseWarnings({items: test.items});
               });
-              it('warnings', function () {
-                c.get('warnings').forEach(function (w, i) {
-                  Em.keys(test.e.warnings[i]).forEach(function (k) {
-                    expect(w[k]).to.eql(test.e.warnings[i][k]);
+
+              test.e.warnings.forEach(function (warning, index) {
+                Object.keys(warning).forEach(function (warningKey) {
+                  it('warning #' + (index + 1) + ' key: ' + warningKey, function () {
+                    expect(c.get('warnings')[index][warningKey]).to.be.eql(warning[warningKey]);
                   });
                 });
               });
 
-              it('warningsByHost', function () {
-                for (var i in test.e.warningsByHost) {
-                  if (test.e.warningsByHost.hasOwnProperty(i)) {
-                    expect(c.get('warningsByHost')[i].warnings.length).to.equal(test.e.warningsByHost[i]);
-                  }
-                }
+              Object.keys(test.e.warningsByHost).forEach(function (warningByHostKey, index) {
+                it ('warningsByHost #' + (index + 1), function () {
+                  expect(c.get('warningsByHost')[index].warnings.length).to.equal(test.e.warningsByHost[warningByHostKey]);
+                });
               });
+
             });
           });
         });

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/wizard/step4_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step4_test.js b/ambari-web/test/controllers/wizard/step4_test.js
index 611aa27..80667c9 100644
--- a/ambari-web/test/controllers/wizard/step4_test.js
+++ b/ambari-web/test/controllers/wizard/step4_test.js
@@ -225,11 +225,22 @@ describe('App.WizardStep4Controller', function () {
     tests.forEach(function(test) {
       var message = 'Erorrs {0} thrown. errorStack property should contains ids: {1}'
         .format(test.errorObjects.mapProperty('id').join(', '), test.expectedIds.join(', '));
-      it(message, function() {
-        test.errorObjects.forEach(function(errorObject) {
-          expect(controller.addValidationError(errorObject)).to.equal(errorObject.shouldBeAdded);
+      describe(message, function() {
+
+        beforeEach(function () {
+          this.added = [];
+          test.errorObjects.forEach(function(errorObject) {
+            this.added.push(controller.addValidationError(errorObject));
+          }, this);
+        });
+
+        it('shouldBeAdded', function() {
+          expect(this.added).to.be.eql(test.errorObjects.mapProperty('shouldBeAdded'));
+        });
+
+        it('expectedIds', function() {
+          expect(controller.get('errorStack').mapProperty('id')).to.eql(test.expectedIds);
         });
-        expect(controller.get('errorStack').mapProperty('id')).to.eql(test.expectedIds);
       });
     })
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/wizard/step5_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step5_test.js b/ambari-web/test/controllers/wizard/step5_test.js
index 2b3b023..a2bc687 100644
--- a/ambari-web/test/controllers/wizard/step5_test.js
+++ b/ambari-web/test/controllers/wizard/step5_test.js
@@ -709,11 +709,8 @@ describe('App.WizardStep5Controller', function () {
           });
 
           it('all needed hosts have valid data', function () {
-            result.forEach(function (r, i) {
-              expect(r.get('host_name')).to.equal(test.e[i].host_name);
-              expect(r.get('masterServices.length')).to.equal(test.e[i].masterServices.length);
-              expect(r.get('hostInfo')).to.be.an.object;
-            });
+            expect(result.mapProperty('host_name')).to.be.eql(test.e.mapProperty('host_name'));
+            expect(result.mapProperty('masterServices.length')).to.be.eql(test.e.mapProperty('masterServices.length'));
           });
         });
       });

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/wizard/step6_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step6_test.js b/ambari-web/test/controllers/wizard/step6_test.js
index 61cf879..56b9e96 100644
--- a/ambari-web/test/controllers/wizard/step6_test.js
+++ b/ambari-web/test/controllers/wizard/step6_test.js
@@ -1588,9 +1588,9 @@ describe('App.WizardStep6Controller', function () {
           expect(controller.get('content.recommendationsHostGroups.blueprint_cluster_binding.host_groups.length')).to.equal(expectedHostGroups.length);
         });
 
-        it('components are valid for each group', function () {
-          controller.get('content.recommendationsHostGroups.blueprint.host_groups').forEach(function (group, index) {
-            expect(group.components.mapProperty('name').sort()).to.eql(item.expected[index]);
+        item.expected.forEach(function (e, index) {
+          it('components are valid for group# ' + (index + 1), function () {
+            expect(controller.get('content.recommendationsHostGroups.blueprint.host_groups')[index].components.mapProperty('name').sort()).to.be.eql(e);
           });
         });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/wizard/step7_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js
index 80e6ac5..d4dcb24 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -1770,12 +1770,15 @@ describe('App.InstallerStep7Controller', function () {
       expect(configs.length - oldConfigs.length).to.be.equal(6);
     });
 
-    it('find the same property in hdfs-client for HAWQ and see if attribute value matches with the corresponding property\'s attribute value in hdfs-site', function () {
+    describe('find the same property in hdfs-client for HAWQ and see if attribute value matches with the corresponding property\'s attribute value in hdfs-site', function () {
       oldConfigs.forEach(function(property) {
-        expect(configs.findProperty('id', property.name + '__hdfs-client').description).to.be.eql(property.description);
-        expect(configs.findProperty('id', property.name + '__hdfs-client').displayName).to.be.eql(property.displayName);
-        expect(configs.findProperty('id', property.name + '__hdfs-client').value).to.be.eql(property.value);
-        expect(configs.findProperty('id', property.name + '__hdfs-client').recommendedValue).to.be.eql(property.recommendedValue);
+        var id = property.name + '__hdfs-client';
+        it(id, function () {
+          expect(configs.findProperty('id', id).description).to.be.equal(property.description);
+          expect(configs.findProperty('id', id).displayName).to.be.equal(property.displayName);
+          expect(configs.findProperty('id', id).value).to.be.equal(property.value);
+          expect(configs.findProperty('id', id).recommendedValue).to.be.equal(property.recommendedValue);
+        });
       });
     });
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/wizard/step8_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step8_test.js b/ambari-web/test/controllers/wizard/step8_test.js
index b40b91c..298c9a8 100644
--- a/ambari-web/test/controllers/wizard/step8_test.js
+++ b/ambari-web/test/controllers/wizard/step8_test.js
@@ -1171,13 +1171,22 @@ describe('App.WizardStep8Controller', function () {
 
   describe('#deleteClusters', function() {
 
-    it('should call App.ajax.send for each provided clusterName', function() {
+    describe('should call App.ajax.send for each provided clusterName', function() {
       var clusterNames = ['h1', 'h2', 'h3'];
-      installerStep8Controller.deleteClusters(clusterNames);
-      var args = testHelpers.filterAjaxRequests('name', 'common.delete.cluster');
-      expect(args).to.have.property('length').equal(clusterNames.length);
+      var args;
+      beforeEach(function () {
+        installerStep8Controller.deleteClusters(clusterNames);
+        args = testHelpers.filterAjaxRequests('name', 'common.delete.cluster');
+      });
+
+      it('args', function () {
+        expect(args).to.have.property('length').equal(clusterNames.length);
+      });
+
       clusterNames.forEach(function(n, i) {
-        expect(args[i][0].data).to.eql({name: n, isLast: i === clusterNames.length - 1});
+        it(n, function () {
+          expect(args[i][0].data).to.eql({name: n, isLast: i === clusterNames.length - 1});
+        });
       });
     });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/wizard/step9_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step9_test.js b/ambari-web/test/controllers/wizard/step9_test.js
index 2eb8709..dd4f6cd 100644
--- a/ambari-web/test/controllers/wizard/step9_test.js
+++ b/ambari-web/test/controllers/wizard/step9_test.js
@@ -188,17 +188,24 @@ describe('App.InstallerStep9Controller', function () {
   });
 
   describe('#resetHostsForRetry', function () {
-    it('All should have status "pending" and message "Waiting"', function () {
-      var hosts = {'host1': Em.Object.create({status: 'failed', message: 'Failed'}), 'host2': Em.Object.create({status: 'success', message: 'Success'})};
+    var hosts = {'host1': Em.Object.create({status: 'failed', message: 'Failed'}), 'host2': Em.Object.create({status: 'success', message: 'Success'})};
+
+    beforeEach(function () {
       c.reopen({content: {hosts: hosts}});
       c.resetHostsForRetry();
-      for (var name in hosts) {
-        if (hosts.hasOwnProperty(name)) {
+    });
+
+    Object.keys(hosts).forEach(function (name) {
+      if (hosts.hasOwnProperty(name)) {
+        it(name + '.status', function () {
           expect(c.get('content.hosts')[name].get('status', 'pending')).to.equal('pending');
+        });
+        it(name + '.message', function () {
           expect(c.get('content.hosts')[name].get('message', 'Waiting')).to.equal('Waiting');
-        }
+        });
       }
     });
+
   });
 
   describe('#setParseHostInfo', function () {
@@ -1353,10 +1360,8 @@ describe('App.InstallerStep9Controller', function () {
       var hosts = Em.A([Em.Object.create({name: 'host1', progress: '33', status: 'info'}), Em.Object.create({name: 'host2', progress: '33', status: 'info'})]);
       c.reopen({hosts: hosts, content: {controllerName: 'installerController', cluster: {status: 'PENDING', name: 'c1'}}});
       c.launchStartServicesErrorCallback({status: 500, statusTesxt: 'Server Error'}, {}, '', {});
-      c.get('hosts').forEach(function (host) {
-        expect(host.get('progress')).to.equal('100');
-        expect(host.get('status')).to.equal('info');
-      });
+      expect(c.get('hosts').everyProperty('progress', '100')).to.be.true;
+      expect(c.get('hosts').everyProperty('status', 'info')).to.be.true;
     });
 
     it('Next button should be disabled', function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/controllers/wizard_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard_test.js b/ambari-web/test/controllers/wizard_test.js
index 06729dd..d9239200 100644
--- a/ambari-web/test/controllers/wizard_test.js
+++ b/ambari-web/test/controllers/wizard_test.js
@@ -1187,9 +1187,7 @@ describe('App.WizardController', function () {
     it('should not save admin_principal or admin_password to the localStorage', function () {
       c.saveServiceConfigProperties(kerberosStepController);
       var saved = c.get('content.serviceConfigProperties');
-      saved.forEach(function(config) {
-        expect(config.value).to.equal('');
-      });
+      expect(saved.everyProperty('value', '')).to.be.true;
     });
   });
 
@@ -1475,8 +1473,8 @@ describe('App.WizardController', function () {
       }
     ];
 
-    it('should convert objects and arrays to pure JS objects and arrays', function () {
-      testCases.forEach(function (testCase) {
+    testCases.forEach(function (testCase, index) {
+      it('should convert objects and arrays to pure JS objects and arrays (' + (index + 1) + ')', function () {
         expect(c.toJSInstance(testCase.o)).to.eql(testCase.e);
       });
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/mappers/service_mapper_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mappers/service_mapper_test.js b/ambari-web/test/mappers/service_mapper_test.js
index 0634f19..4a8d49d 100644
--- a/ambari-web/test/mappers/service_mapper_test.js
+++ b/ambari-web/test/mappers/service_mapper_test.js
@@ -26,8 +26,7 @@ describe('App.serviceMetricsMapper', function () {
 
   describe('#hbaseMapper', function() {
 
-    it ('Round Average Load', function() {
-      var tests = [
+    var tests = [
         {
           components: [
             {
@@ -152,8 +151,9 @@ describe('App.serviceMetricsMapper', function () {
           ],
           e: '1.20'
         }
-      ];
-      tests.forEach(function(test) {
+    ];
+    tests.forEach(function(test) {
+      it('Round Average Load (' + test.e + ')', function () {
         var result = App.serviceMetricsMapper.hbaseMapper(test);
         expect(result.average_load).to.equal(test.e);
       });

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/mixins/common/configs/toggle_isrequired_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/configs/toggle_isrequired_test.js b/ambari-web/test/mixins/common/configs/toggle_isrequired_test.js
index 49865db..4672ae6 100644
--- a/ambari-web/test/mixins/common/configs/toggle_isrequired_test.js
+++ b/ambari-web/test/mixins/common/configs/toggle_isrequired_test.js
@@ -47,11 +47,8 @@ describe('#_overrideConfigIsRequired', function () {
 
   it('should make isRequired = false for kerberos properties', function () {
     instanceObject.overrideConfigIsRequired(serviceConfig);
-    // toggle isRequired to false
-    configs.forEach(function(p) {
-      expect(p.isRequired).to.be.false;
-      expect(p.error).to.be.false;
-    });
+    expect(configs.everyProperty('isRequired', false)).to.be.true;
+    expect(configs.everyProperty('error', false)).to.be.true;
   });
 
   it('should make isRequired = true for kerberos properties', function () {
@@ -59,9 +56,6 @@ describe('#_overrideConfigIsRequired', function () {
     instanceObject.overrideConfigIsRequired(serviceConfig);
     // toggle to true
     instanceObject.overrideConfigIsRequired(serviceConfig);
-
-    configs.forEach(function(p) {
-      expect(p.isRequired).to.be.true;
-    });
+    expect(configs.everyProperty('isRequired', true)).to.be.true;
   });
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/mixins/common/kdc_credentials_controller_mixin_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/kdc_credentials_controller_mixin_test.js b/ambari-web/test/mixins/common/kdc_credentials_controller_mixin_test.js
index 20f6b76..e3a1960 100644
--- a/ambari-web/test/mixins/common/kdc_credentials_controller_mixin_test.js
+++ b/ambari-web/test/mixins/common/kdc_credentials_controller_mixin_test.js
@@ -52,18 +52,25 @@ describe('App.KDCCredentialsControllerMixin', function() {
         message: 'Only temporary store available, config should be disabled, and appropriate hint shown'
       }
     ].forEach(function(test) {
-      it(test.message, function() {
-        var configs = [],
-            config;
-        mixedObject.reopen({
-          isStorePersisted: function() {
-            return test.isStorePersisted;
-          }.property()
+      describe(test.message, function() {
+
+        var config;
+
+        beforeEach(function () {
+          var configs = [];
+          mixedObject.reopen({
+            isStorePersisted: function() {
+              return test.isStorePersisted;
+            }.property()
+          });
+          mixedObject.initilizeKDCStoreProperties(configs);
+          config = configs.findProperty('name', 'persist_credentials');
         });
-        mixedObject.initilizeKDCStoreProperties(configs);
-        config = configs.findProperty('name', 'persist_credentials');
-        Em.keys(test.e).forEach(function(key) {
-          assert.equal(Em.get(config, key), test.e[key], 'validate attribute: ' + key);
+
+        Object.keys(test.e).forEach(function(key) {
+          it(key, function () {
+            assert.equal(Em.get(config, key), test.e[key], 'validate attribute: ' + key);
+          });
         });
       });
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/mixins/common/serverValidator_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/serverValidator_test.js b/ambari-web/test/mixins/common/serverValidator_test.js
index c6d528a..aac91b0 100644
--- a/ambari-web/test/mixins/common/serverValidator_test.js
+++ b/ambari-web/test/mixins/common/serverValidator_test.js
@@ -121,11 +121,17 @@ describe('App.ServerValidatorMixin', function() {
     });
     
     tests.forEach(function(test) {
-      it(test.message, function() {
-        instanceObject.set('stepConfigs', test.stepConfigs);
-        instanceObject.validationSuccess({resources: test.resources});
+      describe(test.message, function() {
+
+        beforeEach(function () {
+          instanceObject.set('stepConfigs', test.stepConfigs);
+          instanceObject.validationSuccess({resources: test.resources});
+        });
+
         test.expected.forEach(function(e) {
-          expect(instanceObject).to.have.deep.property(e.prop, e.value);
+          it(e.prop + ': ' + e.value, function () {
+            expect(instanceObject).to.have.deep.property(e.prop, e.value);
+          });
         });
       });
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/models/cluster_states_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/cluster_states_test.js b/ambari-web/test/models/cluster_states_test.js
index d07845f..96a1832 100644
--- a/ambari-web/test/models/cluster_states_test.js
+++ b/ambari-web/test/models/cluster_states_test.js
@@ -57,14 +57,24 @@ describe('App.clusterStatus', function () {
   });
 
   describe('#getUserPrefSuccessCallback', function () {
-    it('should set the cluster parameters', function () {
-      status.getUserPrefSuccessCallback(response);
+    describe('response', function () {
+      beforeEach(function () {
+        status.getUserPrefSuccessCallback(response);
+      });
       Em.keys(response).forEach(function (key) {
-        expect(status.get(key)).to.equal(response[key]);
+        it(key, function () {
+          expect(status.get(key)).to.equal(response[key]);
+        });
+      });
+    });
+    describe('compressedResponse', function () {
+      beforeEach(function () {
+        status.getUserPrefSuccessCallback(compressedResponse);
       });
-      status.getUserPrefSuccessCallback(compressedResponse);
       Em.keys(response2).forEach(function (key) {
-        expect(status.get(key)).to.equal(response2[key]);
+        it(key, function () {
+          expect(status.get(key)).to.equal(response2[key]);
+        });
       });
     });
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/models/configs/objects/service_config_property_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/configs/objects/service_config_property_test.js b/ambari-web/test/models/configs/objects/service_config_property_test.js
index 2b4a297..b8a6f4e 100644
--- a/ambari-web/test/models/configs/objects/service_config_property_test.js
+++ b/ambari-web/test/models/configs/objects/service_config_property_test.js
@@ -289,17 +289,13 @@ describe('App.ServiceConfigProperty', function () {
   describe('#isPropertyOverridable', function () {
     overridableFalseData.forEach(function (item) {
       it('should be false', function () {
-        Em.keys(item).forEach(function (prop) {
-          serviceConfigProperty.set(prop, item[prop]);
-        });
+        serviceConfigProperty.setProperties(item);
         expect(serviceConfigProperty.get('isPropertyOverridable')).to.be.false;
       });
     });
     overridableTrueData.forEach(function (item) {
       it('should be true', function () {
-        Em.keys(item).forEach(function (prop) {
-          serviceConfigProperty.set(prop, item[prop]);
-        });
+        serviceConfigProperty.setProperties(item);
         expect(serviceConfigProperty.get('isPropertyOverridable')).to.be.true;
       });
     });
@@ -308,17 +304,13 @@ describe('App.ServiceConfigProperty', function () {
   describe('#isOverridden', function () {
     overriddenFalseData.forEach(function (item) {
       it('should be false', function () {
-        Em.keys(item).forEach(function (prop) {
-          serviceConfigProperty.set(prop, item[prop]);
-        });
+        serviceConfigProperty.setProperties(item);
         expect(serviceConfigProperty.get('isOverridden')).to.be.false;
       });
     });
     overriddenTrueData.forEach(function (item) {
       it('should be true', function () {
-        Em.keys(item).forEach(function (prop) {
-          serviceConfigProperty.set(prop, item[prop]);
-        });
+        serviceConfigProperty.setProperties(item);
         expect(serviceConfigProperty.get('isOverridden')).to.be.true;
       });
     });
@@ -327,17 +319,13 @@ describe('App.ServiceConfigProperty', function () {
   describe('#isRemovable', function () {
     removableFalseData.forEach(function (item) {
       it('should be false', function () {
-        Em.keys(item).forEach(function (prop) {
-          serviceConfigProperty.set(prop, item[prop]);
-        });
+        serviceConfigProperty.setProperties(item);
         expect(serviceConfigProperty.get('isRemovable')).to.be.false;
       });
     });
     removableTrueData.forEach(function (item) {
       it('should be true', function () {
-        Em.keys(item).forEach(function (prop) {
-          serviceConfigProperty.set(prop, item[prop]);
-        });
+        serviceConfigProperty.setProperties(item);
         expect(serviceConfigProperty.get('isRemovable')).to.be.true;
       });
     });
@@ -345,10 +333,14 @@ describe('App.ServiceConfigProperty', function () {
 
   describe('#init', function () {
     initPropertyData.forEach(function (item) {
-      it('should set initial data', function () {
-        serviceConfigPropertyInit = App.ServiceConfigProperty.create(item.initial);
+      describe('should set initial data for ' + JSON.stringify(item), function () {
+        beforeEach(function () {
+          serviceConfigPropertyInit = App.ServiceConfigProperty.create(item.initial);
+        });
         Em.keys(item.result).forEach(function (prop) {
-          expect(serviceConfigPropertyInit.get(prop)).to.equal(item.result[prop]);
+          it(prop, function () {
+            expect(serviceConfigPropertyInit.get(prop)).to.equal(item.result[prop]);
+          });
         });
       });
     });
@@ -357,9 +349,7 @@ describe('App.ServiceConfigProperty', function () {
   describe('#isNotDefaultValue', function () {
     notDefaultFalseData.forEach(function (item) {
       it('should be false', function () {
-        Em.keys(item).forEach(function (prop) {
-          serviceConfigProperty.set(prop, item[prop]);
-        });
+        serviceConfigProperty.setProperties(item);
         expect(serviceConfigProperty.get('isNotDefaultValue')).to.be.false;
       });
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/router_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/router_test.js b/ambari-web/test/router_test.js
index de4b77a..7bd2c80 100644
--- a/ambari-web/test/router_test.js
+++ b/ambari-web/test/router_test.js
@@ -94,49 +94,49 @@ describe('App.Router', function () {
       window.location.replace.restore();
     });
 
-    it('should redirect to the latest version of admin view', function() {
-      var tests = [{
-        mockData: {
-          components: [{
-            'RootServiceComponents': {
-              'component_version': '1.9.0'
-            }
-          }, {
-            'RootServiceComponents': {
-              'component_version': '2.0.0'
-            }
-          }]
-        },
-        expected: '/views/ADMIN_VIEW/2.0.0/INSTANCE/#/'
-      }, {
-        mockData: {
-          components: [{
-            'RootServiceComponents': {
-              'component_version': '1.9.0'
-            }
-          }, {
-            'RootServiceComponents': {
-              'component_version': '2.1.0'
-            }
-          }, {
-            'RootServiceComponents': {
-              'component_version': '2.0.0'
-            }
-          }]
-        },
-        expected: '/views/ADMIN_VIEW/2.1.0/INSTANCE/#/'
-      }, {
-        mockData: {
-          versions: [{
-            'RootServiceComponents': {
-              version: '2.1.0'
-            }
-          }]
-        },
-        expected: '/views/ADMIN_VIEW/2.1.0/INSTANCE/#/'
-      }];
+    var tests = [{
+      mockData: {
+        components: [{
+          'RootServiceComponents': {
+            'component_version': '1.9.0'
+          }
+        }, {
+          'RootServiceComponents': {
+            'component_version': '2.0.0'
+          }
+        }]
+      },
+      expected: '/views/ADMIN_VIEW/2.0.0/INSTANCE/#/'
+    }, {
+      mockData: {
+        components: [{
+          'RootServiceComponents': {
+            'component_version': '1.9.0'
+          }
+        }, {
+          'RootServiceComponents': {
+            'component_version': '2.1.0'
+          }
+        }, {
+          'RootServiceComponents': {
+            'component_version': '2.0.0'
+          }
+        }]
+      },
+      expected: '/views/ADMIN_VIEW/2.1.0/INSTANCE/#/'
+    }, {
+      mockData: {
+        components: [{
+          'RootServiceComponents': {
+            component_version: '2.1.0'
+          }
+        }]
+      },
+      expected: '/views/ADMIN_VIEW/2.1.0/INSTANCE/#/'
+    }];
 
-      tests.forEach(function(data) {
+    tests.forEach(function(data, index) {
+      it('should redirect to the latest version of admin view ("' + data.expected + '") #' + (index + 1), function () {
         router.adminViewInfoSuccessCallback(data.mockData);
         expect(window.location.replace.calledWith(data.expected)).to.be.true;
       });

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/utils/ajax/ajax_queue_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/ajax/ajax_queue_test.js b/ambari-web/test/utils/ajax/ajax_queue_test.js
index 89c7f61..10c3299 100644
--- a/ambari-web/test/utils/ajax/ajax_queue_test.js
+++ b/ambari-web/test/utils/ajax/ajax_queue_test.js
@@ -91,7 +91,7 @@ describe('App.ajaxQueue', function () {
     it('for empty queue App.ajax.send shouldn\'t be called', function() {
       ajaxQueue.clear();
       ajaxQueue.runNextRequest();
-      expect(App.ajax.send.called).to.equal(false);
+      expect(App.ajax.send.called).to.equal(false); // eslint-disable-line mocha-cleanup/disallowed-usage
     });
     it('when queue is empty finishedCallback should be called', function() {
       ajaxQueue.clear();

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/utils/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/config_test.js b/ambari-web/test/utils/config_test.js
index b58bfa3..0df828e 100644
--- a/ambari-web/test/utils/config_test.js
+++ b/ambari-web/test/utils/config_test.js
@@ -673,10 +673,10 @@ describe('App.config', function () {
 
     var group = Em.Object.create({name: "group1"});
 
-    it('creates override with save properties as original config', function() {
-      var override = App.config.createOverride(configProperty, {}, group);
-      Object.keys(template).forEach(function (key) {
-        expect(override.get(key)).to.eql(template[key]);
+    Object.keys(template).forEach(function (key) {
+      it(key, function () {
+        var override = App.config.createOverride(configProperty, {}, group);
+        expect(override.get(key)).to.equal(template[key]);
       });
     });
 
@@ -699,19 +699,19 @@ describe('App.config', function () {
       });
     });
 
-    it('overrides some specific values', function() {
-      var overridenTemplate = {
-        value: "v2",
-        recommendedValue: "rv2",
-        savedValue: "sv2",
-        isFinal: true,
-        recommendedIsFinal: false,
-        savedIsFinal: true
-      };
+    var overriddenTemplate = {
+      value: "v2",
+      recommendedValue: "rv2",
+      savedValue: "sv2",
+      isFinal: true,
+      recommendedIsFinal: false,
+      savedIsFinal: true
+    };
 
-      var override = App.config.createOverride(configProperty, overridenTemplate, group);
-      Object.keys(overridenTemplate).forEach(function (key) {
-        expect(override.get(key)).to.eql(overridenTemplate[key]);
+    Object.keys(overriddenTemplate).forEach(function (key) {
+      it('overrides some specific values `' + key + '`', function () {
+        var override = App.config.createOverride(configProperty, overriddenTemplate, group);
+        expect(override.get(key)).to.equal(overriddenTemplate[key]);
       });
     });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/utils/date/timezone_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/date/timezone_test.js b/ambari-web/test/utils/date/timezone_test.js
index f372fa6..da89586 100644
--- a/ambari-web/test/utils/date/timezone_test.js
+++ b/ambari-web/test/utils/date/timezone_test.js
@@ -94,27 +94,25 @@ describe('timezoneUtils', function () {
 
   describe('#getAllTimezoneNames', function () {
 
-    before(function () {
-      this.result = timezoneUtils.getAllTimezoneNames();
-    });
-
-    after(function () {
-      this.result = undefined;
-    });
+    var result = timezoneUtils.getAllTimezoneNames();
 
     it('timezone names are parsed', function () {
       expect(this.result).to.have.length.above(0);
     });
 
-    it('Etc/* are excluded', function () {
-      this.result.forEach(function (tz) {
-        expect(tz.indexOf('Etc/')).to.equal(-1);
+    describe('Etc/* are excluded', function () {
+      result.forEach(function (tz) {
+        it(tz, function () {
+          expect(tz.indexOf('Etc/')).to.equal(-1);
+        });
       });
     });
 
-    it('Abbreviations are excluded', function () {
-      this.result.forEach(function (tz) {
-        expect(tz).to.not.equal(tz.toUpperCase());
+    describe('Abbreviations are excluded', function () {
+      result.forEach(function (tz) {
+        it(tz, function () {
+          expect(tz).to.not.equal(tz.toUpperCase());
+        });
       });
     });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/utils/helper_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/helper_test.js b/ambari-web/test/utils/helper_test.js
index 5d8bc40..2b43f28 100644
--- a/ambari-web/test/utils/helper_test.js
+++ b/ambari-web/test/utils/helper_test.js
@@ -180,11 +180,7 @@ describe('utils/helper', function() {
         expect(testable.length).to.eql(result.length);
       });
       it('should sort array', function() {
-        result.forEach(function(resultObj, index, resultArr) {
-          if (index > resultArr.length - 1) {
-            expect(resultObj.a < resultArr[index + 1].a).to.be.equal(false);
-          }
-        });
+        expect(result.mapProperty('a')).to.be.eql([1, 2, 3, 3, 6, 64]);
       });
       it('should try to sort without throwing exception', function(){
         expect(testable.sortPropertyLight(['a'])).to.ok;

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/views/common/chart/linear_time_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/chart/linear_time_test.js b/ambari-web/test/views/common/chart/linear_time_test.js
index 202a6ad..7d76520 100644
--- a/ambari-web/test/views/common/chart/linear_time_test.js
+++ b/ambari-web/test/views/common/chart/linear_time_test.js
@@ -379,12 +379,18 @@ describe('App.ChartLinearTimeView', function () {
     });
 
     cases.forEach(function (item) {
-      it(item.title || item.displayUnit, function () {
-        view.set('displayUnit', item.displayUnit);
-        view.setYAxisFormatter();
-        view.yAxisFormatter();
+      describe(item.title || item.displayUnit, function () {
+
+        beforeEach(function () {
+          view.set('displayUnit', item.displayUnit);
+          view.setYAxisFormatter();
+          view.yAxisFormatter();
+        });
+
         methodNames.forEach(function (name) {
-          expect(App.ChartLinearTimeView[name].callCount).to.equal(Number(name === item.formatter));
+          it(name, function () {
+            expect(App.ChartLinearTimeView[name].callCount).to.equal(Number(name === item.formatter));
+          });
         });
       });
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/views/common/configs/service_config_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/service_config_view_test.js b/ambari-web/test/views/common/configs/service_config_view_test.js
index f0757a3..8a01d72 100644
--- a/ambari-web/test/views/common/configs/service_config_view_test.js
+++ b/ambari-web/test/views/common/configs/service_config_view_test.js
@@ -80,12 +80,18 @@ describe('App.ServiceConfigView', function () {
     });
 
     testCases.forEach(function (test) {
-      it(test.title, function () {
-        controller.set('selectedService', test.selectedService);
-        controller.set('selectedConfigGroup', test.selectedConfigGroup);
-        view.checkCanEdit();
-        controller.get('selectedService.configCategories').forEach(function (category) {
-          expect(category.get('canAddProperty')).to.equal(test.result[category.get('name')]);
+      describe(test.title, function () {
+
+        beforeEach(function () {
+          controller.set('selectedService', test.selectedService);
+          controller.set('selectedConfigGroup', test.selectedConfigGroup);
+          view.checkCanEdit();
+        });
+        Object.keys(test.result).forEach(function (categoryName) {
+          it(categoryName, function () {
+            var canAddProperty = controller.get('selectedService.configCategories').findProperty('name', categoryName).get('canAddProperty');
+            expect(canAddProperty).to.be.equal(test.result[categoryName]);
+          });
         });
       });
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/views/common/modal_popups/cluster_check_popup_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/modal_popups/cluster_check_popup_test.js b/ambari-web/test/views/common/modal_popups/cluster_check_popup_test.js
index 232c267..71e602a 100644
--- a/ambari-web/test/views/common/modal_popups/cluster_check_popup_test.js
+++ b/ambari-web/test/views/common/modal_popups/cluster_check_popup_test.js
@@ -257,15 +257,19 @@ describe('App.showClusterCheckPopup', function () {
         popup.onPrimary();
       });
 
-      it('result', function () {
+      describe('result', function () {
         Em.keys(item.result).forEach(function (key) {
-          expect(popup[key]).to.equal(item.result[key]);
+          it(key, function () {
+            expect(popup[key]).to.equal(item.result[key]);
+          });
         });
       });
 
-      it('bodyResult', function () {
+      describe('bodyResult', function () {
         Em.keys(item.bodyResult).forEach(function (key) {
-          expect(popupBody[key]).to.eql(item.bodyResult[key]);
+          it(key, function () {
+            expect(popupBody[key]).to.eql(item.bodyResult[key]);
+          });
         });
       });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js b/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js
index 43c05ad..63382bd 100644
--- a/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js
+++ b/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js
@@ -102,15 +102,18 @@ describe('App.ManageAlertNotificationsView', function () {
         }
       }
     ]).forEach(function (test) {
-      it(test.m, function () {
-        Em.keys(test.p).forEach(function (k) {
-          view.set(k, test.p[k]);
+      describe(test.m, function () {
+        beforeEach(function () {
+          view.setProperties(test.p);
+          view.set('controller.selectedAlertNotification', test.selectedAlertNotification);
+          App.isOperator = test.isOperator;
+          view.buttonObserver();
         });
-        view.set('controller.selectedAlertNotification', test.selectedAlertNotification);
-        App.isOperator = test.isOperator;
-        view.buttonObserver();
+
         Em.keys(test.e).forEach(function (k) {
-          expect(view.get(k)).to.equal(test.e[k]);
+          it(k, function () {
+            expect(view.get(k)).to.equal(test.e[k]);
+          });
         });
       });
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/views/wizard/step3_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step3_view_test.js b/ambari-web/test/views/wizard/step3_view_test.js
index bb4c6cb..6d0d0b6 100644
--- a/ambari-web/test/views/wizard/step3_view_test.js
+++ b/ambari-web/test/views/wizard/step3_view_test.js
@@ -20,9 +20,8 @@ var App = require('app');
 require('messages');
 require('views/wizard/step3_view');
 var v;
-describe('App.WizardStep3View', function () {
-
-  var view = App.WizardStep3View.create({
+function getView() {
+  return App.WizardStep3View.create({
     monitorStatuses: function () {
     },
     content: [
@@ -46,6 +45,11 @@ describe('App.WizardStep3View', function () {
       return this.get('content');
     }.property('content')
   });
+}
+
+describe('App.WizardStep3View', function () {
+
+  var view = getView();
 
   describe('#watchSelection', function () {
     it('2 of 3 hosts selected', function () {
@@ -240,13 +244,22 @@ describe('App.WizardStep3View', function () {
   ]);
 
   describe('#countCategoryHosts', function () {
+    var _view;
     testCases.forEach(function (test) {
-      it(test.title, function () {
-        view.set('content', test.content);
-        view.countCategoryHosts();
-        view.get('categories').forEach(function (category) {
-          expect(category.get('hostsCount')).to.equal(test.result[category.get('hostsBootStatus')])
-        })
+      describe(test.title, function () {
+
+        beforeEach(function () {
+          _view = getView();
+          _view.set('content', test.content);
+          _view.countCategoryHosts();
+        });
+
+        Object.keys(test.result).forEach(function (categoryName) {
+          it('`' + categoryName + '`', function () {
+            expect(_view.get('categories').findProperty('hostsBootStatus', categoryName).get('hostsCount')).to.be.equal(test.result[categoryName])
+          });
+        });
+
       });
     }, this);
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/31477a58/ambari-web/test/views/wizard/step9_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step9_view_test.js b/ambari-web/test/views/wizard/step9_view_test.js
index b9c0182..646e945 100644
--- a/ambari-web/test/views/wizard/step9_view_test.js
+++ b/ambari-web/test/views/wizard/step9_view_test.js
@@ -20,20 +20,23 @@ var App = require('app');
 require('views/wizard/step9_view');
 
 var v;
+function getView() {
+  return App.WizardStep9View.create({
+    onStatus: function () {},
+    content: [],
+    pageContent: function () {
+      return this.get('content');
+    }.property('content')
+  });
+}
+
 describe('App.WizardStep9View', function () {
   beforeEach(function () {
     v = App.WizardStep9View.create({
       controller: App.WizardStep9Controller.create()
     });
   });
-  var view = App.WizardStep9View.create({
-    onStatus: function () {
-    },
-    content: [],
-    pageContent: function () {
-      return this.get('content');
-    }.property('content')
-  });
+  var view = getView();
   var testCases = [
     {
       title: 'none hosts',
@@ -194,12 +197,20 @@ describe('App.WizardStep9View', function () {
 
   describe('#countCategoryHosts', function () {
     testCases.forEach(function (test) {
-      it(test.title, function () {
-        view.set('content', test.content);
-        view.countCategoryHosts();
-        view.get('categories').forEach(function (category) {
-          expect(category.get('hostsCount')).to.equal(test.result[category.get('hostStatus')])
-        })
+      describe(test.title, function () {
+        var _v;
+        beforeEach(function () {
+          _v = getView();
+          _v.set('content', test.content);
+          _v.countCategoryHosts();
+        });
+
+        Object.keys(test.result).forEach(function (categoryName) {
+          it('`' + categoryName + '`', function () {
+            expect(_v.get('categories').findProperty('hostStatus', categoryName).get('hostsCount')).to.equal(test.result[categoryName])
+          });
+        });
+
       });
     }, this);
   });
@@ -375,11 +386,17 @@ describe('App.WizardStep9View', function () {
           }
         }
       ]).forEach(function (test) {
-        it(test.status, function () {
-          v.set('controller.status', test.status);
-          v.onStatus();
-          Em.keys(test.e).forEach(function (k) {
-            expect(v.get(k)).to.equal(test.e[k]);
+        describe(test.status, function () {
+
+          beforeEach(function () {
+            v.set('controller.status', test.status);
+            v.onStatus();
+          });
+
+          Object.keys(test.e).forEach(function (k) {
+            it(k, function () {
+              expect(v.get(k)).to.equal(test.e[k]);
+            });
           });
         });
       });
@@ -636,11 +653,17 @@ describe('App.HostStatusView', function () {
           }
         }
       ]).forEach(function (test) {
-        it(JSON.stringify(test.obj), function () {
-          hv.set('obj', test.obj);
-          hv.onStatus();
-          Em.keys(test.e).forEach(function (k) {
-            expect(hv.get(k)).to.equal(test.e[k]);
+        describe(JSON.stringify(test.obj), function () {
+
+          beforeEach(function () {
+            hv.set('obj', test.obj);
+            hv.onStatus();
+          });
+
+          Object.keys(test.e).forEach(function (k) {
+            it(k, function () {
+              expect(hv.get(k)).to.equal(test.e[k]);
+            });
           });
         });
       });


[07/11] ambari git commit: AMBARI-14869: Rename AdminSetting API to Setting (Ajit Kumar via smnaha)

Posted by nc...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/test/java/org/apache/ambari/server/api/services/SettingServiceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/SettingServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/SettingServiceTest.java
new file mode 100644
index 0000000..598e420
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/SettingServiceTest.java
@@ -0,0 +1,101 @@
+/**
+ * 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.
+ */
+package org.apache.ambari.server.api.services;
+
+import org.apache.ambari.server.api.resources.ResourceInstance;
+import org.apache.ambari.server.api.services.parsers.RequestBodyParser;
+import org.apache.ambari.server.api.services.serializers.ResultSerializer;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.UriInfo;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit test for {@link SettingService}
+ */
+public class SettingServiceTest extends BaseServiceTest {
+  @Override
+  public List<ServiceTestInvocation> getTestInvocations() throws Exception {
+    List<ServiceTestInvocation> listInvocations = new ArrayList<>();
+
+    //getSetting
+    SettingService settingService = new TestSettingService("settingName");
+    Method m = settingService.getClass().getMethod("getSetting", String.class, HttpHeaders.class, UriInfo.class, String.class);
+    Object[] args = new Object[] {null, getHttpHeaders(), getUriInfo(), "settingName"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, settingService, m, args, null));
+
+    //getSettings
+    settingService = new TestSettingService(null);
+    m = settingService.getClass().getMethod("getSettings", String.class, HttpHeaders.class, UriInfo.class);
+    args = new Object[] {null, getHttpHeaders(), getUriInfo()};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, settingService, m, args, null));
+
+    //createSetting
+    settingService = new TestSettingService(null);
+    m = settingService.getClass().getMethod("createSetting", String.class, HttpHeaders.class, UriInfo.class);
+    args = new Object[] {"body", getHttpHeaders(), getUriInfo()};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.POST, settingService, m, args, "body"));
+
+    //updateSetting
+    settingService = new TestSettingService("settingName");
+    m = settingService.getClass().getMethod("updateSetting", String.class, HttpHeaders.class, UriInfo.class, String.class);
+    args = new Object[] {"body", getHttpHeaders(), getUriInfo(), "settingName"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.PUT, settingService, m, args, "body"));
+
+    //deleteSetting
+    settingService = new TestSettingService("settingName");
+    m = settingService.getClass().getMethod("deleteSetting", HttpHeaders.class, UriInfo.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "settingName"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.DELETE, settingService, m, args, null));
+
+    return listInvocations;
+  }
+
+  private class TestSettingService extends SettingService {
+    private String settingName;
+
+    private TestSettingService(String settingName) {
+      this.settingName = settingName;
+    }
+
+    @Override
+    ResourceInstance createSettingResource(String settingName) {
+      assertEquals(this.settingName, settingName);
+      return getTestResource();
+    }
+
+    @Override
+    RequestFactory getRequestFactory() {
+      return getTestRequestFactory();
+    }
+
+    @Override
+    protected RequestBodyParser getBodyParser() {
+      return getTestBodyParser();
+    }
+
+    @Override
+    protected ResultSerializer getResultSerializer() {
+      return getTestResultSerializer();
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AdminSettingResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AdminSettingResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AdminSettingResourceProviderTest.java
deleted file mode 100644
index e95449c..0000000
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AdminSettingResourceProviderTest.java
+++ /dev/null
@@ -1,356 +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.
- */
-package org.apache.ambari.server.controller.internal;
-
-import com.google.common.collect.Lists;
-import org.apache.ambari.server.DuplicateResourceException;
-import org.apache.ambari.server.controller.spi.Predicate;
-import org.apache.ambari.server.controller.spi.Request;
-import org.apache.ambari.server.controller.spi.RequestStatus;
-import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
-import org.apache.ambari.server.controller.utilities.PredicateBuilder;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
-import org.apache.ambari.server.orm.dao.AdminSettingDAO;
-import org.apache.ambari.server.orm.entities.AdminSettingEntity;
-import org.apache.ambari.server.security.TestAuthenticationFactory;
-import org.apache.ambari.server.security.authorization.AuthorizationException;
-import org.apache.ambari.server.security.authorization.AuthorizationHelper;
-import org.apache.commons.lang.RandomStringUtils;
-import org.easymock.Capture;
-import org.easymock.IMocksControl;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.security.core.context.SecurityContextHolder;
-
-import java.lang.reflect.Field;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import static org.apache.ambari.server.controller.internal.AdminSettingResourceProvider.ADMINSETTING_NAME_PROPERTY_ID;
-import static org.apache.ambari.server.controller.internal.AdminSettingResourceProvider.ADMINSETTING_SETTING_TYPE_PROPERTY_ID;
-import static org.apache.ambari.server.controller.internal.AdminSettingResourceProvider.ADMINSETTING_CONTENT_PROPERTY_ID;
-import static org.apache.ambari.server.controller.internal.AdminSettingResourceProvider.ADMINSETTING_UPDATED_BY_PROPERTY_ID;
-import static org.apache.ambari.server.controller.internal.AdminSettingResourceProvider.ADMINSETTING_UPDATE_TIMESTAMP_PROPERTY_ID;
-import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.createControl;
-
-import static org.junit.Assert.assertEquals;
-
-public class AdminSettingResourceProviderTest {
-  IMocksControl mockControl;
-  AdminSettingDAO dao;
-  AdminSettingResourceProvider resourceProvider;
-
-
-  @Before
-  public void setUp() throws Exception {
-    mockControl = createControl();
-    dao = mockControl.createMock(AdminSettingDAO.class);
-    resourceProvider = new AdminSettingResourceProvider();
-    setPrivateField(resourceProvider, "dao", dao);
-  }
-
-  @After
-  public void tearDown() {
-    mockControl.verify();
-    SecurityContextHolder.getContext().setAuthentication(null);
-    mockControl.reset();
-  }
-
-  @Test(expected = AuthorizationException.class)
-  public void testGetResources_instance_noAuth() throws Exception {
-    getResources_instance(newEntity("motd"), readRequest());
-  }
-
-  @Test
-  public void testGetResources_instance_clusterUser() throws Exception {
-    setupAuthenticationForClusterUser();
-    String name = "motd";
-    AdminSettingEntity entity = newEntity(name);
-
-    Set<Resource> response = getResources_instance(entity, readRequest());
-    assertEquals(1, response.size());
-    Resource resource = response.iterator().next();
-    assertEqualsEntityAndResource(entity, resource);
-  }
-
-  @Test
-  public void testGetResources_instance_admin() throws Exception {
-    setupAuthenticationForAdmin();
-    AdminSettingEntity entity = newEntity("motd");
-    Set<Resource> response = getResources_instance(entity, readRequest());
-    assertEquals(1, response.size());
-    Resource resource = response.iterator().next();
-    assertEqualsEntityAndResource(entity, resource);
-  }
-
-  @Test(expected = AuthorizationException.class)
-  public void testGetResources_collection_noAuth() throws Exception {
-    mockControl.replay();
-    Request request = PropertyHelper.getReadRequest(
-            ADMINSETTING_NAME_PROPERTY_ID,
-            ADMINSETTING_CONTENT_PROPERTY_ID,
-            ADMINSETTING_SETTING_TYPE_PROPERTY_ID,
-            ADMINSETTING_UPDATED_BY_PROPERTY_ID,
-            ADMINSETTING_UPDATE_TIMESTAMP_PROPERTY_ID);
-    resourceProvider.getResources(request, null);
-  }
-
-  @Test
-  public void testGetResources_collection_clusterUser() throws Exception {
-    setupAuthenticationForClusterUser();
-
-    AdminSettingEntity entity1 = newEntity("motd");
-    AdminSettingEntity entity2 = newEntity("ldap");
-    Request request = PropertyHelper.getReadRequest(
-            ADMINSETTING_NAME_PROPERTY_ID,
-            ADMINSETTING_CONTENT_PROPERTY_ID,
-            ADMINSETTING_SETTING_TYPE_PROPERTY_ID,
-            ADMINSETTING_UPDATED_BY_PROPERTY_ID,
-            ADMINSETTING_UPDATE_TIMESTAMP_PROPERTY_ID);
-
-    expect(dao.findAll()).andReturn(Lists.newArrayList(entity1, entity2));
-    mockControl.replay();
-
-    Set<Resource> response = resourceProvider.getResources(request, null);
-    assertEquals(2, response.size());
-    Map<Object, Resource> resourceMap = new HashMap<>();
-    Iterator<Resource> resourceIterator = response.iterator();
-    Resource nextResource = resourceIterator.next();
-    resourceMap.put(nextResource.getPropertyValue(ADMINSETTING_NAME_PROPERTY_ID), nextResource);
-    nextResource = resourceIterator.next();
-    resourceMap.put(nextResource.getPropertyValue(ADMINSETTING_NAME_PROPERTY_ID), nextResource);
-    assertEqualsEntityAndResource(entity1, resourceMap.get(entity1.getName()));
-    assertEqualsEntityAndResource(entity2, resourceMap.get(entity2.getName()));
-  }
-
-  @Test
-  public void testGetResources_collection_admin() throws Exception {
-    setupAuthenticationForAdmin();
-
-    AdminSettingEntity entity1 = newEntity("motd");
-    AdminSettingEntity entity2 = newEntity("ldap");
-    Request request = PropertyHelper.getReadRequest(
-            ADMINSETTING_NAME_PROPERTY_ID,
-            ADMINSETTING_CONTENT_PROPERTY_ID,
-            ADMINSETTING_SETTING_TYPE_PROPERTY_ID,
-            ADMINSETTING_UPDATED_BY_PROPERTY_ID,
-            ADMINSETTING_UPDATE_TIMESTAMP_PROPERTY_ID);
-    expect(dao.findAll()).andReturn(Lists.newArrayList(entity1, entity2));
-    mockControl.replay();
-
-    Set<Resource> response = resourceProvider.getResources(request, null);
-    assertEquals(2, response.size());
-    Map<Object, Resource> resourceMap = new HashMap<>();
-    Iterator<Resource> resourceIterator = response.iterator();
-    Resource nextResource = resourceIterator.next();
-    resourceMap.put(nextResource.getPropertyValue(ADMINSETTING_NAME_PROPERTY_ID), nextResource);
-    nextResource = resourceIterator.next();
-    resourceMap.put(nextResource.getPropertyValue(ADMINSETTING_NAME_PROPERTY_ID), nextResource);
-    assertEqualsEntityAndResource(entity1, resourceMap.get(entity1.getName()));
-    assertEqualsEntityAndResource(entity2, resourceMap.get(entity2.getName()));
-  }
-
-  @Test(expected = AuthorizationException.class)
-  public void testCreateResource_noAuth() throws Exception {
-    mockControl.replay();
-    resourceProvider.createResources(createRequest(newEntity("moted")));
-  }
-
-  @Test(expected = AuthorizationException.class)
-  public void testCreateResource_clusterUser() throws Exception {
-    setupAuthenticationForClusterUser();
-    mockControl.replay();
-    resourceProvider.createResources(createRequest(newEntity("motd")));
-  }
-
-  @Test
-  public void testCreateResource_admin() throws Exception {
-    setupAuthenticationForAdmin();
-    AdminSettingEntity entity = newEntity("motd");
-    Capture<AdminSettingEntity> entityCapture = Capture.newInstance();
-    Request request = createRequest(entity);
-
-    expect(dao.findByName(entity.getName())).andReturn(null);
-    dao.create(capture(entityCapture));
-    mockControl.replay();
-
-    RequestStatus response = resourceProvider.createResources(request);
-    assertEquals(RequestStatus.Status.Complete, response.getStatus());
-    Set<Resource> associatedResources = response.getAssociatedResources();
-    assertEquals(1, associatedResources.size());
-    AdminSettingEntity capturedEntity = entityCapture.getValue();
-    assertEquals(entity.getName(), capturedEntity.getName());
-    assertEquals(entity.getContent(), capturedEntity.getContent());
-    assertEquals(entity.getSettingType(), capturedEntity.getSettingType());
-    assertEquals(AuthorizationHelper.getAuthenticatedName(), capturedEntity.getUpdatedBy());
-  }
-
-  @Test(expected = ResourceAlreadyExistsException.class)
-  public void testCreateDuplicateResource() throws Exception {
-    setupAuthenticationForAdmin();
-    AdminSettingEntity entity = newEntity("motd");
-    Request request = createRequest(entity);
-
-    expect(dao.findByName(entity.getName())).andReturn(entity);
-    mockControl.replay();
-    resourceProvider.createResources(request);
-  }
-
-  @Test(expected = AuthorizationException.class)
-  public void testUpdateResources_noAuth() throws Exception {
-    mockControl.replay();
-    resourceProvider.updateResources(updateRequest(newEntity("motd")), null);
-  }
-
-  @Test(expected = AuthorizationException.class)
-  public void testUpdateResources_clusterUser() throws Exception {
-    setupAuthenticationForClusterUser();
-    mockControl.replay();
-    resourceProvider.updateResources(updateRequest(newEntity("motd")), null);
-  }
-
-  @Test
-  public void testUpdateResources_admin() throws Exception {
-    setupAuthenticationForAdmin();
-    String name = "motd";
-    AdminSettingEntity oldEntity = newEntity(name);
-    AdminSettingEntity updatedEntity = oldEntity.clone();
-    updatedEntity.setContent("{text}");
-    updatedEntity.setSettingType("new-type");
-
-    PredicateBuilder pb = new PredicateBuilder();
-    Predicate predicate = pb.begin().property(ADMINSETTING_NAME_PROPERTY_ID).equals(name).end().toPredicate();
-    Capture<AdminSettingEntity> capture = Capture.newInstance();
-
-    expect(dao.findByName(name)).andReturn(oldEntity);
-    expect(dao.merge(capture(capture))).andReturn(updatedEntity);
-    mockControl.replay();
-
-    RequestStatus response = resourceProvider.updateResources(updateRequest(updatedEntity), predicate);
-    AdminSettingEntity capturedEntity = capture.getValue();
-    assertEquals(RequestStatus.Status.Complete, response.getStatus());
-    assertEquals(updatedEntity.getId(), capturedEntity.getId());
-    assertEquals(updatedEntity.getName(), capturedEntity.getName());
-    assertEquals(updatedEntity.getSettingType(), capturedEntity.getSettingType());
-    assertEquals(updatedEntity.getContent(), capturedEntity.getContent());
-    assertEquals(AuthorizationHelper.getAuthenticatedName(), capturedEntity.getUpdatedBy());
-  }
-
-  @Test(expected = AuthorizationException.class)
-  public void testDeleteResources_noAuth() throws Exception {
-    mockControl.replay();
-    resourceProvider.deleteResources(null);
-  }
-
-
-  @Test(expected = AuthorizationException.class)
-  public void testDeleteResources_clusterUser() throws Exception {
-    setupAuthenticationForClusterUser();
-    mockControl.replay();
-    resourceProvider.deleteResources(null);
-  }
-
-  @Test
-  public void testDeleteResources() throws Exception {
-    setupAuthenticationForAdmin();
-
-    String name = "motd";
-    PredicateBuilder pb = new PredicateBuilder();
-    Predicate predicate = pb.begin().property(ADMINSETTING_NAME_PROPERTY_ID).equals(name).end().toPredicate();
-    dao.removeByName(name);
-    mockControl.replay();
-    resourceProvider.deleteResources(predicate);
-  }
-
-  private Set<Resource> getResources_instance(AdminSettingEntity entity, Request request) throws Exception {
-    String name = entity.getName();
-    PredicateBuilder pb = new PredicateBuilder();
-    Predicate predicate = pb.begin().property(ADMINSETTING_NAME_PROPERTY_ID).equals(name).end().toPredicate();
-
-    expect(dao.findByName(name)).andReturn(entity).anyTimes();
-    mockControl.replay();
-    return resourceProvider.getResources(request, predicate);
-  }
-
-
-  private Request readRequest() {
-    return PropertyHelper.getReadRequest(
-            ADMINSETTING_NAME_PROPERTY_ID,
-            ADMINSETTING_CONTENT_PROPERTY_ID,
-            ADMINSETTING_SETTING_TYPE_PROPERTY_ID,
-            ADMINSETTING_UPDATED_BY_PROPERTY_ID,
-            ADMINSETTING_UPDATE_TIMESTAMP_PROPERTY_ID);
-  }
-
-  private Request createRequest(AdminSettingEntity entity) {
-    Map<String, Object> properties = new HashMap<>();
-    properties.put(ADMINSETTING_NAME_PROPERTY_ID, entity.getName());
-    properties.put(ADMINSETTING_CONTENT_PROPERTY_ID, entity.getContent());
-    properties.put(ADMINSETTING_UPDATED_BY_PROPERTY_ID, entity.getUpdatedBy());
-    properties.put(ADMINSETTING_SETTING_TYPE_PROPERTY_ID, entity.getSettingType());
-    return PropertyHelper.getCreateRequest(Collections.singleton(properties), null);
-  }
-
-  private Request updateRequest(AdminSettingEntity entity) {
-    Map<String, Object> properties = new HashMap<>();
-    properties.put(ADMINSETTING_NAME_PROPERTY_ID, entity.getName());
-    properties.put(ADMINSETTING_CONTENT_PROPERTY_ID, entity.getContent());
-    properties.put(ADMINSETTING_SETTING_TYPE_PROPERTY_ID, entity.getSettingType());
-    return PropertyHelper.getUpdateRequest(properties, null);
-  }
-
-  private void setupAuthenticationForClusterUser() {
-    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createClusterUser());
-  }
-
-  private void setupAuthenticationForAdmin() {
-    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator());
-  }
-
-  private AdminSettingEntity newEntity(String name) {
-    AdminSettingEntity entity = new AdminSettingEntity();
-    entity.setName(name);
-    entity.setContent(RandomStringUtils.randomAlphabetic(10));
-    entity.setSettingType(RandomStringUtils.randomAlphabetic(5));
-    entity.setUpdatedBy("ambari");
-    entity.setUpdateTimestamp(System.currentTimeMillis());
-    return entity;
-  }
-
-  private void assertEqualsEntityAndResource(AdminSettingEntity entity, Resource resource) {
-    assertEquals(entity.getName(), resource.getPropertyValue(ADMINSETTING_NAME_PROPERTY_ID));
-    assertEquals(entity.getSettingType(), resource.getPropertyValue(ADMINSETTING_SETTING_TYPE_PROPERTY_ID));
-    assertEquals(entity.getContent(), resource.getPropertyValue(ADMINSETTING_CONTENT_PROPERTY_ID));
-    assertEquals(entity.getUpdatedBy(), resource.getPropertyValue(ADMINSETTING_UPDATED_BY_PROPERTY_ID));
-    assertEquals(entity.getUpdateTimestamp(), resource.getPropertyValue(ADMINSETTING_UPDATE_TIMESTAMP_PROPERTY_ID));
-  }
-
-  private void setPrivateField(Object o, String field, Object value) throws Exception{
-    Class<?> c = o.getClass();
-    Field f = c.getDeclaredField(field);
-    f.setAccessible(true);
-    f.set(o, value);
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/SettingResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/SettingResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/SettingResourceProviderTest.java
new file mode 100644
index 0000000..c133220
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/SettingResourceProviderTest.java
@@ -0,0 +1,355 @@
+/**
+ * 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.
+ */
+package org.apache.ambari.server.controller.internal;
+
+import com.google.common.collect.Lists;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.RequestStatus;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
+import org.apache.ambari.server.controller.utilities.PredicateBuilder;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.apache.ambari.server.orm.dao.SettingDAO;
+import org.apache.ambari.server.orm.entities.SettingEntity;
+import org.apache.ambari.server.security.TestAuthenticationFactory;
+import org.apache.ambari.server.security.authorization.AuthorizationException;
+import org.apache.ambari.server.security.authorization.AuthorizationHelper;
+import org.apache.commons.lang.RandomStringUtils;
+import org.easymock.Capture;
+import org.easymock.IMocksControl;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.security.core.context.SecurityContextHolder;
+
+import java.lang.reflect.Field;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import static org.apache.ambari.server.controller.internal.SettingResourceProvider.SETTING_NAME_PROPERTY_ID;
+import static org.apache.ambari.server.controller.internal.SettingResourceProvider.SETTING_SETTING_TYPE_PROPERTY_ID;
+import static org.apache.ambari.server.controller.internal.SettingResourceProvider.SETTING_CONTENT_PROPERTY_ID;
+import static org.apache.ambari.server.controller.internal.SettingResourceProvider.SETTING_UPDATED_BY_PROPERTY_ID;
+import static org.apache.ambari.server.controller.internal.SettingResourceProvider.SETTING_UPDATE_TIMESTAMP_PROPERTY_ID;
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.createControl;
+
+import static org.junit.Assert.assertEquals;
+
+public class SettingResourceProviderTest {
+  IMocksControl mockControl;
+  SettingDAO dao;
+  SettingResourceProvider resourceProvider;
+
+
+  @Before
+  public void setUp() throws Exception {
+    mockControl = createControl();
+    dao = mockControl.createMock(SettingDAO.class);
+    resourceProvider = new SettingResourceProvider();
+    setPrivateField(resourceProvider, "dao", dao);
+  }
+
+  @After
+  public void tearDown() {
+    mockControl.verify();
+    SecurityContextHolder.getContext().setAuthentication(null);
+    mockControl.reset();
+  }
+
+  @Test(expected = AuthorizationException.class)
+  public void testGetResources_instance_noAuth() throws Exception {
+    getResources_instance(newEntity("motd"), readRequest());
+  }
+
+  @Test
+  public void testGetResources_instance_clusterUser() throws Exception {
+    setupAuthenticationForClusterUser();
+    String name = "motd";
+    SettingEntity entity = newEntity(name);
+
+    Set<Resource> response = getResources_instance(entity, readRequest());
+    assertEquals(1, response.size());
+    Resource resource = response.iterator().next();
+    assertEqualsEntityAndResource(entity, resource);
+  }
+
+  @Test
+  public void testGetResources_instance_admin() throws Exception {
+    setupAuthenticationForAdmin();
+    SettingEntity entity = newEntity("motd");
+    Set<Resource> response = getResources_instance(entity, readRequest());
+    assertEquals(1, response.size());
+    Resource resource = response.iterator().next();
+    assertEqualsEntityAndResource(entity, resource);
+  }
+
+  @Test(expected = AuthorizationException.class)
+  public void testGetResources_collection_noAuth() throws Exception {
+    mockControl.replay();
+    Request request = PropertyHelper.getReadRequest(
+            SETTING_NAME_PROPERTY_ID,
+            SETTING_CONTENT_PROPERTY_ID,
+            SETTING_SETTING_TYPE_PROPERTY_ID,
+            SETTING_UPDATED_BY_PROPERTY_ID,
+            SETTING_UPDATE_TIMESTAMP_PROPERTY_ID);
+    resourceProvider.getResources(request, null);
+  }
+
+  @Test
+  public void testGetResources_collection_clusterUser() throws Exception {
+    setupAuthenticationForClusterUser();
+
+    SettingEntity entity1 = newEntity("motd");
+    SettingEntity entity2 = newEntity("ldap");
+    Request request = PropertyHelper.getReadRequest(
+            SETTING_NAME_PROPERTY_ID,
+            SETTING_CONTENT_PROPERTY_ID,
+            SETTING_SETTING_TYPE_PROPERTY_ID,
+            SETTING_UPDATED_BY_PROPERTY_ID,
+            SETTING_UPDATE_TIMESTAMP_PROPERTY_ID);
+
+    expect(dao.findAll()).andReturn(Lists.newArrayList(entity1, entity2));
+    mockControl.replay();
+
+    Set<Resource> response = resourceProvider.getResources(request, null);
+    assertEquals(2, response.size());
+    Map<Object, Resource> resourceMap = new HashMap<>();
+    Iterator<Resource> resourceIterator = response.iterator();
+    Resource nextResource = resourceIterator.next();
+    resourceMap.put(nextResource.getPropertyValue(SETTING_NAME_PROPERTY_ID), nextResource);
+    nextResource = resourceIterator.next();
+    resourceMap.put(nextResource.getPropertyValue(SETTING_NAME_PROPERTY_ID), nextResource);
+    assertEqualsEntityAndResource(entity1, resourceMap.get(entity1.getName()));
+    assertEqualsEntityAndResource(entity2, resourceMap.get(entity2.getName()));
+  }
+
+  @Test
+  public void testGetResources_collection_admin() throws Exception {
+    setupAuthenticationForAdmin();
+
+    SettingEntity entity1 = newEntity("motd");
+    SettingEntity entity2 = newEntity("ldap");
+    Request request = PropertyHelper.getReadRequest(
+            SETTING_NAME_PROPERTY_ID,
+            SETTING_CONTENT_PROPERTY_ID,
+            SETTING_SETTING_TYPE_PROPERTY_ID,
+            SETTING_UPDATED_BY_PROPERTY_ID,
+            SETTING_UPDATE_TIMESTAMP_PROPERTY_ID);
+    expect(dao.findAll()).andReturn(Lists.newArrayList(entity1, entity2));
+    mockControl.replay();
+
+    Set<Resource> response = resourceProvider.getResources(request, null);
+    assertEquals(2, response.size());
+    Map<Object, Resource> resourceMap = new HashMap<>();
+    Iterator<Resource> resourceIterator = response.iterator();
+    Resource nextResource = resourceIterator.next();
+    resourceMap.put(nextResource.getPropertyValue(SETTING_NAME_PROPERTY_ID), nextResource);
+    nextResource = resourceIterator.next();
+    resourceMap.put(nextResource.getPropertyValue(SETTING_NAME_PROPERTY_ID), nextResource);
+    assertEqualsEntityAndResource(entity1, resourceMap.get(entity1.getName()));
+    assertEqualsEntityAndResource(entity2, resourceMap.get(entity2.getName()));
+  }
+
+  @Test(expected = AuthorizationException.class)
+  public void testCreateResource_noAuth() throws Exception {
+    mockControl.replay();
+    resourceProvider.createResources(createRequest(newEntity("moted")));
+  }
+
+  @Test(expected = AuthorizationException.class)
+  public void testCreateResource_clusterUser() throws Exception {
+    setupAuthenticationForClusterUser();
+    mockControl.replay();
+    resourceProvider.createResources(createRequest(newEntity("motd")));
+  }
+
+  @Test
+  public void testCreateResource_admin() throws Exception {
+    setupAuthenticationForAdmin();
+    SettingEntity entity = newEntity("motd");
+    Capture<SettingEntity> entityCapture = Capture.newInstance();
+    Request request = createRequest(entity);
+
+    expect(dao.findByName(entity.getName())).andReturn(null);
+    dao.create(capture(entityCapture));
+    mockControl.replay();
+
+    RequestStatus response = resourceProvider.createResources(request);
+    assertEquals(RequestStatus.Status.Complete, response.getStatus());
+    Set<Resource> associatedResources = response.getAssociatedResources();
+    assertEquals(1, associatedResources.size());
+    SettingEntity capturedEntity = entityCapture.getValue();
+    assertEquals(entity.getName(), capturedEntity.getName());
+    assertEquals(entity.getContent(), capturedEntity.getContent());
+    assertEquals(entity.getSettingType(), capturedEntity.getSettingType());
+    assertEquals(AuthorizationHelper.getAuthenticatedName(), capturedEntity.getUpdatedBy());
+  }
+
+  @Test(expected = ResourceAlreadyExistsException.class)
+  public void testCreateDuplicateResource() throws Exception {
+    setupAuthenticationForAdmin();
+    SettingEntity entity = newEntity("motd");
+    Request request = createRequest(entity);
+
+    expect(dao.findByName(entity.getName())).andReturn(entity);
+    mockControl.replay();
+    resourceProvider.createResources(request);
+  }
+
+  @Test(expected = AuthorizationException.class)
+  public void testUpdateResources_noAuth() throws Exception {
+    mockControl.replay();
+    resourceProvider.updateResources(updateRequest(newEntity("motd")), null);
+  }
+
+  @Test(expected = AuthorizationException.class)
+  public void testUpdateResources_clusterUser() throws Exception {
+    setupAuthenticationForClusterUser();
+    mockControl.replay();
+    resourceProvider.updateResources(updateRequest(newEntity("motd")), null);
+  }
+
+  @Test
+  public void testUpdateResources_admin() throws Exception {
+    setupAuthenticationForAdmin();
+    String name = "motd";
+    SettingEntity oldEntity = newEntity(name);
+    SettingEntity updatedEntity = oldEntity.clone();
+    updatedEntity.setContent("{text}");
+    updatedEntity.setSettingType("new-type");
+
+    PredicateBuilder pb = new PredicateBuilder();
+    Predicate predicate = pb.begin().property(SETTING_NAME_PROPERTY_ID).equals(name).end().toPredicate();
+    Capture<SettingEntity> capture = Capture.newInstance();
+
+    expect(dao.findByName(name)).andReturn(oldEntity);
+    expect(dao.merge(capture(capture))).andReturn(updatedEntity);
+    mockControl.replay();
+
+    RequestStatus response = resourceProvider.updateResources(updateRequest(updatedEntity), predicate);
+    SettingEntity capturedEntity = capture.getValue();
+    assertEquals(RequestStatus.Status.Complete, response.getStatus());
+    assertEquals(updatedEntity.getId(), capturedEntity.getId());
+    assertEquals(updatedEntity.getName(), capturedEntity.getName());
+    assertEquals(updatedEntity.getSettingType(), capturedEntity.getSettingType());
+    assertEquals(updatedEntity.getContent(), capturedEntity.getContent());
+    assertEquals(AuthorizationHelper.getAuthenticatedName(), capturedEntity.getUpdatedBy());
+  }
+
+  @Test(expected = AuthorizationException.class)
+  public void testDeleteResources_noAuth() throws Exception {
+    mockControl.replay();
+    resourceProvider.deleteResources(null);
+  }
+
+
+  @Test(expected = AuthorizationException.class)
+  public void testDeleteResources_clusterUser() throws Exception {
+    setupAuthenticationForClusterUser();
+    mockControl.replay();
+    resourceProvider.deleteResources(null);
+  }
+
+  @Test
+  public void testDeleteResources() throws Exception {
+    setupAuthenticationForAdmin();
+
+    String name = "motd";
+    PredicateBuilder pb = new PredicateBuilder();
+    Predicate predicate = pb.begin().property(SETTING_NAME_PROPERTY_ID).equals(name).end().toPredicate();
+    dao.removeByName(name);
+    mockControl.replay();
+    resourceProvider.deleteResources(predicate);
+  }
+
+  private Set<Resource> getResources_instance(SettingEntity entity, Request request) throws Exception {
+    String name = entity.getName();
+    PredicateBuilder pb = new PredicateBuilder();
+    Predicate predicate = pb.begin().property(SETTING_NAME_PROPERTY_ID).equals(name).end().toPredicate();
+
+    expect(dao.findByName(name)).andReturn(entity).anyTimes();
+    mockControl.replay();
+    return resourceProvider.getResources(request, predicate);
+  }
+
+
+  private Request readRequest() {
+    return PropertyHelper.getReadRequest(
+            SETTING_NAME_PROPERTY_ID,
+            SETTING_CONTENT_PROPERTY_ID,
+            SETTING_SETTING_TYPE_PROPERTY_ID,
+            SETTING_UPDATED_BY_PROPERTY_ID,
+            SETTING_UPDATE_TIMESTAMP_PROPERTY_ID);
+  }
+
+  private Request createRequest(SettingEntity entity) {
+    Map<String, Object> properties = new HashMap<>();
+    properties.put(SETTING_NAME_PROPERTY_ID, entity.getName());
+    properties.put(SETTING_CONTENT_PROPERTY_ID, entity.getContent());
+    properties.put(SETTING_UPDATED_BY_PROPERTY_ID, entity.getUpdatedBy());
+    properties.put(SETTING_SETTING_TYPE_PROPERTY_ID, entity.getSettingType());
+    return PropertyHelper.getCreateRequest(Collections.singleton(properties), null);
+  }
+
+  private Request updateRequest(SettingEntity entity) {
+    Map<String, Object> properties = new HashMap<>();
+    properties.put(SETTING_NAME_PROPERTY_ID, entity.getName());
+    properties.put(SETTING_CONTENT_PROPERTY_ID, entity.getContent());
+    properties.put(SETTING_SETTING_TYPE_PROPERTY_ID, entity.getSettingType());
+    return PropertyHelper.getUpdateRequest(properties, null);
+  }
+
+  private void setupAuthenticationForClusterUser() {
+    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createClusterUser());
+  }
+
+  private void setupAuthenticationForAdmin() {
+    SecurityContextHolder.getContext().setAuthentication(TestAuthenticationFactory.createAdministrator());
+  }
+
+  private SettingEntity newEntity(String name) {
+    SettingEntity entity = new SettingEntity();
+    entity.setName(name);
+    entity.setContent(RandomStringUtils.randomAlphabetic(10));
+    entity.setSettingType(RandomStringUtils.randomAlphabetic(5));
+    entity.setUpdatedBy("ambari");
+    entity.setUpdateTimestamp(System.currentTimeMillis());
+    return entity;
+  }
+
+  private void assertEqualsEntityAndResource(SettingEntity entity, Resource resource) {
+    assertEquals(entity.getName(), resource.getPropertyValue(SETTING_NAME_PROPERTY_ID));
+    assertEquals(entity.getSettingType(), resource.getPropertyValue(SETTING_SETTING_TYPE_PROPERTY_ID));
+    assertEquals(entity.getContent(), resource.getPropertyValue(SETTING_CONTENT_PROPERTY_ID));
+    assertEquals(entity.getUpdatedBy(), resource.getPropertyValue(SETTING_UPDATED_BY_PROPERTY_ID));
+    assertEquals(entity.getUpdateTimestamp(), resource.getPropertyValue(SETTING_UPDATE_TIMESTAMP_PROPERTY_ID));
+  }
+
+  private void setPrivateField(Object o, String field, Object value) throws Exception{
+    Class<?> c = o.getClass();
+    Field f = c.getDeclaredField(field);
+    f.setAccessible(true);
+    f.set(o, value);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/AdminSettingDAOTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/AdminSettingDAOTest.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/AdminSettingDAOTest.java
deleted file mode 100644
index 8258974..0000000
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/AdminSettingDAOTest.java
+++ /dev/null
@@ -1,93 +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.
- */
-package org.apache.ambari.server.orm.dao;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import org.apache.ambari.server.orm.GuiceJpaInitializer;
-import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
-import org.apache.ambari.server.orm.OrmTestHelper;
-import org.apache.ambari.server.orm.entities.AdminSettingEntity;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNull;
-
-public class AdminSettingDAOTest {
-  private  Injector injector;
-  private  AdminSettingDAO dao;
-
-  @Before
-  public void setUp() {
-    injector = Guice.createInjector(new InMemoryDefaultTestModule());
-    dao = injector.getInstance(AdminSettingDAO.class);
-    injector.getInstance(GuiceJpaInitializer.class);
-    injector.getInstance(OrmTestHelper.class).createCluster();
-  }
-
-  @Test
-  public void testCRUD() {
-    Map<String, AdminSettingEntity> entities = new HashMap<>();
-    //Create
-    for (int i=0; i < 3; i++) {
-      AdminSettingEntity entity = new AdminSettingEntity();
-      entity.setName("motd" + i);
-      entity.setContent("test content" + i);
-      entity.setUpdatedBy("ambari");
-      entity.setSettingType("ambari-server");
-      entity.setUpdateTimestamp(System.currentTimeMillis());
-      entities.put(entity.getName(), entity);
-      dao.create(entity);
-    }
-
-    //Retrieve
-    retrieveAndValidateSame(entities);
-    assertEquals(entities.size(), dao.findAll().size());
-
-    //Should return null if doesn't exist.
-    assertNull(dao.findByName("does-not-exist"));
-
-
-    //Update
-    for(Map.Entry<String, AdminSettingEntity> entry : entities.entrySet()) {
-      entry.getValue().setContent(Objects.toString(Math.random()));
-      dao.merge(entry.getValue());
-    }
-
-    retrieveAndValidateSame(entities);
-    assertEquals(entities.size(), dao.findAll().size());
-
-    //Delete
-    for(Map.Entry<String, AdminSettingEntity> entry : entities.entrySet()) {
-      dao.removeByName(entry.getKey());
-    }
-    assertEquals(0, dao.findAll().size());
-  }
-
-  private void retrieveAndValidateSame(Map<String, AdminSettingEntity> entities) {
-    for(Map.Entry<String, AdminSettingEntity> entry : entities.entrySet()) {
-      String name = entry.getKey();
-      assertEquals(entry.getValue(), dao.findByName(name));
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/SettingDAOTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/SettingDAOTest.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/SettingDAOTest.java
new file mode 100644
index 0000000..77f87be
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/dao/SettingDAOTest.java
@@ -0,0 +1,93 @@
+/**
+ * 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.
+ */
+package org.apache.ambari.server.orm.dao;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import org.apache.ambari.server.orm.GuiceJpaInitializer;
+import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
+import org.apache.ambari.server.orm.OrmTestHelper;
+import org.apache.ambari.server.orm.entities.SettingEntity;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNull;
+
+public class SettingDAOTest {
+  private  Injector injector;
+  private SettingDAO dao;
+
+  @Before
+  public void setUp() {
+    injector = Guice.createInjector(new InMemoryDefaultTestModule());
+    dao = injector.getInstance(SettingDAO.class);
+    injector.getInstance(GuiceJpaInitializer.class);
+    injector.getInstance(OrmTestHelper.class).createCluster();
+  }
+
+  @Test
+  public void testCRUD() {
+    Map<String, SettingEntity> entities = new HashMap<>();
+    //Create
+    for (int i=0; i < 3; i++) {
+      SettingEntity entity = new SettingEntity();
+      entity.setName("motd" + i);
+      entity.setContent("test content" + i);
+      entity.setUpdatedBy("ambari");
+      entity.setSettingType("ambari-server");
+      entity.setUpdateTimestamp(System.currentTimeMillis());
+      entities.put(entity.getName(), entity);
+      dao.create(entity);
+    }
+
+    //Retrieve
+    retrieveAndValidateSame(entities);
+    assertEquals(entities.size(), dao.findAll().size());
+
+    //Should return null if doesn't exist.
+    assertNull(dao.findByName("does-not-exist"));
+
+
+    //Update
+    for(Map.Entry<String, SettingEntity> entry : entities.entrySet()) {
+      entry.getValue().setContent(Objects.toString(Math.random()));
+      dao.merge(entry.getValue());
+    }
+
+    retrieveAndValidateSame(entities);
+    assertEquals(entities.size(), dao.findAll().size());
+
+    //Delete
+    for(Map.Entry<String, SettingEntity> entry : entities.entrySet()) {
+      dao.removeByName(entry.getKey());
+    }
+    assertEquals(0, dao.findAll().size());
+  }
+
+  private void retrieveAndValidateSame(Map<String, SettingEntity> entities) {
+    for(Map.Entry<String, SettingEntity> entry : entities.entrySet()) {
+      String name = entry.getKey();
+      assertEquals(entry.getValue(), dao.findByName(name));
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/AdminSettingEntityTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/AdminSettingEntityTest.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/AdminSettingEntityTest.java
deleted file mode 100644
index a7cba23..0000000
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/AdminSettingEntityTest.java
+++ /dev/null
@@ -1,91 +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.
- */
-package org.apache.ambari.server.orm.entities;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import static junit.framework.Assert.assertEquals;
-
-/**
- * AdminSettingEntity unit tests.
- */
-public class AdminSettingEntityTest {
-
-  @Test
-  public void testSetGetId() {
-    long id = 1000;
-    AdminSettingEntity entity = new AdminSettingEntity();
-    entity.setId(id);
-    assertEquals(id, entity.getId());
-  }
-
-  @Test
-  public void testSetGetName() {
-    String name = "motd";
-    AdminSettingEntity entity = new AdminSettingEntity();
-    entity.setName(name);
-    assertEquals(name, entity.getName());
-  }
-
-  @Test
-  public void testSetGetSettingType() {
-    String settingType = "ambari-server";
-    AdminSettingEntity entity = new AdminSettingEntity();
-    entity.setSettingType(settingType);
-    assertEquals(settingType, entity.getSettingType());
-  }
-
-  @Test
-  public void testSetGetContent() {
-    String content = "{tag:random-tag, text:random-text}";
-    AdminSettingEntity entity = new AdminSettingEntity();
-    entity.setContent(content);
-    assertEquals(content, entity.getContent());
-  }
-
-  @Test
-  public void testSetGetUpdatedBy() {
-    String updatedBy = "ambari";
-    AdminSettingEntity entity = new AdminSettingEntity();
-    entity.setUpdatedBy(updatedBy);
-    assertEquals(updatedBy, entity.getUpdatedBy());
-  }
-
-  @Test
-  public void testSetGetUpdatedTimeStamp() {
-    long updateTimeStamp = 1234567890;
-    AdminSettingEntity entity = new AdminSettingEntity();
-    entity.setUpdateTimestamp(updateTimeStamp);
-    assertEquals(updateTimeStamp, entity.getUpdateTimestamp());
-  }
-
-  @Test
-  public void testEquals() {
-    AdminSettingEntity entity = new AdminSettingEntity();
-    entity.setId(1);
-    entity.setName("motd");
-    entity.setContent("{tag:random-tag, text:random-text}");
-    entity.setSettingType("ambari-server");
-    entity.setUpdatedBy("ambari");
-    entity.setUpdateTimestamp(1234567890);
-    AdminSettingEntity newEntity = entity.clone();
-    assertEquals(entity, newEntity);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/SettingEntityTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/SettingEntityTest.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/SettingEntityTest.java
new file mode 100644
index 0000000..defe948
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/entities/SettingEntityTest.java
@@ -0,0 +1,90 @@
+/**
+ * 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.
+ */
+package org.apache.ambari.server.orm.entities;
+
+import org.junit.Test;
+
+import static junit.framework.Assert.assertEquals;
+
+/**
+ * SettingEntity unit tests.
+ */
+public class SettingEntityTest {
+
+  @Test
+  public void testSetGetId() {
+    long id = 1000;
+    SettingEntity entity = new SettingEntity();
+    entity.setId(id);
+    assertEquals(id, entity.getId());
+  }
+
+  @Test
+  public void testSetGetName() {
+    String name = "motd";
+    SettingEntity entity = new SettingEntity();
+    entity.setName(name);
+    assertEquals(name, entity.getName());
+  }
+
+  @Test
+  public void testSetGetSettingType() {
+    String settingType = "ambari-server";
+    SettingEntity entity = new SettingEntity();
+    entity.setSettingType(settingType);
+    assertEquals(settingType, entity.getSettingType());
+  }
+
+  @Test
+  public void testSetGetContent() {
+    String content = "{tag:random-tag, text:random-text}";
+    SettingEntity entity = new SettingEntity();
+    entity.setContent(content);
+    assertEquals(content, entity.getContent());
+  }
+
+  @Test
+  public void testSetGetUpdatedBy() {
+    String updatedBy = "ambari";
+    SettingEntity entity = new SettingEntity();
+    entity.setUpdatedBy(updatedBy);
+    assertEquals(updatedBy, entity.getUpdatedBy());
+  }
+
+  @Test
+  public void testSetGetUpdatedTimeStamp() {
+    long updateTimeStamp = 1234567890;
+    SettingEntity entity = new SettingEntity();
+    entity.setUpdateTimestamp(updateTimeStamp);
+    assertEquals(updateTimeStamp, entity.getUpdateTimestamp());
+  }
+
+  @Test
+  public void testEquals() {
+    SettingEntity entity = new SettingEntity();
+    entity.setId(1);
+    entity.setName("motd");
+    entity.setContent("{tag:random-tag, text:random-text}");
+    entity.setSettingType("ambari-server");
+    entity.setUpdatedBy("ambari");
+    entity.setUpdateTimestamp(1234567890);
+    SettingEntity newEntity = entity.clone();
+    assertEquals(entity, newEntity);
+  }
+
+}


[02/11] ambari git commit: AMBARI-14814. Ambari not showing active/standby status for NameNodes when custom ports are used.(vbrodetskyi)

Posted by nc...@apache.org.
AMBARI-14814. Ambari not showing active/standby status for NameNodes when custom ports are used.(vbrodetskyi)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 5e36bdc922a92405f9d82ccbdff0ba8006903052
Parents: 31477a5
Author: Vitaly Brodetskyi <vb...@hortonworks.com>
Authored: Mon Feb 1 18:56:56 2016 +0200
Committer: Vitaly Brodetskyi <vb...@hortonworks.com>
Committed: Mon Feb 1 18:56:56 2016 +0200

----------------------------------------------------------------------
 .../internal/AbstractProviderModule.java        | 187 +++++++++++++------
 .../server/controller/jmx/JMXHostProvider.java  |   8 +-
 .../controller/jmx/JMXPropertyProvider.java     |  15 +-
 .../internal/JMXHostProviderTest.java           | 130 ++++++++++---
 .../metrics/JMXPropertyProviderTest.java        |   6 +-
 5 files changed, 249 insertions(+), 97 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5e36bdc9/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
index 5fb2cf0..52d95e0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractProviderModule.java
@@ -125,8 +125,10 @@ public abstract class AbstractProviderModule implements ProviderModule,
 
     Map<String, String[]> initPropMap = new HashMap<String, String[]>();
     initPropMap.put("NAMENODE", new String[]{"dfs.http.address", "dfs.namenode.http-address"});
-    initPropMap.put("DATANODE", new String[]{"dfs.datanode.http.address"});
     initPropMap.put("NAMENODE-HTTPS", new String[]{"dfs.namenode.https-address", "dfs.https.port"});
+    initPropMap.put("NAMENODE-HA", new String[]{"dfs.namenode.http-address.%s.%s"});
+    initPropMap.put("NAMENODE-HTTPS-HA", new String[]{"dfs.namenode.https-address.%s.%s"});
+    initPropMap.put("DATANODE", new String[]{"dfs.datanode.http.address"});
     initPropMap.put("JOURNALNODE-HTTPS", new String[]{"dfs.journalnode.https-address"});
     initPropMap.put("JOURNALNODE", new String[]{"dfs.journalnode.http-address"});
     serviceDesiredProperties.put(Service.Type.HDFS, initPropMap);
@@ -197,8 +199,8 @@ public abstract class AbstractProviderModule implements ProviderModule,
   /**
    * JMX ports read from the configs
    */
-  private final Map<String, Map<String, String>> jmxPortMap =
-      new HashMap<String, Map<String, String>>();
+  private final Map<String, Map<String, Map<String, String>> >jmxPortMap =
+      new HashMap<String, Map<String, Map<String, String>>>();
 
   private volatile boolean initialized = false;
 
@@ -481,19 +483,19 @@ public abstract class AbstractProviderModule implements ProviderModule,
   // ----- JMXHostProvider ---------------------------------------------------
 
   @Override
-  public String getPort(String clusterName, String componentName) throws SystemException {
-    return getPort(clusterName, componentName, false);
+  public String getPort(String clusterName, String componentName, String hostName) throws SystemException {
+    return getPort(clusterName, componentName, hostName, false);
   }
 
   @Override
-  public String getPort(String clusterName, String componentName, boolean httpsEnabled) throws SystemException {
+  public String getPort(String clusterName, String componentName, String hostName, boolean httpsEnabled) throws SystemException {
     // Parent map need not be synchronized
-    Map<String, String> clusterJmxPorts = jmxPortMap.get(clusterName);
+    Map<String, Map<String, String>> clusterJmxPorts = jmxPortMap.get(clusterName);
     if (clusterJmxPorts == null) {
       synchronized (jmxPortMap) {
         clusterJmxPorts = jmxPortMap.get(clusterName);
         if (clusterJmxPorts == null) {
-          clusterJmxPorts = new ConcurrentHashMap<String, String>();
+          clusterJmxPorts = new ConcurrentHashMap<String, Map<String, String>>();
           jmxPortMap.put(clusterName, clusterJmxPorts);
         }
       }
@@ -511,30 +513,40 @@ public abstract class AbstractProviderModule implements ProviderModule,
         // performance with a ConcurrentHashMap and maybe get default/existing
         // ports for a few calls.
         if (!currVersion.equals(oldVersion) ||
-            !clusterJmxPorts.containsKey(componentName)) {
+            !(clusterJmxPorts.containsKey(hostName) && clusterJmxPorts.get(hostName).containsKey(componentName))) {
 
           serviceConfigVersions.put(configType, currVersion);
 
-          Map<String, String[]> componentPorts = new HashMap<String, String[]>();
-          String[] componentsHttpsPorts;
-
-          if (httpsEnabled) {
-            componentsHttpsPorts = serviceDesiredProperties.get(service).get(componentName + "-HTTPS");
-          } else {
-            componentsHttpsPorts = serviceDesiredProperties.get(service).get(componentName);
-          }
-          componentPorts.put(componentName, componentsHttpsPorts);
+          Map<String, Object> configProperties = getConfigProperties(
+              clusterName,
+              currVersion,
+              serviceConfigTypes.get(service)
+          );
+
+          Map<String, String[]> componentPortsProperties = new HashMap<String, String[]>();
+          componentPortsProperties.put(
+              componentName,
+              getPortProperties(service,
+                  componentName,
+                  hostName,
+                  configProperties,
+                  httpsEnabled
+              )
+          );
 
           Map<String, String> portMap = getDesiredConfigMap(clusterName,
               currVersion, serviceConfigTypes.get(service),
-              componentPorts);
+              componentPortsProperties, configProperties);
 
           for (Entry<String, String> entry : portMap.entrySet()) {
             // portString will be null if the property defined for the component doesn't exist
             // this will trigger using the default port for the component
             String portString = getPortString(entry.getValue());
             if (null != portString) {
-              clusterJmxPorts.put(entry.getKey(), portString);
+              if(!clusterJmxPorts.containsKey(hostName)) {
+                clusterJmxPorts.put(hostName, new ConcurrentHashMap<String, String>());
+              }
+              clusterJmxPorts.get(hostName).put(entry.getKey(), portString);
             }
           }
         }
@@ -544,7 +556,46 @@ public abstract class AbstractProviderModule implements ProviderModule,
     }
 
     LOG.debug("jmxPortMap -> " + jmxPortMap);
-    return clusterJmxPorts.get(componentName);
+    return clusterJmxPorts.get(hostName).get(componentName);
+  }
+
+  /**
+   * Computes properties that contains proper port for {@code componentName} on {@code hostName}. Must contain custom logic
+   * for different configurations(like NAMENODE HA).
+   * @param service service type
+   * @param componentName component name
+   * @param hostName host which contain requested component
+   * @param properties properties which used for special cases(like NAMENODE HA)
+   * @param httpsEnabled indicates if https enabled for component
+   * @return property name that contain port for {@code componentName} on {@code hostName}
+   */
+  String[] getPortProperties(Service.Type service, String componentName, String hostName, Map<String, Object> properties, boolean httpsEnabled) {
+    componentName = httpsEnabled ? componentName + "-HTTPS" : componentName;
+
+    if(componentName.equals("NAMENODE")) {
+      // iterate over nameservices and namenodes, to find out namenode http(s) property for concrete host
+      if(properties.containsKey("dfs.nameservices")) {
+        for(String nameserviceId : ((String)properties.get("dfs.nameservices")).split(",")) {
+          String haComponentName = componentName + "-HA";
+          if(properties.containsKey("dfs.ha.namenodes."+nameserviceId)) {
+            for (String namenodeId : ((String)properties.get("dfs.ha.namenodes." + nameserviceId)).split(",")) {
+              String propertyName = String.format(
+                  serviceDesiredProperties.get(service).get(haComponentName)[0],
+                  nameserviceId,
+                  namenodeId
+              );
+              if (properties.containsKey(propertyName)) {
+                String propertyValue = (String)properties.get(propertyName);
+                if (propertyValue.split(":")[0].equals(hostName)) {
+                  return new String[]{propertyName};
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+    return serviceDesiredProperties.get(service).get(componentName);
   }
 
   /**
@@ -882,9 +933,9 @@ public abstract class AbstractProviderModule implements ProviderModule,
     }
     return versionTag;
   }
-  // TODO get configs using ConfigHelper
-  private Map<String, String> getDesiredConfigMap(String clusterName, String versionTag,
-      String configType, Map<String, String[]> keys) throws NoSuchParentResourceException,
+
+  private Map<String, Object> getConfigProperties(String clusterName, String versionTag, String configType)
+      throws NoSuchParentResourceException,
       UnsupportedPropertyException, SystemException {
     // Get desired configs based on the tag
     ResourceProvider configResourceProvider = getResourceProvider(Resource.Type.Configuration);
@@ -902,53 +953,67 @@ public abstract class AbstractProviderModule implements ProviderModule,
       LOG.info("Resource for the desired config not found. " + e);
       return Collections.emptyMap();
     }
+    for (Resource res : configResources) {
+      return res.getPropertiesMap().get(PROPERTIES_CATEGORY);
+    }
+    return Collections.emptyMap();
+  }
+
+  private Map<String, String> getDesiredConfigMap(String clusterName, String versionTag,
+                                                  String configType, Map<String, String[]> keys) throws NoSuchParentResourceException,
+      UnsupportedPropertyException, SystemException {
+    return getDesiredConfigMap(clusterName, versionTag, configType, keys, null);
+  }
 
+  // TODO get configs using ConfigHelper
+  private Map<String, String> getDesiredConfigMap(String clusterName, String versionTag,
+                                                  String configType, Map<String, String[]> keys, Map<String, Object> configProperties) throws NoSuchParentResourceException,
+      UnsupportedPropertyException, SystemException {
+    if(configProperties == null) {
+      configProperties = getConfigProperties(clusterName, versionTag, configType);
+    }
     Map<String, String> mConfigs = new HashMap<String, String>();
-    if (configResources != null) {
-      for (Resource res : configResources) {
-        Map<String, String> evaluatedProperties = null;
-        for (Entry<String, String[]> entry : keys.entrySet()) {
-          String propName = null;
-          String value = null;
-
-          for (String pname : entry.getValue()) {
-            propName = pname;
-            // For NN HA the property key contains nameservice id
-            Map<String, Object> properties = res.getPropertiesMap().get(PROPERTIES_CATEGORY);
-            if (properties != null) {
-              for (Map.Entry<String, Object> propertyEntry : properties.entrySet()) {
-                if (propertyEntry.getKey().startsWith(pname)) {
-                  value = (String) propertyEntry.getValue();
-                  break;
-                }
-              }
-            }
-            if (null != value) {
+    if (!configProperties.isEmpty()) {
+      Map<String, String> evaluatedProperties = null;
+      for (Entry<String, String[]> entry : keys.entrySet()) {
+        String propName = null;
+        String value = null;
+
+        for (String pname : entry.getValue()) {
+          propName = pname;
+          // For NN HA the property key contains nameservice id
+          for (Map.Entry<String, Object> propertyEntry : configProperties.entrySet()) {
+            if (propertyEntry.getKey().startsWith(pname)) {
+              value = (String) propertyEntry.getValue();
               break;
             }
           }
 
-          if (value != null && value.contains("${")) {
-            if (evaluatedProperties == null) {
-              evaluatedProperties = new HashMap<String, String>();
-              Map<String, Object> properties = res.getPropertiesMap().get(PROPERTIES_CATEGORY);
-              for (Map.Entry<String, Object> subentry : properties.entrySet()) {
-                String keyString = subentry.getKey();
-                Object object = subentry.getValue();
-                String valueString;
-                if (object != null && object instanceof String) {
-                  valueString = (String) object;
-                  evaluatedProperties.put(keyString, valueString);
-                  postProcessPropertyValue(keyString, valueString, evaluatedProperties, null);
-                }
+          if (null != value) {
+            break;
+          }
+        }
+
+        if (value != null && value.contains("${")) {
+          if (evaluatedProperties == null) {
+            evaluatedProperties = new HashMap<String, String>();
+            for (Map.Entry<String, Object> subentry : configProperties.entrySet()) {
+              String keyString = subentry.getKey();
+              Object object = subentry.getValue();
+              String valueString;
+              if (object != null && object instanceof String) {
+                valueString = (String) object;
+                evaluatedProperties.put(keyString, valueString);
+                postProcessPropertyValue(keyString, valueString, evaluatedProperties, null);
               }
             }
           }
-          value = postProcessPropertyValue(propName, value, evaluatedProperties, null);
-          LOG.debug("PROPERTY -> key: " + propName + ", " + "value: " + value);
-
-          mConfigs.put(entry.getKey(), value);
         }
+        value = postProcessPropertyValue(propName, value, evaluatedProperties, null);
+        LOG.debug("PROPERTY -> key: " + propName + ", " + "value: " + value);
+
+        mConfigs.put(entry.getKey(), value);
+
       }
     }
     return mConfigs;

http://git-wip-us.apache.org/repos/asf/ambari/blob/5e36bdc9/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHostProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHostProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHostProvider.java
index ca5b89f..15d44b2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHostProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHostProvider.java
@@ -42,12 +42,13 @@ public interface JMXHostProvider {
    *
    * @param clusterName    the cluster name
    * @param componentName  the component name
+   * @param hostName       the component hostName
    *
    * @return the port for the specified cluster name and component
    *
    * @throws SystemException if unable to get the JMX port
    */
-  public String getPort(String clusterName, String componentName)
+  public String getPort(String clusterName, String componentName, String hostName)
       throws SystemException;
 
   /**
@@ -55,13 +56,14 @@ public interface JMXHostProvider {
    *
    * @param clusterName    the cluster name
    * @param componentName  the component name
-   * @param componentName httpsEnabled https enabled
+   * @param hostName       the component hostName
+   * @param httpsEnabled   https enabled
    *
    * @return the port for the specified cluster name and component
    *
    * @throws SystemException if unable to get the JMX port
    */
-  public String getPort(String clusterName, String componentName, boolean httpsEnabled)
+  public String getPort(String clusterName, String componentName, String hostName,  boolean httpsEnabled)
       throws SystemException;
   
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/5e36bdc9/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java
index f8215f6..1e7f4af 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java
@@ -198,12 +198,6 @@ public class JMXPropertyProvider extends ThreadPoolEnabledPropertyProvider {
       httpsEnabled = true;
     }
 
-    String port = getPort(clusterName, componentName, httpsEnabled);
-    if (port == null) {
-      LOG.warn("Unable to get JMX metrics.  No port value for " + componentName);
-      return resource;
-    }
-
     Set<String> hostNames = getHosts(resource, clusterName, componentName);
     if (hostNames == null || hostNames.isEmpty()) {
       LOG.warn("Unable to get JMX metrics.  No host name for " + componentName);
@@ -216,6 +210,11 @@ public class JMXPropertyProvider extends ThreadPoolEnabledPropertyProvider {
       try {
         for (String hostName : hostNames) {
           try {
+            String port = getPort(clusterName, componentName, hostName, httpsEnabled);
+            if (port == null) {
+              LOG.warn("Unable to get JMX metrics.  No port value for " + componentName);
+              return resource;
+            }
             if (LOG.isDebugEnabled()) {
               LOG.debug("Spec: " + getSpec(protocol, hostName, port, "/jmx"));
             }
@@ -357,11 +356,11 @@ public class JMXPropertyProvider extends ThreadPoolEnabledPropertyProvider {
     }
   }
 
-  private String getPort(String clusterName, String componentName, boolean httpsEnabled) throws SystemException {
+  private String getPort(String clusterName, String componentName, String hostName, boolean httpsEnabled) throws SystemException {
     String portMapKey = String.format("%s-%s-%s", clusterName, componentName, httpsEnabled);
     String port = clusterComponentPortsMap.get(portMapKey);
     if (port==null) {
-      port = jmxHostProvider.getPort(clusterName, componentName, httpsEnabled);
+      port = jmxHostProvider.getPort(clusterName, componentName, hostName, httpsEnabled);
       port = port == null ? DEFAULT_JMX_PORTS.get(componentName) : port;
       clusterComponentPortsMap.put(portMapKey, port);
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/5e36bdc9/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
index 37190ee..187e0a6 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
@@ -311,6 +311,75 @@ public class JMXHostProviderTest {
       ("hdfs-site").getProperties().get(NAMENODE_PORT_V1));
   }
 
+  private void createConfigsNameNodeHa() throws AmbariException, AuthorizationException {
+    String clusterName = "nnha";
+    ClusterRequest r = new ClusterRequest(null, clusterName, "HDP-2.0.6", null);
+    controller.createCluster(r);
+    Cluster cluster = clusters.getCluster(clusterName);
+    cluster.setDesiredStackVersion(new StackId("HDP-2.0.6"));
+    String serviceName = "HDFS";
+    createService(clusterName, serviceName, null);
+    String componentName1 = "NAMENODE";
+    String componentName2 = "DATANODE";
+    String componentName3 = "HDFS_CLIENT";
+
+    createServiceComponent(clusterName, serviceName, componentName1,
+        State.INIT);
+    createServiceComponent(clusterName, serviceName, componentName2,
+        State.INIT);
+    createServiceComponent(clusterName, serviceName, componentName3,
+        State.INIT);
+
+    String host1 = "h1";
+    clusters.addHost(host1);
+    Map<String, String> hostAttributes = new HashMap<String, String>();
+    hostAttributes.put("os_family", "redhat");
+    hostAttributes.put("os_release_version", "5.9");
+    clusters.getHost("h1").setHostAttributes(hostAttributes);
+    clusters.getHost("h1").persist();
+    String host2 = "h2";
+    clusters.addHost(host2);
+    hostAttributes = new HashMap<String, String>();
+    hostAttributes.put("os_family", "redhat");
+    hostAttributes.put("os_release_version", "6.3");
+    clusters.getHost("h2").setHostAttributes(hostAttributes);
+    clusters.getHost("h2").persist();
+    clusters.mapHostToCluster(host1, clusterName);
+    clusters.mapHostToCluster(host2, clusterName);
+
+    createServiceComponentHost(clusterName, serviceName, componentName1,
+        host1, null);
+    createServiceComponentHost(clusterName, serviceName, componentName1,
+        host2, null);
+    createServiceComponentHost(clusterName, serviceName, componentName2,
+        host1, null);
+    createServiceComponentHost(clusterName, serviceName, componentName2,
+        host2, null);
+    createServiceComponentHost(clusterName, serviceName, componentName3,
+        host1, null);
+    createServiceComponentHost(clusterName, serviceName, componentName3,
+        host2, null);
+
+    // Create configs
+    Map<String, String> configs = new HashMap<String, String>();
+    configs.put("dfs.nameservices", "ns");
+    configs.put("dfs.namenode.http-address", "h1:50070");
+    configs.put("dfs.namenode.http-address.ns.nn1", "h1:50071");
+    configs.put("dfs.namenode.http-address.ns.nn2", "h2:50072");
+    configs.put("dfs.namenode.https-address", "h1:50470");
+    configs.put("dfs.namenode.https-address.ns.nn1", "h1:50473");
+    configs.put("dfs.namenode.https-address.ns.nn2", "h2:50474");
+    configs.put("dfs.ha.namenodes.ns", "nn1,nn2");
+
+
+    ConfigurationRequest cr1 = new ConfigurationRequest(clusterName,
+        "hdfs-site", "version1", configs, null);
+
+    ClusterRequest crReq = new ClusterRequest(cluster.getClusterId(), clusterName, null, null);
+    crReq.setDesiredConfig(Collections.singletonList(cr1));
+    controller.updateClusters(Collections.singleton(crReq), null);
+  }
+
 
   @Test
   public void testJMXPortMapInitAtServiceLevelVersion1() throws
@@ -324,12 +393,12 @@ public class JMXHostProviderTest {
     providerModule.registerResourceProvider(Resource.Type.Service);
     providerModule.registerResourceProvider(Resource.Type.Configuration);
     // Non default port addresses
-    Assert.assertEquals("70070", providerModule.getPort("c1", "NAMENODE"));
-    Assert.assertEquals("70075", providerModule.getPort("c1", "DATANODE"));
+    Assert.assertEquals("70070", providerModule.getPort("c1", "NAMENODE", "localhost"));
+    Assert.assertEquals("70075", providerModule.getPort("c1", "DATANODE", "localhost"));
     // Default port addresses
-    Assert.assertEquals(null, providerModule.getPort("c1", "JOBTRACKER"));
-    Assert.assertEquals(null, providerModule.getPort("c1", "TASKTRACKER"));
-    Assert.assertEquals(null, providerModule.getPort("c1", "HBASE_MASTER"));
+    Assert.assertEquals(null, providerModule.getPort("c1", "JOBTRACKER", "localhost"));
+    Assert.assertEquals(null, providerModule.getPort("c1", "TASKTRACKER", "localhost"));
+    Assert.assertEquals(null, providerModule.getPort("c1", "HBASE_MASTER", "localhost"));
   }
 
   @Test
@@ -344,12 +413,29 @@ public class JMXHostProviderTest {
     providerModule.registerResourceProvider(Resource.Type.Service);
     providerModule.registerResourceProvider(Resource.Type.Configuration);
     // Non default port addresses
-    Assert.assertEquals("70071", providerModule.getPort("c1", "NAMENODE"));
-    Assert.assertEquals("70075", providerModule.getPort("c1", "DATANODE"));
+    Assert.assertEquals("70071", providerModule.getPort("c1", "NAMENODE", "localhost"));
+    Assert.assertEquals("70075", providerModule.getPort("c1", "DATANODE", "localhost"));
     // Default port addresses
-    Assert.assertEquals(null, providerModule.getPort("c1", "JOBTRACKER"));
-    Assert.assertEquals(null, providerModule.getPort("c1", "TASKTRACKER"));
-    Assert.assertEquals(null, providerModule.getPort("c1", "HBASE_MASTER"));
+    Assert.assertEquals(null, providerModule.getPort("c1", "JOBTRACKER", "localhost"));
+    Assert.assertEquals(null, providerModule.getPort("c1", "TASKTRACKER", "localhost"));
+    Assert.assertEquals(null, providerModule.getPort("c1", "HBASE_MASTER", "localhost"));
+  }
+
+  @Test
+  public void testJMXPortMapNameNodeHa() throws
+      NoSuchParentResourceException,
+      ResourceAlreadyExistsException, UnsupportedPropertyException,
+      SystemException, AmbariException, NoSuchResourceException {
+
+    createConfigsNameNodeHa();
+
+    JMXHostProviderModule providerModule = new JMXHostProviderModule();
+    providerModule.registerResourceProvider(Resource.Type.Service);
+    providerModule.registerResourceProvider(Resource.Type.Configuration);
+
+
+    Assert.assertEquals("50071", providerModule.getPort("nnha", "NAMENODE", "h1"));
+    Assert.assertEquals("50072", providerModule.getPort("nnha", "NAMENODE", "h2"));
   }
 
   @Test
@@ -364,12 +450,12 @@ public class JMXHostProviderTest {
     providerModule.registerResourceProvider(Resource.Type.Cluster);
     providerModule.registerResourceProvider(Resource.Type.Configuration);
     // Non default port addresses
-    Assert.assertEquals("70070", providerModule.getPort("c1", "NAMENODE"));
-    Assert.assertEquals("70075", providerModule.getPort("c1", "DATANODE"));
+    Assert.assertEquals("70070", providerModule.getPort("c1", "NAMENODE", "localhost"));
+    Assert.assertEquals("70075", providerModule.getPort("c1", "DATANODE", "localhost"));
     // Default port addresses
-    Assert.assertEquals(null, providerModule.getPort("c1", "JOBTRACKER"));
-    Assert.assertEquals(null, providerModule.getPort("c1", "TASKTRACKER"));
-    Assert.assertEquals(null, providerModule.getPort("c1", "HBASE_MASTER"));
+    Assert.assertEquals(null, providerModule.getPort("c1", "JOBTRACKER", "localhost"));
+    Assert.assertEquals(null, providerModule.getPort("c1", "TASKTRACKER", "localhost"));
+    Assert.assertEquals(null, providerModule.getPort("c1", "HBASE_MASTER", "localhost"));
   }
 
   @Test
@@ -411,7 +497,7 @@ public class JMXHostProviderTest {
     providerModule.registerResourceProvider(Resource.Type.Cluster);
     providerModule.registerResourceProvider(Resource.Type.Configuration);
     Assert.assertEquals("https", providerModule.getJMXProtocol("c1", "RESOURCEMANAGER"));
-    Assert.assertEquals("8090", providerModule.getPort("c1", "RESOURCEMANAGER", true));
+    Assert.assertEquals("8090", providerModule.getPort("c1", "RESOURCEMANAGER", "localhost", true));
 
   }
 
@@ -425,7 +511,7 @@ public class JMXHostProviderTest {
     providerModule.registerResourceProvider(Resource.Type.Cluster);
     providerModule.registerResourceProvider(Resource.Type.Configuration);
     Assert.assertEquals("https", providerModule.getJMXProtocol("c1", "JOURNALNODE"));
-    Assert.assertEquals("8481", providerModule.getPort("c1", "JOURNALNODE", true));
+    Assert.assertEquals("8481", providerModule.getPort("c1", "JOURNALNODE", "localhost", true));
   }
 
   @Test
@@ -440,7 +526,7 @@ public class JMXHostProviderTest {
     providerModule.registerResourceProvider(Resource.Type.Cluster);
     providerModule.registerResourceProvider(Resource.Type.Configuration);
     // Non default port addresses
-    Assert.assertEquals("8088", providerModule.getPort("c1", "RESOURCEMANAGER"));
+    Assert.assertEquals("8088", providerModule.getPort("c1", "RESOURCEMANAGER", "localhost"));
 
     Map<String, String> yarnConfigs = new HashMap<String, String>();
     yarnConfigs.put(RESOURCEMANAGER_PORT, "localhost:50030");
@@ -451,12 +537,12 @@ public class JMXHostProviderTest {
     ClusterRequest crReq = new ClusterRequest(1L, "c1", null, null);
     crReq.setDesiredConfig(Collections.singletonList(cr2));
     controller.updateClusters(Collections.singleton(crReq), null);
-    Assert.assertEquals("50030", providerModule.getPort("c1", "RESOURCEMANAGER"));
-    Assert.assertEquals("11111", providerModule.getPort("c1", "NODEMANAGER"));
+    Assert.assertEquals("50030", providerModule.getPort("c1", "RESOURCEMANAGER", "localhost"));
+    Assert.assertEquals("11111", providerModule.getPort("c1", "NODEMANAGER", "localhost"));
 
     //Unrelated ports
-    Assert.assertEquals("70070", providerModule.getPort("c1", "NAMENODE"));
-    Assert.assertEquals(null, providerModule.getPort("c1", "JOBTRACKER"));
+    Assert.assertEquals("70070", providerModule.getPort("c1", "NAMENODE", "localhost"));
+    Assert.assertEquals(null, providerModule.getPort("c1", "JOBTRACKER", "localhost"));
   }
 
   private static class JMXHostProviderModule extends AbstractProviderModule {

http://git-wip-us.apache.org/repos/asf/ambari/blob/5e36bdc9/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/JMXPropertyProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/JMXPropertyProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/JMXPropertyProviderTest.java
index 2fef7be..6dfced1 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/JMXPropertyProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/metrics/JMXPropertyProviderTest.java
@@ -491,12 +491,12 @@ public class JMXPropertyProviderTest {
     }
 
     @Override
-    public String getPort(String clusterName, String componentName, boolean httpsEnabled) throws SystemException {
-      return getPort(clusterName, componentName);
+    public String getPort(String clusterName, String componentName, String hostName, boolean httpsEnabled) throws SystemException {
+      return getPort(clusterName, componentName, hostName);
     }
 
     @Override
-    public String getPort(String clusterName, String componentName) throws
+    public String getPort(String clusterName, String componentName, String hostName) throws
       SystemException {
 
       if (unknownPort) {


[05/11] ambari git commit: AMBARI-14866. Increase timeout for server-side tasks (rlevas)

Posted by nc...@apache.org.
AMBARI-14866. Increase timeout for server-side tasks (rlevas)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 9a0348957540b3ce3ab5cdcc609bb938ba424c1e
Parents: 9991ad8
Author: Robert Levas <rl...@hortonworks.com>
Authored: Mon Feb 1 17:48:59 2016 -0500
Committer: Robert Levas <rl...@hortonworks.com>
Committed: Mon Feb 1 17:48:59 2016 -0500

----------------------------------------------------------------------
 ambari-server/conf/unix/ambari.properties       |  3 +++
 ambari-server/conf/windows/ambari.properties    |  3 +++
 .../server/configuration/Configuration.java     | 20 ++++++++++++++++
 .../server/controller/KerberosHelperImpl.java   | 16 ++++++-------
 .../internal/UpgradeResourceProvider.java       |  2 +-
 .../serveraction/ServerActionExecutor.java      | 25 +++++++++++++++++---
 .../server/configuration/ConfigurationTest.java | 15 ++++++++++++
 7 files changed, 72 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9a034895/ambari-server/conf/unix/ambari.properties
----------------------------------------------------------------------
diff --git a/ambari-server/conf/unix/ambari.properties b/ambari-server/conf/unix/ambari.properties
index fd1b91e..23f3187 100644
--- a/ambari-server/conf/unix/ambari.properties
+++ b/ambari-server/conf/unix/ambari.properties
@@ -76,6 +76,9 @@ agent.task.timeout=900
 # Default timeout in seconds before package installation task is killed
 agent.package.install.task.timeout=1800
 
+# Default timeout in seconds before a server-side task is killed
+server.task.timeout=1200
+
 # thread pool maximums
 client.threadpool.size.max=25
 agent.threadpool.size.max=25

http://git-wip-us.apache.org/repos/asf/ambari/blob/9a034895/ambari-server/conf/windows/ambari.properties
----------------------------------------------------------------------
diff --git a/ambari-server/conf/windows/ambari.properties b/ambari-server/conf/windows/ambari.properties
index 1dbc28a..803f351 100644
--- a/ambari-server/conf/windows/ambari.properties
+++ b/ambari-server/conf/windows/ambari.properties
@@ -65,6 +65,9 @@ agent.task.timeout=600
 # Default timeout in seconds before package installation task is killed
 agent.package.install.task.timeout=1800
 
+# Default timeout in seconds before a server-side task is killed
+server.task.timeout=1200
+
 # thread pool maximums
 client.threadpool.size.max=25
 agent.threadpool.size.max=25

http://git-wip-us.apache.org/repos/asf/ambari/blob/9a034895/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
index d1453a0..4a4ae43 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
@@ -357,6 +357,12 @@ public class Configuration {
   public static final String AGENT_TASK_TIMEOUT_DEFAULT = "900";
   public static final String AGENT_PACKAGE_INSTALL_TASK_TIMEOUT_DEFAULT = "1800";
 
+  /**
+   * Server side task (default) timeout value
+   */
+  public static final String SERVER_TASK_TIMEOUT_KEY = "server.task.timeout";
+  public static final String SERVER_TASK_TIMEOUT_DEFAULT = "1200";
+
   public static final String CUSTOM_ACTION_DEFINITION_KEY = "custom.action.definitions";
   public static final String SHARED_RESOURCES_DIR_KEY = "shared.resources.dir";
   private static final String CUSTOM_ACTION_DEFINITION_DEF_VALUE = "/var/lib/ambari-server/resources/custom_action_definitions";
@@ -1879,6 +1885,20 @@ public class Configuration {
     }
   }
 
+  /**
+   * @return default server-side task timeout in seconds.
+   */
+  public Integer getDefaultServerTaskTimeout() {
+    String value = properties.getProperty(SERVER_TASK_TIMEOUT_KEY, SERVER_TASK_TIMEOUT_DEFAULT);
+    if (StringUtils.isNumeric(value)) {
+      return Integer.parseInt(value);
+    } else {
+      LOG.warn("Value of {} ({}) should be a number, falling back to default value ({})",
+          SERVER_TASK_TIMEOUT_KEY, value, SERVER_TASK_TIMEOUT_DEFAULT);
+      return Integer.parseInt(SERVER_TASK_TIMEOUT_DEFAULT);
+    }
+  }
+
   public String getResourceDirPath() {
     return properties.getProperty(RESOURCES_DIR_KEY, RESOURCES_DIR_DEFAULT);
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/9a034895/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java
index a0e6ccb..63aa92d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/KerberosHelperImpl.java
@@ -2418,7 +2418,7 @@ public class KerberosHelperImpl implements KerberosHelper {
           event,
           commandParameters,
           "Preparing Operations",
-          1200);
+          configuration.getDefaultServerTaskTimeout());
 
       RoleGraph roleGraph = roleGraphFactory.createNew(roleCommandOrder);
       roleGraph.build(stage);
@@ -2441,7 +2441,7 @@ public class KerberosHelperImpl implements KerberosHelper {
           event,
           commandParameters,
           "Preparing Operations",
-          1200);
+          configuration.getDefaultServerTaskTimeout());
 
       RoleGraph roleGraph = roleGraphFactory.createNew(roleCommandOrder);
       roleGraph.build(stage);
@@ -2464,7 +2464,7 @@ public class KerberosHelperImpl implements KerberosHelper {
           event,
           commandParameters,
           "Preparing Operations",
-          1200);
+          configuration.getDefaultServerTaskTimeout());
 
       RoleGraph roleGraph = roleGraphFactory.createNew(roleCommandOrder);
       roleGraph.build(stage);
@@ -2487,7 +2487,7 @@ public class KerberosHelperImpl implements KerberosHelper {
           event,
           commandParameters,
           "Create Principals",
-          1200);
+          configuration.getDefaultServerTaskTimeout());
 
       RoleGraph roleGraph = roleGraphFactory.createNew(roleCommandOrder);
       roleGraph.build(stage);
@@ -2510,7 +2510,7 @@ public class KerberosHelperImpl implements KerberosHelper {
           event,
           commandParameters,
           "Destroy Principals",
-          1200);
+          configuration.getDefaultServerTaskTimeout());
 
       RoleGraph roleGraph = roleGraphFactory.createNew(roleCommandOrder);
       roleGraph.build(stage);
@@ -2533,7 +2533,7 @@ public class KerberosHelperImpl implements KerberosHelper {
           event,
           commandParameters,
           "Create Keytabs",
-          1200);
+          configuration.getDefaultServerTaskTimeout());
 
       RoleGraph roleGraph = roleGraphFactory.createNew(roleCommandOrder);
       roleGraph.build(stage);
@@ -2665,7 +2665,7 @@ public class KerberosHelperImpl implements KerberosHelper {
           event,
           commandParameters,
           "Update Service Configurations",
-          1200);
+          configuration.getDefaultServerTaskTimeout());
 
       RoleGraph roleGraph = roleGraphFactory.createNew(roleCommandOrder);
       roleGraph.build(stage);
@@ -2718,7 +2718,7 @@ public class KerberosHelperImpl implements KerberosHelper {
           event,
           commandParameters,
           "Kerberization Clean Up",
-          1200);
+          configuration.getDefaultServerTaskTimeout());
 
       RoleGraph roleGraph = roleGraphFactory.createNew(roleCommandOrder);
       roleGraph.build(stage);

http://git-wip-us.apache.org/repos/asf/ambari/blob/9a034895/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
index 5a6a50d..70440fc 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
@@ -1513,7 +1513,7 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
         getManagementController().getAuthName(), Role.AMBARI_SERVER_ACTION, RoleCommand.EXECUTE,
         cluster.getClusterName(),
         new ServiceComponentHostServerActionEvent(null, System.currentTimeMillis()), commandParams,
-        itemDetail, null, Integer.valueOf(1200), allowRetry,
+        itemDetail, null, s_configuration.getDefaultServerTaskTimeout(), allowRetry,
         context.isComponentFailureAutoSkipped());
 
     request.addStages(Collections.singletonList(stage));

http://git-wip-us.apache.org/repos/asf/ambari/blob/9a034895/ambari-server/src/main/java/org/apache/ambari/server/serveraction/ServerActionExecutor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/ServerActionExecutor.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/ServerActionExecutor.java
index 00b8a74..20cf5bb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/ServerActionExecutor.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/ServerActionExecutor.java
@@ -35,6 +35,7 @@ import org.apache.ambari.server.actionmanager.HostRoleStatus;
 import org.apache.ambari.server.actionmanager.Request;
 import org.apache.ambari.server.agent.CommandReport;
 import org.apache.ambari.server.agent.ExecutionCommand;
+import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.internal.CalculatedStatus;
 import org.apache.ambari.server.security.authorization.internal.InternalAuthenticationToken;
 import org.apache.ambari.server.utils.StageUtils;
@@ -57,7 +58,7 @@ import org.springframework.security.core.context.SecurityContextHolder;
 public class ServerActionExecutor {
 
   private final static Logger LOG = LoggerFactory.getLogger(ServerActionExecutor.class);
-  private final static Long EXECUTION_TIMEOUT_MS = 1000L * 60 * 5;
+  private final static Long DEFAULT_EXECUTION_TIMEOUT_MS = 1000L * 60 * 5;
   private final static Long POLLING_TIMEOUT_MS = 1000L * 5;
 
   /**
@@ -67,6 +68,13 @@ public class ServerActionExecutor {
   private static Injector injector;
 
   /**
+   * The Ambari configuration used to obtain configured details such as the default server-side action
+   * timeout.
+   */
+  @Inject
+  private static Configuration configuration;
+
+  /**
    * Maps request IDs to "blackboards" of shared data.
    * <p/>
    * This map is not synchronized, so any access to it should synchronize on
@@ -354,13 +362,24 @@ public class ServerActionExecutor {
     try {
       timeout = (paramsTimeout == null)
           ? null
-          : (Long.parseLong(paramsTimeout) * 1000); // Convert seconds to milliseconds
+          : (Long.parseLong(paramsTimeout) * 1000L); // Convert seconds to milliseconds
     } catch (NumberFormatException e) {
       timeout = null;
     }
 
+    // If a configured timeout value is not set for the command, attempt to get the configured
+    // default
+    if (timeout == null) {
+      Integer defaultTimeoutSeconds = configuration.getDefaultServerTaskTimeout();
+      if (defaultTimeoutSeconds != null) {
+        timeout = defaultTimeoutSeconds * 1000L; // convert seconds to milliseconds
+      }
+    }
+
+    // If a timeout value was not determined, return the hard-coded timeout value, else return the
+    // determined timeout value.
     return (timeout == null)
-        ? EXECUTION_TIMEOUT_MS
+        ? DEFAULT_EXECUTION_TIMEOUT_MS
         : ((timeout < 0) ? 0 : timeout);
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/9a034895/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java b/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
index 67c0979..4e236f3 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/configuration/ConfigurationTest.java
@@ -319,6 +319,21 @@ public class ConfigurationTest {
 
 
   @Test
+  public void testGetDefaultServerTaskTimeout() {
+    Properties ambariProperties = new Properties();
+    Configuration conf = new Configuration(ambariProperties);
+
+    Assert.assertEquals(Integer.valueOf(1200), conf.getDefaultServerTaskTimeout());
+
+    ambariProperties = new Properties();
+    ambariProperties.setProperty(Configuration.SERVER_TASK_TIMEOUT_KEY, "3600");
+
+    conf = new Configuration(ambariProperties);
+
+    Assert.assertEquals(Integer.valueOf(3600), conf.getDefaultServerTaskTimeout());
+  }
+
+  @Test
   public void testGetLdapServerProperties_WrongManagerPassword() throws Exception {
     final Properties ambariProperties = new Properties();
     ambariProperties.setProperty(Configuration.LDAP_MANAGER_PASSWORD_KEY, "somePassword");


[08/11] ambari git commit: AMBARI-14869: Rename AdminSetting API to Setting (Ajit Kumar via smnaha)

Posted by nc...@apache.org.
AMBARI-14869: Rename AdminSetting API to Setting (Ajit Kumar via smnaha)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 774d689eee8a26a0511e23f182a1d3e65c22c5eb
Parents: 6ce1565
Author: Nahappan Somasundaram <ns...@hortonworks.com>
Authored: Mon Feb 1 18:15:03 2016 -0800
Committer: Nahappan Somasundaram <ns...@hortonworks.com>
Committed: Mon Feb 1 18:15:03 2016 -0800

----------------------------------------------------------------------
 .../resources/ResourceInstanceFactoryImpl.java  |   4 +-
 .../api/services/AdminSettingService.java       | 148 --------
 .../server/api/services/SettingService.java     | 148 ++++++++
 .../internal/AdminSettingResourceProvider.java  | 250 -------------
 .../internal/DefaultProviderModule.java         |   4 +-
 .../internal/SettingResourceProvider.java       | 251 +++++++++++++
 .../ambari/server/controller/spi/Resource.java  |   4 +-
 .../ambari/server/orm/dao/AdminSettingDAO.java  | 100 ------
 .../ambari/server/orm/dao/SettingDAO.java       | 100 ++++++
 .../server/orm/entities/AdminSettingEntity.java | 149 --------
 .../server/orm/entities/SettingEntity.java      | 149 ++++++++
 .../authorization/RoleAuthorization.java        |   2 +-
 .../main/resources/Ambari-DDL-Derby-CREATE.sql  |   8 +-
 .../main/resources/Ambari-DDL-MySQL-CREATE.sql  |   8 +-
 .../main/resources/Ambari-DDL-Oracle-CREATE.sql |   8 +-
 .../resources/Ambari-DDL-Postgres-CREATE.sql    |   8 +-
 .../Ambari-DDL-Postgres-EMBEDDED-CREATE.sql     |  10 +-
 .../resources/Ambari-DDL-SQLAnywhere-CREATE.sql |   8 +-
 .../resources/Ambari-DDL-SQLServer-CREATE.sql   |   8 +-
 .../src/main/resources/META-INF/persistence.xml |   2 +-
 .../api/services/AdminSettingServiceTest.java   | 101 ------
 .../server/api/services/SettingServiceTest.java | 101 ++++++
 .../AdminSettingResourceProviderTest.java       | 356 -------------------
 .../internal/SettingResourceProviderTest.java   | 355 ++++++++++++++++++
 .../server/orm/dao/AdminSettingDAOTest.java     |  93 -----
 .../ambari/server/orm/dao/SettingDAOTest.java   |  93 +++++
 .../orm/entities/AdminSettingEntityTest.java    |  91 -----
 .../server/orm/entities/SettingEntityTest.java  |  90 +++++
 28 files changed, 1324 insertions(+), 1325 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
index 070a505..4c12094 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
@@ -408,8 +408,8 @@ public class ResourceInstanceFactoryImpl implements ResourceInstanceFactory {
         resourceDefinition = new SimpleResourceDefinition(Resource.Type.UserAuthorization, "authorization", "authorizations");
         break;
 
-      case AdminSetting:
-        resourceDefinition = new SimpleResourceDefinition(Resource.Type.AdminSetting, "admin-setting", "admin-settings");
+      case Setting:
+        resourceDefinition = new SimpleResourceDefinition(Resource.Type.Setting, "setting", "settings");
         break;
 
       default:

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/main/java/org/apache/ambari/server/api/services/AdminSettingService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AdminSettingService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AdminSettingService.java
deleted file mode 100644
index 2c5b77d..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AdminSettingService.java
+++ /dev/null
@@ -1,148 +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.
- */
-
-package org.apache.ambari.server.api.services;
-
-import org.apache.ambari.server.api.resources.ResourceInstance;
-import org.apache.ambari.server.controller.spi.Resource;
-
-
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import java.util.Collections;
-
-/**
- * Service responsible for admin setting resource requests.
- */
-@Path("/admin-settings/")
-public class AdminSettingService extends BaseService {
-
-  /**
-   * Construct a AdminSettingService.
-   */
-  public AdminSettingService() {
-
-  }
-
-  /**
-   * Handles: GET  /settings
-   * Get all clusters.
-   *
-   * @param headers  http headers
-   * @param ui       uri info
-   *
-   * @return admin setting collection resource representation
-   */
-  @GET
-  @Produces("text/plain")
-  public Response getSettings(String body, @Context HttpHeaders headers, @Context UriInfo ui) {
-    return handleRequest(headers, body, ui, Request.Type.GET, createSettingResource(null));
-  }
-
-  /**
-   * Handles: GET /admin-settings/{settingName}
-   * Get a specific admin setting.
-   *
-   * @param headers      http headers
-   * @param ui           uri info
-   * @param settingName  settingName
-   *
-   * @return admin setting instance representation
-   */
-  @GET
-  @Path("{settingName}")
-  @Produces("text/plain")
-  public Response getSetting(String body, @Context HttpHeaders headers, @Context UriInfo ui,
-                             @PathParam("settingName") String settingName) {
-    return handleRequest(headers, body, ui, Request.Type.GET, createSettingResource(settingName));
-  }
-
-  /**
-   * Handles: POST /admin-settings/{settingName}
-   * Create a specific admin setting.
-   *
-   * @param headers      http headers
-   * @param ui           uri info
-   *
-   * @return information regarding the created setting
-   */
-   @POST
-   @Produces("text/plain")
-   public Response createSetting(String body, @Context HttpHeaders headers, @Context UriInfo ui) {
-     return handleRequest(headers, body, ui, Request.Type.POST, createSettingResource(null));
-  }
-
-  /**
-   * Handles: PUT /admin-settings/{settingName}
-   * Update a specific admin setting.
-   *
-   * @param headers      http headers
-   * @param ui           uri info
-   * @param settingName  setting name
-   *
-   * @return information regarding the updated setting
-   */
-  @PUT
-  @Path("{settingName}")
-  @Produces("text/plain")
-  public Response updateSetting(String body, @Context HttpHeaders headers, @Context UriInfo ui,
-                                @PathParam("settingName") String settingName) {
-    return handleRequest(headers, body, ui, Request.Type.PUT, createSettingResource(settingName));
-  }
-
-  /**
-   * Handles: DELETE /admin-settings/{settingName}
-   * Delete a specific admin setting.
-   *
-   * @param headers      http headers
-   * @param ui           uri info
-   * @param settingName  setting name
-   *
-   * @return information regarding the deleted setting
-   */
-  @DELETE
-  @Path("{settingName}")
-  @Produces("text/plain")
-  public Response deleteSetting(@Context HttpHeaders headers, @Context UriInfo ui,
-                                @PathParam("settingName") String settingName) {
-    return handleRequest(headers, null, ui, Request.Type.DELETE, createSettingResource(settingName));
-  }
-
-  // ----- helper methods ----------------------------------------------------
-
-  /**
-   * Create an admin setting resource instance.
-   *
-   * @param settingName setting name
-   *
-   * @return an admin setting resource instance
-   */
-  ResourceInstance createSettingResource(String settingName) {
-    return createResource(Resource.Type.AdminSetting,
-        Collections.singletonMap(Resource.Type.AdminSetting, settingName));
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/main/java/org/apache/ambari/server/api/services/SettingService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/SettingService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/SettingService.java
new file mode 100644
index 0000000..db6f002
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/SettingService.java
@@ -0,0 +1,148 @@
+/**
+ * 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.
+ */
+
+package org.apache.ambari.server.api.services;
+
+import org.apache.ambari.server.api.resources.ResourceInstance;
+import org.apache.ambari.server.controller.spi.Resource;
+
+
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import java.util.Collections;
+
+/**
+ * Service responsible for setting resource requests.
+ */
+@Path("/settings/")
+public class SettingService extends BaseService {
+
+  /**
+   * Construct a SettingService.
+   */
+  public SettingService() {
+
+  }
+
+  /**
+   * Handles: GET  /settings
+   * Get all clusters.
+   *
+   * @param headers  http headers
+   * @param ui       uri info
+   *
+   * @return setting collection resource representation
+   */
+  @GET
+  @Produces("text/plain")
+  public Response getSettings(String body, @Context HttpHeaders headers, @Context UriInfo ui) {
+    return handleRequest(headers, body, ui, Request.Type.GET, createSettingResource(null));
+  }
+
+  /**
+   * Handles: GET /settings/{settingName}
+   * Get a specific setting.
+   *
+   * @param headers      http headers
+   * @param ui           uri info
+   * @param settingName  settingName
+   *
+   * @return setting instance representation
+   */
+  @GET
+  @Path("{settingName}")
+  @Produces("text/plain")
+  public Response getSetting(String body, @Context HttpHeaders headers, @Context UriInfo ui,
+                             @PathParam("settingName") String settingName) {
+    return handleRequest(headers, body, ui, Request.Type.GET, createSettingResource(settingName));
+  }
+
+  /**
+   * Handles: POST /settings/{settingName}
+   * Create a specific setting.
+   *
+   * @param headers      http headers
+   * @param ui           uri info
+   *
+   * @return information regarding the created setting
+   */
+   @POST
+   @Produces("text/plain")
+   public Response createSetting(String body, @Context HttpHeaders headers, @Context UriInfo ui) {
+     return handleRequest(headers, body, ui, Request.Type.POST, createSettingResource(null));
+  }
+
+  /**
+   * Handles: PUT /settings/{settingName}
+   * Update a specific setting.
+   *
+   * @param headers      http headers
+   * @param ui           uri info
+   * @param settingName  setting name
+   *
+   * @return information regarding the updated setting
+   */
+  @PUT
+  @Path("{settingName}")
+  @Produces("text/plain")
+  public Response updateSetting(String body, @Context HttpHeaders headers, @Context UriInfo ui,
+                                @PathParam("settingName") String settingName) {
+    return handleRequest(headers, body, ui, Request.Type.PUT, createSettingResource(settingName));
+  }
+
+  /**
+   * Handles: DELETE /settings/{settingName}
+   * Delete a specific setting.
+   *
+   * @param headers      http headers
+   * @param ui           uri info
+   * @param settingName  setting name
+   *
+   * @return information regarding the deleted setting
+   */
+  @DELETE
+  @Path("{settingName}")
+  @Produces("text/plain")
+  public Response deleteSetting(@Context HttpHeaders headers, @Context UriInfo ui,
+                                @PathParam("settingName") String settingName) {
+    return handleRequest(headers, null, ui, Request.Type.DELETE, createSettingResource(settingName));
+  }
+
+  // ----- helper methods ----------------------------------------------------
+
+  /**
+   * Create a setting resource instance.
+   *
+   * @param settingName setting name
+   *
+   * @return a setting resource instance
+   */
+  ResourceInstance createSettingResource(String settingName) {
+    return createResource(Resource.Type.Setting,
+        Collections.singletonMap(Resource.Type.Setting, settingName));
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AdminSettingResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AdminSettingResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AdminSettingResourceProvider.java
deleted file mode 100644
index e8d5b5e..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AdminSettingResourceProvider.java
+++ /dev/null
@@ -1,250 +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.
- */
-package org.apache.ambari.server.controller.internal;
-
-import com.google.inject.Inject;
-import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.DuplicateResourceException;
-import org.apache.ambari.server.StaticallyInject;
-import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
-import org.apache.ambari.server.controller.spi.NoSuchResourceException;
-import org.apache.ambari.server.controller.spi.Predicate;
-import org.apache.ambari.server.controller.spi.Request;
-import org.apache.ambari.server.controller.spi.RequestStatus;
-import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
-import org.apache.ambari.server.controller.spi.SystemException;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
-import org.apache.ambari.server.orm.dao.AdminSettingDAO;
-import org.apache.ambari.server.orm.entities.AdminSettingEntity;
-import org.apache.ambari.server.security.authorization.AuthorizationException;
-import org.apache.ambari.server.security.authorization.AuthorizationHelper;
-import org.apache.ambari.server.security.authorization.RoleAuthorization;
-import org.apache.commons.lang.ObjectUtils;
-import org.apache.commons.lang.StringUtils;
-
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
-/**
- * This class deals with managing CRUD operation on {@link AdminSettingEntity}.
- */
-@StaticallyInject
-public class AdminSettingResourceProvider extends AbstractAuthorizedResourceProvider {
-
-  protected static final String ID = "id";
-  protected static final String ADMINSETTING = "AdminSetting";
-  protected static final String ADMINSETTING_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("AdminSettings", "name");
-  protected static final String ADMINSETTING_SETTING_TYPE_PROPERTY_ID = PropertyHelper.getPropertyId("AdminSettings", "setting_type");
-  protected static final String ADMINSETTING_CONTENT_PROPERTY_ID = PropertyHelper.getPropertyId("AdminSettings", "content");
-  protected static final String ADMINSETTING_UPDATED_BY_PROPERTY_ID = PropertyHelper.getPropertyId("AdminSettings", "updated_by");
-  protected static final String ADMINSETTING_UPDATE_TIMESTAMP_PROPERTY_ID = PropertyHelper.getPropertyId("AdminSettings", "update_timestamp");
-
-  /**
-   * The property ids for a admin setting resource.
-   */
-  private static final Set<String> propertyIds = new HashSet<>();
-
-  /**
-   * The key property ids for a admin setting resource.
-   */
-  private static final Map<Resource.Type, String> keyPropertyIds = new HashMap<>();
-
-  private static final Set<String> requiredProperties = new HashSet<>();
-
-  @Inject
-  private static AdminSettingDAO dao;
-
-  static {
-    propertyIds.add(ADMINSETTING_NAME_PROPERTY_ID);
-    propertyIds.add(ADMINSETTING_SETTING_TYPE_PROPERTY_ID);
-    propertyIds.add(ADMINSETTING_CONTENT_PROPERTY_ID);
-    propertyIds.add(ADMINSETTING_UPDATED_BY_PROPERTY_ID);
-    propertyIds.add(ADMINSETTING_UPDATE_TIMESTAMP_PROPERTY_ID);
-    propertyIds.add(ADMINSETTING_SETTING_TYPE_PROPERTY_ID);
-    propertyIds.add(ADMINSETTING);
-
-    keyPropertyIds.put(Resource.Type.AdminSetting, ADMINSETTING_NAME_PROPERTY_ID);
-
-    requiredProperties.add(ADMINSETTING_NAME_PROPERTY_ID);
-    requiredProperties.add(ADMINSETTING_SETTING_TYPE_PROPERTY_ID);
-    requiredProperties.add(ADMINSETTING_CONTENT_PROPERTY_ID);
-  }
-
-  protected AdminSettingResourceProvider() {
-    super(propertyIds, keyPropertyIds);
-    EnumSet<RoleAuthorization> requiredAuthorizations = EnumSet.of(RoleAuthorization.AMBARI_MANAGE_ADMIN_SETTINGS);
-    setRequiredCreateAuthorizations(requiredAuthorizations);
-    setRequiredDeleteAuthorizations(requiredAuthorizations);
-    setRequiredUpdateAuthorizations(requiredAuthorizations);
-  }
-
-  @Override
-  protected Set<String> getPKPropertyIds() {
-    return new HashSet<>(keyPropertyIds.values());
-  }
-
-  @Override
-  public RequestStatus createResourcesAuthorized(Request request)
-          throws NoSuchParentResourceException, ResourceAlreadyExistsException, SystemException {
-    Set<Resource> associatedResources = new HashSet<>();
-
-    for (Map<String, Object> properties : request.getProperties()) {
-      AdminSettingEntity settingEntity = createResources(newCreateCommand(request, properties));
-      Resource resource = new ResourceImpl(Resource.Type.AdminSetting);
-      resource.setProperty(ADMINSETTING_NAME_PROPERTY_ID, settingEntity.getName());
-      associatedResources.add(resource);
-    }
-
-    return getRequestStatus(null, associatedResources);
-  }
-
-  @Override
-  public Set<Resource> getResourcesAuthorized(Request request, Predicate predicate) throws NoSuchResourceException {
-    List<AdminSettingEntity> entities = new LinkedList<>();
-    final Set<Map<String, Object>> propertyMaps = getPropertyMaps(predicate);
-    if (propertyMaps.isEmpty()) {
-      entities = dao.findAll();
-    }
-    for (Map<String, Object> propertyMap: propertyMaps) {
-      if (propertyMap.containsKey(ADMINSETTING_NAME_PROPERTY_ID)) {
-        String name = propertyMap.get(ADMINSETTING_NAME_PROPERTY_ID).toString();
-        AdminSettingEntity entity = dao.findByName(name);
-        if (entity == null) {
-          throw new NoSuchResourceException(String.format("AdminSetting with name %s does not exists", name));
-        }
-        entities.add(entity);
-      } else {
-        entities = dao.findAll();
-        break;
-      }
-    }
-    Set<String> requestedIds = getRequestPropertyIds(request, predicate);
-    Set<Resource> resources = new HashSet<>();
-    for(AdminSettingEntity entity : entities) {
-      resources.add(toResource(entity, requestedIds));
-    }
-    return resources;
-  }
-
-  @Override
-  public RequestStatus updateResourcesAuthorized(Request request, Predicate predicate)
-          throws NoSuchResourceException, NoSuchParentResourceException, SystemException {
-    modifyResources(newUpdateCommand(request));
-    return getRequestStatus(null);
-  }
-
-  @Override
-  public RequestStatus deleteResourcesAuthorized(Predicate predicate) {
-    final Set<Map<String, Object>> propertyMaps = getPropertyMaps(predicate);
-    for (Map<String, Object> propertyMap : propertyMaps) {
-      if (propertyMap.containsKey(ADMINSETTING_NAME_PROPERTY_ID)) {
-        dao.removeByName(propertyMap.get(ADMINSETTING_NAME_PROPERTY_ID).toString());
-      }
-    }
-    return getRequestStatus(null);
-  }
-
-
-  private Command<AdminSettingEntity> newCreateCommand(final Request request, final Map<String, Object> properties) {
-    return new Command<AdminSettingEntity>() {
-      @Override
-      public AdminSettingEntity invoke() throws AmbariException, AuthorizationException {
-        AdminSettingEntity entity = toEntity(properties);
-        if (dao.findByName(entity.getName()) != null) {
-          throw new DuplicateResourceException(
-                  String.format("Setting already exists. setting name :%s ", entity.getName()));
-        }
-        dao.create(entity);
-        notifyCreate(Resource.Type.AdminSetting, request);
-        return entity;
-      }
-    };
-  }
-
-  private Command<Void> newUpdateCommand(final Request request) throws NoSuchResourceException, SystemException {
-    return new Command<Void>() {
-      @Override
-      public Void invoke() throws AmbariException {
-        final Set<Map<String, Object>> propertyMaps = request.getProperties();
-        for (Map<String, Object> propertyMap : propertyMaps) {
-          if (propertyMap.containsKey(ADMINSETTING_NAME_PROPERTY_ID)) {
-            String name = propertyMap.get(ADMINSETTING_NAME_PROPERTY_ID).toString();
-            AdminSettingEntity entity = dao.findByName(name);
-            if (entity == null) {
-              throw new AmbariException(String.format("There is no admin setting with name: %s ", name));
-            }
-            updateEntity(entity, propertyMap);
-            dao.merge(entity);
-          }
-        }
-        return null;
-      }
-    };
-  }
-
-  private void updateEntity(AdminSettingEntity entity, Map<String, Object> propertyMap) throws AmbariException {
-    String name = propertyMap.get(ADMINSETTING_NAME_PROPERTY_ID).toString();
-    if (!Objects.equals(name, entity.getName())) {
-      throw new AmbariException("Name for AdminSetting is immutable, cannot change name.");
-    }
-
-    if (StringUtils.isNotBlank(ObjectUtils.toString(propertyMap.get(ADMINSETTING_CONTENT_PROPERTY_ID)))) {
-      entity.setContent(propertyMap.get(ADMINSETTING_CONTENT_PROPERTY_ID).toString());
-    }
-
-    if (StringUtils.isNotBlank(ObjectUtils.toString(propertyMap.get(ADMINSETTING_SETTING_TYPE_PROPERTY_ID)))) {
-      entity.setSettingType(propertyMap.get(ADMINSETTING_SETTING_TYPE_PROPERTY_ID).toString());
-    }
-
-    entity.setUpdatedBy(AuthorizationHelper.getAuthenticatedName());
-    entity.setUpdateTimestamp(System.currentTimeMillis());
-  }
-
-  private Resource toResource(final AdminSettingEntity adminSettingEntity, final Set<String> requestedIds) {
-    Resource resource = new ResourceImpl(Resource.Type.AdminSetting);
-    setResourceProperty(resource, ADMINSETTING_NAME_PROPERTY_ID, adminSettingEntity.getName(), requestedIds);
-    setResourceProperty(resource, ADMINSETTING_SETTING_TYPE_PROPERTY_ID, adminSettingEntity.getSettingType(), requestedIds);
-    setResourceProperty(resource, ADMINSETTING_CONTENT_PROPERTY_ID, adminSettingEntity.getContent(), requestedIds);
-    setResourceProperty(resource, ADMINSETTING_UPDATED_BY_PROPERTY_ID, adminSettingEntity.getUpdatedBy(), requestedIds);
-    setResourceProperty(resource, ADMINSETTING_UPDATE_TIMESTAMP_PROPERTY_ID, adminSettingEntity.getUpdateTimestamp(), requestedIds);
-    return resource;
-  }
-
-  private AdminSettingEntity toEntity(final Map<String, Object> properties) throws AmbariException {
-    for (String propertyName: requiredProperties) {
-      if (properties.get(propertyName) == null) {
-        throw new AmbariException(String.format("Property %s should be provided", propertyName));
-      }
-    }
-
-    AdminSettingEntity entity = new AdminSettingEntity();
-    entity.setName(properties.get(ADMINSETTING_NAME_PROPERTY_ID).toString());
-    entity.setSettingType(properties.get(ADMINSETTING_SETTING_TYPE_PROPERTY_ID).toString());
-    entity.setContent(properties.get(ADMINSETTING_CONTENT_PROPERTY_ID).toString());
-    entity.setUpdatedBy(AuthorizationHelper.getAuthenticatedName());
-    entity.setUpdateTimestamp(System.currentTimeMillis());
-    return entity;
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java
index ab76458..da334b2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/DefaultProviderModule.java
@@ -112,8 +112,8 @@ public class DefaultProviderModule extends AbstractProviderModule {
         return new OperatingSystemResourceProvider(managementController);
       case Repository:
         return new RepositoryResourceProvider(managementController);
-      case AdminSetting:
-        return new AdminSettingResourceProvider();
+      case Setting:
+        return new SettingResourceProvider();
       case Artifact:
         return new ArtifactResourceProvider(managementController);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/SettingResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/SettingResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/SettingResourceProvider.java
new file mode 100644
index 0000000..e1f9015
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/SettingResourceProvider.java
@@ -0,0 +1,251 @@
+/**
+ * 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.
+ */
+package org.apache.ambari.server.controller.internal;
+
+import com.google.inject.Inject;
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.DuplicateResourceException;
+import org.apache.ambari.server.StaticallyInject;
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
+import org.apache.ambari.server.controller.spi.NoSuchResourceException;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.RequestStatus;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.apache.ambari.server.orm.dao.SettingDAO;
+import org.apache.ambari.server.orm.entities.SettingEntity;
+import org.apache.ambari.server.security.authorization.AuthorizationException;
+import org.apache.ambari.server.security.authorization.AuthorizationHelper;
+import org.apache.ambari.server.security.authorization.RoleAuthorization;
+import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang.StringUtils;
+
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+
+/**
+ * This class deals with managing CRUD operation on {@link SettingEntity}.
+ */
+@StaticallyInject
+public class SettingResourceProvider extends AbstractAuthorizedResourceProvider {
+
+  private static final String SETTINGS = "Settings";
+  protected static final String ID = "id";
+  protected static final String SETTING = "Setting";
+  protected static final String SETTING_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(SETTINGS, "name");
+  protected static final String SETTING_SETTING_TYPE_PROPERTY_ID = PropertyHelper.getPropertyId(SETTINGS, "setting_type");
+  protected static final String SETTING_CONTENT_PROPERTY_ID = PropertyHelper.getPropertyId(SETTINGS, "content");
+  protected static final String SETTING_UPDATED_BY_PROPERTY_ID = PropertyHelper.getPropertyId(SETTINGS, "updated_by");
+  protected static final String SETTING_UPDATE_TIMESTAMP_PROPERTY_ID = PropertyHelper.getPropertyId(SETTINGS, "update_timestamp");
+
+  /**
+   * The property ids for setting resource.
+   */
+  private static final Set<String> propertyIds = new HashSet<>();
+
+  /**
+   * The key property ids for setting resource.
+   */
+  private static final Map<Resource.Type, String> keyPropertyIds = new HashMap<>();
+
+  private static final Set<String> requiredProperties = new HashSet<>();
+
+  @Inject
+  private static SettingDAO dao;
+
+  static {
+    propertyIds.add(SETTING_NAME_PROPERTY_ID);
+    propertyIds.add(SETTING_SETTING_TYPE_PROPERTY_ID);
+    propertyIds.add(SETTING_CONTENT_PROPERTY_ID);
+    propertyIds.add(SETTING_UPDATED_BY_PROPERTY_ID);
+    propertyIds.add(SETTING_UPDATE_TIMESTAMP_PROPERTY_ID);
+    propertyIds.add(SETTING_SETTING_TYPE_PROPERTY_ID);
+    propertyIds.add(SETTING);
+
+    keyPropertyIds.put(Resource.Type.Setting, SETTING_NAME_PROPERTY_ID);
+
+    requiredProperties.add(SETTING_NAME_PROPERTY_ID);
+    requiredProperties.add(SETTING_SETTING_TYPE_PROPERTY_ID);
+    requiredProperties.add(SETTING_CONTENT_PROPERTY_ID);
+  }
+
+  protected SettingResourceProvider() {
+    super(propertyIds, keyPropertyIds);
+    EnumSet<RoleAuthorization> requiredAuthorizations = EnumSet.of(RoleAuthorization.AMBARI_MANAGE_SETTINGS);
+    setRequiredCreateAuthorizations(requiredAuthorizations);
+    setRequiredDeleteAuthorizations(requiredAuthorizations);
+    setRequiredUpdateAuthorizations(requiredAuthorizations);
+  }
+
+  @Override
+  protected Set<String> getPKPropertyIds() {
+    return new HashSet<>(keyPropertyIds.values());
+  }
+
+  @Override
+  public RequestStatus createResourcesAuthorized(Request request)
+          throws NoSuchParentResourceException, ResourceAlreadyExistsException, SystemException {
+    Set<Resource> associatedResources = new HashSet<>();
+
+    for (Map<String, Object> properties : request.getProperties()) {
+      SettingEntity settingEntity = createResources(newCreateCommand(request, properties));
+      Resource resource = new ResourceImpl(Resource.Type.Setting);
+      resource.setProperty(SETTING_NAME_PROPERTY_ID, settingEntity.getName());
+      associatedResources.add(resource);
+    }
+
+    return getRequestStatus(null, associatedResources);
+  }
+
+  @Override
+  public Set<Resource> getResourcesAuthorized(Request request, Predicate predicate) throws NoSuchResourceException {
+    List<SettingEntity> entities = new LinkedList<>();
+    final Set<Map<String, Object>> propertyMaps = getPropertyMaps(predicate);
+    if (propertyMaps.isEmpty()) {
+      entities = dao.findAll();
+    }
+    for (Map<String, Object> propertyMap: propertyMaps) {
+      if (propertyMap.containsKey(SETTING_NAME_PROPERTY_ID)) {
+        String name = propertyMap.get(SETTING_NAME_PROPERTY_ID).toString();
+        SettingEntity entity = dao.findByName(name);
+        if (entity == null) {
+          throw new NoSuchResourceException(String.format("Setting with name %s does not exists", name));
+        }
+        entities.add(entity);
+      } else {
+        entities = dao.findAll();
+        break;
+      }
+    }
+    Set<String> requestedIds = getRequestPropertyIds(request, predicate);
+    Set<Resource> resources = new HashSet<>();
+    for(SettingEntity entity : entities) {
+      resources.add(toResource(entity, requestedIds));
+    }
+    return resources;
+  }
+
+  @Override
+  public RequestStatus updateResourcesAuthorized(Request request, Predicate predicate)
+          throws NoSuchResourceException, NoSuchParentResourceException, SystemException {
+    modifyResources(newUpdateCommand(request));
+    return getRequestStatus(null);
+  }
+
+  @Override
+  public RequestStatus deleteResourcesAuthorized(Predicate predicate) {
+    final Set<Map<String, Object>> propertyMaps = getPropertyMaps(predicate);
+    for (Map<String, Object> propertyMap : propertyMaps) {
+      if (propertyMap.containsKey(SETTING_NAME_PROPERTY_ID)) {
+        dao.removeByName(propertyMap.get(SETTING_NAME_PROPERTY_ID).toString());
+      }
+    }
+    return getRequestStatus(null);
+  }
+
+
+  private Command<SettingEntity> newCreateCommand(final Request request, final Map<String, Object> properties) {
+    return new Command<SettingEntity>() {
+      @Override
+      public SettingEntity invoke() throws AmbariException, AuthorizationException {
+        SettingEntity entity = toEntity(properties);
+        if (dao.findByName(entity.getName()) != null) {
+          throw new DuplicateResourceException(
+                  String.format("Setting already exists. setting name :%s ", entity.getName()));
+        }
+        dao.create(entity);
+        notifyCreate(Resource.Type.Setting, request);
+        return entity;
+      }
+    };
+  }
+
+  private Command<Void> newUpdateCommand(final Request request) throws NoSuchResourceException, SystemException {
+    return new Command<Void>() {
+      @Override
+      public Void invoke() throws AmbariException {
+        final Set<Map<String, Object>> propertyMaps = request.getProperties();
+        for (Map<String, Object> propertyMap : propertyMaps) {
+          if (propertyMap.containsKey(SETTING_NAME_PROPERTY_ID)) {
+            String name = propertyMap.get(SETTING_NAME_PROPERTY_ID).toString();
+            SettingEntity entity = dao.findByName(name);
+            if (entity == null) {
+              throw new AmbariException(String.format("There is no setting with name: %s ", name));
+            }
+            updateEntity(entity, propertyMap);
+            dao.merge(entity);
+          }
+        }
+        return null;
+      }
+    };
+  }
+
+  private void updateEntity(SettingEntity entity, Map<String, Object> propertyMap) throws AmbariException {
+    String name = propertyMap.get(SETTING_NAME_PROPERTY_ID).toString();
+    if (!Objects.equals(name, entity.getName())) {
+      throw new AmbariException("Name for Setting is immutable, cannot change name.");
+    }
+
+    if (StringUtils.isNotBlank(ObjectUtils.toString(propertyMap.get(SETTING_CONTENT_PROPERTY_ID)))) {
+      entity.setContent(propertyMap.get(SETTING_CONTENT_PROPERTY_ID).toString());
+    }
+
+    if (StringUtils.isNotBlank(ObjectUtils.toString(propertyMap.get(SETTING_SETTING_TYPE_PROPERTY_ID)))) {
+      entity.setSettingType(propertyMap.get(SETTING_SETTING_TYPE_PROPERTY_ID).toString());
+    }
+
+    entity.setUpdatedBy(AuthorizationHelper.getAuthenticatedName());
+    entity.setUpdateTimestamp(System.currentTimeMillis());
+  }
+
+  private Resource toResource(final SettingEntity settingEntity, final Set<String> requestedIds) {
+    Resource resource = new ResourceImpl(Resource.Type.Setting);
+    setResourceProperty(resource, SETTING_NAME_PROPERTY_ID, settingEntity.getName(), requestedIds);
+    setResourceProperty(resource, SETTING_SETTING_TYPE_PROPERTY_ID, settingEntity.getSettingType(), requestedIds);
+    setResourceProperty(resource, SETTING_CONTENT_PROPERTY_ID, settingEntity.getContent(), requestedIds);
+    setResourceProperty(resource, SETTING_UPDATED_BY_PROPERTY_ID, settingEntity.getUpdatedBy(), requestedIds);
+    setResourceProperty(resource, SETTING_UPDATE_TIMESTAMP_PROPERTY_ID, settingEntity.getUpdateTimestamp(), requestedIds);
+    return resource;
+  }
+
+  private SettingEntity toEntity(final Map<String, Object> properties) throws AmbariException {
+    for (String propertyName: requiredProperties) {
+      if (properties.get(propertyName) == null) {
+        throw new AmbariException(String.format("Property %s should be provided", propertyName));
+      }
+    }
+
+    SettingEntity entity = new SettingEntity();
+    entity.setName(properties.get(SETTING_NAME_PROPERTY_ID).toString());
+    entity.setSettingType(properties.get(SETTING_SETTING_TYPE_PROPERTY_ID).toString());
+    entity.setContent(properties.get(SETTING_CONTENT_PROPERTY_ID).toString());
+    entity.setUpdatedBy(AuthorizationHelper.getAuthenticatedName());
+    entity.setUpdateTimestamp(System.currentTimeMillis());
+    return entity;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
index 9d6af76..f5fa5f1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
@@ -76,7 +76,7 @@ public interface Resource {
   enum InternalType {
     Cluster,
     Service,
-    AdminSetting,
+    Setting,
     Host,
     Component,
     HostComponent,
@@ -187,7 +187,7 @@ public interface Resource {
      */
     public static final Type Cluster = InternalType.Cluster.getType();
     public static final Type Service = InternalType.Service.getType();
-    public static final Type AdminSetting = InternalType.AdminSetting.getType();
+    public static final Type Setting = InternalType.Setting.getType();
     public static final Type Host = InternalType.Host.getType();
     public static final Type Component = InternalType.Component.getType();
     public static final Type HostComponent = InternalType.HostComponent.getType();

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AdminSettingDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AdminSettingDAO.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AdminSettingDAO.java
deleted file mode 100644
index 30e032f..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AdminSettingDAO.java
+++ /dev/null
@@ -1,100 +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.
- */
-package org.apache.ambari.server.orm.dao;
-
-import com.google.inject.Inject;
-import com.google.inject.Provider;
-import com.google.inject.Singleton;
-import com.google.inject.persist.Transactional;
-import org.apache.ambari.server.orm.RequiresSession;
-import org.apache.ambari.server.orm.entities.AdminSettingEntity;
-import org.apache.commons.lang.StringUtils;
-
-import javax.persistence.EntityManager;
-import javax.persistence.TypedQuery;
-import java.util.List;
-
-@Singleton
-public class AdminSettingDAO {
-
-  @Inject
-  Provider<EntityManager> entityManagerProvider;
-  @Inject
-  DaoUtils daoUtils;
-
-  /**
-   * Find an admin setting with the given name.
-   *
-   * @param name - name of admin setting.
-   * @return  a matching admin setting or null
-   */
-  @RequiresSession
-  public AdminSettingEntity findByName(String name) {
-    if (StringUtils.isBlank(name)) {
-      return null;
-    }
-    TypedQuery<AdminSettingEntity> query = entityManagerProvider.get()
-            .createNamedQuery("adminSettingByName", AdminSettingEntity.class);
-    query.setParameter("name", name);
-    return daoUtils.selectOne(query);
-  }
-
-  /**
-   * Find all admin settings.
-   *
-   * @return all admin setting instances.
-   */
-  @RequiresSession
-  public List<AdminSettingEntity> findAll() {
-    return daoUtils.selectAll(entityManagerProvider.get(), AdminSettingEntity.class);
-  }
-
-  /**
-   * Create a new admin setting entity.
-   *
-   * @param entity - entity to be created
-   */
-  @Transactional
-  public void create(AdminSettingEntity entity) {
-    entityManagerProvider.get().persist(entity);
-  }
-
-  /**
-   * Update admin setting instance.
-   *
-   * @param entity - entity to be updated.
-   * @return - updated admin entity.
-   */
-  @Transactional
-  public AdminSettingEntity merge(AdminSettingEntity entity) {
-    return entityManagerProvider.get().merge(entity);
-  }
-
-  /**
-   * Delete admin setting with given name.
-   *
-   * @param name - name of admin setting to be deleted.
-   */
-  @Transactional
-  public void removeByName(String name) {
-    AdminSettingEntity entity = findByName(name);
-    if (entity!= null) {
-      entityManagerProvider.get().remove(entity);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/SettingDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/SettingDAO.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/SettingDAO.java
new file mode 100644
index 0000000..2d0da20
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/SettingDAO.java
@@ -0,0 +1,100 @@
+/**
+ * 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.
+ */
+package org.apache.ambari.server.orm.dao;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
+import com.google.inject.persist.Transactional;
+import org.apache.ambari.server.orm.RequiresSession;
+import org.apache.ambari.server.orm.entities.SettingEntity;
+import org.apache.commons.lang.StringUtils;
+
+import javax.persistence.EntityManager;
+import javax.persistence.TypedQuery;
+import java.util.List;
+
+@Singleton
+public class SettingDAO {
+
+  @Inject
+  Provider<EntityManager> entityManagerProvider;
+  @Inject
+  DaoUtils daoUtils;
+
+  /**
+   * Find a setting with the given name.
+   *
+   * @param name - name of setting.
+   * @return  a matching setting or null
+   */
+  @RequiresSession
+  public SettingEntity findByName(String name) {
+    if (StringUtils.isBlank(name)) {
+      return null;
+    }
+    TypedQuery<SettingEntity> query = entityManagerProvider.get()
+            .createNamedQuery("settingByName", SettingEntity.class);
+    query.setParameter("name", name);
+    return daoUtils.selectOne(query);
+  }
+
+  /**
+   * Find all settings.
+   *
+   * @return all setting instances.
+   */
+  @RequiresSession
+  public List<SettingEntity> findAll() {
+    return daoUtils.selectAll(entityManagerProvider.get(), SettingEntity.class);
+  }
+
+  /**
+   * Create a new setting entity.
+   *
+   * @param entity - entity to be created
+   */
+  @Transactional
+  public void create(SettingEntity entity) {
+    entityManagerProvider.get().persist(entity);
+  }
+
+  /**
+   * Update setting instance.
+   *
+   * @param entity - entity to be updated.
+   * @return - updated entity.
+   */
+  @Transactional
+  public SettingEntity merge(SettingEntity entity) {
+    return entityManagerProvider.get().merge(entity);
+  }
+
+  /**
+   * Delete setting with given name.
+   *
+   * @param name - name of setting to be deleted.
+   */
+  @Transactional
+  public void removeByName(String name) {
+    SettingEntity entity = findByName(name);
+    if (entity!= null) {
+      entityManagerProvider.get().remove(entity);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AdminSettingEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AdminSettingEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AdminSettingEntity.java
deleted file mode 100644
index 9edc7b5..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AdminSettingEntity.java
+++ /dev/null
@@ -1,149 +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.
- */
-package org.apache.ambari.server.orm.entities;
-
-import javax.persistence.Basic;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Lob;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-import javax.persistence.TableGenerator;
-import java.util.Objects;
-
-/**
- * Entity representing AdminSetting.
- */
-@Table(name = "adminsetting")
-@TableGenerator(name = "admin_setting_id_generator",
-    table = "ambari_sequences", pkColumnName = "sequence_name", valueColumnName = "sequence_value",
-        pkColumnValue = "admin_setting_id_seq", initialValue = 0)
-
-@NamedQuery(name = "adminSettingByName", query = "SELECT adminSetting FROM AdminSettingEntity adminsetting WHERE adminSetting.name=:name")
-@Entity
-public class AdminSettingEntity {
-  @Id
-  @Column(name = "id", nullable = false, insertable = true, updatable = false)
-  @GeneratedValue(strategy = GenerationType.TABLE, generator = "admin_setting_id_generator")
-  private long id;
-
-  @Column(name = "name", nullable = false, insertable = true, updatable = false, unique = true)
-  @Basic
-  private String name;
-
-  @Column(name = "setting_type", nullable = false, insertable = true, updatable = true)
-  @Basic
-  private String settingType;
-
-  @Column(name = "content", nullable = false, insertable = true, updatable = true)
-  @Lob
-  @Basic
-  private String content;
-
-  @Column(name = "updated_by", nullable = false, insertable = true, updatable = true)
-  @Basic
-  private String updatedBy;
-
-  @Column(name = "update_timestamp", nullable = false, insertable = true, updatable = true)
-  @Basic
-  private long updateTimestamp;
-
-  public AdminSettingEntity() {
-  }
-
-  public long getId() {
-    return id;
-  }
-
-  public void setId(long id) {
-    this.id = id;
-  }
-
-  public String getName() {
-    return name;
-  }
-
-  public void setName(String name) {
-    this.name = name;
-  }
-
-  public String getSettingType() {
-    return settingType;
-  }
-
-  public void setSettingType(String settingType) {
-    this.settingType = settingType;
-  }
-
-  public String getContent() {
-    return content;
-  }
-
-  public void setContent(String content) {
-    this.content = content;
-  }
-
-  public String getUpdatedBy() {
-    return updatedBy;
-  }
-
-  public void setUpdatedBy(String updatedBy) {
-    this.updatedBy = updatedBy;
-  }
-
-  public long getUpdateTimestamp() {
-    return updateTimestamp;
-  }
-
-  public void setUpdateTimestamp(long updateTimestamp) {
-    this.updateTimestamp = updateTimestamp;
-  }
-
-  public AdminSettingEntity clone() {
-    AdminSettingEntity cloned = new AdminSettingEntity();
-    cloned.setId(id);
-    cloned.setName(name);
-    cloned.setContent(content);
-    cloned.setSettingType(settingType);
-    cloned.setUpdatedBy(updatedBy);
-    cloned.setUpdateTimestamp(updateTimestamp);
-    return cloned;
-  }
-
-  @Override
-  public boolean equals(Object o) {
-    if (this == o) return true;
-    if (o == null || getClass() != o.getClass()) return false;
-
-    AdminSettingEntity entity = (AdminSettingEntity) o;
-    return id == entity.id &&
-            Objects.equals(name, entity.name) &&
-            Objects.equals(settingType, entity.settingType) &&
-            Objects.equals(content, entity.content) &&
-            Objects.equals(updatedBy, entity.updatedBy) &&
-            updateTimestamp == entity.updateTimestamp;
-  }
-
-  @Override
-  public int hashCode() {
-    return Objects.hash(id, name, settingType, content, updatedBy, updateTimestamp);
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/SettingEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/SettingEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/SettingEntity.java
new file mode 100644
index 0000000..20820cd
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/SettingEntity.java
@@ -0,0 +1,149 @@
+/**
+ * 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.
+ */
+package org.apache.ambari.server.orm.entities;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Lob;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+import java.util.Objects;
+
+/**
+ * Entity representing Setting.
+ */
+@Table(name = "setting")
+@TableGenerator(name = "setting_id_generator",
+    table = "ambari_sequences", pkColumnName = "sequence_name", valueColumnName = "sequence_value",
+        pkColumnValue = "setting_id_seq", initialValue = 0)
+
+@NamedQuery(name = "settingByName", query = "SELECT setting FROM SettingEntity setting WHERE setting.name=:name")
+@Entity
+public class SettingEntity {
+  @Id
+  @Column(name = "id", nullable = false, insertable = true, updatable = false)
+  @GeneratedValue(strategy = GenerationType.TABLE, generator = "setting_id_generator")
+  private long id;
+
+  @Column(name = "name", nullable = false, insertable = true, updatable = false, unique = true)
+  @Basic
+  private String name;
+
+  @Column(name = "setting_type", nullable = false, insertable = true, updatable = true)
+  @Basic
+  private String settingType;
+
+  @Column(name = "content", nullable = false, insertable = true, updatable = true)
+  @Lob
+  @Basic
+  private String content;
+
+  @Column(name = "updated_by", nullable = false, insertable = true, updatable = true)
+  @Basic
+  private String updatedBy;
+
+  @Column(name = "update_timestamp", nullable = false, insertable = true, updatable = true)
+  @Basic
+  private long updateTimestamp;
+
+  public SettingEntity() {
+  }
+
+  public long getId() {
+    return id;
+  }
+
+  public void setId(long id) {
+    this.id = id;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  public String getSettingType() {
+    return settingType;
+  }
+
+  public void setSettingType(String settingType) {
+    this.settingType = settingType;
+  }
+
+  public String getContent() {
+    return content;
+  }
+
+  public void setContent(String content) {
+    this.content = content;
+  }
+
+  public String getUpdatedBy() {
+    return updatedBy;
+  }
+
+  public void setUpdatedBy(String updatedBy) {
+    this.updatedBy = updatedBy;
+  }
+
+  public long getUpdateTimestamp() {
+    return updateTimestamp;
+  }
+
+  public void setUpdateTimestamp(long updateTimestamp) {
+    this.updateTimestamp = updateTimestamp;
+  }
+
+  public SettingEntity clone() {
+    SettingEntity cloned = new SettingEntity();
+    cloned.setId(id);
+    cloned.setName(name);
+    cloned.setContent(content);
+    cloned.setSettingType(settingType);
+    cloned.setUpdatedBy(updatedBy);
+    cloned.setUpdateTimestamp(updateTimestamp);
+    return cloned;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    SettingEntity entity = (SettingEntity) o;
+    return id == entity.id &&
+            Objects.equals(name, entity.name) &&
+            Objects.equals(settingType, entity.settingType) &&
+            Objects.equals(content, entity.content) &&
+            Objects.equals(updatedBy, entity.updatedBy) &&
+            updateTimestamp == entity.updateTimestamp;
+  }
+
+  @Override
+  public int hashCode() {
+    return Objects.hash(id, name, settingType, content, updatedBy, updateTimestamp);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/RoleAuthorization.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/RoleAuthorization.java b/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/RoleAuthorization.java
index 1935d83..a77263d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/RoleAuthorization.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/security/authorization/RoleAuthorization.java
@@ -32,7 +32,7 @@ public enum RoleAuthorization {
   AMBARI_ADD_DELETE_CLUSTERS("AMBARI.ADD_DELETE_CLUSTERS"),
   AMBARI_ASSIGN_ROLES("AMBARI.ASSIGN_ROLES"),
   AMBARI_EDIT_STACK_REPOS("AMBARI.EDIT_STACK_REPOS"),
-  AMBARI_MANAGE_ADMIN_SETTINGS("AMBARI.MANAGE_ADMIN_SETTINGS"),
+  AMBARI_MANAGE_SETTINGS("AMBARI.MANAGE_SETTINGS"),
   AMBARI_MANAGE_GROUPS("AMBARI.MANAGE_GROUPS"),
   AMBARI_MANAGE_STACK_VERSIONS("AMBARI.MANAGE_STACK_VERSIONS"),
   AMBARI_MANAGE_USERS("AMBARI.MANAGE_USERS"),

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
index 9982c2a..0fdfd2b 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
@@ -655,7 +655,7 @@ CREATE TABLE topology_logical_task (
   PRIMARY KEY (id)
 );
 
-CREATE TABLE adminsetting (
+CREATE TABLE setting (
   id BIGINT NOT NULL,
   name VARCHAR(255) NOT NULL UNIQUE,
   setting_type VARCHAR(255) NOT NULL,
@@ -1033,7 +1033,7 @@ INSERT INTO ambari_sequences (sequence_name, sequence_value)
   union all
   select 'topology_host_group_id_seq', 0 FROM SYSIBM.SYSDUMMY1
   union all
-  select 'admin_setting_id_seq', 0 FROM SYSIBM.SYSDUMMY1
+  select 'setting_id_seq', 0 FROM SYSIBM.SYSDUMMY1
   union all
   select 'hostcomponentstate_id_seq', 0  FROM SYSIBM.SYSDUMMY1;
 
@@ -1111,7 +1111,7 @@ INSERT INTO roleauthorization(authorization_id, authorization_name)
   SELECT 'AMBARI.ADD_DELETE_CLUSTERS', 'Create new clusters' FROM SYSIBM.SYSDUMMY1 UNION ALL
   SELECT 'AMBARI.SET_SERVICE_USERS_GROUPS', 'Set service users and groups' FROM SYSIBM.SYSDUMMY1 UNION ALL
   SELECT 'AMBARI.RENAME_CLUSTER', 'Rename clusters' FROM SYSIBM.SYSDUMMY1 UNION ALL
-  SELECT 'AMBARI.MANAGE_ADMIN_SETTINGS', 'Manage administrative settings' FROM SYSIBM.SYSDUMMY1 UNION ALL
+  SELECT 'AMBARI.MANAGE_SETTINGS', 'Manage settings' FROM SYSIBM.SYSDUMMY1 UNION ALL
   SELECT 'AMBARI.MANAGE_USERS', 'Manage users' FROM SYSIBM.SYSDUMMY1 UNION ALL
   SELECT 'AMBARI.MANAGE_GROUPS', 'Manage groups' FROM SYSIBM.SYSDUMMY1 UNION ALL
   SELECT 'AMBARI.MANAGE_VIEWS', 'Manage Ambari Views' FROM SYSIBM.SYSDUMMY1 UNION ALL
@@ -1292,7 +1292,7 @@ INSERT INTO permission_roleauthorization(permission_id, authorization_id)
   SELECT permission_id, 'AMBARI.ADD_DELETE_CLUSTERS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR'  UNION ALL
   SELECT permission_id, 'AMBARI.SET_SERVICE_USERS_GROUPS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR'  UNION ALL
   SELECT permission_id, 'AMBARI.RENAME_CLUSTER' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR'  UNION ALL
-  SELECT permission_id, 'AMBARI.MANAGE_ADMIN_SETTINGS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR'  UNION ALL
+  SELECT permission_id, 'AMBARI.MANAGE_SETTINGS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR'  UNION ALL
   SELECT permission_id, 'AMBARI.MANAGE_USERS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR'  UNION ALL
   SELECT permission_id, 'AMBARI.MANAGE_GROUPS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR'  UNION ALL
   SELECT permission_id, 'AMBARI.MANAGE_VIEWS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR'  UNION ALL

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
index f05ebd2..11e43c2 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -662,7 +662,7 @@ CREATE TABLE topology_logical_task (
   PRIMARY KEY (id)
 );
 
-CREATE TABLE adminsetting (
+CREATE TABLE setting (
   id BIGINT NOT NULL,
   name VARCHAR(255) NOT NULL UNIQUE,
   setting_type VARCHAR(255) NOT NULL,
@@ -997,7 +997,7 @@ INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('topology_lo
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('topology_logical_task_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('topology_request_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('topology_host_group_id_seq', 0);
-INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('admin_setting_id_seq', 0);
+INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('setting_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('hostcomponentstate_id_seq', 0);
 
 insert into adminresourcetype (resource_type_id, resource_type_name)
@@ -1076,7 +1076,7 @@ INSERT INTO roleauthorization(authorization_id, authorization_name)
   SELECT 'AMBARI.ADD_DELETE_CLUSTERS', 'Create new clusters' UNION ALL
   SELECT 'AMBARI.SET_SERVICE_USERS_GROUPS', 'Set service users and groups' UNION ALL
   SELECT 'AMBARI.RENAME_CLUSTER', 'Rename clusters' UNION ALL
-  SELECT 'AMBARI.MANAGE_ADMIN_SETTINGS', 'Manage administrative settings' UNION ALL
+  SELECT 'AMBARI.MANAGE_SETTINGS', 'Manage administrative settings' UNION ALL
   SELECT 'AMBARI.MANAGE_USERS', 'Manage users' UNION ALL
   SELECT 'AMBARI.MANAGE_GROUPS', 'Manage groups' UNION ALL
   SELECT 'AMBARI.MANAGE_VIEWS', 'Manage Ambari Views' UNION ALL
@@ -1263,7 +1263,7 @@ INSERT INTO permission_roleauthorization(permission_id, authorization_id)
   SELECT permission_id, 'AMBARI.ADD_DELETE_CLUSTERS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
   SELECT permission_id, 'AMBARI.SET_SERVICE_USERS_GROUPS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
   SELECT permission_id, 'AMBARI.RENAME_CLUSTER' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
-  SELECT permission_id, 'AMBARI.MANAGE_ADMIN_SETTINGS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
+  SELECT permission_id, 'AMBARI.MANAGE_SETTINGS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
   SELECT permission_id, 'AMBARI.MANAGE_USERS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
   SELECT permission_id, 'AMBARI.MANAGE_GROUPS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
   SELECT permission_id, 'AMBARI.MANAGE_VIEWS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
index 96ef3fa..8d4ba28 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -651,7 +651,7 @@ CREATE TABLE topology_logical_task (
   PRIMARY KEY (id)
 );
 
-CREATE TABLE adminsetting (
+CREATE TABLE setting (
   id NUMBER(19) NOT NULL,
   name VARCHAR(255) NOT NULL UNIQUE,
   setting_type VARCHAR(255) NOT NULL,
@@ -987,7 +987,7 @@ INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('topology_lo
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('topology_logical_task_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('topology_request_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('topology_host_group_id_seq', 0);
-INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('admin_setting_id_seq', 0);
+INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('setting_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('hostcomponentstate_id_seq', 0);
 
 INSERT INTO metainfo("metainfo_key", "metainfo_value") values ('version', '${ambariVersion}');
@@ -1068,7 +1068,7 @@ INSERT INTO roleauthorization(authorization_id, authorization_name)
   SELECT 'AMBARI.ADD_DELETE_CLUSTERS', 'Create new clusters' FROM dual UNION ALL
   SELECT 'AMBARI.SET_SERVICE_USERS_GROUPS', 'Set service users and groups' FROM dual UNION ALL
   SELECT 'AMBARI.RENAME_CLUSTER', 'Rename clusters' FROM dual UNION ALL
-  SELECT 'AMBARI.MANAGE_ADMIN_SETTINGS', 'Manage administrative settings' FROM dual UNION ALL
+  SELECT 'AMBARI.MANAGE_SETTINGS', 'Manage settings' FROM dual UNION ALL
   SELECT 'AMBARI.MANAGE_USERS', 'Manage users' FROM dual UNION ALL
   SELECT 'AMBARI.MANAGE_GROUPS', 'Manage groups' FROM dual UNION ALL
   SELECT 'AMBARI.MANAGE_VIEWS', 'Manage Ambari Views' FROM dual UNION ALL
@@ -1255,7 +1255,7 @@ INSERT INTO permission_roleauthorization(permission_id, authorization_id)
   SELECT permission_id, 'AMBARI.ADD_DELETE_CLUSTERS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
   SELECT permission_id, 'AMBARI.SET_SERVICE_USERS_GROUPS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
   SELECT permission_id, 'AMBARI.RENAME_CLUSTER' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
-  SELECT permission_id, 'AMBARI.MANAGE_ADMIN_SETTINGS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
+  SELECT permission_id, 'AMBARI.MANAGE_SETTINGS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
   SELECT permission_id, 'AMBARI.MANAGE_USERS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
   SELECT permission_id, 'AMBARI.MANAGE_GROUPS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
   SELECT permission_id, 'AMBARI.MANAGE_VIEWS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
index 8bd9d03..c762ac4 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -655,7 +655,7 @@ CREATE TABLE topology_logical_task (
   PRIMARY KEY (id)
 );
 
-CREATE TABLE adminsetting (
+CREATE TABLE setting (
   id BIGINT NOT NULL,
   name VARCHAR(255) NOT NULL UNIQUE,
   setting_type VARCHAR(255) NOT NULL,
@@ -1033,7 +1033,7 @@ INSERT INTO ambari_sequences (sequence_name, sequence_value)
   union all
   select 'topology_host_group_id_seq', 0
   union all
-  select 'admin_setting_id_seq', 0
+  select 'setting_id_seq', 0
   union all
   select 'hostcomponentstate_id_seq', 0;
 
@@ -1113,7 +1113,7 @@ INSERT INTO roleauthorization(authorization_id, authorization_name)
   SELECT 'AMBARI.ADD_DELETE_CLUSTERS', 'Create new clusters' UNION ALL
   SELECT 'AMBARI.SET_SERVICE_USERS_GROUPS', 'Set service users and groups' UNION ALL
   SELECT 'AMBARI.RENAME_CLUSTER', 'Rename clusters' UNION ALL
-  SELECT 'AMBARI.MANAGE_ADMIN_SETTINGS', 'Manage administrative settings' UNION ALL
+  SELECT 'AMBARI.MANAGE_SETTINGS', 'Manage administrative settings' UNION ALL
   SELECT 'AMBARI.MANAGE_USERS', 'Manage users' UNION ALL
   SELECT 'AMBARI.MANAGE_GROUPS', 'Manage groups' UNION ALL
   SELECT 'AMBARI.MANAGE_VIEWS', 'Manage Ambari Views' UNION ALL
@@ -1300,7 +1300,7 @@ INSERT INTO permission_roleauthorization(permission_id, authorization_id)
   SELECT permission_id, 'AMBARI.ADD_DELETE_CLUSTERS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
   SELECT permission_id, 'AMBARI.SET_SERVICE_USERS_GROUPS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
   SELECT permission_id, 'AMBARI.RENAME_CLUSTER' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
-  SELECT permission_id, 'AMBARI.MANAGE_ADMIN_SETTINGS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
+  SELECT permission_id, 'AMBARI.MANAGE_SETTINGS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
   SELECT permission_id, 'AMBARI.MANAGE_USERS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
   SELECT permission_id, 'AMBARI.MANAGE_GROUPS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
   SELECT permission_id, 'AMBARI.MANAGE_VIEWS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
index 54999cb..81b41fe 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
@@ -736,7 +736,7 @@ CREATE TABLE ambari.topology_logical_task (
 );
 GRANT ALL PRIVILEGES ON TABLE ambari.topology_logical_task TO :username;
 
-CREATE TABLE ambari.adminsetting (
+CREATE TABLE ambari.setting (
   id BIGINT NOT NULL,
   name VARCHAR(255) NOT NULL UNIQUE,
   setting_type VARCHAR(255) NOT NULL,
@@ -745,7 +745,7 @@ CREATE TABLE ambari.adminsetting (
   update_timestamp BIGINT NOT NULL,
   PRIMARY KEY (id)
 );
-GRANT ALL PRIVILEGES ON TABLE ambari.adminsetting TO :username;
+GRANT ALL PRIVILEGES ON TABLE ambari.setting TO :username;
 
 -- tasks indices --
 CREATE INDEX idx_stage_request_id ON ambari.stage (request_id);
@@ -1132,7 +1132,7 @@ INSERT INTO ambari.ambari_sequences (sequence_name, sequence_value)
   union all
   select 'topology_host_group_id_seq', 0
   union all
-  select 'admin_setting_id_seq', 0
+  select 'setting_id_seq', 0
   union all
   select 'hostcomponentstate_id_seq', 0;
 
@@ -1212,7 +1212,7 @@ INSERT INTO ambari.roleauthorization(authorization_id, authorization_name)
   SELECT 'AMBARI.ADD_DELETE_CLUSTERS', 'Create new clusters' UNION ALL
   SELECT 'AMBARI.SET_SERVICE_USERS_GROUPS', 'Set service users and groups' UNION ALL
   SELECT 'AMBARI.RENAME_CLUSTER', 'Rename clusters' UNION ALL
-  SELECT 'AMBARI.MANAGE_ADMIN_SETTINGS', 'Manage administrative settings' UNION ALL
+  SELECT 'AMBARI.MANAGE_SETTINGS', 'Manage settings' UNION ALL
   SELECT 'AMBARI.MANAGE_USERS', 'Manage users' UNION ALL
   SELECT 'AMBARI.MANAGE_GROUPS', 'Manage groups' UNION ALL
   SELECT 'AMBARI.MANAGE_VIEWS', 'Manage Ambari Views' UNION ALL
@@ -1399,7 +1399,7 @@ INSERT INTO ambari.permission_roleauthorization(permission_id, authorization_id)
   SELECT permission_id, 'AMBARI.ADD_DELETE_CLUSTERS' FROM ambari.adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
   SELECT permission_id, 'AMBARI.SET_SERVICE_USERS_GROUPS' FROM ambari.adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
   SELECT permission_id, 'AMBARI.RENAME_CLUSTER' FROM ambari.adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
-  SELECT permission_id, 'AMBARI.MANAGE_ADMIN_SETTINGS' FROM ambari.adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
+  SELECT permission_id, 'AMBARI.MANAGE_SETTINGS' FROM ambari.adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
   SELECT permission_id, 'AMBARI.MANAGE_USERS' FROM ambari.adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
   SELECT permission_id, 'AMBARI.MANAGE_GROUPS' FROM ambari.adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
   SELECT permission_id, 'AMBARI.MANAGE_VIEWS' FROM ambari.adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
index ce058e2..f8c9b8d 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
@@ -652,7 +652,7 @@ CREATE TABLE topology_logical_task (
   PRIMARY KEY (id)
 );
 
-CREATE TABLE adminsetting (
+CREATE TABLE setting (
   id NUMERIC(19) NOT NULL,
   name VARCHAR(255) NOT NULL UNIQUE,
   setting_type VARCHAR(255) NOT NULL,
@@ -984,7 +984,7 @@ INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('topology_lo
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('topology_logical_task_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('topology_request_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('topology_host_group_id_seq', 0);
-INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('admin_setting_id_seq', 0);
+INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('setting_id_seq', 0);
 INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('hostcomponentstate_id_seq', 0);
 
 insert into adminresourcetype (resource_type_id, resource_type_name)
@@ -1063,7 +1063,7 @@ insert into adminpermission(permission_id, permission_name, resource_type_id, pe
     SELECT 'AMBARI.ADD_DELETE_CLUSTERS', 'Create new clusters' UNION ALL
     SELECT 'AMBARI.SET_SERVICE_USERS_GROUPS', 'Set service users and groups' UNION ALL
     SELECT 'AMBARI.RENAME_CLUSTER', 'Rename clusters' UNION ALL
-    SELECT 'AMBARI.MANAGE_ADMIN_SETTINGS', 'Manage administrative settings' UNION ALL
+    SELECT 'AMBARI.MANAGE_SETTINGS', 'Manage settings' UNION ALL
     SELECT 'AMBARI.MANAGE_USERS', 'Manage users' UNION ALL
     SELECT 'AMBARI.MANAGE_GROUPS', 'Manage groups' UNION ALL
     SELECT 'AMBARI.MANAGE_VIEWS', 'Manage Ambari Views' UNION ALL
@@ -1250,7 +1250,7 @@ insert into adminpermission(permission_id, permission_name, resource_type_id, pe
     SELECT permission_id, 'AMBARI.ADD_DELETE_CLUSTERS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
     SELECT permission_id, 'AMBARI.SET_SERVICE_USERS_GROUPS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
     SELECT permission_id, 'AMBARI.RENAME_CLUSTER' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
-    SELECT permission_id, 'AMBARI.MANAGE_ADMIN_SETTINGS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
+    SELECT permission_id, 'AMBARI.MANAGE_SETTINGS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
     SELECT permission_id, 'AMBARI.MANAGE_USERS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
     SELECT permission_id, 'AMBARI.MANAGE_GROUPS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
     SELECT permission_id, 'AMBARI.MANAGE_VIEWS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
index 66ea512..324c24d 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
@@ -760,7 +760,7 @@ CREATE TABLE topology_logical_task (
   PRIMARY KEY CLUSTERED (id)
 );
 
-CREATE TABLE adminsetting (
+CREATE TABLE setting (
   id BIGINT NOT NULL,
   name VARCHAR(255) NOT NULL UNIQUE,
   setting_type VARCHAR(255) NOT NULL,
@@ -1100,7 +1100,7 @@ BEGIN TRANSACTION
     ('topology_logical_task_id_seq', 0),
     ('topology_request_id_seq', 0),
     ('topology_host_group_id_seq', 0),
-    ('admin_setting_id_seq', 0),
+    ('setting_id_seq', 0),
     ('hostcomponentstate_id_seq', 0);
 
   insert into adminresourcetype (resource_type_id, resource_type_name)
@@ -1173,7 +1173,7 @@ BEGIN TRANSACTION
     SELECT 'AMBARI.ADD_DELETE_CLUSTERS', 'Create new clusters' UNION ALL
     SELECT 'AMBARI.SET_SERVICE_USERS_GROUPS', 'Set service users and groups' UNION ALL
     SELECT 'AMBARI.RENAME_CLUSTER', 'Rename clusters' UNION ALL
-    SELECT 'AMBARI.MANAGE_ADMIN_SETTINGS', 'Manage administrative settings' UNION ALL
+    SELECT 'AMBARI.MANAGE_SETTINGS', 'Manage settings' UNION ALL
     SELECT 'AMBARI.MANAGE_USERS', 'Manage users' UNION ALL
     SELECT 'AMBARI.MANAGE_GROUPS', 'Manage groups' UNION ALL
     SELECT 'AMBARI.MANAGE_VIEWS', 'Manage Ambari Views' UNION ALL
@@ -1360,7 +1360,7 @@ BEGIN TRANSACTION
     SELECT permission_id, 'AMBARI.ADD_DELETE_CLUSTERS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
     SELECT permission_id, 'AMBARI.SET_SERVICE_USERS_GROUPS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
     SELECT permission_id, 'AMBARI.RENAME_CLUSTER' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
-    SELECT permission_id, 'AMBARI.MANAGE_ADMIN_SETTINGS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
+    SELECT permission_id, 'AMBARI.MANAGE_SETTINGS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
     SELECT permission_id, 'AMBARI.MANAGE_USERS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
     SELECT permission_id, 'AMBARI.MANAGE_GROUPS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL
     SELECT permission_id, 'AMBARI.MANAGE_VIEWS' FROM adminpermission WHERE permission_name='AMBARI.ADMINISTRATOR' UNION ALL

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/META-INF/persistence.xml b/ambari-server/src/main/resources/META-INF/persistence.xml
index 280b9b6..7fd0391 100644
--- a/ambari-server/src/main/resources/META-INF/persistence.xml
+++ b/ambari-server/src/main/resources/META-INF/persistence.xml
@@ -88,7 +88,7 @@
     <class>org.apache.ambari.server.orm.entities.TopologyHostInfoEntity</class>
     <class>org.apache.ambari.server.orm.entities.TopologyHostTaskEntity</class>
     <class>org.apache.ambari.server.orm.entities.TopologyLogicalTaskEntity</class>
-    <class>org.apache.ambari.server.orm.entities.AdminSettingEntity</class>
+    <class>org.apache.ambari.server.orm.entities.SettingEntity</class>
     <class>org.apache.ambari.server.orm.entities.KerberosDescriptorEntity</class>
 
     <properties>

http://git-wip-us.apache.org/repos/asf/ambari/blob/774d689e/ambari-server/src/test/java/org/apache/ambari/server/api/services/AdminSettingServiceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AdminSettingServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AdminSettingServiceTest.java
deleted file mode 100644
index d84c97d..0000000
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AdminSettingServiceTest.java
+++ /dev/null
@@ -1,101 +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.
- */
-package org.apache.ambari.server.api.services;
-
-import org.apache.ambari.server.api.resources.ResourceInstance;
-import org.apache.ambari.server.api.services.parsers.RequestBodyParser;
-import org.apache.ambari.server.api.services.serializers.ResultSerializer;
-
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.UriInfo;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Unit test for {@link AdminSettingService}
- */
-public class AdminSettingServiceTest extends BaseServiceTest {
-  @Override
-  public List<ServiceTestInvocation> getTestInvocations() throws Exception {
-    List<ServiceTestInvocation> listInvocations = new ArrayList<>();
-
-    //getSetting
-    AdminSettingService adminSettingService = new TestAdminSettingService("settingName");
-    Method m = adminSettingService.getClass().getMethod("getSetting", String.class, HttpHeaders.class, UriInfo.class, String.class);
-    Object[] args = new Object[] {null, getHttpHeaders(), getUriInfo(), "settingName"};
-    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, adminSettingService, m, args, null));
-
-    //getSettings
-    adminSettingService = new TestAdminSettingService(null);
-    m = adminSettingService.getClass().getMethod("getSettings", String.class, HttpHeaders.class, UriInfo.class);
-    args = new Object[] {null, getHttpHeaders(), getUriInfo()};
-    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, adminSettingService, m, args, null));
-
-    //createSetting
-    adminSettingService = new TestAdminSettingService(null);
-    m = adminSettingService.getClass().getMethod("createSetting", String.class, HttpHeaders.class, UriInfo.class);
-    args = new Object[] {"body", getHttpHeaders(), getUriInfo()};
-    listInvocations.add(new ServiceTestInvocation(Request.Type.POST, adminSettingService, m, args, "body"));
-
-    //updateSetting
-    adminSettingService = new TestAdminSettingService("settingName");
-    m = adminSettingService.getClass().getMethod("updateSetting", String.class, HttpHeaders.class, UriInfo.class, String.class);
-    args = new Object[] {"body", getHttpHeaders(), getUriInfo(), "settingName"};
-    listInvocations.add(new ServiceTestInvocation(Request.Type.PUT, adminSettingService, m, args, "body"));
-
-    //deleteSetting
-    adminSettingService = new TestAdminSettingService("settingName");
-    m = adminSettingService.getClass().getMethod("deleteSetting", HttpHeaders.class, UriInfo.class, String.class);
-    args = new Object[] {getHttpHeaders(), getUriInfo(), "settingName"};
-    listInvocations.add(new ServiceTestInvocation(Request.Type.DELETE, adminSettingService, m, args, null));
-
-    return listInvocations;
-  }
-
-  private class TestAdminSettingService extends AdminSettingService {
-    private String adminSettingName;
-
-    private TestAdminSettingService(String settingName) {
-      this.adminSettingName = settingName;
-    }
-
-    @Override
-    ResourceInstance createSettingResource(String settingName) {
-      assertEquals(this.adminSettingName, settingName);
-      return getTestResource();
-    }
-
-    @Override
-    RequestFactory getRequestFactory() {
-      return getTestRequestFactory();
-    }
-
-    @Override
-    protected RequestBodyParser getBodyParser() {
-      return getTestBodyParser();
-    }
-
-    @Override
-    protected ResultSerializer getResultSerializer() {
-      return getTestResultSerializer();
-    }
-  }
-}


[11/11] ambari git commit: Merge branch 'trunk' into branch-dev-patch-upgrade

Posted by nc...@apache.org.
Merge branch 'trunk' into branch-dev-patch-upgrade


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 4c5d2bd0a927f45f99c4045c4c9036859f0d19c8
Parents: 77af8e5 8ba3d0b
Author: Nate Cole <nc...@hortonworks.com>
Authored: Tue Feb 2 07:40:38 2016 -0500
Committer: Nate Cole <nc...@hortonworks.com>
Committed: Tue Feb 2 07:40:38 2016 -0500

----------------------------------------------------------------------
 .../src/main/python/ambari_agent/HostInfo.py    |   4 +-
 ambari-server/conf/unix/ambari.properties       |   3 +
 ambari-server/conf/windows/ambari.properties    |   3 +
 .../resources/ResourceInstanceFactoryImpl.java  |   4 +-
 .../api/services/AdminSettingService.java       | 148 --------
 .../server/api/services/SettingService.java     | 148 ++++++++
 .../StackAdvisorBlueprintProcessor.java         |  66 +++-
 .../server/configuration/Configuration.java     |  20 ++
 .../server/controller/KerberosHelperImpl.java   |  16 +-
 .../internal/AbstractProviderModule.java        | 187 ++++++----
 .../internal/AdminSettingResourceProvider.java  | 250 -------------
 .../internal/DefaultProviderModule.java         |   4 +-
 .../internal/SettingResourceProvider.java       | 251 +++++++++++++
 .../internal/UpgradeResourceProvider.java       |   2 +-
 .../server/controller/jmx/JMXHostProvider.java  |   8 +-
 .../controller/jmx/JMXPropertyProvider.java     |  15 +-
 .../ambari/server/controller/spi/Resource.java  |   4 +-
 .../ambari/server/orm/dao/AdminSettingDAO.java  | 100 ------
 .../ambari/server/orm/dao/SettingDAO.java       | 100 ++++++
 .../server/orm/entities/AdminSettingEntity.java | 149 --------
 .../server/orm/entities/SettingEntity.java      | 149 ++++++++
 .../authorization/RoleAuthorization.java        |   2 +-
 .../serveraction/ServerActionExecutor.java      |  25 +-
 .../main/resources/Ambari-DDL-Derby-CREATE.sql  |   8 +-
 .../main/resources/Ambari-DDL-MySQL-CREATE.sql  |   8 +-
 .../main/resources/Ambari-DDL-Oracle-CREATE.sql |   8 +-
 .../resources/Ambari-DDL-Postgres-CREATE.sql    |   8 +-
 .../Ambari-DDL-Postgres-EMBEDDED-CREATE.sql     |  10 +-
 .../resources/Ambari-DDL-SQLAnywhere-CREATE.sql |   8 +-
 .../resources/Ambari-DDL-SQLServer-CREATE.sql   |   8 +-
 .../src/main/resources/META-INF/persistence.xml |   2 +-
 .../HAWQ/2.0.0/package/scripts/params.py        |  21 --
 .../0.4.0/package/scripts/setup_ranger_xml.py   |   5 +
 .../RANGER/configuration/ranger-admin-site.xml  |  10 +
 .../stacks/HDP/2.3/services/stack_advisor.py    |  11 +
 .../api/services/AdminSettingServiceTest.java   | 101 ------
 .../server/api/services/SettingServiceTest.java | 101 ++++++
 .../StackAdvisorBlueprintProcessorTest.java     | 100 +++++-
 .../server/configuration/ConfigurationTest.java |  15 +
 .../AdminSettingResourceProviderTest.java       | 356 -------------------
 .../internal/JMXHostProviderTest.java           | 130 +++++--
 .../internal/SettingResourceProviderTest.java   | 355 ++++++++++++++++++
 .../metrics/JMXPropertyProviderTest.java        |   6 +-
 .../server/orm/dao/AdminSettingDAOTest.java     |  93 -----
 .../ambari/server/orm/dao/SettingDAOTest.java   |  93 +++++
 .../orm/entities/AdminSettingEntityTest.java    |  91 -----
 .../server/orm/entities/SettingEntityTest.java  |  90 +++++
 .../stacks/2.3/common/test_stack_advisor.py     |   3 +-
 ambari-web/app/messages.js                      |   3 +-
 .../main/alerts/definition_details.hbs          |   6 +
 .../main/alerts/definition_details_view.js      |   6 +
 .../global/cluster_controller_test.js           |   4 +-
 .../progress_controller_test.js                 |   4 +-
 .../admin/kerberos/step4_controller_test.js     |   7 +-
 ...anage_alert_notifications_controller_test.js |  85 +++--
 .../main/host/add_controller_test.js            |   2 +
 .../test/controllers/wizard/step3_test.js       |  43 +--
 .../test/controllers/wizard/step4_test.js       |  19 +-
 .../test/controllers/wizard/step5_test.js       |   7 +-
 .../test/controllers/wizard/step6_test.js       |   6 +-
 .../test/controllers/wizard/step7_test.js       |  13 +-
 .../test/controllers/wizard/step8_test.js       |  19 +-
 .../test/controllers/wizard/step9_test.js       |  23 +-
 ambari-web/test/controllers/wizard_test.js      |   8 +-
 ambari-web/test/mappers/service_mapper_test.js  |   8 +-
 .../common/configs/toggle_isrequired_test.js    |  12 +-
 .../kdc_credentials_controller_mixin_test.js    |  29 +-
 .../test/mixins/common/serverValidator_test.js  |  14 +-
 ambari-web/test/models/cluster_states_test.js   |  20 +-
 .../objects/service_config_property_test.js     |  38 +-
 ambari-web/test/router_test.js                  |  84 ++---
 ambari-web/test/utils/ajax/ajax_queue_test.js   |   2 +-
 ambari-web/test/utils/config_test.js            |  32 +-
 ambari-web/test/utils/date/timezone_test.js     |  24 +-
 ambari-web/test/utils/helper_test.js            |   6 +-
 .../test/views/common/chart/linear_time_test.js |  16 +-
 .../common/configs/service_config_view_test.js  |  18 +-
 .../modal_popups/cluster_check_popup_test.js    |  12 +-
 .../manage_alert_notifications_view_test.js     |  17 +-
 ambari-web/test/views/wizard/step3_view_test.js |  31 +-
 ambari-web/test/views/wizard/step9_view_test.js |  71 ++--
 81 files changed, 2235 insertions(+), 1753 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4c5d2bd0/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
----------------------------------------------------------------------
diff --cc ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
index 987c11b,4c12094..da00d55
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
@@@ -408,14 -408,10 +408,14 @@@ public class ResourceInstanceFactoryImp
          resourceDefinition = new SimpleResourceDefinition(Resource.Type.UserAuthorization, "authorization", "authorizations");
          break;
  
-       case AdminSetting:
-         resourceDefinition = new SimpleResourceDefinition(Resource.Type.AdminSetting, "admin-setting", "admin-settings");
+       case Setting:
+         resourceDefinition = new SimpleResourceDefinition(Resource.Type.Setting, "setting", "settings");
          break;
  
 +      case VersionDefinition:
 +        resourceDefinition = new VersionDefinitionResourceDefinition();
 +        break;
 +
        default:
          throw new IllegalArgumentException("Unsupported resource type: " + type);
      }

http://git-wip-us.apache.org/repos/asf/ambari/blob/4c5d2bd0/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ambari/blob/4c5d2bd0/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ambari/blob/4c5d2bd0/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ambari/blob/4c5d2bd0/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ambari/blob/4c5d2bd0/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ambari/blob/4c5d2bd0/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ambari/blob/4c5d2bd0/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ambari/blob/4c5d2bd0/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/ambari/blob/4c5d2bd0/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
----------------------------------------------------------------------


[03/11] ambari git commit: AMBARI-14868. Remove Host Check for Ganglia directories.(vbrodetskyi)

Posted by nc...@apache.org.
AMBARI-14868. Remove Host Check for Ganglia directories.(vbrodetskyi)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: d456b158041fe87b92cfd45942714dde16924a2a
Parents: 5e36bdc
Author: Vitaly Brodetskyi <vb...@hortonworks.com>
Authored: Mon Feb 1 22:45:30 2016 +0200
Committer: Vitaly Brodetskyi <vb...@hortonworks.com>
Committed: Mon Feb 1 22:45:30 2016 +0200

----------------------------------------------------------------------
 ambari-agent/src/main/python/ambari_agent/HostInfo.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d456b158/ambari-agent/src/main/python/ambari_agent/HostInfo.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/HostInfo.py b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
index 6583490..805597a 100644
--- a/ambari-agent/src/main/python/ambari_agent/HostInfo.py
+++ b/ambari-agent/src/main/python/ambari_agent/HostInfo.py
@@ -126,13 +126,13 @@ def get_ntp_service():
 class HostInfoLinux(HostInfo):
   # List of project names to be used to find alternatives folders etc.
   DEFAULT_PROJECT_NAMES = [
-    "hadoop*", "hadoop", "hbase", "hcatalog", "hive", "ganglia",
+    "hadoop*", "hadoop", "hbase", "hcatalog", "hive",
     "oozie", "sqoop", "hue", "zookeeper", "mapred", "hdfs", "flume",
     "storm", "hive-hcatalog", "tez", "falcon", "ambari_qa", "hadoop_deploy",
     "rrdcached", "hcat", "ambari-qa", "sqoop-ambari-qa", "sqoop-ambari_qa",
     "webhcat", "hadoop-hdfs", "hadoop-yarn", "hadoop-mapreduce",
     "knox", "yarn", "hive-webhcat", "kafka", "slider", "storm-slider-client",
-    "ganglia-web", "mahout", "spark", "pig", "phoenix", "ranger", "accumulo",
+    "mahout", "spark", "pig", "phoenix", "ranger", "accumulo",
     "ambari-metrics-collector", "ambari-metrics-monitor", "atlas"
   ]
 


[04/11] ambari git commit: AMBARI-14722. Blueprints Stack advisor should consider user provided inputs on ONLY_STACK_DEFAULTS_APPLY strategy. (Oliver Szabo via rnettleton)

Posted by nc...@apache.org.
AMBARI-14722. Blueprints Stack advisor should consider user provided inputs on ONLY_STACK_DEFAULTS_APPLY strategy. (Oliver Szabo via rnettleton)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 9991ad88b8a226fe6fce8b28b17feec314112fa0
Parents: d456b15
Author: Bob Nettleton <rn...@hortonworks.com>
Authored: Mon Feb 1 17:35:46 2016 -0500
Committer: Bob Nettleton <rn...@hortonworks.com>
Committed: Mon Feb 1 17:35:46 2016 -0500

----------------------------------------------------------------------
 .../StackAdvisorBlueprintProcessor.java         |  66 +++++++++++-
 .../StackAdvisorBlueprintProcessorTest.java     | 100 ++++++++++++++++++-
 2 files changed, 160 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9991ad88/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
index 337ad06..ea9fffb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
@@ -19,6 +19,7 @@
 package org.apache.ambari.server.api.services.stackadvisor;
 
 import com.google.common.base.Preconditions;
+import com.google.common.base.Predicates;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
@@ -36,8 +37,13 @@ import org.apache.ambari.server.api.services.stackadvisor.recommendations.Recomm
 import org.apache.ambari.server.api.services.stackadvisor.recommendations.RecommendationResponse.BlueprintConfigurations;
 import org.apache.ambari.server.controller.internal.ConfigurationTopologyException;
 import org.apache.ambari.server.controller.internal.Stack;
+import org.apache.ambari.server.orm.entities.BlueprintConfiguration;
+import org.apache.ambari.server.state.ValueAttributesInfo;
 import org.apache.ambari.server.topology.AdvisedConfiguration;
+import org.apache.ambari.server.topology.Blueprint;
 import org.apache.ambari.server.topology.ClusterTopology;
+import org.apache.ambari.server.topology.ConfigRecommendationStrategy;
+import org.apache.ambari.server.topology.Configuration;
 import org.apache.ambari.server.topology.HostGroup;
 import org.apache.ambari.server.topology.HostGroupInfo;
 import org.slf4j.Logger;
@@ -161,13 +167,71 @@ public class StackAdvisorBlueprintProcessor {
     Preconditions.checkArgument(response.getRecommendations().getBlueprint().getConfigurations() != null,
       "Configurations are missing from the recommendation blueprint response.");
 
+    Map<String, Map<String, String>> userProvidedProperties = getUserProvidedProperties(topology);
     Map<String, BlueprintConfigurations> recommendedConfigurations =
       response.getRecommendations().getBlueprint().getConfigurations();
     for (Map.Entry<String, BlueprintConfigurations> configEntry : recommendedConfigurations.entrySet()) {
       String configType = configEntry.getKey();
-      BlueprintConfigurations blueprintConfig = configEntry.getValue();
+      BlueprintConfigurations blueprintConfig = filterBlueprintConfig(configType, configEntry.getValue(),
+        userProvidedProperties, topology);
       topology.getAdvisedConfigurations().put(configType, new AdvisedConfiguration(
         blueprintConfig.getProperties(), blueprintConfig.getPropertyAttributes()));
     }
   }
+
+  /**
+   * Gather user defined properties. (keep that only which is not included in the stack defaults or it overrides the stack default value)
+   */
+  private Map<String, Map<String, String>> getUserProvidedProperties(ClusterTopology topology) {
+    Map<String, Map<String, String>> userProvidedProperties = Maps.newHashMap();
+    Blueprint blueprint = topology.getBlueprint();
+    Configuration stackDefaults = blueprint.getStack().getConfiguration(blueprint.getServices());
+
+    Map<String, Map<String, String>> stackDefaultProps = stackDefaults.getProperties();
+    Map<String, Map<String, String>> fullConfig = topology.getConfiguration().getFullProperties();
+
+    for (Map.Entry<String, Map<String, String>> configGroup : fullConfig.entrySet()) {
+      String configType = configGroup.getKey();
+      Map<String, String> configsToAdd = Maps.newHashMap();
+      for (Map.Entry<String, String> configProp : configGroup.getValue().entrySet()) {
+        if (stackDefaultProps.containsKey(configType) && stackDefaultProps.get(configType).containsKey(configProp.getKey())) {
+          String originalValue = stackDefaultProps.get(configType).get(configProp.getKey());
+          if (originalValue != null && !originalValue.equals(configProp.getValue())) {
+            configsToAdd.put(configProp.getKey(), configProp.getValue());
+          }
+        } else {
+          configsToAdd.put(configProp.getKey(), configProp.getValue());
+        }
+      }
+      if (!configsToAdd.isEmpty()) {
+        userProvidedProperties.put(configGroup.getKey(), configsToAdd);
+      }
+    }
+
+    return userProvidedProperties;
+  }
+
+  /**
+   * Remove user defined properties from stack advisor output in case of it applies only on the stack defaults
+   */
+  private BlueprintConfigurations filterBlueprintConfig(String configType, BlueprintConfigurations config,
+                                                        Map<String, Map<String, String>> userProvidedProperties,
+                                                        ClusterTopology topology) {
+    if (topology.getConfigRecommendationStrategy() == ConfigRecommendationStrategy.ONLY_STACK_DEFAULTS_APPLY) {
+      if (userProvidedProperties.containsKey(configType)) {
+        BlueprintConfigurations newConfig = new BlueprintConfigurations();
+        Map<String, String> filteredProps = Maps.filterKeys(config.getProperties(),
+          Predicates.not(Predicates.in(userProvidedProperties.get(configType).keySet())));
+        newConfig.setProperties(Maps.newHashMap(filteredProps));
+
+        if (config.getPropertyAttributes() != null) {
+          Map<String, ValueAttributesInfo> filteredAttributes = Maps.filterKeys(config.getPropertyAttributes(),
+            Predicates.not(Predicates.in(userProvidedProperties.get(configType).keySet())));
+          newConfig.setPropertyAttributes(Maps.newHashMap(filteredAttributes));
+        }
+        return newConfig;
+      }
+    }
+    return config;
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/9991ad88/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessorTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessorTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessorTest.java
index 60a8dde..c4e694b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessorTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessorTest.java
@@ -20,7 +20,7 @@ package org.apache.ambari.server.api.services.stackadvisor;
 
 import com.google.common.collect.Maps;
 import org.apache.ambari.server.controller.internal.ConfigurationTopologyException;
-import org.apache.ambari.server.topology.Component;
+import org.apache.ambari.server.topology.ConfigRecommendationStrategy;
 import org.apache.ambari.server.topology.Configuration;
 import org.apache.ambari.server.topology.HostGroup;
 import static org.easymock.EasyMock.anyObject;
@@ -29,6 +29,7 @@ import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.reset;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.util.Arrays;
@@ -77,21 +78,93 @@ public class StackAdvisorBlueprintProcessorTest {
     expect(clusterTopology.getAdvisedConfigurations()).andReturn(advisedConfigurations).anyTimes();
     expect(clusterTopology.getConfiguration()).andReturn(configuration).anyTimes();
     expect(clusterTopology.isClusterKerberosEnabled()).andReturn(false).anyTimes();
+    expect(clusterTopology.getConfigRecommendationStrategy()).andReturn(ConfigRecommendationStrategy.ALWAYS_APPLY);
     expect(blueprint.getStack()).andReturn(stack).anyTimes();
     expect(stack.getVersion()).andReturn("2.3").anyTimes();
     expect(stack.getName()).andReturn("HDP").anyTimes();
+    expect(stack.getConfiguration(Arrays.asList("HDFS", "YARN", "HIVE"))).andReturn(createStackDefaults()).anyTimes();
     expect(blueprint.getServices()).andReturn(Arrays.asList("HDFS", "YARN", "HIVE")).anyTimes();
     expect(blueprint.getHostGroups()).andReturn(createHostGroupMap()).anyTimes();
     expect(hostGroup.getComponentNames()).andReturn(Arrays.asList("comp1", "comp2")).anyTimes();
     expect(stackAdvisorHelper.recommend(anyObject(StackAdvisorRequest.class))).andReturn(createRecommendationResponse());
-    expect(configuration.getFullProperties()).andReturn(createProps());
+    expect(configuration.getFullProperties()).andReturn(createProps()).anyTimes();
+
+    replay(clusterTopology, blueprint, stack, hostGroup, configuration, stackAdvisorHelper);
+    // WHEN
+    underTest.adviseConfiguration(clusterTopology);
+    // THEN
+    assertTrue(advisedConfigurations.get("core-site").getProperties().containsKey("dummyKey1"));
+    assertTrue(advisedConfigurations.get("core-site").getProperties().containsKey("dummyKey3"));
+    assertTrue(advisedConfigurations.get("core-site").getPropertyValueAttributes().containsKey("dummyKey2"));
+    assertTrue(advisedConfigurations.get("core-site").getPropertyValueAttributes().containsKey("dummyKey3"));
+    assertEquals("dummyValue", advisedConfigurations.get("core-site").getProperties().get("dummyKey1"));
+    assertEquals(Boolean.toString(true), advisedConfigurations.get("core-site")
+      .getPropertyValueAttributes().get("dummyKey2").getDelete());
+  }
+
+  @Test
+  public void testAdviseConfigurationWithOnlyStackDefaultsApply() throws StackAdvisorException, ConfigurationTopologyException {
+    // GIVEN
+    Map<String, AdvisedConfiguration> advisedConfigurations = new HashMap<String, AdvisedConfiguration>();
+    expect(clusterTopology.getBlueprint()).andReturn(blueprint).anyTimes();
+    expect(clusterTopology.getHostGroupInfo()).andReturn(createHostGroupInfo()).anyTimes();
+    expect(clusterTopology.getAdvisedConfigurations()).andReturn(advisedConfigurations).anyTimes();
+    expect(clusterTopology.getConfiguration()).andReturn(configuration).anyTimes();
+    expect(clusterTopology.isClusterKerberosEnabled()).andReturn(false).anyTimes();
+    expect(clusterTopology.getConfigRecommendationStrategy()).andReturn(ConfigRecommendationStrategy.ONLY_STACK_DEFAULTS_APPLY);
+    expect(blueprint.getStack()).andReturn(stack).anyTimes();
+    expect(stack.getVersion()).andReturn("2.3").anyTimes();
+    expect(stack.getName()).andReturn("HDP").anyTimes();
+    expect(stack.getConfiguration(Arrays.asList("HDFS", "YARN", "HIVE"))).andReturn(createStackDefaults()).anyTimes();
+    expect(blueprint.getServices()).andReturn(Arrays.asList("HDFS", "YARN", "HIVE")).anyTimes();
+    expect(blueprint.getHostGroups()).andReturn(createHostGroupMap()).anyTimes();
+    expect(hostGroup.getComponentNames()).andReturn(Arrays.asList("comp1", "comp2")).anyTimes();
+    expect(stackAdvisorHelper.recommend(anyObject(StackAdvisorRequest.class))).andReturn(createRecommendationResponse());
+    expect(configuration.getFullProperties()).andReturn(createProps()).anyTimes();
+
+    replay(clusterTopology, blueprint, stack, hostGroup, configuration, stackAdvisorHelper);
+    // WHEN
+    underTest.adviseConfiguration(clusterTopology);
+    // THEN
+    assertTrue(advisedConfigurations.get("core-site").getProperties().containsKey("dummyKey1"));
+    assertFalse(advisedConfigurations.get("core-site").getProperties().containsKey("dummyKey3"));
+    assertTrue(advisedConfigurations.get("core-site").getPropertyValueAttributes().containsKey("dummyKey2"));
+    assertFalse(advisedConfigurations.get("core-site").getPropertyValueAttributes().containsKey("dummyKey3"));
+    assertEquals("dummyValue", advisedConfigurations.get("core-site").getProperties().get("dummyKey1"));
+    assertEquals(Boolean.toString(true), advisedConfigurations.get("core-site")
+      .getPropertyValueAttributes().get("dummyKey2").getDelete());
+  }
+
+  @Test
+  public void testAdviseConfigurationWithOnlyStackDefaultsApplyWhenNoUserInputForDefault() throws StackAdvisorException, ConfigurationTopologyException {
+    // GIVEN
+    Map<String, Map<String, String>> props = createProps();
+    props.get("core-site").put("dummyKey3", "stackDefaultValue");
+    Map<String, AdvisedConfiguration> advisedConfigurations = new HashMap<String, AdvisedConfiguration>();
+    expect(clusterTopology.getBlueprint()).andReturn(blueprint).anyTimes();
+    expect(clusterTopology.getHostGroupInfo()).andReturn(createHostGroupInfo()).anyTimes();
+    expect(clusterTopology.getAdvisedConfigurations()).andReturn(advisedConfigurations).anyTimes();
+    expect(clusterTopology.getConfiguration()).andReturn(configuration).anyTimes();
+    expect(clusterTopology.isClusterKerberosEnabled()).andReturn(false).anyTimes();
+    expect(clusterTopology.getConfigRecommendationStrategy()).andReturn(ConfigRecommendationStrategy.ONLY_STACK_DEFAULTS_APPLY);
+    expect(blueprint.getStack()).andReturn(stack).anyTimes();
+    expect(stack.getVersion()).andReturn("2.3").anyTimes();
+    expect(stack.getName()).andReturn("HDP").anyTimes();
+    expect(stack.getConfiguration(Arrays.asList("HDFS", "YARN", "HIVE"))).andReturn(createStackDefaults()).anyTimes();
+    expect(blueprint.getServices()).andReturn(Arrays.asList("HDFS", "YARN", "HIVE")).anyTimes();
+    expect(blueprint.getHostGroups()).andReturn(createHostGroupMap()).anyTimes();
+    expect(hostGroup.getComponentNames()).andReturn(Arrays.asList("comp1", "comp2")).anyTimes();
+    expect(stackAdvisorHelper.recommend(anyObject(StackAdvisorRequest.class))).andReturn(createRecommendationResponse());
+    expect(configuration.getFullProperties()).andReturn(props).anyTimes();
 
     replay(clusterTopology, blueprint, stack, hostGroup, configuration, stackAdvisorHelper);
     // WHEN
     underTest.adviseConfiguration(clusterTopology);
     // THEN
     assertTrue(advisedConfigurations.get("core-site").getProperties().containsKey("dummyKey1"));
+    assertTrue(advisedConfigurations.get("core-site").getProperties().containsKey("dummyKey3"));
     assertTrue(advisedConfigurations.get("core-site").getPropertyValueAttributes().containsKey("dummyKey2"));
+    assertTrue(advisedConfigurations.get("core-site").getPropertyValueAttributes().containsKey("dummyKey3"));
     assertEquals("dummyValue", advisedConfigurations.get("core-site").getProperties().get("dummyKey1"));
     assertEquals(Boolean.toString(true), advisedConfigurations.get("core-site")
       .getPropertyValueAttributes().get("dummyKey2").getDelete());
@@ -157,6 +230,7 @@ public class StackAdvisorBlueprintProcessorTest {
     Map<String, Map<String, String>> props = Maps.newHashMap();
     Map<String, String> siteProps = Maps.newHashMap();
     siteProps.put("myprop", "myvalue");
+    siteProps.put("dummyKey3", "userinput");
     props.put("core-site", siteProps);
     return props;
   }
@@ -178,6 +252,18 @@ public class StackAdvisorBlueprintProcessorTest {
     return hostGroupInfoMap;
   }
 
+  private Configuration createStackDefaults() {
+    Map<String, Map<String, String>> stackDefaultProps =
+      new HashMap<String, Map<String, String>>();
+    Map<String, String> coreSiteDefault = new HashMap<String, String>();
+    coreSiteDefault.put("dummyKey3", "stackDefaultValue");
+    stackDefaultProps.put("core-site", coreSiteDefault);
+
+    Map<String, Map<String, Map<String, String>>> stackDefaultAttributes =
+      new HashMap<String, Map<String, Map<String, String>>>();
+    return new Configuration(stackDefaultProps, stackDefaultAttributes);
+  }
+
   private RecommendationResponse createRecommendationResponse() {
     RecommendationResponse response = new RecommendationResponse();
     RecommendationResponse.Recommendation recommendations = new RecommendationResponse.Recommendation();
@@ -188,11 +274,15 @@ public class StackAdvisorBlueprintProcessorTest {
       new RecommendationResponse.BlueprintConfigurations();
     Map<String, String> properties = new HashMap<String, String>();
     properties.put("dummyKey1", "dummyValue");
+    properties.put("dummyKey3", "dummyValue-override");
     blueprintConfig.setProperties(properties);
     Map<String, ValueAttributesInfo> propAttributes = new HashMap<String, ValueAttributesInfo>();
-    ValueAttributesInfo valueAttributesInfo = new ValueAttributesInfo();
-    valueAttributesInfo.setDelete("true");
-    propAttributes.put("dummyKey2", valueAttributesInfo);
+    ValueAttributesInfo valueAttributesInfo1 = new ValueAttributesInfo();
+    ValueAttributesInfo valueAttributesInfo2 = new ValueAttributesInfo();
+    valueAttributesInfo1.setDelete("true");
+    valueAttributesInfo2.setDelete("true");
+    propAttributes.put("dummyKey2", valueAttributesInfo1);
+    propAttributes.put("dummyKey3", valueAttributesInfo2);
     blueprintConfig.setPropertyAttributes(propAttributes);
     blueprintConfigurationsMap.put("core-site", blueprintConfig);
     blueprint.setConfigurations(blueprintConfigurationsMap);


[09/11] ambari git commit: AMBARI-14562. Ranger - If configured audit store is 'solr', then audit_store value should be 'solr'(gautam)

Posted by nc...@apache.org.
AMBARI-14562. Ranger - If configured audit store is 'solr', then audit_store value should be 'solr'(gautam)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 6e098207dd0d8c015df7dd5f7ddede87ee269216
Parents: 774d689
Author: Gautam Borad <ga...@apache.org>
Authored: Fri Jan 22 09:25:37 2016 +0530
Committer: Gautam Borad <ga...@apache.org>
Committed: Tue Feb 2 15:18:48 2016 +0530

----------------------------------------------------------------------
 .../RANGER/0.4.0/package/scripts/setup_ranger_xml.py     |  5 +++++
 .../services/RANGER/configuration/ranger-admin-site.xml  | 10 ++++++++++
 .../resources/stacks/HDP/2.3/services/stack_advisor.py   | 11 +++++++++++
 .../test/python/stacks/2.3/common/test_stack_advisor.py  |  3 ++-
 4 files changed, 28 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/6e098207/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/setup_ranger_xml.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/setup_ranger_xml.py b/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/setup_ranger_xml.py
index 119da1a..4660cf8 100644
--- a/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/setup_ranger_xml.py
+++ b/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/setup_ranger_xml.py
@@ -196,6 +196,11 @@ def setup_ranger_db(upgrade_type=None):
     owner = params.unix_user,
   )
 
+  ModifyPropertiesFile(format("{ranger_home}/install.properties"),
+    properties = {'audit_store': params.ranger_audit_source_type},
+    owner = params.unix_user,
+  )
+
   if params.db_flavor.lower() == 'sqla':
     ModifyPropertiesFile(format("{ranger_home}/install.properties"),
       properties = {'SQL_CONNECTOR_JAR': format('{ranger_home}/ews/lib/{jdbc_jar_name}')},

http://git-wip-us.apache.org/repos/asf/ambari/blob/6e098207/ambari-server/src/main/resources/stacks/HDP/2.3/services/RANGER/configuration/ranger-admin-site.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/services/RANGER/configuration/ranger-admin-site.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/services/RANGER/configuration/ranger-admin-site.xml
index e9eecde..07eb7c4 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/services/RANGER/configuration/ranger-admin-site.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/services/RANGER/configuration/ranger-admin-site.xml
@@ -164,6 +164,16 @@
     <name>ranger.audit.source.type</name>
     <value>solr</value>
     <description>db or solr, based on the audit destination used</description>
+    <depends-on>
+      <property>
+        <type>ranger-env</type>
+        <name>xasecure.audit.destination.solr</name>
+      </property>
+      <property>
+        <type>ranger-env</type>
+        <name>xasecure.audit.destination.db</name>
+      </property>
+    </depends-on>
   </property>
 
   <property>

http://git-wip-us.apache.org/repos/asf/ambari/blob/6e098207/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py
index 3e60f05..dae3e8a 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/services/stack_advisor.py
@@ -624,6 +624,17 @@ class HDP23StackAdvisor(HDP22StackAdvisor):
                 rangerAuditProperty = services["configurations"][item['filename']]["properties"][item['configname']]
               putRangerAuditProperty(item['target_configname'], rangerAuditProperty)
 
+    audit_solr_flag = 'false'
+    audit_db_flag = 'false'
+    ranger_audit_source_type = 'solr'
+    if 'ranger-env' in services['configurations'] and 'xasecure.audit.destination.solr' in services['configurations']["ranger-env"]["properties"]:
+      audit_solr_flag = services['configurations']["ranger-env"]["properties"]['xasecure.audit.destination.solr']
+    if 'ranger-env' in services['configurations'] and 'xasecure.audit.destination.db' in services['configurations']["ranger-env"]["properties"]:
+      audit_db_flag = services['configurations']["ranger-env"]["properties"]['xasecure.audit.destination.db']
+
+    if audit_db_flag == 'true' and audit_solr_flag == 'false':
+      ranger_audit_source_type = 'db'
+    putRangerAdminProperty('ranger.audit.source.type',ranger_audit_source_type)
 
 
   def recommendYARNConfigurations(self, configurations, clusterData, services, hosts):

http://git-wip-us.apache.org/repos/asf/ambari/blob/6e098207/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py b/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py
index e345e2a..965ce98 100644
--- a/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py
+++ b/ambari-server/src/test/python/stacks/2.3/common/test_stack_advisor.py
@@ -1531,7 +1531,8 @@ class TestHDP23StackAdvisor(TestCase):
       },
       'ranger-admin-site': {
         'properties': {
-          "ranger.audit.solr.zookeepers": "NONE"
+          "ranger.audit.solr.zookeepers": "NONE",
+          "ranger.audit.source.type": "solr"
         }
       },
       'ranger-env': {


[06/11] ambari git commit: AMBARI-14850: Removed unused functions from params.py in HAWQ (bhuvnesh2703 via jaoki)

Posted by nc...@apache.org.
AMBARI-14850: Removed unused functions from params.py in HAWQ (bhuvnesh2703 via jaoki)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 6ce156554600214339c7e8c35219abaf570346e9
Parents: 9a03489
Author: Jun Aoki <ja...@apache.org>
Authored: Mon Feb 1 17:19:59 2016 -0800
Committer: Jun Aoki <ja...@apache.org>
Committed: Mon Feb 1 17:19:59 2016 -0800

----------------------------------------------------------------------
 .../HAWQ/2.0.0/package/scripts/params.py        | 21 --------------------
 1 file changed, 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/6ce15655/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/params.py b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/params.py
index 604ddc0..add3c63 100644
--- a/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/params.py
+++ b/ambari-server/src/main/resources/common-services/HAWQ/2.0.0/package/scripts/params.py
@@ -22,14 +22,7 @@ from hawq_constants import PXF_PORT, pxf_hdfs_test_dir
 from resource_management import Script
 from resource_management.libraries.functions.default import default
 from resource_management.libraries.resources.hdfs_resource import HdfsResource
-from resource_management.libraries.resources.execute_hadoop import ExecuteHadoop
 from resource_management.libraries.functions import get_kinit_path
-from resource_management.libraries.functions import conf_select
-try:
-    from resource_management.libraries.functions import hdp_select as hadoop_select
-except ImportError:
-    from resource_management.libraries.functions import phd_select as hadoop_select
-
 
 config = Script.get_config()
 
@@ -70,9 +63,6 @@ security_enabled = config['configurations']['cluster-env']['security_enabled']
 hdfs_user_keytab = config['configurations']['hadoop-env']['hdfs_user_keytab']
 kinit_path_local = get_kinit_path(default('/configurations/kerberos-env/executable_search_paths', None))
 hdfs_principal_name = config['configurations']['hadoop-env']['hdfs_principal_name']
-hadoop_conf_dir = conf_select.get_hadoop_conf_dir()
-hadoop_bin_dir = hadoop_select.get_hadoop_dir("bin")
-execute_path = os.environ['PATH'] + os.pathsep + hadoop_bin_dir
 dfs_nameservice = default('/configurations/hdfs-site/dfs.nameservices', None)
 
 # HDFSResource partial function
@@ -85,17 +75,6 @@ HdfsResource = functools.partial(HdfsResource,
                                  hdfs_site=hdfs_site,
                                  default_fs=default_fs)
 
-# ExecuteHadoop partial function
-ExecuteHadoop = functools.partial(ExecuteHadoop,
-                                  user=hdfs_superuser,
-                                  logoutput=True,
-                                  conf_dir=hadoop_conf_dir,
-                                  security_enabled=security_enabled,
-                                  kinit_path_local=kinit_path_local,
-                                  keytab=hdfs_user_keytab,
-                                  principal=hdfs_principal_name,
-                                  bin_dir=execute_path)
-
 
 # For service Check
 is_pxf_installed = __get_component_host("pxf_hosts") is not None


[10/11] ambari git commit: AMBARI-14874. Alert Instance filter issues (onechiporenko)

Posted by nc...@apache.org.
AMBARI-14874. Alert Instance filter issues (onechiporenko)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 8ba3d0beb794f979f24174ed5324d99a1c4a8e73
Parents: 6e09820
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Tue Feb 2 12:09:18 2016 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Tue Feb 2 12:09:18 2016 +0200

----------------------------------------------------------------------
 ambari-web/app/messages.js                                  | 3 ++-
 ambari-web/app/templates/main/alerts/definition_details.hbs | 6 ++++++
 ambari-web/app/views/main/alerts/definition_details_view.js | 6 ++++++
 3 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8ba3d0be/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 916ca2a..2de2f2b 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1010,7 +1010,7 @@ Em.I18n.translations = {
   'alerts.definition.details.serviceHost': 'Service / Host',
   'alerts.definition.details.24-hour': '24-Hour',
   'alerts.definition.details.notification': 'Notification',
-  'alerts.definition.details.noAlerts': 'No alert instances to show',
+  'alerts.definition.details.noAlerts': 'No alert instances to display',
   'alerts.definition.details.configs.thresholdsErrorMsg': 'Critical threshold should be larger than warning threshold',
 
   'alerts.notifications.error.email': 'Must be a valid email address',
@@ -2694,6 +2694,7 @@ Em.I18n.translations = {
   'tableView.filters.clearAllFilters': 'clear filters',
   'tableView.filters.showAll': 'Show All',
   'tableView.filters.filteredConfigVersionInfo': '{0} of {1} versions showing',
+  'tableView.filters.filteredAlertInstancesInfo': '{0} of {1} instances showing',
 
   'rollingrestart.dialog.title': 'Restart {0}s',
   'rollingrestart.dialog.primary': 'Trigger Rolling Restart',

http://git-wip-us.apache.org/repos/asf/ambari/blob/8ba3d0be/ambari-web/app/templates/main/alerts/definition_details.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/alerts/definition_details.hbs b/ambari-web/app/templates/main/alerts/definition_details.hbs
index cd45524..9502378 100644
--- a/ambari-web/app/templates/main/alerts/definition_details.hbs
+++ b/ambari-web/app/templates/main/alerts/definition_details.hbs
@@ -232,6 +232,12 @@
         </table>
 
         <div class="page-bar">
+          <div class="filtered-info span4">
+            {{#if view.showFilteredContent}}
+              <label>{{view.filteredContentInfo}} - <a {{action clearFilters target="view"}}
+                href="#">{{t tableView.filters.clearAllFilters}}</a></label>
+            {{/if}}
+          </div>
           <div class="items-on-page">
             <label>{{t common.show}}: {{view view.rowsPerPageSelectView selectionBinding="view.displayLength"}}</label>
           </div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/8ba3d0be/ambari-web/app/views/main/alerts/definition_details_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/alerts/definition_details_view.js b/ambari-web/app/views/main/alerts/definition_details_view.js
index a534b16..7467b0f 100644
--- a/ambari-web/app/views/main/alerts/definition_details_view.js
+++ b/ambari-web/app/views/main/alerts/definition_details_view.js
@@ -42,6 +42,12 @@ App.MainAlertDefinitionDetailsView = App.TableView.extend({
 
   colPropAssoc: ['serviceName', 'hostName', 'state'],
 
+  /**
+   * return filtered number of all content number information displayed on the page footer bar
+   * @returns {String}
+   */
+  filteredContentInfo: Em.computed.i18nFormat('tableView.filters.filteredAlertInstancesInfo', 'filteredCount', 'totalCount'),
+
   content: function () {
     return this.get('controller.alerts');
   }.property('controller.alerts.@each'),