You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2017/02/17 21:29:59 UTC

[01/15] ambari git commit: AMBARI-20017. PixieDust - Decrease Service Check running time under 3 mins (dlysnichenko)

Repository: ambari
Updated Branches:
  refs/heads/branch-feature-AMBARI-20053 f4638d24d -> e8e2df21f


AMBARI-20017. PixieDust - Decrease Service Check running time under 3 mins (dlysnichenko)


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

Branch: refs/heads/branch-feature-AMBARI-20053
Commit: 18fc2586fa7410823b3d7a9354cf5b10be0dc2e0
Parents: 347ba2a
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Thu Feb 16 23:17:09 2017 +0200
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Thu Feb 16 23:17:09 2017 +0200

----------------------------------------------------------------------
 .../controller/AmbariCustomCommandExecutionHelper.java   |  8 ++++++++
 .../org/apache/ambari/server/state/ConfigHelper.java     |  2 ++
 .../stacks/HDP/2.0.6/configuration/cluster-env.xml       | 11 +++++++++++
 3 files changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/18fc2586/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
index b601893..eeb2de5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
@@ -142,6 +142,8 @@ public class AmbariCustomCommandExecutionHelper {
 
   private final static String ALIGN_MAINTENANCE_STATE = "align_maintenance_state";
 
+  public final static int MIN_STRICT_SERVICE_CHECK_TIMEOUT = 120;
+  
   @Inject
   private ActionMetadata actionMetadata;
 
@@ -766,6 +768,12 @@ public class AmbariCustomCommandExecutionHelper {
     }
 
     commandParams.put(COMMAND_TIMEOUT, commandTimeout);
+    String checkType = configHelper.getValueFromDesiredConfigurations(cluster, ConfigHelper.CLUSTER_ENV, ConfigHelper.SERVICE_CHECK_TYPE);
+    if (ConfigHelper.SERVICE_CHECK_MINIMAL.equals(checkType)) {
+      int actualTimeout = Integer.parseInt(commandParams.get(COMMAND_TIMEOUT)) / 2;
+      actualTimeout = actualTimeout < MIN_STRICT_SERVICE_CHECK_TIMEOUT ? MIN_STRICT_SERVICE_CHECK_TIMEOUT : actualTimeout;
+      commandParams.put(COMMAND_TIMEOUT, Integer.toString(actualTimeout));
+    }
     commandParams.put(SERVICE_PACKAGE_FOLDER, serviceInfo.getServicePackageFolder());
     commandParams.put(HOOKS_FOLDER, stackInfo.getStackHooksFolder());
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/18fc2586/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
index 0e5b434..6572bbb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
@@ -86,6 +86,7 @@ public class ConfigHelper {
   public static final String CLUSTER_ENV = "cluster-env";
   public static final String CLUSTER_ENV_ALERT_REPEAT_TOLERANCE = "alerts_repeat_tolerance";
   public static final String CLUSTER_ENV_RETRY_ENABLED = "command_retry_enabled";
+  public static final String SERVICE_CHECK_TYPE = "service_check_type";
   public static final String CLUSTER_ENV_RETRY_COMMANDS = "commands_to_retry";
   public static final String CLUSTER_ENV_RETRY_MAX_TIME_IN_SEC = "command_retry_max_time_in_sec";
   public static final String COMMAND_RETRY_MAX_TIME_IN_SEC_DEFAULT = "600";
@@ -94,6 +95,7 @@ public class ConfigHelper {
 
   public static final String HTTP_ONLY = "HTTP_ONLY";
   public static final String HTTPS_ONLY = "HTTPS_ONLY";
+  public static final String SERVICE_CHECK_MINIMAL = "minimal";
 
   /**
    * The tag given to newly created versions.

http://git-wip-us.apache.org/repos/asf/ambari/blob/18fc2586/ambari-server/src/main/resources/stacks/HDP/2.0.6/configuration/cluster-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/configuration/cluster-env.xml b/ambari-server/src/main/resources/stacks/HDP/2.0.6/configuration/cluster-env.xml
index 3af8f08..3f74aa7 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/configuration/cluster-env.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/configuration/cluster-env.xml
@@ -296,4 +296,15 @@ gpgcheck=0</value>
     <description>Flag to turn on when external setup of External Ranger is done.</description>
     <on-ambari-upgrade add="false"/>
   </property>
+  <property>
+    <name>service_check_type</name>
+    <display-name>Service Check Type</display-name>
+    <value>full</value>
+    <description>Indicates the complexity of the service check.  Valid values are 'minimal' or 'full'.</description>
+    <on-ambari-upgrade add="true"/>
+    <value-attributes>
+      <visible>true</visible>
+      <empty-value-valid>true</empty-value-valid>
+    </value-attributes>
+  </property>
 </configuration>


[14/15] ambari git commit: AMBARI-20065 - Livy server start failed after downgrade with missing livy.server.kerberos.keytab error (jonathanhurley)

Posted by jo...@apache.org.
AMBARI-20065 - Livy server start failed after downgrade with missing livy.server.kerberos.keytab error (jonathanhurley)


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

Branch: refs/heads/branch-feature-AMBARI-20053
Commit: a5dc2d2cc98eb5b2f59cc7bc13b947e84c15479b
Parents: 8dabd55
Author: Jonathan Hurley <jh...@hortonworks.com>
Authored: Fri Feb 17 10:40:04 2017 -0500
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Fri Feb 17 15:18:27 2017 -0500

----------------------------------------------------------------------
 .../stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml      | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a5dc2d2c/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml
index 4fb68ed..bb9ec1b 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml
@@ -61,10 +61,6 @@
           <function>prepare</function>
         </task>
       </execute-stage>
-
-      <execute-stage service="SPARK" component="LIVY_SERVER" title="Apply config changes for Livy Server">
-        <task xsi:type="configure" id="hdp_2_5_0_0_rename_spark_livy_configs"/>
-      </execute-stage>
     </group>
 
     <group xsi:type="stop" name="STOP_HIGH_LEVEL_SERVICE_COMPONENTS" title="Stop Components for High-Level Services">
@@ -497,6 +493,11 @@
           <summary>Updating the Hive Log4J2 properties to include parameterizations</summary>
         </task>
       </execute-stage>
+      
+      <!-- SPARK -->
+      <execute-stage service="SPARK" component="LIVY_SERVER" title="Apply config changes for Livy Server">
+        <task xsi:type="configure" id="hdp_2_5_0_0_rename_spark_livy_configs"/>
+      </execute-stage>      
     </group>
 
     <!--


[09/15] ambari git commit: AMBARI-20013. Appendum - Add Solr authorization settings during LogSearch/Atlas/Ranger startup (oleewere)

Posted by jo...@apache.org.
AMBARI-20013. Appendum - Add Solr authorization settings during LogSearch/Atlas/Ranger startup (oleewere)


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

Branch: refs/heads/branch-feature-AMBARI-20053
Commit: dd174f417cbfe4181e5503c57b4c273009c856ae
Parents: bcf7289
Author: oleewere <ol...@gmail.com>
Authored: Fri Feb 17 17:52:29 2017 +0100
Committer: oleewere <ol...@gmail.com>
Committed: Fri Feb 17 17:52:48 2017 +0100

----------------------------------------------------------------------
 .../src/test/python/stacks/2.3/ATLAS/test_metadata_server.py   | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/dd174f41/ambari-server/src/test/python/stacks/2.3/ATLAS/test_metadata_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.3/ATLAS/test_metadata_server.py b/ambari-server/src/test/python/stacks/2.3/ATLAS/test_metadata_server.py
index 12f8412..388aa57 100644
--- a/ambari-server/src/test/python/stacks/2.3/ATLAS/test_metadata_server.py
+++ b/ambari-server/src/test/python/stacks/2.3/ATLAS/test_metadata_server.py
@@ -20,6 +20,7 @@ limitations under the License.
 
 from mock.mock import MagicMock, call, patch
 from resource_management.libraries.script.script import Script
+from resource_management.libraries.functions import get_kinit_path
 from stacks.utils.RMFTestCase import *
 import json
 import sys
@@ -302,8 +303,9 @@ class TestMetadataServer(RMFTestCase):
     self.assertResourceCalledRegexp('^Directory$', '^/tmp/solr_config_atlas_configs_0.[0-9]*',
                                     action=['delete'],
                                     create_parents=True)
-
-    self.assertResourceCalled('Execute', "ambari-sudo.sh /usr/bin/kinit -kt /etc/security/keytabs/ambari-infra-solr.keytab infra-solr/c6401.ambari.apache.org@EXAMPLE.COM; ambari-sudo.sh curl -k -s --negotiate -u : http://c6401.ambari.apache.org:8886/solr/admin/authorization | grep authorization.enabled && ambari-sudo.sh /usr/bin/kinit -kt /etc/security/keytabs/ambari-infra-solr.keytab infra-solr/c6401.ambari.apache.org@EXAMPLE.COM; ambari-sudo.sh curl -H 'Content-type:application/json' -d '{\"set-user-role\": {\"atlas@EXAMPLE.COM\": [\"atlas_user\", \"ranger_audit_user\", \"dev\"]}}' -s -o /dev/null -w'%{http_code}' --negotiate -u: -k http://c6401.ambari.apache.org:8886/solr/admin/authorization | grep 200",
+    kinit_path_local = get_kinit_path()
+    self.assertResourceCalled('Execute', "ambari-sudo.sh " + kinit_path_local + " -kt /etc/security/keytabs/ambari-infra-solr.keytab infra-solr/c6401.ambari.apache.org@EXAMPLE.COM; ambari-sudo.sh curl -k -s --negotiate -u : http://c6401.ambari.apache.org:8886/solr/admin/authorization | grep authorization.enabled && ambari-sudo.sh "
+                              + kinit_path_local +" -kt /etc/security/keytabs/ambari-infra-solr.keytab infra-solr/c6401.ambari.apache.org@EXAMPLE.COM; ambari-sudo.sh curl -H 'Content-type:application/json' -d '{\"set-user-role\": {\"atlas@EXAMPLE.COM\": [\"atlas_user\", \"ranger_audit_user\", \"dev\"]}}' -s -o /dev/null -w'%{http_code}' --negotiate -u: -k http://c6401.ambari.apache.org:8886/solr/admin/authorization | grep 200",
                               logoutput = True, tries = 30, try_sleep = 10)
 
     self.assertResourceCalledRegexp('^Execute$', '^ambari-sudo.sh JAVA_HOME=/usr/jdk64/jdk1.7.0_45 /usr/lib/ambari-infra-solr-client/solrCloudCli.sh --zookeeper-connect-string c6401.ambari.apache.org:2181/infra-solr --create-collection --collection vertex_index --config-set atlas_configs --shards 1 --replication 1 --max-shards 1 --retry 5 --interval 10')


[15/15] ambari git commit: Merge branch 'trunk' into branch-feature-AMBARI-20053

Posted by jo...@apache.org.
Merge branch 'trunk' into branch-feature-AMBARI-20053


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

Branch: refs/heads/branch-feature-AMBARI-20053
Commit: e8e2df21f7fe91fa8a028bb3043bed831093a090
Parents: f4638d2 a5dc2d2
Author: Jonathan Hurley <jh...@hortonworks.com>
Authored: Fri Feb 17 16:29:16 2017 -0500
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Fri Feb 17 16:29:16 2017 -0500

----------------------------------------------------------------------
 .../libraries/functions/constants.py            |   2 +
 .../functions/setup_ranger_plugin_xml.py        |  23 +-
 .../actionmanager/ActionDBAccessorImpl.java     | 108 ++--
 .../server/actionmanager/ActionScheduler.java   |  31 +
 .../ambari/server/actionmanager/Request.java    |   8 +-
 .../ambari/server/actionmanager/Stage.java      |  25 +
 .../checks/DatabaseConsistencyCheckHelper.java  |  19 +
 .../AmbariCustomCommandExecutionHelper.java     |   8 +
 .../controller/internal/CalculatedStatus.java   | 390 +++++++++++-
 .../ambari/server/events/TaskCreateEvent.java   |  48 ++
 .../apache/ambari/server/events/TaskEvent.java  |  66 ++
 .../ambari/server/events/TaskUpdateEvent.java   |  35 ++
 .../listeners/tasks/TaskStatusListener.java     | 609 +++++++++++++++++++
 .../events/publishers/TaskEventPublisher.java   |  62 ++
 .../server/orm/dao/HostRoleCommandDAO.java      |  67 +-
 .../ambari/server/orm/dao/RequestDAO.java       |   8 +
 .../apache/ambari/server/orm/dao/StageDAO.java  |  32 +-
 .../orm/entities/HostRoleCommandEntity.java     |   4 +-
 .../server/orm/entities/RequestEntity.java      |  49 +-
 .../ambari/server/orm/entities/StageEntity.java |  70 ++-
 .../server/orm/entities/StageEntityPK.java      |  12 +
 .../ambari/server/state/ConfigHelper.java       |   2 +
 .../ambari/server/topology/HostRequest.java     |   2 +-
 .../server/upgrade/UpgradeCatalog300.java       |  70 +++
 .../main/resources/Ambari-DDL-Derby-CREATE.sql  |   7 +-
 .../main/resources/Ambari-DDL-MySQL-CREATE.sql  |   7 +-
 .../main/resources/Ambari-DDL-Oracle-CREATE.sql |   7 +-
 .../resources/Ambari-DDL-Postgres-CREATE.sql    |   7 +-
 .../resources/Ambari-DDL-SQLAnywhere-CREATE.sql |   7 +-
 .../resources/Ambari-DDL-SQLServer-CREATE.sql   |   7 +-
 .../RANGER/0.4.0/package/scripts/params.py      |  18 +
 .../0.4.0/package/scripts/setup_ranger_xml.py   |  67 +-
 .../0.5.0/configuration/ranger-admin-site.xml   |  12 +
 .../0.7.0/configuration/ranger-admin-site.xml   |  31 +
 .../0.5.0.2.3/configuration/kms-env.xml         |  10 +
 .../RANGER_KMS/0.5.0.2.3/package/scripts/kms.py |  51 +-
 .../0.5.0.2.3/package/scripts/params.py         |  10 +
 .../HDP/2.0.6/configuration/cluster-env.xml     |  11 +
 .../HDP/2.0.6/properties/stack_features.json    |  10 +
 .../stacks/HDP/2.3/upgrades/config-upgrade.xml  |   7 +
 .../HDP/2.3/upgrades/nonrolling-upgrade-2.6.xml |   4 +
 .../stacks/HDP/2.3/upgrades/upgrade-2.6.xml     |   1 +
 .../stacks/HDP/2.4/upgrades/config-upgrade.xml  |   7 +
 .../HDP/2.4/upgrades/nonrolling-upgrade-2.6.xml |   4 +
 .../stacks/HDP/2.4/upgrades/upgrade-2.6.xml     |   1 +
 .../stacks/HDP/2.5/upgrades/config-upgrade.xml  |   7 +
 .../HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml |  13 +-
 .../stacks/HDP/2.5/upgrades/upgrade-2.6.xml     |   1 +
 .../configuration/ranger-kms-site.xml           |  68 +++
 .../stacks/HDP/2.6/services/stack_advisor.py    |  20 +-
 .../actionmanager/TestActionDBAccessorImpl.java |   3 +-
 .../actionmanager/TestActionScheduler.java      |  71 ++-
 .../alerts/AmbariPerformanceRunnableTest.java   |   7 +-
 .../internal/UpgradeResourceProviderTest.java   |   1 -
 .../UpgradeSummaryResourceProviderTest.java     |   1 -
 .../listeners/tasks/TaskStatusListenerTest.java | 164 +++++
 .../ambari/server/state/ConfigHelperTest.java   |   2 +
 .../cluster/ClusterEffectiveVersionTest.java    |   5 +-
 .../services/RetryUpgradeActionServiceTest.java |   1 -
 .../server/upgrade/UpgradeCatalog300Test.java   |  20 +
 .../stacks/2.3/ATLAS/test_metadata_server.py    |   6 +-
 .../stacks/2.5/RANGER/test_ranger_admin.py      |  16 +-
 .../stacks/2.5/RANGER/test_ranger_usersync.py   |   8 +-
 .../stacks/2.5/RANGER_KMS/test_kms_server.py    |  70 ++-
 .../stacks/2.6/RANGER/test_ranger_admin.py      |  40 +-
 .../stacks/2.6/RANGER/test_ranger_tagsync.py    |  19 +-
 .../stacks/2.6/common/test_stack_advisor.py     |  69 +++
 .../2.6/configs/ranger-admin-default.json       |   6 +-
 ambari-web/app/assets/test/tests.js             |   1 +
 .../controllers/main/service/info/configs.js    |  35 +-
 ambari-web/app/data/dashboard_widgets.js        | 196 ++++++
 ambari-web/app/messages.js                      |   2 +-
 .../app/mixins/common/track_request_mixin.js    |  11 +-
 .../mixins/main/dashboard/widgets/editable.js   |  91 +--
 .../dashboard/widgets/editable_with_limit.js    | 106 +---
 .../widgets/single_numeric_threshold.js         | 127 +---
 .../common/configs/service_config_category.hbs  |   4 +-
 .../main/dashboard/edit_widget_popup.hbs        |  20 +-
 .../edit_widget_popup_single_threshold.hbs      |  12 +-
 ambari-web/app/views.js                         |   1 +
 .../app/views/common/configs/controls_view.js   |   2 +-
 .../modal_popups/edit_dashboard_widget_popup.js | 436 +++++++++++++
 ambari-web/app/views/main/dashboard/widget.js   | 173 ++----
 ambari-web/app/views/main/dashboard/widgets.js  | 266 +-------
 .../views/main/dashboard/widgets/text_widget.js |  23 +-
 .../app/views/main/host/combo_search_box.js     |   1 +
 .../main/service/info/config_test.js            |  45 ++
 .../edit_dashboard_widget_popup_test.js         | 214 +++++++
 .../test/views/main/dashboard/widget_test.js    | 112 +---
 .../test/views/main/dashboard/widgets_test.js   |  10 +-
 .../views/main/host/combo_search_box_test.js    |   6 +-
 docs/pom.xml                                    |  34 +-
 92 files changed, 3577 insertions(+), 1005 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e8e2df21/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
----------------------------------------------------------------------

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

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

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

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

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

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


[04/15] ambari git commit: AMBARI-20043. Don't rerender all widgets when one of them is changed (onechiporenko)

Posted by jo...@apache.org.
AMBARI-20043. Don't rerender all widgets when one of them is changed (onechiporenko)


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

Branch: refs/heads/branch-feature-AMBARI-20053
Commit: 05c76ed609dfcf75e0ff211aa8032834ef8e9f73
Parents: 984b35e
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Thu Feb 16 15:25:48 2017 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Fri Feb 17 10:26:47 2017 +0200

----------------------------------------------------------------------
 ambari-web/app/assets/test/tests.js             |   1 +
 ambari-web/app/data/dashboard_widgets.js        | 196 +++++++++
 ambari-web/app/messages.js                      |   2 +-
 .../app/mixins/common/track_request_mixin.js    |   6 +-
 .../mixins/main/dashboard/widgets/editable.js   |  91 +---
 .../dashboard/widgets/editable_with_limit.js    | 106 +----
 .../widgets/single_numeric_threshold.js         | 127 +-----
 .../main/dashboard/edit_widget_popup.hbs        |  20 +-
 .../edit_widget_popup_single_threshold.hbs      |  12 +-
 ambari-web/app/views.js                         |   1 +
 .../modal_popups/edit_dashboard_widget_popup.js | 436 +++++++++++++++++++
 ambari-web/app/views/main/dashboard/widget.js   | 173 ++------
 ambari-web/app/views/main/dashboard/widgets.js  | 266 ++---------
 .../views/main/dashboard/widgets/text_widget.js |  23 +-
 .../edit_dashboard_widget_popup_test.js         | 214 +++++++++
 .../test/views/main/dashboard/widget_test.js    | 112 +----
 .../test/views/main/dashboard/widgets_test.js   |  10 +-
 17 files changed, 968 insertions(+), 828 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/05c76ed6/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index d47d558..05c1657 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -253,6 +253,7 @@ var files = [
   'test/views/common/widget/template_widget_view_test',
   'test/views/common/widget/heatmap_widget_view_test',
   'test/views/common/modal_popups/cluster_check_popup_test',
+  'test/views/common/modal_popups/edit_dashboard_widget_popup_test',
   'test/views/common/modal_popups/hosts_table_list_popup_test',
   'test/views/common/modal_popups/dependent_configs_list_popup_test',
   'test/views/main/admin_test',

http://git-wip-us.apache.org/repos/asf/ambari/blob/05c76ed6/ambari-web/app/data/dashboard_widgets.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/data/dashboard_widgets.js b/ambari-web/app/data/dashboard_widgets.js
new file mode 100644
index 0000000..d58b0e2
--- /dev/null
+++ b/ambari-web/app/data/dashboard_widgets.js
@@ -0,0 +1,196 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+module.exports = [
+  {
+    id: 1,
+    viewName: 'NameNodeHeapPieChartView',
+    sourceName: 'HDFS',
+    title: Em.I18n.t('dashboard.widgets.NameNodeHeap'),
+    threshold: [80, 90]
+  },
+  {
+    id: 2,
+    viewName: 'NameNodeCapacityPieChartView',
+    sourceName: 'HDFS',
+    title: Em.I18n.t('dashboard.widgets.HDFSDiskUsage'),
+    threshold: [85, 95]
+  },
+  {
+    id: 3,
+    viewName: 'NameNodeCpuPieChartView',
+    sourceName: 'HDFS',
+    title: Em.I18n.t('dashboard.widgets.NameNodeCpu'),
+    threshold: [90, 95]
+  },
+  {
+    id: 4,
+    viewName: 'DataNodeUpView',
+    sourceName: 'HDFS',
+    title: Em.I18n.t('dashboard.widgets.DataNodeUp'),
+    threshold: [80, 90]
+  },
+  {
+    id: 5,
+    viewName: 'NameNodeRpcView',
+    sourceName: 'HDFS',
+    title: Em.I18n.t('dashboard.widgets.NameNodeRpc'),
+    threshold: [1000, 3000]
+  },
+  {
+    id: 6,
+    viewName: 'ChartClusterMetricsMemoryWidgetView',
+    sourceName: 'HOST_METRICS',
+    title: Em.I18n.t('dashboard.clusterMetrics.memory'),
+    threshold: []
+  },
+  {
+    id: 7,
+    viewName: 'ChartClusterMetricsNetworkWidgetView',
+    sourceName: 'HOST_METRICS',
+    title: Em.I18n.t('dashboard.clusterMetrics.network'),
+    threshold: []
+  },
+  {
+    id: 8,
+    viewName: 'ChartClusterMetricsCPUWidgetView',
+    sourceName: 'HOST_METRICS',
+    title: Em.I18n.t('dashboard.clusterMetrics.cpu'),
+    threshold: []
+  },
+  {
+    id: 9,
+    viewName: 'ChartClusterMetricsLoadWidgetView',
+    sourceName: 'HOST_METRICS',
+    title: Em.I18n.t('dashboard.clusterMetrics.load'),
+    threshold: []
+  },
+  {
+    id: 10,
+    viewName: 'NameNodeUptimeView',
+    sourceName: 'HDFS',
+    title: Em.I18n.t('dashboard.widgets.NameNodeUptime'),
+    threshold: []
+  },
+  {
+    id: 11,
+    viewName: 'HDFSLinksView',
+    sourceName: 'HDFS',
+    title: Em.I18n.t('dashboard.widgets.HDFSLinks'),
+    threshold: []
+  },
+  {
+    id: 12,
+    viewName: 'HBaseLinksView',
+    sourceName: 'HBASE',
+    title: Em.I18n.t('dashboard.widgets.HBaseLinks'),
+    threshold: []
+  },
+  {
+    id: 13,
+    viewName: 'HBaseMasterHeapPieChartView',
+    sourceName: 'HBASE',
+    title: Em.I18n.t('dashboard.widgets.HBaseMasterHeap'),
+    threshold: [70, 90]
+  },
+  {
+    id: 14,
+    viewName: 'HBaseAverageLoadView',
+    sourceName: 'HBASE',
+    title: Em.I18n.t('dashboard.widgets.HBaseAverageLoad'),
+    threshold: [150, 250]
+  },
+  {
+    id: 15,
+    viewName: 'HBaseRegionsInTransitionView',
+    sourceName: 'HBASE',
+    title: Em.I18n.t('dashboard.widgets.HBaseRegionsInTransition'),
+    threshold: [3, 10],
+    isHiddenByDefault: true
+  },
+  {
+    id: 16,
+    viewName: 'HBaseMasterUptimeView',
+    sourceName: 'HBASE',
+    title: Em.I18n.t('dashboard.widgets.HBaseMasterUptime'),
+    threshold: []
+  },
+  {
+    id: 17,
+    viewName: 'ResourceManagerHeapPieChartView',
+    sourceName: 'YARN',
+    title: Em.I18n.t('dashboard.widgets.ResourceManagerHeap'),
+    threshold: [70, 90]
+  },
+  {
+    id: 18,
+    viewName: 'ResourceManagerUptimeView',
+    sourceName: 'YARN',
+    title: Em.I18n.t('dashboard.widgets.ResourceManagerUptime'),
+    threshold: []
+  },
+  {
+    id: 19,
+    viewName: 'NodeManagersLiveView',
+    sourceName: 'YARN',
+    title: Em.I18n.t('dashboard.widgets.NodeManagersLive'),
+    threshold: [50, 75]
+  },
+  {
+    id: 20,
+    viewName: 'YARNMemoryPieChartView',
+    sourceName: 'YARN',
+    title: Em.I18n.t('dashboard.widgets.YARNMemory'),
+    threshold: [50, 75]
+  },
+  {
+    id: 21,
+    viewName: 'SuperVisorUpView',
+    sourceName: 'STORM',
+    title: Em.I18n.t('dashboard.widgets.SuperVisorUp'),
+    threshold: [85, 95]
+  },
+  {
+    id: 22,
+    viewName: 'FlumeAgentUpView',
+    sourceName: 'FLUME',
+    title: Em.I18n.t('dashboard.widgets.FlumeAgentUp'),
+    threshold: [85, 95]
+  },
+  {
+    id: 23,
+    viewName: 'YARNLinksView',
+    sourceName: 'YARN',
+    title: Em.I18n.t('dashboard.widgets.YARNLinks'),
+    threshold: []
+  },
+  {
+    id: 24,
+    viewName: 'HawqSegmentUpView',
+    sourceName: 'HAWQ',
+    title: Em.I18n.t('dashboard.widgets.HawqSegmentUp'),
+    threshold: [75, 90]
+  },
+  {
+    id: 25,
+    viewName: 'PxfUpView',
+    sourceName: 'PXF',
+    title: Em.I18n.t('dashboard.widgets.PxfUp'),
+    threshold: []
+  }
+];
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/05c76ed6/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 81833f3..5d69b53 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -2860,7 +2860,7 @@ Em.I18n.translations = {
   'dashboard.widgets.NodeManagersLive': 'NodeManagers Live',
   'dashboard.widgets.YARNMemory': 'YARN Memory',
   'dashboard.widgets.YARNLinks': 'YARN Links',
-  'dashboard.widgets.error.invalid': 'Invalid! Enter a number between 0 - {0}',
+  'dashboard.widgets.error.invalid': 'Invalid! Enter a number between {0} - {1}',
   'dashboard.widgets.error.smaller': 'Threshold 1 should be smaller than threshold 2!',
   'dashboard.widgets.HawqSegmentUp': 'HAWQ Segments Live',
   'dashboard.widgets.PxfUp': 'PXF Agents Live',

http://git-wip-us.apache.org/repos/asf/ambari/blob/05c76ed6/ambari-web/app/mixins/common/track_request_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/track_request_mixin.js b/ambari-web/app/mixins/common/track_request_mixin.js
index c665253..dd97b97 100644
--- a/ambari-web/app/mixins/common/track_request_mixin.js
+++ b/ambari-web/app/mixins/common/track_request_mixin.js
@@ -38,14 +38,14 @@ App.TrackRequestMixin = Em.Mixin.create({
     this.get('requestsInProgress').pushObject({
       request: request,
       id: requestId,
-      status: request.state(),
-      completed: ['resolved', 'rejected'].contains(request.state())
+      status: Em.tryInvoke(request, 'state'),
+      completed: ['resolved', 'rejected'].contains(Em.tryInvoke(request, 'state'))
     });
     request.always(function() {
       var requestInProgress = self.get('requestsInProgress').findProperty('id', requestId) || {};
       Em.setProperties(requestInProgress, {
         completed: true,
-        status: request.state()
+        status: Em.tryInvoke(request, 'state')
       });
     });
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/05c76ed6/ambari-web/app/mixins/main/dashboard/widgets/editable.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/dashboard/widgets/editable.js b/ambari-web/app/mixins/main/dashboard/widgets/editable.js
index fcb6bfb..482ff6a 100644
--- a/ambari-web/app/mixins/main/dashboard/widgets/editable.js
+++ b/ambari-web/app/mixins/main/dashboard/widgets/editable.js
@@ -20,93 +20,22 @@ var App = require('app');
 
 App.EditableWidgetMixin = Em.Mixin.create({
 
-  hintInfo: '',
-
   editWidget: function () {
-    var self = this;
-    var configObj = Ember.Object.create({
-      thresholdMin: self.get('thresholdMin') + '',
-      thresholdMax: self.get('thresholdMax') + '',
-      hintInfo: self.get('hintInfo'),
-      isThresh1Error: false,
-      isThresh2Error: false,
-      errorMessage1: "",
-      errorMessage2: "",
-      maxValue: 'infinity',
-      observeNewThresholdValue: function () {
-        var thresholdMin = this.get('thresholdMin');
-        var thresholdMax = this.get('thresholdMax');
-        if (thresholdMin.trim() !== "") {
-          if (isNaN(thresholdMin) || thresholdMin < 0) {
-            this.set('isThresh1Error', true);
-            this.set('errorMessage1', 'Invalid! Enter a number larger than 0');
-          } else if ( this.get('isThresh2Error') === false && parseFloat(thresholdMax)<= parseFloat(thresholdMin)){
-            this.set('isThresh1Error', true);
-            this.set('errorMessage1', 'Threshold 1 should be smaller than threshold 2 !');
-          } else {
-            this.set('isThresh1Error', false);
-            this.set('errorMessage1', '');
-          }
-        } else {
-          this.set('isThresh1Error', true);
-          this.set('errorMessage1', 'This is required');
-        }
-
-        if (thresholdMax.trim() !== "") {
-          if (isNaN(thresholdMax) || thresholdMax < 0) {
-            this.set('isThresh2Error', true);
-            this.set('errorMessage2', 'Invalid! Enter a number larger than 0');
-          } else {
-            this.set('isThresh2Error', false);
-            this.set('errorMessage2', '');
-          }
-        } else {
-          this.set('isThresh2Error', true);
-          this.set('errorMessage2', 'This is required');
-        }
+    return App.EditDashboardWidgetPopup.show({
 
-      }.observes('thresholdMin', 'thresholdMax')
+      widgetView: this,
 
-    });
-
-    App.ModalPopup.show({
-      header: Em.I18n.t('dashboard.widgets.popupHeader'),
-      classNames: [ 'modal-edit-widget'],
-      modalDialogClasses: ['modal-lg'],
-      bodyClass: Ember.View.extend({
-        templateName: require('templates/main/dashboard/edit_widget_popup'),
-        configPropertyObj: configObj
+      sliderHandlersManager: App.EditDashboardWidgetPopup.DoubleHandlers.create({
+        maxValue: 'infinity',
+        thresholdMin: this.get('thresholdMin'),
+        thresholdMax: this.get('thresholdMax')
       }),
-      primary: Em.I18n.t('common.apply'),
-      onPrimary: function () {
-        configObj.observeNewThresholdValue();
-        if (!configObj.isThresh1Error && !configObj.isThresh2Error) {
-
-          var parent = self.get('parentView');
-          var userPreferences = parent.get('userPreferences');
-          userPreferences.threshold[Number(self.get('id'))] = [configObj.get('thresholdMin'), configObj.get('thresholdMax')];
-          parent.saveWidgetsSettings(userPreferences);
-          parent.renderWidgets();
-          this.hide();
-        }
-      },
 
-      didInsertElement: function () {
-        this._super();
-        var colors = [App.healthStatusGreen, App.healthStatusOrange, App.healthStatusRed]; //color green, orange ,red
-        var handlers = [33, 66]; //fixed value
+      sliderDisabled: true,
+      sliderHandlers: [33, 66],
+      sliderMaxValue: 100,
+      sliderColors: [App.healthStatusGreen, App.healthStatusOrange, App.healthStatusRed]
 
-        $("#slider-range").slider({
-          range: true,
-          disabled: true, //handlers cannot move
-          min: 0,
-          max: 100,
-          values: handlers,
-          create: function (event, ui) {
-            self.updateColors(handlers, colors);
-          }
-        });
-      }
     });
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/05c76ed6/ambari-web/app/mixins/main/dashboard/widgets/editable_with_limit.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/dashboard/widgets/editable_with_limit.js b/ambari-web/app/mixins/main/dashboard/widgets/editable_with_limit.js
index ddf2a26..1cb96df 100644
--- a/ambari-web/app/mixins/main/dashboard/widgets/editable_with_limit.js
+++ b/ambari-web/app/mixins/main/dashboard/widgets/editable_with_limit.js
@@ -23,110 +23,18 @@ var App = require('app');
  */
 App.EditableWithLimitWidgetMixin = Em.Mixin.create({
 
-  hintInfo: '',
-
   editWidget: function () {
-    var parent = this;
-    var maxTmp = parseFloat(parent.get('maxValue'));
-    var configObj = Ember.Object.create({
-      thresholdMin: parent.get('thresholdMin') + '',
-      thresholdMax: parent.get('thresholdMax') + '',
-      hintInfo: parent.get('hintInfo'),
-      thresholdMinError: false,
-      thresholdMaxError: false,
-      thresholdMinErrorMessage: '',
-      thresholdMaxErrorMessage: '',
-      maxValue: maxTmp,
-      observeNewThresholdValue: function () {
-        var thresholdMin = this.get('thresholdMin');
-        var thresholdMax = this.get('thresholdMax');
-        if (thresholdMin.trim() !== '') {
-          if (isNaN(thresholdMin) || thresholdMin > maxTmp || thresholdMin < 0){
-            this.set('thresholdMinError', true);
-            this.set('thresholdMinErrorMessage', 'Invalid! Enter a number between 0 - ' + maxTmp);
-          } else if ( this.get('thresholdMaxError') === false && parseFloat(thresholdMax)<= parseFloat(thresholdMin)) {
-            this.set('thresholdMinError', true);
-            this.set('thresholdMinErrorMessage', 'Threshold 1 should be smaller than threshold 2 !');
-          } else {
-            this.set('thresholdMinError', false);
-            this.set('thresholdMinErrorMessage', '');
-          }
-        } else {
-          this.set('thresholdMinError', true);
-          this.set('thresholdMinErrorMessage', 'This is required');
-        }
-
-        if (thresholdMax.trim() !== '') {
-          if (isNaN(thresholdMax) || thresholdMax > maxTmp || thresholdMax < 0) {
-            this.set('thresholdMaxError', true);
-            this.set('thresholdMaxErrorMessage', 'Invalid! Enter a number between 0 - ' + maxTmp);
-          } else {
-            this.set('thresholdMaxError', false);
-            this.set('thresholdMaxErrorMessage', '');
-          }
-        } else {
-          this.set('thresholdMaxError', true);
-          this.set('thresholdMaxErrorMessage', 'This is required');
-        }
-
-        // update the slider handles and color
-        if (!this.get('thresholdMinError') && !this.get('thresholdMaxError')) {
-          $("#slider-range").slider('values', 0 , parseFloat(thresholdMin));
-          $("#slider-range").slider('values', 1 , parseFloat(thresholdMax));
-        }
-      }.observes('thresholdMin', 'thresholdMax')
-
-    });
 
-    App.ModalPopup.show({
-      header: Em.I18n.t('dashboard.widgets.popupHeader'),
-      classNames: ['modal-edit-widget'],
-      modalDialogClasses: ['modal-lg'],
-      bodyClass: Ember.View.extend({
-        templateName: require('templates/main/dashboard/edit_widget_popup'),
-        configPropertyObj: configObj
-      }),
-      primary: Em.I18n.t('common.apply'),
-      onPrimary: function () {
-        configObj.observeNewThresholdValue();
-        if (!configObj.thresholdMinError && !configObj.thresholdMaxError) {
-          parent.set('thresholdMin', parseFloat(configObj.get('thresholdMin')) );
-          parent.set('thresholdMax', parseFloat(configObj.get('thresholdMax')) );
-          if (!App.get('testMode')) {
-            var bigParent = parent.get('parentView');
-            bigParent.getUserPref(bigParent.get('persistKey'));
-            var oldValue = bigParent.get('currentPrefObject');
-            oldValue.threshold[parseInt(parent.id, 10)] = [configObj.get('thresholdMin'), configObj.get('thresholdMax')];
-            bigParent.postUserPref(bigParent.get('persistKey'),oldValue);
-          }
-          this.hide();
-        }
-      },
+    return App.EditDashboardWidgetPopup.show({
 
-      didInsertElement: function () {
-        this._super();
-        var handlers = [configObj.get('thresholdMin'), configObj.get('thresholdMax')];
-        var colors = [App.healthStatusRed, App.healthStatusOrange, App.healthStatusGreen]; //color red, orange, green
+      widgetView: this,
 
-        $("#slider-range").slider({
-          range: true,
-          min: 0,
-          max: maxTmp,
-          values: handlers,
-          create: function () {
-            parent.updateColors(handlers, colors);
-          },
-          slide: function (event, ui) {
-            parent.updateColors(ui.values, colors);
-            configObj.set('thresholdMin', ui.values[0] + '');
-            configObj.set('thresholdMax', ui.values[1] + '');
-          },
-          change: function (event, ui) {
-            parent.updateColors(ui.values, colors);
-          }
-        });
+      sliderHandlersManager: App.EditDashboardWidgetPopup.DoubleHandlers.create({
+        maxValue: parseFloat(this.get('maxValue')),
+        thresholdMin: this.get('thresholdMin'),
+        thresholdMax: this.get('thresholdMax')
+      })
 
-      }
     });
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/05c76ed6/ambari-web/app/mixins/main/dashboard/widgets/single_numeric_threshold.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/dashboard/widgets/single_numeric_threshold.js b/ambari-web/app/mixins/main/dashboard/widgets/single_numeric_threshold.js
index 06bcffe..36172b7 100644
--- a/ambari-web/app/mixins/main/dashboard/widgets/single_numeric_threshold.js
+++ b/ambari-web/app/mixins/main/dashboard/widgets/single_numeric_threshold.js
@@ -23,126 +23,25 @@ var App = require('app');
  */
 App.SingleNumericThresholdMixin = Em.Mixin.create({
 
-  /**
-   * @type {Em.Object}
-   * @class
-   */
-  widgetConfig: Ember.Object.extend({
-    thresholdMin: '',
-    hintInfo: '',
-    isThresh1Error: false,
-    errorMessage1: "",
-
-    maxValue: 0,
-    observeThresh1Value: function () {
-      var thresholdMin = this.get('thresholdMin');
-      var maxValue = this.get('maxValue');
-
-      if (thresholdMin.trim() !== "") {
-        if (isNaN(thresholdMin) || thresholdMin > maxValue || thresholdMin < 0) {
-          this.set('isThresh1Error', true);
-          this.set('errorMessage1', Em.I18n.t('dashboard.widgets.error.invalid').format(maxValue));
-        } else {
-          this.set('isThresh1Error', false);
-          this.set('errorMessage1', '');
-        }
-      } else {
-        this.set('isThresh1Error', true);
-        this.set('errorMessage1', Em.I18n.t('admin.users.editError.requiredField'));
-      }
-        this.updateSlider();
-    }.observes('thresholdMin', 'maxValue'),
-
-    updateSlider: function () {
-      var thresholdMin = this.get('thresholdMin');
-      // update the slider handles and color
-      if (this.get('isThresh1Error') === false) {
-        $("#slider-range")
-          .slider('values', 0, parseFloat(thresholdMin))
-      }
-    }
-  }),
-
-  /**
-   * edit widget
-   * @param {object} event
-   */
   editWidget: function () {
-    var parent = this;
-    var maxTmp = parseFloat(this.get('maxValue'));
-    var configObj = this.get('widgetConfig').create({
-      thresholdMin: this.get('thresholdMin') + '',
-      hintInfo: this.get('hintInfo') + '',
-      maxValue: parseFloat(this.get('maxValue'))
-    });
+    return App.EditDashboardWidgetPopup.show({
+
+      widgetView: this,
 
-    App.ModalPopup.show({
-        header: Em.I18n.t('dashboard.widgets.popupHeader'),
-        classNames: ['modal-edit-widget'],
-        modalDialogClasses: ['modal-lg'],
-        bodyClass: Ember.View.extend({
-          templateName: require('templates/main/dashboard/edit_widget_popup_single_threshold'),
-          configPropertyObj: configObj
-        }),
-        primary: Em.I18n.t('common.apply'),
-        onPrimary: function () {
-          configObj.observeThresh1Value();
-          if (!configObj.isThresh1Error) {
-            var bigParent = parent.get('parentView');
-            parent.set('thresholdMin', parseFloat(configObj.get('thresholdMin')));
-            if (!App.get('testMode')) {
-              // save to persist
-              var userPreferences = bigParent.get('userPreferences');
-              userPreferences.threshold[parseInt(parent.get('id'), 10)] = [configObj.get('thresholdMin')];
-              bigParent.saveWidgetsSettings(userPreferences);
-              bigParent.renderWidgets();
-            }
-            this.hide();
-          }
-        },
-        didInsertElement: function () {
-          this._super();
-          var handlers = [configObj.get('thresholdMin')];
-          var _this = this;
+      sliderHandlersManager: App.EditDashboardWidgetPopup.SingleHandler.create({
+        thresholdMin: this.get('thresholdMin'),
+        maxValue: parseFloat(this.get('maxValue'))
+      }),
 
-          $("#slider-range").slider({
-            range: false,
-            min: 0,
-            max: maxTmp,
-            values: handlers,
-            create: function () {
-              _this.updateColors(handlers);
-            },
-            slide: function (event, ui) {
-              _this.updateColors(ui.values);
-              configObj.set('thresholdMin', ui.values[0] + '');
-            },
-            change: function (event, ui) {
-              _this.updateColors(ui.values);
-            }
-          });
-        },
+      bodyClass: App.EditDashboardWidgetPopup.EditDashboardWidgetPopupBody.extend({
+        templateName: require('templates/main/dashboard/edit_widget_popup_single_threshold')
+      }),
 
-      updateColors: function (handlers) {
-        var colors = [App.healthStatusGreen, App.healthStatusRed]; //color green,red
-        var colorstops = colors[0] + ", "; // start with the first color
-        for (var i = 0; i < handlers.length; i++) {
-          colorstops += colors[i] + " " + handlers[i] * 100 / maxTmp + "%,";
-          colorstops += colors[i + 1] + " " + handlers[i] * 100 / maxTmp + "%,";
-        }
-        colorstops += colors[colors.length - 1];
-        var sliderElement = $('#slider-range');
-        var css1 = '-webkit-linear-gradient(left,' + colorstops + ')'; // chrome & safari
-        sliderElement.css('background-image', css1);
-        var css2 = '-ms-linear-gradient(left,' + colorstops + ')'; // IE 10+
-        sliderElement.css('background-image', css2);
-        var css3 = '-moz-linear-gradient(left,' + colorstops + ')'; // Firefox
-        sliderElement.css('background-image', css3);
+      sliderIsRange: false,
 
-        sliderElement.find('.ui-widget-header').css({'background-color': '#FF8E00', 'background-image': 'none'}); // change the  original ranger color
-      }
+      sliderColors: [App.healthStatusGreen, App.healthStatusRed]
 
-      });
+    });
 
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/05c76ed6/ambari-web/app/templates/main/dashboard/edit_widget_popup.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/dashboard/edit_widget_popup.hbs b/ambari-web/app/templates/main/dashboard/edit_widget_popup.hbs
index 7caf085..60c9741 100644
--- a/ambari-web/app/templates/main/dashboard/edit_widget_popup.hbs
+++ b/ambari-web/app/templates/main/dashboard/edit_widget_popup.hbs
@@ -18,7 +18,7 @@
 <form class="form-horizontal" autocomplete="off">
     <div class="each-row">
         <div class="alert alert-info">
-          {{{view.configPropertyObj.hintInfo}}}
+          {{{view.parentView.widgetView.hintInfo}}}
         </div>
     </div>
 
@@ -32,20 +32,20 @@
         <div id="slider-value1" class="value-on-slider col-md-2">
           <input type="text" value="0" disabled="disabled" class="form-control" />
         </div>
-        <div id="slider-value2" {{bindAttr class="view.configPropertyObj.thresholdMinError:slider-error :value-on-slider :col-md-4 view.configPropertyObj.thresholdMinError:has-error"}}>
-          {{view Ember.TextField class="form-control" valueBinding="view.configPropertyObj.thresholdMin"}}
-          {{#if view.configPropertyObj.thresholdMinErrorMessage}}
-            <span class="help-block validation-block">{{view.configPropertyObj.thresholdMinErrorMessage}}</span>
+        <div id="slider-value2" {{bindAttr class="view.parentView.sliderHandlersManager.thresholdMinError:slider-error :value-on-slider :col-md-4 view.parentView.sliderHandlersManager.thresholdMinError:has-error"}}>
+          {{view Ember.TextField class="form-control" valueBinding="view.parentView.sliderHandlersManager.thresholdMin"}}
+          {{#if view.parentView.sliderHandlersManager.thresholdMinError}}
+            <span class="help-block validation-block">{{view.parentView.sliderHandlersManager.thresholdMinErrorMessage}}</span>
           {{/if}}
         </div>
-        <div id="slider-value3" {{bindAttr class="view.configPropertyObj.thresholdMaxError:slider-error :value-on-slider :col-md-4 view.configPropertyObj.thresholdMaxError:has-error"}}>
-          {{view Ember.TextField class="form-control" valueBinding="view.configPropertyObj.thresholdMax"}}
-          {{#if view.configPropertyObj.thresholdMaxErrorMessage}}
-            <span class="help-block validation-block">{{view.configPropertyObj.thresholdMaxErrorMessage}}</span>
+        <div id="slider-value3" {{bindAttr class="view.parentView.sliderHandlersManager.thresholdMaxError:slider-error :value-on-slider :col-md-4 view.parentView.sliderHandlersManager.thresholdMaxError:has-error"}}>
+          {{view Ember.TextField class="form-control" valueBinding="view.parentView.sliderHandlersManager.thresholdMax"}}
+          {{#if view.parentView.sliderHandlersManager.thresholdMaxError}}
+            <span class="help-block validation-block">{{view.parentView.sliderHandlersManager.thresholdMaxErrorMessage}}</span>
           {{/if}}
         </div>
         <div id="slider-value4" class="value-on-slider col-md-2">
-          {{view Em.TextField valueBinding="view.configPropertyObj.maxValue" classNames="form-control" disabled="disabled"}}
+          {{view Em.TextField valueBinding="view.parentView.sliderHandlersManager.maxValue" classNames="form-control" disabled="disabled"}}
         </div>
     </div>
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/05c76ed6/ambari-web/app/templates/main/dashboard/edit_widget_popup_single_threshold.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/dashboard/edit_widget_popup_single_threshold.hbs b/ambari-web/app/templates/main/dashboard/edit_widget_popup_single_threshold.hbs
index 86ffb47..416852e 100644
--- a/ambari-web/app/templates/main/dashboard/edit_widget_popup_single_threshold.hbs
+++ b/ambari-web/app/templates/main/dashboard/edit_widget_popup_single_threshold.hbs
@@ -19,7 +19,7 @@
 <form class="form-horizontal" autocomplete="off">
   <div class="each-row">
     <div class="alert alert-info">
-      {{{view.configPropertyObj.hintInfo}}}
+      {{{view.parentView.widgetView.hintInfo}}}
     </div>
   </div>
 
@@ -33,14 +33,14 @@
     <div id="slider-value1" class="value-on-slider col-md-2">
       <input type="text" value="0" disabled="disabled" class="form-control" />
     </div>
-      <div id="slider-value2" {{bindAttr class="view.configPropertyObj.isThresh1Error:slider-error :value-on-slider :col-md-4 :col-md-offset-2 :col-sm-offset-2 view.configPropertyObj.isThresh1Error:has-error"}}>
-        {{view Ember.TextField valueBinding="view.configPropertyObj.thresholdMin" class="form-control"}}
-        {{#if view.configPropertyObj.errorMessage1}}
-          <span class="help-block validation-block">{{view.configPropertyObj.errorMessage1}}</span>
+      <div id="slider-value2" {{bindAttr class="view.parentView.sliderHandlersManager.thresholdMinError:slider-error :value-on-slider :col-md-4 :col-md-offset-2 :col-sm-offset-2 view.parentView.sliderHandlersManager.thresholdMinError:has-error"}}>
+        {{view Ember.TextField valueBinding="view.parentView.sliderHandlersManager.thresholdMin" class="form-control"}}
+        {{#if view.parentView.sliderHandlersManager.thresholdMinErrorMessage}}
+          <span class="help-block validation-block">{{view.parentView.sliderHandlersManager.thresholdMinErrorMessage}}</span>
         {{/if}}
       </div>
     <div id="slider-value3" class="value-on-slider col-md-2 col-md-offset-2 col-sm-offset-2">
-      {{view Em.TextField valueBinding="view.configPropertyObj.maxValue" classNames="form-control" disabled="disabled"}}
+      {{view Em.TextField valueBinding="view.parentView.sliderHandlersManager.maxValue" classNames="form-control" disabled="disabled"}}
     </div>
   </div>
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/05c76ed6/ambari-web/app/views.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js
index 77b5d5a..6972d2a 100644
--- a/ambari-web/app/views.js
+++ b/ambari-web/app/views.js
@@ -33,6 +33,7 @@ require('views/common/chart/linear');
 require('views/common/chart/linear_time');
 require('views/common/modal_popup');
 require('views/common/modal_popups/alert_popup');
+require('views/common/modal_popups/edit_dashboard_widget_popup');
 require('views/common/modal_popups/manage_kdc_credentials_popup');
 require('views/common/modal_popups/confirmation_feedback_popup');
 require('views/common/modal_popups/confirmation_popup');

http://git-wip-us.apache.org/repos/asf/ambari/blob/05c76ed6/ambari-web/app/views/common/modal_popups/edit_dashboard_widget_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/modal_popups/edit_dashboard_widget_popup.js b/ambari-web/app/views/common/modal_popups/edit_dashboard_widget_popup.js
new file mode 100644
index 0000000..7ea1b32
--- /dev/null
+++ b/ambari-web/app/views/common/modal_popups/edit_dashboard_widget_popup.js
@@ -0,0 +1,436 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+const {isValidFloat} = require('utils/validator');
+
+/**
+ * Thresholds manager for sliders with single value
+ * Usage:
+ * <pre>
+ * SingleHandler.create({
+ *    thresholdMin: 12,
+ *    minValue: 10,
+ *    maxValue: 100
+ * });
+ * </pre>
+ *
+ * @class SingleHandler
+ */
+const SingleHandler = Em.Object.extend({
+
+  /**
+   * @type {number}
+   */
+  thresholdMin: null,
+
+  /**
+   * @type {number}
+   * @default 0
+   */
+  minValue: 0,
+
+  /**
+   * @type {number}
+   */
+  maxValue: null,
+
+  /**
+   * Is <code>thresholdMin</code> invalid
+   * true - invalid
+   * false - valid
+   *
+   * @type {boolean}
+   */
+  thresholdMinError: Em.computed.bool('thresholdMinErrorMessage'),
+
+  /**
+   * Alias for <code>thresholdMinError</code>
+   *
+   * @type {boolean}
+   */
+  hasErrors: Em.computed.alias('thresholdMinError'),
+
+  /**
+   * Error message for <code>thresholdMin</code>
+   * <ul>
+   *  <li>Value is not a number</li>
+   *  <li>Value is out of range <code>(minValue - maxValue)</code></li>
+   * </ul>
+   * Empty message means that <code>thresholdMin</code> has valid value
+   *
+   * @type {string}
+   */
+  thresholdMinErrorMessage: function () {
+    var thresholdMin = this.get('thresholdMin');
+    var maxValue = this.get('maxValue');
+    var minValue = this.get('minValue');
+    if (!isValidFloat(thresholdMin) || thresholdMin > maxValue || thresholdMin < minValue) {
+      return Em.I18n.t('dashboard.widgets.error.invalid').format(minValue, maxValue);
+    }
+    return '';
+  }.property('thresholdMin', 'maxValue'),
+
+  /**
+   * Formatted threshold value
+   *
+   * @type {number[]}
+   */
+  preparedThresholds: function () {
+    return [parseFloat(this.get('thresholdMin'))];
+  }.property('thresholdMin'),
+
+  /**
+   * Force set new values for threshold
+   *
+   * @param {number[]} newValues
+   */
+  updateThresholds(newValues) {
+    this.set('thresholdMin', newValues[0]);
+  }
+
+});
+
+/**
+ * Thresholds manager for sliders with double values
+ * Usage:
+ * <pre>
+ * SingleHandler.create({
+ *    thresholdMin: 12,
+ *    thresholdMax: 40,
+ *    minValue: 10,
+ *    maxValue: 100
+ * });
+ * </pre>
+ *
+ * @class DoubleHandlers
+ */
+const DoubleHandlers = SingleHandler.extend({
+
+  /**
+   * @type {number}
+   */
+  thresholdMax: null,
+
+  /**
+   * Is <code>thresholdMax</code> invalid
+   * true - invalid
+   * false - valid
+   *
+   * @type {boolean}
+   */
+  thresholdMaxError: Em.computed.bool('thresholdMaxErrorMessage'),
+
+  /**
+   * Is some threshold invalid
+   * true - some one is invalid
+   * false - thresholds are valid
+   *
+   * @type {boolean}
+   */
+  hasErrors: Em.computed.or('thresholdMinError', 'thresholdMaxError'),
+
+  /**
+   * Error message for <code>thresholdMin</code>
+   * <ul>
+   *  <li>Value is not a number</li>
+   *  <li>Value is out of range <code>(minValue - maxValue)</code></li>
+   *  <li><code>thresholdMin</code>-value greater than <code>thresholdMax</code>-value</li>
+   * </ul>
+   * Empty message means that <code>thresholdMin</code> has valid value
+   *
+   * @type {string}
+   */
+  thresholdMinErrorMessage: function () {
+    var thresholdMin = this.get('thresholdMin');
+    var thresholdMax = this.get('thresholdMax');
+    var maxValue = this.get('maxValue');
+    var minValue = this.get('minValue');
+    if (!isValidFloat(thresholdMin) || thresholdMin > maxValue || thresholdMin < minValue) {
+      return Em.I18n.t('dashboard.widgets.error.invalid').format(minValue, maxValue);
+    }
+    if (this.get('thresholdMaxError') === false && thresholdMax <= thresholdMin) {
+      return Em.I18n.t('dashboard.widgets.error.smaller');
+    }
+    return '';
+  }.property('thresholdMin', 'thresholdMax'),
+
+  /**
+   * Error message for <code>thresholdMax</code>
+   * <ul>
+   *  <li>Value is not a number</li>
+   *  <li>Value is out of range <code>(minValue - maxValue)</code></li>
+   * </ul>
+   * Empty message means that <code>thresholdMax</code> has valid value
+   *
+   * @type {string}
+   */
+  thresholdMaxErrorMessage: function () {
+    var thresholdMax = this.get('thresholdMax');
+    var maxValue = this.get('maxValue');
+    var minValue = this.get('minValue');
+    if (!isValidFloat(thresholdMax) || thresholdMax > maxValue || thresholdMax < minValue) {
+      return Em.I18n.t('dashboard.widgets.error.invalid').format(minValue, maxValue);
+    }
+    return '';
+  }.property('thresholdMax'),
+
+  /**
+   * Threshold values ready to save
+   *
+   * @type {number[]}
+   */
+  preparedThresholds: function () {
+    return [parseFloat(this.get('thresholdMin')), parseFloat(this.get('thresholdMax'))];
+  }.property('thresholdMin', 'thresholdMax'),
+
+  /**
+   * Force set new values for threshold
+   *
+   * @param {number[]} newValues
+   */
+  updateThresholds(newValues) {
+    this.set('thresholdMin', newValues[0]);
+    this.set('thresholdMax', newValues[1]);
+  }
+
+});
+
+/**
+ * Common body-view for popup with sliders
+ *
+ * @class EditDashboardWidgetPopupBody
+ */
+const EditDashboardWidgetPopupBody = Em.View.extend({
+  templateName: require('templates/main/dashboard/edit_widget_popup')
+});
+
+/**
+ * Popup with slider to edit dashboard widget
+ * Usage:
+ * <pre>
+ *   App.EditDashboardWidgetPopup.show({
+ *    widgetView: this,
+ *    sliderHandlersManager: App.EditDashboardWidgetPopup.DoubleHandlers.create({
+ *      maxValue: 100,
+ *      thresholdMin: this.get('thresholdMin'),
+ *      thresholdMax: this.get('thresholdMax')
+ *    })
+ *  });
+ * </pre>
+ *
+ * <code>widgetView</code> should be set to view with widget.
+ * Usually you will use <code>App.EditDashboardWidgetPopup</code> inside of some <code>App.DashboardWidgetView</code> instance,
+ * so <code>widgetView</code> may be set to <code>this</code>
+ * <code>sliderHandlersManager</code> should be set to some of the <code>App.EditDashboardWidgetPopup.SingleHandler</code>
+ * or <code>App.EditDashboardWidgetPopup.DoubleHandler</code>
+ *
+ * You can't use <code>App.EditDashboardWidgetPopup</code> without setting this two properties!
+ *
+ * @class App.EditDashboardWidgetPopup
+ */
+App.EditDashboardWidgetPopup = App.ModalPopup.extend({
+
+  header: Em.I18n.t('dashboard.widgets.popupHeader'),
+  classNames: ['modal-edit-widget'],
+  modalDialogClasses: ['modal-lg'],
+  primary: Em.I18n.t('common.apply'),
+  disablePrimary: Em.computed.alias('sliderHandlersManager.hasErrors'),
+
+  /**
+   * Can't be null or undefined
+   *
+   * @type {SingleHandler|DoubleHandlers}
+   */
+  sliderHandlersManager: null,
+
+  /**
+   * Widget view
+   * Can't be not a view. Used to save Thresholds. Normally it's an instance of <code>App.DashboardWidgetView</code>
+   *
+   * @type {Em.View}
+   */
+  widgetView: null,
+
+  /**
+   * Determines if slider is enabled for slide
+   * true - don't enabled
+   * false - enabled
+   *
+   * Determines if slider handlers should be updated with Threshold values
+   * true - don't update
+   * false - update
+   *
+   * Used as option <code>disabled</code> for $.ui.slider
+   *
+   * @type {boolean}
+   */
+  sliderDisabled: false,
+
+  /**
+   * Slider "ticks"
+   * Used as option <code>values</code> for $.ui.slider
+   *
+   * @type {number[]}
+   */
+  sliderHandlers: function () {
+    return this.get('sliderHandlersManager.preparedThresholds');
+  }.property('sliderHandlersManager.preparedThresholds.[]'),
+
+  /**
+   * Colors used for slider ranges
+   * @type {string[]}
+   */
+  sliderColors: [App.healthStatusRed, App.healthStatusOrange, App.healthStatusGreen],
+
+  /**
+   * Maximum value for slider
+   * Used as option <code>max</code> for $.ui.slider
+   *
+   * @type {number}
+   */
+  sliderMaxValue: Em.computed.alias('sliderHandlersManager.maxValue'),
+
+  /**
+   * Minimum value for slider
+   * Used as option <code>min</code> for $.ui.slider
+   *
+   * @type {number}
+   */
+  sliderMinValue: 0,
+
+  /**
+   * Check how many handlers has slider
+   * true - 2 handlers
+   * false - 1 handler
+   *
+   * Used as option <code>range</code> for $.ui.slider
+   *
+   * @type {boolean}
+   */
+  sliderIsRange: true,
+
+  bodyClass: EditDashboardWidgetPopupBody,
+
+  init() {
+    Em.assert('`widgetView` should be valid view', this.get('widgetView.isView'));
+    Em.assert('`sliderHandlersManager` should be set', !!this.get('sliderHandlersManager'));
+    return this._super(...arguments);
+  },
+
+  /**
+   * Save new threshold value on popup-close (means Primary click)
+   * Use <code>widgetView</code> to get <code>widgetsView</code> and save new values
+   * Current widget is updated too (without redrawing)
+   */
+  saveThreshold () {
+    let preparedThresholds = this.get('sliderHandlersManager.preparedThresholds');
+    this.get('widgetView').saveWidgetThresholds(preparedThresholds);
+  },
+
+  /**
+   * Update slider values when new threshold values are provided
+   * Don't do anything if some value is invalid or slider is disabled
+   *
+   * @private
+   */
+  _updateSliderValues: function() {
+    var sliderHandlersManager = this.get('sliderHandlersManager');
+    if (!sliderHandlersManager.get('hasErrors') && !this.get('sliderDisabled')) {
+      $('#slider-range').slider('values', sliderHandlersManager.get('preparedThresholds'));
+    }
+  }.observes('sliderDisabled', 'sliderHandlersManager.preparedThresholds.[]', 'sliderHandlersManager.hasErrors'),
+
+  onPrimary () {
+    let sliderHandlersManager = this.get('sliderHandlersManager');
+    if (!sliderHandlersManager.get('hasErrors')) {
+      this.saveThreshold();
+      this.hide();
+    }
+  },
+
+  /**
+   * Create slider in the popup when it's opened
+   */
+  createSlider() {
+    var self = this;
+    let sliderHandlersManager = this.get('sliderHandlersManager');
+    var handlers = this.get('sliderHandlers');
+
+    $('#slider-range').slider({
+      range: this.get('sliderIsRange'),
+      min: this.get('sliderMinValue'),
+      max: this.get('sliderMaxValue'),
+      disabled: this.get('sliderDisabled'),
+      values: handlers,
+      create: function () {
+        self.updateSliderColors(handlers);
+      },
+      slide: function (event, ui) {
+        self.updateSliderColors(ui.values);
+        sliderHandlersManager.updateThresholds(ui.values);
+      },
+      change: function (event, ui) {
+        self.updateSliderColors(ui.values);
+      }
+    });
+  },
+
+  didInsertElement: function () {
+    this._super();
+    this.createSlider();
+  },
+
+  /**
+   * Update colors on slider using <code>sliderColors</code> theme when user interacts with it
+   *
+   * @param {number[]} handlers
+   */
+  updateSliderColors(handlers) {
+    let gradient = this._getGradientStr(handlers);
+    $('#slider-range')
+      .css('background-image', '-webkit-' + gradient)
+      .css('background-image', '-ms-' + gradient)
+      .css('background-image', '-moz-' + gradient)
+      .find('.ui-widget-header').css({
+        'background-color': App.healthStatusOrange,
+        'background-image': 'none'
+      });
+  },
+
+  /**
+   * @param {number[]} handlers
+   * @returns {string}
+   * @private
+   */
+  _getGradientStr(handlers) {
+    let maxValue = this.get('sliderMaxValue');
+    let colors = this.get('sliderColors');
+    let gradient = colors[0] + ', ' + handlers.map((handler, i) => {
+        return `${colors[i]}  ${handlers[i] * 100 / maxValue}%, ${colors[i + 1]} ${handlers[i] * 100 / maxValue}%,`;
+      }).join('') + colors[colors.length - 1];
+    return `linear-gradient(left,${gradient})`;
+  }
+
+});
+
+App.EditDashboardWidgetPopup.reopenClass({
+  SingleHandler,
+  DoubleHandlers,
+  EditDashboardWidgetPopupBody
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/05c76ed6/ambari-web/app/views/main/dashboard/widget.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widget.js b/ambari-web/app/views/main/dashboard/widget.js
index e7a626c..9fba906 100644
--- a/ambari-web/app/views/main/dashboard/widget.js
+++ b/ambari-web/app/views/main/dashboard/widget.js
@@ -30,9 +30,19 @@ App.DashboardWidgetView = Em.View.extend({
 
   sourceName: Em.computed.alias('widget.sourceName'),
 
+  /**
+   * Bound from template
+   *
+   * @type {object}
+   */
   widget: null,
 
   /**
+   * @type {Em.View}
+   */
+  widgetsView: Em.computed.alias('parentView'),
+
+  /**
    * @type {object} - record from model that serve as data source
    */
   model: function () {
@@ -79,6 +89,11 @@ App.DashboardWidgetView = Em.View.extend({
   hiddenInfoClass: "hidden-info-two-line",
 
   /**
+   * @type {string}
+   */
+  hintInfo: Em.computed.i18nFormat('dashboard.widgets.hintInfo.common', 'maxValue'),
+
+  /**
    * @type {number}
    * @default 0
    */
@@ -100,61 +115,6 @@ App.DashboardWidgetView = Em.View.extend({
    */
   isDataLoadedBinding: 'App.router.clusterController.isServiceContentFullyLoaded',
 
-  /**
-   * @type {Em.Object}
-   * @class
-   */
-  widgetConfig: Ember.Object.extend({
-    thresholdMin: '',
-    thresholdMax: '',
-    hintInfo: Em.computed.i18nFormat('dashboard.widgets.hintInfo.common', 'maxValue'),
-    thresholdMinError: false,
-    thresholdMaxError: false,
-    thresholdMinErrorMessage: "",
-    thresholdMaxErrorMessage: "",
-    maxValue: 0,
-    validateThreshold: function(thresholdName) {
-      var thresholdMin = this.get('thresholdMin'),
-       thresholdMax = this.get('thresholdMax'),
-       maxValue = this.get('maxValue'),
-       currentThreshold = this.get(thresholdName),
-       isError = false,
-       errorMessage = '';
-
-      if (currentThreshold.trim() !== "") {
-        if (isNaN(currentThreshold) || currentThreshold > maxValue || currentThreshold < 0) {
-          isError = true;
-          errorMessage = Em.I18n.t('dashboard.widgets.error.invalid').format(maxValue);
-        } else if (parseFloat(thresholdMax) <= parseFloat(thresholdMin)) {
-          isError = true;
-          errorMessage = Em.I18n.t('dashboard.widgets.error.smaller');
-        } else {
-          isError = false;
-          errorMessage = '';
-        }
-      } else {
-        isError = true;
-        errorMessage = Em.I18n.t('admin.users.editError.requiredField');
-      }
-      this.set(thresholdName + 'ErrorMessage', errorMessage);
-      this.set(thresholdName + 'Error', isError);
-      this.updateSlider();
-    },
-    observeThreshMinValue: function () {
-      this.validateThreshold('thresholdMin');
-    }.observes('thresholdMin', 'maxValue'),
-    observeThreshMaxValue: function () {
-      this.validateThreshold('thresholdMax');
-    }.observes('thresholdMax', 'maxValue'),
-    updateSlider: function () {
-      if (this.get('thresholdMinError') === false && this.get('thresholdMaxError') === false) {
-        $("#slider-range")
-          .slider('values', 0, parseFloat(this.get('thresholdMin')))
-          .slider('values', 1, parseFloat(this.get('thresholdMax')));
-      }
-    }
-  }),
-
   didInsertElement: function () {
     App.tooltip(this.$("[rel='ZoomInTooltip']"), {
       placement: 'left',
@@ -190,97 +150,36 @@ App.DashboardWidgetView = Em.View.extend({
   },
 
   /**
-   * edit widget
+   * Update thresholds for widget and save this them to persist
+   *
+   * @param {number[]} preparedThresholds
    */
-  editWidget: function () {
-    var configObj = this.get('widgetConfig').create({
-      thresholdMin: this.get('thresholdMin') + '',
-      thresholdMax: this.get('thresholdMax') + '',
-      maxValue: parseFloat(this.get('maxValue'))
-    });
-    this.showEditDialog(configObj);
+  saveWidgetThresholds(preparedThresholds) {
+    const widgetsView = this.get('widgetsView');
+    const userPreferences = widgetsView.get('userPreferences');
+    const widgetId = Number(this.get('id'));
+    userPreferences.threshold[widgetId] = preparedThresholds;
+    this.set('widget.threshold', userPreferences.threshold[widgetId]);
+    widgetsView.saveWidgetsSettings(userPreferences);
   },
 
   /**
-   *  show edit dialog
-   * @param {Em.Object} configObj
-   * @returns {App.ModalPopup}
+   * edit widget
    */
-  showEditDialog: function (configObj) {
-    var self = this;
-    var maxValue = this.get('maxValue');
-
-    return App.ModalPopup.show({
-      header: Em.I18n.t('dashboard.widgets.popupHeader'),
-      classNames: ['modal-edit-widget'],
-      modalDialogClasses: ['modal-lg'],
-      bodyClass: Ember.View.extend({
-        templateName: require('templates/main/dashboard/edit_widget_popup'),
-        configPropertyObj: configObj
-      }),
-      configObj: configObj,
-      disablePrimary: Em.computed.or('configObj.thresholdMinError', 'configObj.thresholdMaxError'),
-      primary: Em.I18n.t('common.apply'),
-      onPrimary: function () {
-        configObj.observeThreshMinValue();
-        configObj.observeThreshMaxValue();
-        if (!configObj.thresholdMinError && !configObj.thresholdMaxError) {
-          self.set('thresholdMin', parseFloat(configObj.get('thresholdMin')));
-          self.set('thresholdMax', parseFloat(configObj.get('thresholdMax')));
-
-          var parent = self.get('parentView');
-          var userPreferences = parent.get('userPreferences');
-          userPreferences.threshold[Number(self.get('id'))] = [configObj.get('thresholdMin'), configObj.get('thresholdMax')];
-          parent.saveWidgetsSettings(userPreferences);
-          parent.renderWidgets();
-
-          this.hide();
-        }
-      },
+  editWidget: function () {
+    return App.EditDashboardWidgetPopup.show({
 
-      didInsertElement: function () {
-        this._super();
-        var _this = this;
-        var handlers = [configObj.get('thresholdMin'), configObj.get('thresholdMax')];
+      widgetView: this,
 
-        $("#slider-range").slider({
-          range: true,
-          min: 0,
-          max: maxValue,
-          values: handlers,
-          create: function () {
-            _this.updateColors(handlers);
-          },
-          slide: function (event, ui) {
-            _this.updateColors(ui.values);
-            configObj.set('thresholdMin', ui.values[0] + '');
-            configObj.set('thresholdMax', ui.values[1] + '');
-          },
-          change: function (event, ui) {
-            _this.updateColors(ui.values);
-          }
-        });
-      },
-      updateColors: function (handlers) {
-        var colors = [App.healthStatusGreen, App.healthStatusOrange, App.healthStatusRed];
-        var colorStops = colors[0] + ", ";
+      sliderHandlersManager: App.EditDashboardWidgetPopup.DoubleHandlers.create({
+        thresholdMin: this.get('thresholdMin'),
+        thresholdMax: this.get('thresholdMax'),
+        maxValue: parseFloat(this.get('maxValue'))
+      }),
 
-        for (var i = 0; i < handlers.length; i++) {
-          colorStops += colors[i] + " " + handlers[i] * 100 / maxValue + "%,";
-          colorStops += colors[i + 1] + " " + handlers[i] * 100 / maxValue + "%,";
-        }
-        colorStops += colors[colors.length - 1];
-        var sliderElement = $('#slider-range');
-        var gradient = 'linear-gradient(left,' + colorStops + ')';
+      sliderColors: [App.healthStatusGreen, App.healthStatusOrange, App.healthStatusRed]
 
-        sliderElement.css('background-image', '-webkit-' + gradient);
-        sliderElement.css('background-image', '-ms-' + gradient);
-        sliderElement.css('background-image', '-moz-' + gradient);
-        sliderElement.find('.ui-widget-header').css({
-          'background-color': '#FF8E00',
-          'background-image': 'none'
-        });
-      }
     });
   }
+
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/05c76ed6/ambari-web/app/views/main/dashboard/widgets.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets.js b/ambari-web/app/views/main/dashboard/widgets.js
index 572625d..16840a5 100644
--- a/ambari-web/app/views/main/dashboard/widgets.js
+++ b/ambari-web/app/views/main/dashboard/widgets.js
@@ -32,184 +32,7 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap
   name: 'mainDashboardWidgetsView',
   templateName: require('templates/main/dashboard/widgets'),
 
-  widgetsDefinition: [
-    {
-      id: 1,
-      viewName: 'NameNodeHeapPieChartView',
-      sourceName: 'HDFS',
-      title: Em.I18n.t('dashboard.widgets.NameNodeHeap'),
-      threshold: [80, 90]
-    },
-    {
-      id: 2,
-      viewName: 'NameNodeCapacityPieChartView',
-      sourceName: 'HDFS',
-      title: Em.I18n.t('dashboard.widgets.HDFSDiskUsage'),
-      threshold: [85, 95]
-    },
-    {
-      id: 3,
-      viewName: 'NameNodeCpuPieChartView',
-      sourceName: 'HDFS',
-      title: Em.I18n.t('dashboard.widgets.NameNodeCpu'),
-      threshold: [90, 95]
-    },
-    {
-      id: 4,
-      viewName: 'DataNodeUpView',
-      sourceName: 'HDFS',
-      title: Em.I18n.t('dashboard.widgets.DataNodeUp'),
-      threshold: [80, 90]
-    },
-    {
-      id: 5,
-      viewName: 'NameNodeRpcView',
-      sourceName: 'HDFS',
-      title: Em.I18n.t('dashboard.widgets.NameNodeRpc'),
-      threshold: [1000, 3000]
-    },
-    {
-      id: 6,
-      viewName: 'ChartClusterMetricsMemoryWidgetView',
-      sourceName: 'HOST_METRICS',
-      title: Em.I18n.t('dashboard.clusterMetrics.memory'),
-      threshold: []
-    },
-    {
-      id: 7,
-      viewName: 'ChartClusterMetricsNetworkWidgetView',
-      sourceName: 'HOST_METRICS',
-      title: Em.I18n.t('dashboard.clusterMetrics.network'),
-      threshold: []
-    },
-    {
-      id: 8,
-      viewName: 'ChartClusterMetricsCPUWidgetView',
-      sourceName: 'HOST_METRICS',
-      title: Em.I18n.t('dashboard.clusterMetrics.cpu'),
-      threshold: []
-    },
-    {
-      id: 9,
-      viewName: 'ChartClusterMetricsLoadWidgetView',
-      sourceName: 'HOST_METRICS',
-      title: Em.I18n.t('dashboard.clusterMetrics.load'),
-      threshold: []
-    },
-    {
-      id: 10,
-      viewName: 'NameNodeUptimeView',
-      sourceName: 'HDFS',
-      title: Em.I18n.t('dashboard.widgets.NameNodeUptime'),
-      threshold: []
-    },
-    {
-      id: 11,
-      viewName: 'HDFSLinksView',
-      sourceName: 'HDFS',
-      title: Em.I18n.t('dashboard.widgets.HDFSLinks'),
-      threshold: []
-    },
-    {
-      id: 12,
-      viewName: 'HBaseLinksView',
-      sourceName: 'HBASE',
-      title: Em.I18n.t('dashboard.widgets.HBaseLinks'),
-      threshold: []
-    },
-    {
-      id: 13,
-      viewName: 'HBaseMasterHeapPieChartView',
-      sourceName: 'HBASE',
-      title: Em.I18n.t('dashboard.widgets.HBaseMasterHeap'),
-      threshold: [70, 90]
-    },
-    {
-      id: 14,
-      viewName: 'HBaseAverageLoadView',
-      sourceName: 'HBASE',
-      title: Em.I18n.t('dashboard.widgets.HBaseAverageLoad'),
-      threshold: [150, 250]
-    },
-    {
-      id: 15,
-      viewName: 'HBaseRegionsInTransitionView',
-      sourceName: 'HBASE',
-      title: Em.I18n.t('dashboard.widgets.HBaseRegionsInTransition'),
-      threshold: [3, 10],
-      isHiddenByDefault: true
-    },
-    {
-      id: 16,
-      viewName: 'HBaseMasterUptimeView',
-      sourceName: 'HBASE',
-      title: Em.I18n.t('dashboard.widgets.HBaseMasterUptime'),
-      threshold: []
-    },
-    {
-      id: 17,
-      viewName: 'ResourceManagerHeapPieChartView',
-      sourceName: 'YARN',
-      title: Em.I18n.t('dashboard.widgets.ResourceManagerHeap'),
-      threshold: [70, 90]
-    },
-    {
-      id: 18,
-      viewName: 'ResourceManagerUptimeView',
-      sourceName: 'YARN',
-      title: Em.I18n.t('dashboard.widgets.ResourceManagerUptime'),
-      threshold: []
-    },
-    {
-      id: 19,
-      viewName: 'NodeManagersLiveView',
-      sourceName: 'YARN',
-      title: Em.I18n.t('dashboard.widgets.NodeManagersLive'),
-      threshold: [50, 75]
-    },
-    {
-      id: 20,
-      viewName: 'YARNMemoryPieChartView',
-      sourceName: 'YARN',
-      title: Em.I18n.t('dashboard.widgets.YARNMemory'),
-      threshold: [50, 75]
-    },
-    {
-      id: 21,
-      viewName: 'SuperVisorUpView',
-      sourceName: 'STORM',
-      title: Em.I18n.t('dashboard.widgets.SuperVisorUp'),
-      threshold: [85, 95]
-    },
-    {
-      id: 22,
-      viewName: 'FlumeAgentUpView',
-      sourceName: 'FLUME',
-      title: Em.I18n.t('dashboard.widgets.FlumeAgentUp'),
-      threshold: [85, 95]
-    },
-    {
-      id: 23,
-      viewName: 'YARNLinksView',
-      sourceName: 'YARN',
-      title: Em.I18n.t('dashboard.widgets.YARNLinks'),
-      threshold: []
-    },
-    {
-      id: 24,
-      viewName: 'HawqSegmentUpView',
-      sourceName: 'HAWQ',
-      title: Em.I18n.t('dashboard.widgets.HawqSegmentUp'),
-      threshold: [75, 90]
-    },
-    {
-      id: 25,
-      viewName: 'PxfUpView',
-      sourceName: 'PXF',
-      title: Em.I18n.t('dashboard.widgets.PxfUp'),
-      threshold: []
-    }
-  ],
+  widgetsDefinition: require('data/dashboard_widgets'),
 
   widgetsDefinitionMap: function () {
     return this.get('widgetsDefinition').toMapByProperty('id');
@@ -275,15 +98,13 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap
   userPreferences: null,
 
   didInsertElement: function () {
-    var self = this;
-
     this._super();
-    this.loadWidgetsSettings().complete(function() {
-      self.checkServicesChange();
-      self.renderWidgets();
-      self.set('isDataLoaded', true);
+    this.loadWidgetsSettings().complete(() => {
+      this.checkServicesChange();
+      this.renderWidgets();
+      this.set('isDataLoaded', true);
       App.loadTimer.finish('Dashboard Metrics Page');
-      Em.run.next(self, 'makeSortable');
+      Em.run.next(this, 'makeSortable');
     });
   },
 
@@ -337,11 +158,10 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap
 
   resolveConfigDependencies: function(widgetsDefinition) {
     var clusterEnv = App.router.get('clusterController.clusterEnv').properties;
-    var yarnMemoryWidget = widgetsDefinition.findProperty('id', 20);
-
     if (clusterEnv.hide_yarn_memory_widget === 'true') {
-      yarnMemoryWidget.isHiddenByDefault = true;
+      widgetsDefinition.findProperty('id', 20).isHiddenByDefault = true;
     }
+    return widgetsDefinition;
   },
 
   generateDefaultUserPreferences: function() {
@@ -353,14 +173,10 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap
     };
 
     this.resolveConfigDependencies(widgetsDefinition);
-
     widgetsDefinition.forEach(function(widget) {
       if (App.Service.find(widget.sourceName).get('isLoaded') || widget.sourceName === 'HOST_METRICS') {
-        if (widget.isHiddenByDefault) {
-          preferences.hidden.push(widget.id);
-        } else {
-          preferences.visible.push(widget.id);
-        }
+        let state = widget.isHiddenByDefault ? 'hidden' : 'visible';
+        preferences[state].push(widget.id);
       }
       preferences.threshold[widget.id] = widget.threshold;
     });
@@ -421,18 +237,13 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap
     };
     var isChanged = false;
 
-    defaultPreferences.visible.forEach(function(id) {
-      if (!userPreferences.visible.contains(id) && !userPreferences.hidden.contains(id)) {
-        isChanged = true;
-        newValue.visible.push(id);
-      }
-    });
-
-    defaultPreferences.hidden.forEach(function(id) {
-      if (!userPreferences.visible.contains(id) && !userPreferences.hidden.contains(id)) {
-        isChanged = true;
-        newValue.hidden.push(id);
-      }
+    ['visible', 'hidden'].forEach(state => {
+      defaultPreferences[state].forEach(id => {
+        if (!userPreferences.visible.contains(id) && !userPreferences.hidden.contains(id)) {
+          isChanged = true;
+          newValue[state].push(id);
+        }
+      });
     });
     if (isChanged) {
       this.saveWidgetsSettings(newValue);
@@ -443,15 +254,14 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap
    * Reset widgets visibility-status
    */
   resetAllWidgets: function () {
-    var self = this;
-    App.showConfirmationPopup(function () {
-      self.saveWidgetsSettings(self.generateDefaultUserPreferences());
-      self.setProperties({
+    App.showConfirmationPopup(() => {
+      this.saveWidgetsSettings(this.generateDefaultUserPreferences());
+      this.setProperties({
         currentTimeRangeIndex: 0,
         customStartTime: null,
         customEndTime: null
       });
-      self.renderWidgets();
+      this.renderWidgets();
     });
   },
 
@@ -469,23 +279,21 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap
         var widgetsArray = $('div[viewid]');
 
         var userPreferences = self.get('userPreferences') || self.getDBProperty(self.get('persistKey'));
-        var newValue = Em.Object.create({
+        var newValue = {
           visible: [],
           hidden: userPreferences.hidden,
           threshold: userPreferences.threshold
+        };
+        newValue.visible = userPreferences.visible.map((item, index) => {
+          var viewID = widgetsArray.get(index).getAttribute('viewid');
+          return Number(viewID.split('-')[1]);
         });
-        var size = userPreferences.visible.length;
-        for (var j = 0; j <= size - 1; j++) {
-          var viewID = widgetsArray.get(j).getAttribute('viewid');
-          var id = Number(viewID.split("-").get(1));
-          newValue.visible.push(id);
-        }
         self.saveWidgetsSettings(newValue);
       },
-      activate: function (event, ui) {
+      activate: function () {
         self.set('isMoving', true);
       },
-      deactivate: function (event, ui) {
+      deactivate: function () {
         self.set('isMoving', false);
       }
     }).disableSelection();
@@ -511,21 +319,9 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, Ap
     }),
     applyFilter: function () {
       var parent = this.get('parentView'),
-        hiddenWidgets = this.get('hiddenWidgets'),
-        userPreferences = parent.get('userPreferences'),
-        newValue = {
-          visible: userPreferences.visible.slice(0),
-          hidden: userPreferences.hidden.slice(0),
-          threshold: userPreferences.threshold
-        };
-
-      hiddenWidgets.filterProperty('checked').forEach(function (item) {
-        newValue.visible.push(item.id);
-        newValue.hidden = newValue.hidden.without(item.id);
-        hiddenWidgets.removeObject(item);
-      }, this);
-      parent.saveWidgetsSettings(newValue);
-      parent.renderWidgets();
+        hiddenWidgets = this.get('hiddenWidgets');
+      hiddenWidgets.filterProperty('checked').setEach('isVisible', true);
+      parent.saveWidgetsSettings();
     }
   }),
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/05c76ed6/ambari-web/app/views/main/dashboard/widgets/text_widget.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets/text_widget.js b/ambari-web/app/views/main/dashboard/widgets/text_widget.js
index daa354c..79f0573 100644
--- a/ambari-web/app/views/main/dashboard/widgets/text_widget.js
+++ b/ambari-web/app/views/main/dashboard/widgets/text_widget.js
@@ -32,26 +32,5 @@ App.TextDashboardWidgetView = App.DashboardWidgetView.extend({
     return this.get('data') === null;
   }.property('data'),
 
-  hiddenInfo: [],
-
-  maxValue: null,
-
-  updateColors: function (handlers, colors) {
-    var colorstops = colors[0] + ", "; // start with the first color
-    for (var i = 0; i < handlers.length; i++) {
-      colorstops += colors[i] + " " + handlers[i] + "%,";
-      colorstops += colors[i + 1] + " " + handlers[i] + "%,";
-    }
-    colorstops += colors[colors.length - 1];
-    var cssForChromeAndSafari = '-webkit-linear-gradient(left,' + colorstops + ')'; // chrome & safari
-    var slider = $('#slider-range');
-    slider.css('background-image', cssForChromeAndSafari);
-    var cssForIE = '-ms-linear-gradient(left,' + colorstops + ')'; // IE 10+
-    slider.css('background-image', cssForIE);
-    //$('#slider-range').css('filter', 'progid:DXImageTransform.Microsoft.gradient( startColorStr= ' + colors[0] + ', endColorStr= ' + colors[2] +',  GradientType=1 )' ); // IE 10-
-    var cssForFireFox = '-moz-linear-gradient(left,' + colorstops + ')'; // Firefox
-    slider.css('background-image', cssForFireFox);
-
-    slider.find('.ui-widget-header').css({'background-color': '#FF8E00', 'background-image': 'none'}); // change the  original ranger color
-  }
+  hiddenInfo: []
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/05c76ed6/ambari-web/test/views/common/modal_popups/edit_dashboard_widget_popup_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/modal_popups/edit_dashboard_widget_popup_test.js b/ambari-web/test/views/common/modal_popups/edit_dashboard_widget_popup_test.js
new file mode 100644
index 0000000..3335cf3
--- /dev/null
+++ b/ambari-web/test/views/common/modal_popups/edit_dashboard_widget_popup_test.js
@@ -0,0 +1,214 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var App = require('app');
+
+function getView() {
+  return App.EditDashboardWidgetPopup.create({
+    widgetView: Em.View.create(),
+    sliderHandlersManager: {}
+  });
+}
+
+describe('App.EditDashboardWidgetPopup', function () {
+
+  App.TestAliases.testAsComputedAlias(getView(), 'disablePrimary', 'sliderHandlersManager.hasErrors');
+
+  App.TestAliases.testAsComputedAlias(getView(), 'sliderMaxValue', 'sliderHandlersManager.maxValue');
+
+  describe('#init', function () {
+
+    it('should throw an Error if no `widgetView` provided', function () {
+      expect(function () {
+        App.EditDashboardWidgetPopup.create({
+          sliderHandlersManager: {}
+        });
+      }).to.throw(/`widgetView` should be valid view/);
+    });
+
+    it('should throw an Error if no `sliderHandlersManager` provided', function () {
+      expect(function () {
+        App.EditDashboardWidgetPopup.create({
+          widgetView: Em.View.create(),
+        });
+      }).to.throw(/`sliderHandlersManager` should be set/);
+    });
+
+  });
+
+});
+
+describe('App.EditDashboardWidgetPopup.SingleHandler', function () {
+
+  var handler;
+
+  function getSingleHandler() {
+    return App.EditDashboardWidgetPopup.SingleHandler.create();
+  }
+
+  beforeEach(function () {
+    handler = getSingleHandler();
+  });
+
+  App.TestAliases.testAsComputedAlias(getSingleHandler(), 'hasErrors', 'thresholdMinError');
+
+  describe('#updateThresholds', function () {
+
+    it('should update `thresholdMin`', function () {
+      handler.set('thresholdMin', -1);
+      handler.updateThresholds([100500]);
+      expect(handler.get('thresholdMin')).to.be.equal(100500);
+    });
+
+  });
+
+  describe('#thresholdMinErrorMessage', function() {
+
+    var minValue = 0;
+    var maxValue = 100;
+    var msg = Em.I18n.t('dashboard.widgets.error.invalid').format(minValue, maxValue);
+
+    beforeEach(function() {
+      handler.setProperties({
+        minValue: minValue,
+        maxValue: maxValue
+      });
+    });
+
+    [
+      {thresholdMin: -1, e: msg},
+      {thresholdMin: 101, e: msg},
+      {thresholdMin: 'abc', e: msg},
+      {thresholdMin: 60, e: ''}
+    ].forEach(function(test) {
+      it('thresholdMin: ' + JSON.stringify(test.thresholdMin), function () {
+        handler.set('thresholdMin', test.thresholdMin);
+        expect(handler.get('thresholdMinErrorMessage')).to.be.equal(test.e);
+      });
+    });
+
+  });
+
+  describe('#preparedThresholds', function () {
+
+    it('mapped to array threshold values', function () {
+      handler.setProperties({
+        thresholdMin: 1
+      });
+      expect(handler.get('preparedThresholds')).to.be.eql([1]);
+    });
+
+  });
+
+});
+
+describe('App.EditDashboardWidgetPopup.DoubleHandlers', function () {
+
+  var handler;
+
+  function getDoubleHandlers() {
+    return App.EditDashboardWidgetPopup.DoubleHandlers.create();
+  }
+
+  beforeEach(function () {
+    handler = getDoubleHandlers();
+  });
+
+  App.TestAliases.testAsComputedOr(getDoubleHandlers(), 'hasErrors', ['thresholdMinError', 'thresholdMaxError']);
+
+  describe('#updateThresholds', function () {
+
+    it('should update `thresholdMin` and `thresholdMax`', function () {
+      handler.set('thresholdMin', -1);
+      handler.set('thresholdMax', 1);
+      handler.updateThresholds([1234, 4321]);
+      expect(handler.get('thresholdMin')).to.be.equal(1234);
+      expect(handler.get('thresholdMax')).to.be.equal(4321);
+    });
+
+  });
+
+  describe('#thresholdMinErrorMessage', function() {
+
+    var minValue = 0;
+    var maxValue = 100;
+    var msg = Em.I18n.t('dashboard.widgets.error.invalid').format(minValue, maxValue);
+    var msg2 = Em.I18n.t('dashboard.widgets.error.smaller');
+
+    beforeEach(function() {
+      handler.setProperties({
+        minValue: minValue,
+        maxValue: maxValue
+      });
+    });
+
+    [
+      {thresholdMin: -1, e: msg},
+      {thresholdMin: 101, e: msg},
+      {thresholdMin: 'abc', e: msg},
+      {thresholdMin: 60, e: ''},
+      {thresholdMin: 99, e: msg2}
+    ].forEach(function(test) {
+      it('thresholdMin: ' + JSON.stringify(test.thresholdMin), function () {
+        handler.set('thresholdMin', test.thresholdMin);
+        handler.set('thresholdMax', 98);
+        expect(handler.get('thresholdMinErrorMessage')).to.be.equal(test.e);
+      });
+    });
+
+  });
+
+  describe('#thresholdMaxErrorMessage', function () {
+    var minValue = 0;
+    var maxValue = 100;
+    var msg = Em.I18n.t('dashboard.widgets.error.invalid').format(minValue, maxValue);
+
+    beforeEach(function() {
+      handler.setProperties({
+        minValue: minValue,
+        maxValue: maxValue
+      });
+    });
+
+    [
+      {thresholdMax: -1, e: msg},
+      {thresholdMax: 101, e: msg},
+      {thresholdMax: 'abc', e: msg},
+      {thresholdMax: 60, e: ''}
+    ].forEach(function(test) {
+      it('thresholdMax: ' + JSON.stringify(test.thresholdMax), function () {
+        handler.set('thresholdMax', test.thresholdMax);
+        expect(handler.get('thresholdMaxErrorMessage')).to.be.equal(test.e);
+      });
+    });
+  });
+
+  describe('#preparedThresholds', function () {
+
+    it('mapped to array threshold values', function () {
+      handler.setProperties({
+        thresholdMin: 1,
+        thresholdMax: 2
+      });
+      expect(handler.get('preparedThresholds')).to.be.eql([1, 2]);
+    });
+
+  });
+
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/05c76ed6/ambari-web/test/views/main/dashboard/widget_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widget_test.js b/ambari-web/test/views/main/dashboard/widget_test.js
index a504c6d..8e10cef 100644
--- a/ambari-web/test/views/main/dashboard/widget_test.js
+++ b/ambari-web/test/views/main/dashboard/widget_test.js
@@ -89,97 +89,6 @@ describe('App.DashboardWidgetView', function () {
     });
   });
 
-  describe('#widgetConfig', function () {
-    var widgetConfig;
-
-    beforeEach(function() {
-      widgetConfig = view.get('widgetConfig').create();
-    });
-
-    describe('#validateThreshold()', function () {
-
-      beforeEach(function () {
-        sinon.stub(widgetConfig, 'updateSlider');
-      });
-
-      afterEach(function () {
-        widgetConfig.updateSlider.restore();
-      });
-
-      it('updateSlider should be called', function () {
-        widgetConfig.validateThreshold('thresholdMin');
-        expect(widgetConfig.updateSlider).to.be.called;
-      });
-
-      it('thresholdMin is empty', function () {
-        widgetConfig.set('thresholdMin', '');
-        widgetConfig.validateThreshold('thresholdMin');
-        expect(widgetConfig.get('thresholdMinError')).to.be.true;
-        expect(widgetConfig.get('thresholdMinErrorMessage')).to.be.equal(Em.I18n.t('admin.users.editError.requiredField'));
-      });
-
-      it('thresholdMin is NaN', function () {
-        widgetConfig.set('thresholdMin', 'a');
-        widgetConfig.validateThreshold('thresholdMin');
-        expect(widgetConfig.get('thresholdMinError')).to.be.true;
-        expect(widgetConfig.get('thresholdMinErrorMessage')).to.be.equal(Em.I18n.t('dashboard.widgets.error.invalid').format(0));
-      });
-
-      it('thresholdMin bigger than maxValue', function () {
-        widgetConfig.set('thresholdMin', '1');
-        widgetConfig.validateThreshold('thresholdMin');
-        expect(widgetConfig.get('thresholdMinError')).to.be.true;
-        expect(widgetConfig.get('thresholdMinErrorMessage')).to.be.equal(Em.I18n.t('dashboard.widgets.error.invalid').format(0));
-      });
-
-      it('thresholdMin less than 0', function () {
-        widgetConfig.set('thresholdMin', '-1');
-        widgetConfig.validateThreshold('thresholdMin');
-        expect(widgetConfig.get('thresholdMinError')).to.be.true;
-        expect(widgetConfig.get('thresholdMinErrorMessage')).to.be.equal(Em.I18n.t('dashboard.widgets.error.invalid').format(0));
-      });
-
-      it('thresholdMin bigger than thresholdMax', function () {
-        widgetConfig.set('thresholdMin', '2');
-        widgetConfig.set('thresholdMax', '1');
-        widgetConfig.set('maxValue', 100);
-        widgetConfig.validateThreshold('thresholdMin');
-        expect(widgetConfig.get('thresholdMinError')).to.be.true;
-        expect(widgetConfig.get('thresholdMinErrorMessage')).to.be.equal(Em.I18n.t('dashboard.widgets.error.smaller'));
-      });
-    });
-
-    describe('#observeThreshMinValue()', function() {
-
-      beforeEach(function() {
-        sinon.stub(widgetConfig, 'validateThreshold');
-      });
-      afterEach(function() {
-        widgetConfig.validateThreshold.restore();
-      });
-
-      it('validateThreshold should be called', function() {
-        widgetConfig.observeThreshMinValue();
-        expect(widgetConfig.validateThreshold.calledWith('thresholdMin')).to.be.true;
-      });
-    });
-
-    describe('#observeThreshMaxValue()', function() {
-
-      beforeEach(function() {
-        sinon.stub(widgetConfig, 'validateThreshold');
-      });
-      afterEach(function() {
-        widgetConfig.validateThreshold.restore();
-      });
-
-      it('validateThreshold should be called', function() {
-        widgetConfig.observeThreshMaxValue();
-        expect(widgetConfig.validateThreshold.calledWith('thresholdMax')).to.be.true;
-      });
-    });
-  });
-
   describe('#didInsertElement()', function() {
 
     beforeEach(function() {
@@ -250,25 +159,6 @@ describe('App.DashboardWidgetView', function () {
   describe('#editWidget()', function() {
 
     beforeEach(function() {
-      sinon.stub(view, 'showEditDialog');
-    });
-
-    afterEach(function() {
-      view.showEditDialog.restore();
-    });
-
-    it('showEditDialog should be called', function() {
-      view.reopen({
-        widgetConfig: Em.Object.extend()
-      });
-      view.editWidget();
-      expect(view.showEditDialog).to.be.calledOnce;
-    });
-  });
-
-  describe('#showEditDialog()', function() {
-
-    beforeEach(function() {
       sinon.stub(App.ModalPopup, 'show');
     });
 
@@ -277,7 +167,7 @@ describe('App.DashboardWidgetView', function () {
     });
 
     it('App.ModalPopup.show should be called', function() {
-      view.showEditDialog();
+      view.editWidget();
       expect(App.ModalPopup.show).to.be.calledOnce;
     });
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/05c76ed6/ambari-web/test/views/main/dashboard/widgets_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets_test.js b/ambari-web/test/views/main/dashboard/widgets_test.js
index 5d1ddb2..4700ac8 100644
--- a/ambari-web/test/views/main/dashboard/widgets_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets_test.js
@@ -426,15 +426,7 @@ describe('App.MainDashboardWidgetsView', function () {
       });
 
       it('saveWidgetsSettings should be called', function() {
-        expect(plusButtonFilterView.get('parentView').saveWidgetsSettings.getCall(0).args[0]).to.be.eql({
-          visible: [2, 1],
-          hidden: [3],
-          threshold: {}
-        });
-      });
-
-      it('renderWidgets should be called', function() {
-        expect(plusButtonFilterView.get('parentView').renderWidgets).to.be.calledOnce;
+        expect(plusButtonFilterView.get('parentView').saveWidgetsSettings.calledOnce).to.be.true;
       });
     });
   });


[12/15] ambari git commit: Updated committer list. (yusaku)

Posted by jo...@apache.org.
Updated committer list. (yusaku)


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

Branch: refs/heads/branch-feature-AMBARI-20053
Commit: db51ba46dde65bc6034d7deb1e64b18d8a460185
Parents: 0fc7a66
Author: Yusaku Sako <yu...@hortonworks.com>
Authored: Fri Feb 17 10:27:26 2017 -0800
Committer: Yusaku Sako <yu...@hortonworks.com>
Committed: Fri Feb 17 10:27:26 2017 -0800

----------------------------------------------------------------------
 docs/pom.xml | 34 +++++++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/db51ba46/docs/pom.xml
----------------------------------------------------------------------
diff --git a/docs/pom.xml b/docs/pom.xml
index db907d1..6c0da94 100644
--- a/docs/pom.xml
+++ b/docs/pom.xml
@@ -386,27 +386,39 @@
             </organization>
         </developer>
         <developer>
-            <id>eyang</id>
-            <name>Eric Yang</name>
-            <email>eyang@apache.org</email>
+            <id>eboyd</id>
+            <name>Erin A. Boyd</name>
+            <email>eboyd@apache.org</email>
             <timezone>-8</timezone>
             <roles>
-                <role>PMC</role>
+                <role>Committer</role>
             </roles>
             <organization>
-                IBM            
-            </organization>            
+                 Red Hat
+            </organization>
         </developer>
         <developer>
-            <id>eboyd</id>
-            <name>Erin A. Boyd</name>
-            <email>eboyd@apache.org</email>
-            <timezone>-8</timezone>
+            <id>echekanskiy</id>
+            <name>Eugene Chekanskiy</name>
+            <email>echekanskiy@apache.org</email>
+            <timezone>+2</timezone>
             <roles>
                 <role>Committer</role>
             </roles>
             <organization>
-                 Red Hat
+                 Hortonworks
+            </organization>
+        </developer>
+        <developer>
+            <id>eyang</id>
+            <name>Eric Yang</name>
+            <email>eyang@apache.org</email>
+            <timezone>-8</timezone>
+            <roles>
+                <role>PMC</role>
+            </roles>
+            <organization>
+                IBM
             </organization>
         </developer>
         <developer>


[02/15] ambari git commit: AMBARI-20051. Hosts filter component list is not sorted so it is difficult to use (akovalenko)

Posted by jo...@apache.org.
AMBARI-20051. Hosts filter component list is not sorted so it is difficult to use (akovalenko)


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

Branch: refs/heads/branch-feature-AMBARI-20053
Commit: ce404d640e930b7326dc1857ac1ae6ce03b2884e
Parents: 18fc258
Author: Aleksandr Kovalenko <ak...@hortonworks.com>
Authored: Thu Feb 16 18:05:18 2017 +0200
Committer: Aleksandr Kovalenko <ak...@hortonworks.com>
Committed: Fri Feb 17 03:12:46 2017 +0200

----------------------------------------------------------------------
 ambari-web/app/views/main/host/combo_search_box.js       | 1 +
 ambari-web/test/views/main/host/combo_search_box_test.js | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ce404d64/ambari-web/app/views/main/host/combo_search_box.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/combo_search_box.js b/ambari-web/app/views/main/host/combo_search_box.js
index 2f9900a..372c3f7 100644
--- a/ambari-web/app/views/main/host/combo_search_box.js
+++ b/ambari-web/app/views/main/host/combo_search_box.js
@@ -307,6 +307,7 @@ App.MainHostComboSearchBoxView = Em.View.extend({
         App.router.get('mainHostController.labelValueMap')[displayName] = component.get('componentName');
       }
     });
+    hostComponentList = hostComponentList.sortProperty('label');
     return hostComponentList;
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/ce404d64/ambari-web/test/views/main/host/combo_search_box_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/host/combo_search_box_test.js b/ambari-web/test/views/main/host/combo_search_box_test.js
index c82167c..0775f66 100644
--- a/ambari-web/test/views/main/host/combo_search_box_test.js
+++ b/ambari-web/test/views/main/host/combo_search_box_test.js
@@ -663,11 +663,11 @@ describe('App.MainHostComboSearchBoxView', function () {
       App.router.get.restore();
     });
 
-    it("should return host-component list", function() {
+    it("should return sorted host-component list", function() {
       expect(view.getHostComponentList()).to.be.eql([
+        {label: 'cc1', category: 'Component'},
         {label: 'mc1', category: 'Component'},
-        {label: 'sc1', category: 'Component'},
-        {label: 'cc1', category: 'Component'}
+        {label: 'sc1', category: 'Component'}
       ]);
       expect(labelValueMap).to.be.eql({
         mc1: 'MC1',


[07/15] ambari git commit: AMBARI-20024. Relax ranger config DB consistency check rules (aonishuk)

Posted by jo...@apache.org.
AMBARI-20024. Relax ranger config DB consistency check rules (aonishuk)


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

Branch: refs/heads/branch-feature-AMBARI-20053
Commit: c8c134ee7c51a18df4613539e3b424cf17138645
Parents: b501425
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Fri Feb 17 13:36:12 2017 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Fri Feb 17 13:36:12 2017 +0200

----------------------------------------------------------------------
 .../checks/DatabaseConsistencyCheckHelper.java   | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c8c134ee/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
index 926ec65..e895fc5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
@@ -33,6 +33,8 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.Scanner;
 import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import javax.annotation.Nullable;
 import javax.inject.Provider;
@@ -934,6 +936,12 @@ public class DatabaseConsistencyCheckHelper {
                 Collection<String> serviceConfigsFromDB = dbServiceConfigs.get(serviceName);
                 if (serviceConfigsFromDB != null && serviceConfigsFromStack != null) {
                   serviceConfigsFromStack.removeAll(serviceConfigsFromDB);
+
+                  // skip ranger-{service_name}-* from being checked, unless ranger is installed
+                  if(!dbServiceConfigs.containsKey("RANGER")) {
+                    removeStringsByRegexp(serviceConfigsFromStack, "^ranger-"+ serviceName.toLowerCase() + "-" + "*");
+                  }
+
                   if (!serviceConfigsFromStack.isEmpty()) {
                     error("Required config(s): {} is(are) not available for service {} with service config version {} in cluster {}",
                             StringUtils.join(serviceConfigsFromStack, ","), serviceName, Integer.toString(serviceVersion), clusterName);
@@ -1009,4 +1017,15 @@ public class DatabaseConsistencyCheckHelper {
     }
   }
 
+  private static void removeStringsByRegexp(Collection<String> stringItems, String regexp) {
+      Pattern pattern = Pattern.compile(regexp);
+
+      for (Iterator<String> iterator = stringItems.iterator(); iterator.hasNext();) {
+        String stringItem = iterator.next();
+        Matcher matcher = pattern.matcher(stringItem);
+        if (matcher.find()) {
+          iterator.remove();
+        }
+      }
+  }
 }


[06/15] ambari git commit: AMBARI-19915 Add Ranger KMS SSL properties in ambari stack (mugdha)

Posted by jo...@apache.org.
AMBARI-19915 Add Ranger KMS SSL properties in ambari stack (mugdha)


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

Branch: refs/heads/branch-feature-AMBARI-20053
Commit: b5014253706c85cba77c781672443d94de3e5ef4
Parents: c395f69
Author: Mugdha Varadkar <mu...@apache.org>
Authored: Fri Feb 17 16:13:49 2017 +0530
Committer: Mugdha Varadkar <mu...@apache.org>
Committed: Fri Feb 17 16:26:25 2017 +0530

----------------------------------------------------------------------
 .../libraries/functions/constants.py            |  1 +
 .../0.5.0.2.3/configuration/kms-env.xml         | 10 +++
 .../RANGER_KMS/0.5.0.2.3/package/scripts/kms.py | 22 ++++++-
 .../0.5.0.2.3/package/scripts/params.py         |  8 ++-
 .../HDP/2.0.6/properties/stack_features.json    |  5 ++
 .../stacks/HDP/2.3/upgrades/config-upgrade.xml  |  7 ++
 .../HDP/2.3/upgrades/nonrolling-upgrade-2.6.xml |  4 ++
 .../stacks/HDP/2.3/upgrades/upgrade-2.6.xml     |  1 +
 .../stacks/HDP/2.4/upgrades/config-upgrade.xml  |  7 ++
 .../HDP/2.4/upgrades/nonrolling-upgrade-2.6.xml |  4 ++
 .../stacks/HDP/2.4/upgrades/upgrade-2.6.xml     |  1 +
 .../stacks/HDP/2.5/upgrades/config-upgrade.xml  |  7 ++
 .../HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml |  4 ++
 .../stacks/HDP/2.5/upgrades/upgrade-2.6.xml     |  1 +
 .../configuration/ranger-kms-site.xml           | 68 +++++++++++++++++++
 .../stacks/HDP/2.6/services/stack_advisor.py    | 20 +++++-
 .../stacks/2.5/RANGER_KMS/test_kms_server.py    | 20 ++++++
 .../stacks/2.6/common/test_stack_advisor.py     | 69 ++++++++++++++++++++
 18 files changed, 256 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b5014253/ambari-common/src/main/python/resource_management/libraries/functions/constants.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/constants.py b/ambari-common/src/main/python/resource_management/libraries/functions/constants.py
index c31b883..f553ad2 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/constants.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/constants.py
@@ -117,3 +117,4 @@ class StackFeature:
   ATLAS_HDFS_SITE_ON_NAMENODE_HA='atlas_hdfs_site_on_namenode_ha'
   HIVE_INTERACTIVE_GA_SUPPORT='hive_interactive_ga'
   SECURE_RANGER_SSL_PASSWORD = "secure_ranger_ssl_password"
+  RANGER_KMS_SSL = "ranger_kms_ssl"

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5014253/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/configuration/kms-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/configuration/kms-env.xml b/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/configuration/kms-env.xml
index 7dea07f..e5c0673 100644
--- a/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/configuration/kms-env.xml
+++ b/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/configuration/kms-env.xml
@@ -58,6 +58,16 @@
     <value>9292</value>
     <description/>
     <on-ambari-upgrade add="true"/>
+    <depends-on>
+      <property>
+        <type>ranger-kms-site</type>
+        <name>ranger.service.https.port</name>
+      </property>
+      <property>
+        <type>ranger-kms-site</type>
+        <name>ranger.service.https.attrib.ssl.enabled</name>
+      </property>
+    </depends-on>
   </property>
   <property>
     <name>create_db_user</name>

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5014253/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms.py b/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms.py
index 536ba76..1afe136 100755
--- a/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms.py
+++ b/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms.py
@@ -140,6 +140,16 @@ def kms(upgrade_type=None):
       create_parents = True
     )
 
+    Directory("/etc/security/serverKeys",
+      create_parents = True,
+      cd_access = "a"
+    )
+
+    Directory("/etc/ranger/kms",
+      create_parents = True,
+      cd_access = "a"
+    )
+
     copy_jdbc_connector()
 
     File(format("/usr/lib/ambari-agent/{check_db_connection_jar_name}"),
@@ -270,6 +280,8 @@ def kms(upgrade_type=None):
     do_keystore_setup(params.credential_provider_path, params.masterkey_alias, params.kms_master_key_password)
     if params.stack_support_kms_hsm and params.enable_kms_hsm:
       do_keystore_setup(params.credential_provider_path, params.hms_partition_alias, unicode(params.hms_partition_passwd))
+    if params.stack_supports_ranger_kms_ssl and params.ranger_kms_ssl_enabled:
+      do_keystore_setup(params.ranger_kms_cred_ssl_path, params.ranger_kms_ssl_keystore_alias, params.ranger_kms_ssl_passwd)
 
     # remove plain-text password from xml configs
     dbks_site_copy = {}
@@ -288,9 +300,17 @@ def kms(upgrade_type=None):
       mode=0644
     )
 
+    ranger_kms_site_copy = {}
+    ranger_kms_site_copy.update(params.config['configurations']['ranger-kms-site'])
+    if params.stack_supports_ranger_kms_ssl:
+      # remove plain-text password from xml configs
+      for prop in params.ranger_kms_site_password_properties:
+        if prop in ranger_kms_site_copy:
+          ranger_kms_site_copy[prop] = "_"
+
     XmlConfig("ranger-kms-site.xml",
       conf_dir=params.kms_conf_dir,
-      configurations=params.config['configurations']['ranger-kms-site'],
+      configurations=ranger_kms_site_copy,
       configuration_attributes=params.config['configuration_attributes']['ranger-kms-site'],
       owner=params.kms_user,
       group=params.kms_group,

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5014253/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/params.py b/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/params.py
index 8473160..dc830d5 100755
--- a/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/params.py
+++ b/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/params.py
@@ -48,6 +48,7 @@ stack_support_kms_hsm = check_stack_feature(StackFeature.RANGER_KMS_HSM_SUPPORT,
 stack_supports_ranger_kerberos = check_stack_feature(StackFeature.RANGER_KERBEROS_SUPPORT, version_for_stack_feature_checks)
 stack_supports_pid = check_stack_feature(StackFeature.RANGER_KMS_PID_SUPPORT, version_for_stack_feature_checks)
 stack_supports_ranger_audit_db = check_stack_feature(StackFeature.RANGER_AUDIT_DB_SUPPORT, version_for_stack_feature_checks)
+stack_supports_ranger_kms_ssl = check_stack_feature(StackFeature.RANGER_KMS_SSL, version_for_stack_feature_checks)
 
 hadoop_conf_dir = conf_select.get_hadoop_conf_dir()
 security_enabled = config['configurations']['cluster-env']['security_enabled']
@@ -279,4 +280,9 @@ if security_enabled:
 
 plugin_audit_password_property = 'xasecure.audit.destination.db.password'
 kms_plugin_password_properties = ['xasecure.policymgr.clientssl.keystore.password', 'xasecure.policymgr.clientssl.truststore.password']
-dbks_site_password_properties = ['ranger.db.encrypt.key.password', 'ranger.ks.jpa.jdbc.password', 'ranger.ks.hsm.partition.password']
\ No newline at end of file
+dbks_site_password_properties = ['ranger.db.encrypt.key.password', 'ranger.ks.jpa.jdbc.password', 'ranger.ks.hsm.partition.password']
+ranger_kms_site_password_properties = ['ranger.service.https.attrib.keystore.pass']
+ranger_kms_cred_ssl_path = config['configurations']['ranger-kms-site']['ranger.credential.provider.path']
+ranger_kms_ssl_keystore_alias = config['configurations']['ranger-kms-site']['ranger.service.https.attrib.keystore.credential.alias']
+ranger_kms_ssl_passwd = config['configurations']['ranger-kms-site']['ranger.service.https.attrib.keystore.pass']
+ranger_kms_ssl_enabled = config['configurations']['ranger-kms-site']['ranger.service.https.attrib.ssl.enabled']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5014253/ambari-server/src/main/resources/stacks/HDP/2.0.6/properties/stack_features.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/properties/stack_features.json b/ambari-server/src/main/resources/stacks/HDP/2.0.6/properties/stack_features.json
index 5e173b7..bc2e7a7 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/properties/stack_features.json
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/properties/stack_features.json
@@ -387,6 +387,11 @@
       "name": "secure_ranger_ssl_password",
       "description": "Securing Ranger Admin and Usersync SSL and Trustore related passwords in jceks",
       "min_version": "2.6.0.0"
+    },
+    {
+      "name": "ranger_kms_ssl",
+      "description": "Ranger KMS SSL properties in ambari stack",
+      "min_version": "2.6.0.0"
     }
   ]
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5014253/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/config-upgrade.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/config-upgrade.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/config-upgrade.xml
index 478f9b4..ba155ab 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/config-upgrade.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/config-upgrade.xml
@@ -338,6 +338,13 @@
             <replace key="content" find="log4j.appender.kms-audit=org.apache.log4j.DailyRollingFileAppender" replace-with="log4j.appender.kms-audit=org.apache.log4j.DailyRollingFileAppender&#xA;log4j.appender.kms-audit.MaxFileSize = {{ranger_kms_audit_log_maxfilesize}}MB"/>
             <replace key="content" find="log4j.appender.kms-audit=org.apache.log4j.DailyRollingFileAppender" replace-with="log4j.appender.kms-audit=org.apache.log4j.DailyRollingFileAppender&#xA;log4j.appender.kms-audit.MaxBackupIndex = {{ranger_kms_audit_log_maxbackupindex}}"/>
           </definition>
+          <definition xsi:type="configure" id="hdp_2_6_0_0_remove_ranger_kms_duplicate_ssl">
+            <type>ranger-kms-site</type>
+            <transfer operation="delete" delete-key="ranger.https.attrib.keystore.file"
+              if-type="ranger-kms-site" if-key="ranger.service.https.attrib.keystore.file" if-key-state="present"/>
+            <transfer operation="delete" delete-key="ranger.service.https.attrib.clientAuth"
+              if-type="ranger-kms-site" if-key="ranger.service.https.attrib.client.auth" if-key-state="present"/>
+          </definition>
         </changes>
       </component>
     </service>

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5014253/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.6.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.6.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.6.xml
index d5ddeeb..e6a3c94 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.6.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/nonrolling-upgrade-2.6.xml
@@ -556,6 +556,10 @@
         </task>
       </execute-stage>
 
+      <execute-stage service="RANGER_KMS" component="RANGER_KMS_SERVER" title="Apply config changes for Ranger KMS">
+        <task xsi:type="configure" id="hdp_2_6_0_0_remove_ranger_kms_duplicate_ssl"/>
+      </execute-stage>
+
       <!-- KNOX -->
       <execute-stage service="KNOX" component="KNOX_GATEWAY" title="Apply config changes for Knox Gateway">
         <task xsi:type="configure" id="hdp_2_5_0_0_remove_ranger_knox_audit_db"/>

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5014253/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.6.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.6.xml b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.6.xml
index 88486e6..7d8438f 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.6.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.3/upgrades/upgrade-2.6.xml
@@ -654,6 +654,7 @@
         <pre-upgrade>
           <task xsi:type="configure" id="hdp_2_5_0_0_remove_ranger_kms_audit_db" />
           <task xsi:type="configure" id="kms_log4j_parameterize" />
+          <task xsi:type="configure" id="hdp_2_6_0_0_remove_ranger_kms_duplicate_ssl" />
           <task xsi:type="execute" hosts="any" sequential="true">
             <summary>Upgrading Ranger KMS database schema</summary>
             <script>scripts/kms_server.py</script>

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5014253/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/config-upgrade.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/config-upgrade.xml b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/config-upgrade.xml
index 18f5fa1..d19bb76 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/config-upgrade.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/config-upgrade.xml
@@ -229,6 +229,13 @@
             <replace key="content" find="log4j.appender.kms-audit=org.apache.log4j.DailyRollingFileAppender" replace-with="log4j.appender.kms-audit=org.apache.log4j.DailyRollingFileAppender&#xA;log4j.appender.kms-audit.MaxFileSize = {{ranger_kms_audit_log_maxfilesize}}MB"/>
             <replace key="content" find="log4j.appender.kms-audit=org.apache.log4j.DailyRollingFileAppender" replace-with="log4j.appender.kms-audit=org.apache.log4j.DailyRollingFileAppender&#xA;log4j.appender.kms-audit.MaxBackupIndex = {{ranger_kms_audit_log_maxbackupindex}}"/>
           </definition>
+          <definition xsi:type="configure" id="hdp_2_6_0_0_remove_ranger_kms_duplicate_ssl">
+            <type>ranger-kms-site</type>
+            <transfer operation="delete" delete-key="ranger.https.attrib.keystore.file"
+              if-type="ranger-kms-site" if-key="ranger.service.https.attrib.keystore.file" if-key-state="present"/>
+            <transfer operation="delete" delete-key="ranger.service.https.attrib.clientAuth"
+              if-type="ranger-kms-site" if-key="ranger.service.https.attrib.client.auth" if-key-state="present"/>
+          </definition>
         </changes>
       </component>
     </service>

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5014253/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.6.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.6.xml b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.6.xml
index 94b19c6..69a894c 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.6.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/nonrolling-upgrade-2.6.xml
@@ -563,6 +563,10 @@
         </task>
       </execute-stage>
 
+      <execute-stage service="RANGER_KMS" component="RANGER_KMS_SERVER" title="Apply config changes for Ranger KMS">
+        <task xsi:type="configure" id="hdp_2_6_0_0_remove_ranger_kms_duplicate_ssl"/>
+      </execute-stage>
+
       <!--ATLAS-->
       <execute-stage service="ATLAS" component="ATLAS_SERVER" title="Parameterizing Atlas Log4J Properties">
         <task xsi:type="configure" id="atlas_log4j_parameterize">

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5014253/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.6.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.6.xml b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.6.xml
index 626bc63..0c9a8ea 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.6.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.4/upgrades/upgrade-2.6.xml
@@ -643,6 +643,7 @@
         <pre-upgrade>
           <task xsi:type="configure" id="hdp_2_5_0_0_remove_ranger_kms_audit_db" />
           <task xsi:type="configure" id="kms_log4j_parameterize" />
+          <task xsi:type="configure" id="hdp_2_6_0_0_remove_ranger_kms_duplicate_ssl" />
           <task xsi:type="execute" hosts="any" sequential="true">
             <summary>Upgrading Ranger KMS database schema</summary>
             <script>scripts/kms_server.py</script>

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5014253/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/config-upgrade.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/config-upgrade.xml b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/config-upgrade.xml
index 15837df..7236186 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/config-upgrade.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/config-upgrade.xml
@@ -270,6 +270,13 @@
         <replace key="content" find="log4j.appender.kms-audit=org.apache.log4j.DailyRollingFileAppender" replace-with="log4j.appender.kms-audit=org.apache.log4j.DailyRollingFileAppender&#xA;log4j.appender.kms-audit.MaxFileSize = {{ranger_kms_audit_log_maxfilesize}}MB"/>
         <replace key="content" find="log4j.appender.kms-audit=org.apache.log4j.DailyRollingFileAppender" replace-with="log4j.appender.kms-audit=org.apache.log4j.DailyRollingFileAppender&#xA;log4j.appender.kms-audit.MaxBackupIndex = {{ranger_kms_audit_log_maxbackupindex}}"/>
       </definition>
+      <definition xsi:type="configure" id="hdp_2_6_0_0_remove_ranger_kms_duplicate_ssl">
+        <type>ranger-kms-site</type>
+        <transfer operation="delete" delete-key="ranger.https.attrib.keystore.file"
+          if-type="ranger-kms-site" if-key="ranger.service.https.attrib.keystore.file" if-key-state="present"/>
+        <transfer operation="delete" delete-key="ranger.service.https.attrib.clientAuth"
+          if-type="ranger-kms-site" if-key="ranger.service.https.attrib.client.auth" if-key-state="present"/>
+      </definition>
     </changes>
     </component>
     </service>

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5014253/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml
index 62991e6..4fb68ed 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/nonrolling-upgrade-2.6.xml
@@ -402,6 +402,10 @@
         </task>
       </execute-stage>
 
+      <execute-stage service="RANGER_KMS" component="RANGER_KMS_SERVER" title="Apply config changes for Ranger KMS">
+        <task xsi:type="configure" id="hdp_2_6_0_0_remove_ranger_kms_duplicate_ssl"/>
+      </execute-stage>
+
       <!--ATLAS-->
       <execute-stage service="ATLAS" component="ATLAS_SERVER" title="Parameterizing Atlas Log4J Properties">
         <task xsi:type="configure" id="atlas_log4j_parameterize">

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5014253/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.6.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.6.xml b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.6.xml
index 818a6c0..0a02734 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.6.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.5/upgrades/upgrade-2.6.xml
@@ -553,6 +553,7 @@
       <component name="RANGER_KMS_SERVER">
         <pre-upgrade>
           <task xsi:type="configure" id="kms_log4j_parameterize" />
+          <task xsi:type="configure" id="hdp_2_6_0_0_remove_ranger_kms_duplicate_ssl" />
           <task xsi:type="execute" hosts="any" sequential="true">
             <summary>Upgrading Ranger KMS database schema</summary>
             <script>scripts/kms_server.py</script>

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5014253/ambari-server/src/main/resources/stacks/HDP/2.6/services/RANGER_KMS/configuration/ranger-kms-site.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.6/services/RANGER_KMS/configuration/ranger-kms-site.xml b/ambari-server/src/main/resources/stacks/HDP/2.6/services/RANGER_KMS/configuration/ranger-kms-site.xml
new file mode 100644
index 0000000..cd63e6e
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.6/services/RANGER_KMS/configuration/ranger-kms-site.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+/**
+ * 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.
+ */
+-->
+<configuration>
+  <property>
+    <name>ranger.service.https.attrib.keystore.file</name>
+    <value>/etc/security/serverKeys/ranger-kms-keystore.jks</value>
+    <on-ambari-upgrade add="false"/>
+    <description/>
+  </property>
+  <property>
+    <name>ranger.service.https.attrib.client.auth</name>
+    <value>want</value>
+    <on-ambari-upgrade add="false"/>
+    <description/>
+  </property>
+  <property>
+    <name>ranger.service.https.attrib.keystore.keyalias</name>
+    <value>rangerkms</value>
+    <on-ambari-upgrade add="false"/>
+    <description/>
+  </property>
+  <property>
+    <name>ranger.service.https.attrib.keystore.pass</name>
+    <value>rangerkms</value>
+    <property-type>PASSWORD</property-type>
+    <value-attributes>
+      <type>password</type>
+    </value-attributes>
+    <on-ambari-upgrade add="false"/>
+    <description/>
+  </property>
+  <property>
+    <name>ranger.credential.provider.path</name>
+    <value>/etc/ranger/kms/rangerkms.jceks</value>
+    <on-ambari-upgrade add="false"/>
+    <description/>
+  </property>
+  <property>
+    <name>ranger.service.https.attrib.keystore.credential.alias</name>
+    <value>keyStoreCredentialAlias</value>
+    <on-ambari-upgrade add="false"/>
+    <description/>
+  </property>
+  <property>
+    <name>ajp.enabled</name>
+    <value>false</value>
+    <on-ambari-upgrade add="false"/>
+    <description/>
+  </property>
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5014253/ambari-server/src/main/resources/stacks/HDP/2.6/services/stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.6/services/stack_advisor.py b/ambari-server/src/main/resources/stacks/HDP/2.6/services/stack_advisor.py
index 969c3dd..d8413b6 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.6/services/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.6/services/stack_advisor.py
@@ -33,7 +33,8 @@ class HDP26StackAdvisor(HDP25StackAdvisor):
           "DRUID": self.recommendDruidConfigurations,
           "ATLAS": self.recommendAtlasConfigurations,
           "TEZ": self.recommendTezConfigurations,
-          "RANGER": self.recommendRangerConfigurations
+          "RANGER": self.recommendRangerConfigurations,
+          "RANGER_KMS": self.recommendRangerKMSConfigurations
       }
       parentRecommendConfDict.update(childRecommendConfDict)
       return parentRecommendConfDict
@@ -301,3 +302,20 @@ class HDP26StackAdvisor(HDP25StackAdvisor):
                             "Need to set ranger.usersync.group.searchenabled as true, as ranger.usersync.ldap.deltasync is enabled")})
 
     return self.toConfigurationValidationProblems(validationItems, "ranger-ugsync-site")
+
+  def recommendRangerKMSConfigurations(self, configurations, clusterData, services, hosts):
+    super(HDP26StackAdvisor, self).recommendRangerKMSConfigurations(configurations, clusterData, services, hosts)
+    putRangerKmsEnvProperty = self.putProperty(configurations, "kms-env", services)
+
+    ranger_kms_ssl_enabled = False
+    ranger_kms_ssl_port = "9393"
+    if 'ranger-kms-site' in services['configurations'] and 'ranger.service.https.attrib.ssl.enabled' in services['configurations']['ranger-kms-site']['properties']:
+      ranger_kms_ssl_enabled = services['configurations']['ranger-kms-site']['properties']['ranger.service.https.attrib.ssl.enabled'].lower() == "true"
+
+    if 'ranger-kms-site' in services['configurations'] and 'ranger.service.https.port' in services['configurations']['ranger-kms-site']['properties']:
+      ranger_kms_ssl_port = services['configurations']['ranger-kms-site']['properties']['ranger.service.https.port']
+
+    if ranger_kms_ssl_enabled:
+      putRangerKmsEnvProperty("kms_port", ranger_kms_ssl_port)
+    else:
+      putRangerKmsEnvProperty("kms_port", "9292")
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5014253/ambari-server/src/test/python/stacks/2.5/RANGER_KMS/test_kms_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.5/RANGER_KMS/test_kms_server.py b/ambari-server/src/test/python/stacks/2.5/RANGER_KMS/test_kms_server.py
index c2fc270..6f41b6d 100644
--- a/ambari-server/src/test/python/stacks/2.5/RANGER_KMS/test_kms_server.py
+++ b/ambari-server/src/test/python/stacks/2.5/RANGER_KMS/test_kms_server.py
@@ -208,6 +208,16 @@ class TestRangerKMS(RMFTestCase):
       create_parents = True
     )
 
+    self.assertResourceCalled('Directory', '/etc/security/serverKeys',
+      create_parents = True,
+      cd_access = "a",
+    )
+
+    self.assertResourceCalled('Directory', '/etc/ranger/kms',
+      create_parents = True,
+      cd_access = "a",
+    )
+
     self.assertResourceCalled('File', '/usr/hdp/current/ranger-kms/ews/webapp/lib/mysql-connector-java-old.jar',
         action = ['delete'],
     )
@@ -559,6 +569,16 @@ class TestRangerKMS(RMFTestCase):
       create_parents = True
     )
 
+    self.assertResourceCalled('Directory', '/etc/security/serverKeys',
+      create_parents = True,
+      cd_access = "a",
+    )
+
+    self.assertResourceCalled('Directory', '/etc/ranger/kms',
+      create_parents = True,
+      cd_access = "a",
+    )
+
     self.assertResourceCalled('File', '/usr/hdp/current/ranger-kms/ews/webapp/lib/mysql-connector-java-old.jar',
         action = ['delete'],
     )

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5014253/ambari-server/src/test/python/stacks/2.6/common/test_stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.6/common/test_stack_advisor.py b/ambari-server/src/test/python/stacks/2.6/common/test_stack_advisor.py
index b7f8cbb..c15eaf1 100644
--- a/ambari-server/src/test/python/stacks/2.6/common/test_stack_advisor.py
+++ b/ambari-server/src/test/python/stacks/2.6/common/test_stack_advisor.py
@@ -780,6 +780,75 @@ class TestHDP26StackAdvisor(TestCase):
     self.stackAdvisor.recommendRangerConfigurations(recommendedConfigurations, clusterData, services, None)
     self.assertEquals(recommendedConfigurations, expected)
 
+  def test_recommendRangerKMSConfigurations(self):
+    clusterData = {}
+    services = {
+      "ambari-server-properties": {
+        "ambari-server.user": "root"
+        },
+      "Versions": {
+        "stack_version" : "2.6",
+        },
+      "services": [
+        {
+          "StackServices": {
+            "service_name": "RANGER_KMS",
+            "service_version": "0.7.0.2.6"
+          },
+          "components": [
+            {
+              "StackServiceComponents": {
+                "component_name": "RANGER_KMS_SERVER",
+                "hostnames": ["host1"]
+              }
+            }
+          ]
+        }
+      ],
+      "configurations": {
+        'ranger-kms-site': {
+          'properties': {
+            "ranger.service.https.attrib.ssl.enabled": "true",
+            "ranger.service.https.port": "9393"
+          }
+        }
+      }
+    }
+
+    expected = {
+      'kms-site': {
+        'properties': {},
+        'property_attributes': {
+          'hadoop.kms.proxyuser.HTTP.users': {'delete': 'true'},
+          'hadoop.kms.proxyuser.root.hosts': {'delete': 'true'},
+          'hadoop.kms.proxyuser.root.users': {'delete': 'true'},
+          'hadoop.kms.proxyuser.HTTP.hosts': {'delete': 'true'}
+        }
+      },
+      'core-site': {
+        'properties': {}
+      },
+      'kms-properties': {
+        'properties': {}
+      },
+      'ranger-kms-audit': {
+        'properties': {}
+      },
+      'kms-env': {
+        'properties': {
+          'kms_port': '9393'
+        }
+      },
+      'dbks-site': {
+        'properties': {}
+      }
+    }
+
+    recommendedConfigurations = {}
+
+    self.stackAdvisor.recommendRangerKMSConfigurations(recommendedConfigurations, clusterData, services, None)
+    self.assertEquals(recommendedConfigurations, expected)
+
 def load_json(self, filename):
   file = os.path.join(self.testDirectory, filename)
   with open(file, 'rb') as f:


[10/15] ambari git commit: AMBARI-18868. Stage and Request status should be persisted in the database. (jaimin)

Posted by jo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RequestEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RequestEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RequestEntity.java
index 7944d21..f19aa72 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RequestEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RequestEntity.java
@@ -69,9 +69,28 @@ public class RequestEntity {
   @Enumerated(value = EnumType.STRING)
   private RequestType requestType;
 
-  @Column(name = "status")
+  /**
+   * This is the logical status of the request and
+   * represents if the intent of the request has been accomplished or not
+   *
+   *  Status calculated by calculating {@link StageEntity#status} of all belonging stages
+   *
+   */
+  @Column(name = "status", nullable = false)
   @Enumerated(value = EnumType.STRING)
-  private HostRoleStatus status;
+  private HostRoleStatus status = HostRoleStatus.PENDING;
+
+  /**
+   * This status informs if any of the underlying tasks
+   * have faced any type of failures {@link HostRoleStatus#isFailedState()}
+   *
+   * Status calculated by only taking into account
+   * all belonging {@link HostRoleCommandEntity#status} (or {@link StageEntity#status})
+   *
+   */
+  @Column(name = "display_status", nullable = false)
+  @Enumerated(value = EnumType.STRING)
+  private HostRoleStatus displayStatus = HostRoleStatus.PENDING;
 
   @Basic
   @Column(name = "create_time", nullable = false)
@@ -89,7 +108,7 @@ public class RequestEntity {
   @Column(name = "exclusive_execution", insertable = true, updatable = true, nullable = false)
   private Integer exclusive = 0;
 
-  @OneToMany(mappedBy = "request")
+  @OneToMany(mappedBy = "request", cascade = CascadeType.REMOVE)
   private Collection<StageEntity> stages;
 
   @OneToMany(mappedBy = "requestEntity", cascade = CascadeType.ALL)
@@ -207,14 +226,38 @@ public class RequestEntity {
     this.commandName = commandName;
   }
 
+  /**
+   *  get status for the request
+   * @return {@link HostRoleStatus}
+   */
   public HostRoleStatus getStatus() {
     return status;
   }
 
+  /**
+   * sets status for the request
+   * @param status {@link HostRoleStatus}
+   */
   public void setStatus(HostRoleStatus status) {
     this.status = status;
   }
 
+  /**
+   * get display status for the request
+   * @return  {@link HostRoleStatus}
+   */
+  public HostRoleStatus getDisplayStatus() {
+    return displayStatus;
+  }
+
+  /**
+   * sets display status for the request
+   * @param displayStatus {@link HostRoleStatus}
+   */
+  public void setDisplayStatus(HostRoleStatus displayStatus) {
+    this.displayStatus = displayStatus;
+  }
+
   public RequestScheduleEntity getRequestScheduleEntity() {
     return requestScheduleEntity;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity.java
index f9c8810..f68338f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntity.java
@@ -39,17 +39,21 @@ import javax.persistence.OneToMany;
 import javax.persistence.Table;
 
 import org.apache.ambari.server.actionmanager.CommandExecutionType;
+import org.apache.ambari.server.actionmanager.HostRoleStatus;
 
 @Entity
 @Table(name = "stage")
 @IdClass(org.apache.ambari.server.orm.entities.StageEntityPK.class)
 @NamedQueries({
     @NamedQuery(
-        name = "StageEntity.findByCommandStatuses",
-        query = "SELECT stage from StageEntity stage WHERE stage.stageId IN (SELECT roleCommand.stageId from HostRoleCommandEntity roleCommand WHERE roleCommand.status IN :statuses AND roleCommand.stageId = stage.stageId AND roleCommand.requestId = stage.requestId ) ORDER BY stage.requestId, stage.stageId"),
+        name = "StageEntity.findByStatuses",
+        query = "SELECT stage from StageEntity stage WHERE stage.status IN :statuses ORDER BY stage.requestId, stage.stageId"),
+    @NamedQuery(
+        name = "StageEntity.findByPK",
+        query = "SELECT stage from StageEntity stage WHERE stage.requestId = :requestId AND stage.stageId = :stageId"),
     @NamedQuery(
         name = "StageEntity.findByRequestIdAndCommandStatuses",
-        query = "SELECT stage from StageEntity stage WHERE stage.stageId IN (SELECT roleCommand.stageId from HostRoleCommandEntity roleCommand WHERE roleCommand.requestId = :requestId AND roleCommand.status IN :statuses AND roleCommand.stageId = stage.stageId AND roleCommand.requestId = stage.requestId ) ORDER BY stage.stageId"),
+        query = "SELECT stage from StageEntity stage WHERE stage.status IN :statuses AND stage.requestId = :requestId ORDER BY stage.stageId"),
     @NamedQuery(
         name = "StageEntity.findIdsByRequestId",
         query = "SELECT stage.stageId FROM StageEntity stage WHERE stage.requestId = :requestId ORDER BY stage.stageId ASC") })
@@ -110,6 +114,32 @@ public class StageEntity {
   @Basic
   private byte[] hostParamsStage;
 
+  /**
+   * This status informs if the advanced criteria for the stage success
+   * as established at the time of stage creation has been accomplished or not
+   *
+   *  Status calculated by taking into account following
+   *  a) {@link #roleSuccessCriterias}
+   *  b) {@link #skippable}
+   *  c) {@link HostRoleCommandEntity#autoSkipOnFailure}
+   *  d) {@link HostRoleCommandEntity#status}
+   *
+   */
+  @Column(name = "status",  nullable = false)
+  @Enumerated(EnumType.STRING)
+  private HostRoleStatus status = HostRoleStatus.PENDING;
+
+  /**
+   * This status informs if any of the underlying tasks
+   * have faced any type of failures {@link HostRoleStatus#isFailedState()}
+   *
+   * Status calculated by only taking into account {@link HostRoleCommandEntity#status}
+   *
+   */
+  @Column(name = "display_status", nullable = false)
+  @Enumerated(EnumType.STRING)
+  private HostRoleStatus displayStatus = HostRoleStatus.PENDING;
+
   @ManyToOne
   @JoinColumn(name = "request_id", referencedColumnName = "request_id", nullable = false)
   private RequestEntity request;
@@ -195,6 +225,40 @@ public class StageEntity {
     this.commandExecutionType = commandExecutionType;
   }
 
+  /**
+   * get status for the stage
+   * @return {@link HostRoleStatus}
+   */
+  public HostRoleStatus getStatus() {
+    return status;
+  }
+
+  /**
+   * sets status for the stage
+   * @param status {@link HostRoleStatus}
+   */
+  public void setStatus(HostRoleStatus status) {
+    this.status = status;
+  }
+
+  /**
+   * get display status for the stage
+   * @return  {@link HostRoleStatus}
+   */
+  public HostRoleStatus getDisplayStatus() {
+    return displayStatus;
+  }
+
+
+  /**
+   * sets display status for the stage
+   * @param displayStatus {@link HostRoleStatus}
+   */
+  public void setDisplayStatus(HostRoleStatus displayStatus) {
+    this.displayStatus = displayStatus;
+  }
+
+
   @Override
   public boolean equals(Object o) {
     if (this == o) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntityPK.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntityPK.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntityPK.java
index 9ca0470..34d175c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntityPK.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/StageEntityPK.java
@@ -68,4 +68,16 @@ public class StageEntityPK implements Serializable {
     result = 31 * result + (stageId != null ? stageId.hashCode() : 0);
     return result;
   }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String toString() {
+    StringBuilder buffer = new StringBuilder("StageEntityPK{");
+    buffer.append("stageId=").append(getStageId());
+    buffer.append("requestId=").append(getRequestId());
+    buffer.append("}");
+    return buffer.toString();
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog300.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog300.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog300.java
index 4f90ef3..0267a5e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog300.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog300.java
@@ -19,11 +19,25 @@ package org.apache.ambari.server.upgrade;
 
 
 import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
 import java.util.Map;
 
+import javax.persistence.EntityManager;
+
 import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.actionmanager.HostRoleCommand;
+import org.apache.ambari.server.actionmanager.HostRoleStatus;
+import org.apache.ambari.server.actionmanager.Stage;
+import org.apache.ambari.server.actionmanager.StageFactory;
 import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.internal.CalculatedStatus;
+import org.apache.ambari.server.orm.DBAccessor;
 import org.apache.ambari.server.orm.dao.DaoUtils;
+import org.apache.ambari.server.orm.dao.RequestDAO;
+import org.apache.ambari.server.orm.entities.RequestEntity;
+import org.apache.ambari.server.orm.entities.StageEntity;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
@@ -41,6 +55,12 @@ public class UpgradeCatalog300 extends AbstractUpgradeCatalog {
    */
   private static final Logger LOG = LoggerFactory.getLogger(UpgradeCatalog300.class);
 
+  private static final String STAGE_TABLE = "stage";
+  private static final String STAGE_STATUS_COLUMN = "status";
+  private static final String STAGE_DISPLAY_STATUS_COLUMN = "display_status";
+  private static final String REQUEST_TABLE = "request";
+  private static final String REQUEST_DISPLAY_STATUS_COLUMN = "display_status";
+
   @Inject
   DaoUtils daoUtils;
 
@@ -83,6 +103,16 @@ public class UpgradeCatalog300 extends AbstractUpgradeCatalog {
    */
   @Override
   protected void executeDDLUpdates() throws AmbariException, SQLException {
+    updateStageTable();
+  }
+
+  protected void updateStageTable() throws SQLException {
+    dbAccessor.addColumn(STAGE_TABLE,
+        new DBAccessor.DBColumnInfo(STAGE_STATUS_COLUMN, String.class, 255, HostRoleStatus.PENDING, false));
+    dbAccessor.addColumn(STAGE_TABLE,
+        new DBAccessor.DBColumnInfo(STAGE_DISPLAY_STATUS_COLUMN, String.class, 255, HostRoleStatus.PENDING, false));
+    dbAccessor.addColumn(REQUEST_TABLE,
+        new DBAccessor.DBColumnInfo(REQUEST_DISPLAY_STATUS_COLUMN, String.class, 255, HostRoleStatus.PENDING, false));
   }
 
   /**
@@ -99,6 +129,7 @@ public class UpgradeCatalog300 extends AbstractUpgradeCatalog {
   protected void executeDMLUpdates() throws AmbariException, SQLException {
     addNewConfigurationsFromXml();
     showHcatDeletedUserMessage();
+    setStatusOfStagesAndRequests();
   }
 
   protected void showHcatDeletedUserMessage() {
@@ -122,4 +153,43 @@ public class UpgradeCatalog300 extends AbstractUpgradeCatalog {
 
   }
 
+  protected void setStatusOfStagesAndRequests() {
+    executeInTransaction(new Runnable() {
+      @Override
+      public void run() {
+        try {
+          RequestDAO requestDAO = injector.getInstance(RequestDAO.class);
+          StageFactory stageFactory = injector.getInstance(StageFactory.class);
+          EntityManager em = getEntityManagerProvider().get();
+          List<RequestEntity> requestEntities= requestDAO.findAll();
+          for (RequestEntity requestEntity: requestEntities) {
+            Collection<StageEntity> stageEntities= requestEntity.getStages();
+            List <HostRoleStatus> stageDisplayStatuses = new ArrayList<>();
+            List <HostRoleStatus> stageStatuses = new ArrayList<>();
+            for (StageEntity stageEntity: stageEntities) {
+              Stage stage = stageFactory.createExisting(stageEntity);
+              List<HostRoleCommand> hostRoleCommands = stage.getOrderedHostRoleCommands();
+              Map<HostRoleStatus, Integer> statusCount = CalculatedStatus.calculateStatusCountsForTasks(hostRoleCommands);
+              HostRoleStatus stageDisplayStatus = CalculatedStatus.calculateSummaryDisplayStatus(statusCount, hostRoleCommands.size(), stage.isSkippable());
+              HostRoleStatus stageStatus = CalculatedStatus.calculateStageStatus(hostRoleCommands, statusCount, stage.getSuccessFactors(), stage.isSkippable());
+              stageEntity.setStatus(stageStatus);
+              stageStatuses.add(stageStatus);
+              stageEntity.setDisplayStatus(stageDisplayStatus);
+              stageDisplayStatuses.add(stageDisplayStatus);
+              em.merge(stageEntity);
+            }
+            HostRoleStatus requestStatus = CalculatedStatus.getOverallStatusForRequest(stageStatuses);
+            requestEntity.setStatus(requestStatus);
+            HostRoleStatus requestDisplayStatus = CalculatedStatus.getOverallDisplayStatusForRequest(stageDisplayStatuses);
+            requestEntity.setDisplayStatus(requestDisplayStatus);
+            em.merge(requestEntity);
+          }
+        } catch (Exception e) {
+          LOG.warn("Setting status for stages and Requests threw exception. ", e);
+        }
+      }
+    });
+
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/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 f007b53..6c7cb09 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
@@ -345,7 +345,8 @@ CREATE TABLE request (
   request_type VARCHAR(255),
   request_schedule_id BIGINT,
   start_time BIGINT NOT NULL,
-  status VARCHAR(255),
+  status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
+  display_status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
   CONSTRAINT PK_request PRIMARY KEY (request_id),
   CONSTRAINT FK_request_schedule_id FOREIGN KEY (request_schedule_id) REFERENCES requestschedule (schedule_id));
 
@@ -361,6 +362,8 @@ CREATE TABLE stage (
   command_params BLOB,
   host_params BLOB,
   command_execution_type VARCHAR(32) NOT NULL DEFAULT 'STAGE',
+  status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
+  display_status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
   CONSTRAINT PK_stage PRIMARY KEY (stage_id, request_id),
   CONSTRAINT FK_stage_request_id FOREIGN KEY (request_id) REFERENCES request (request_id));
 
@@ -378,7 +381,7 @@ CREATE TABLE host_role_command (
   start_time BIGINT NOT NULL,
   original_start_time BIGINT NOT NULL,
   end_time BIGINT,
-  status VARCHAR(255),
+  status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
   auto_skip_on_failure SMALLINT DEFAULT 0 NOT NULL,
   std_error BLOB,
   std_out BLOB,

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/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 f6cb896..ebb0da0 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -356,7 +356,8 @@ CREATE TABLE request (
   request_context VARCHAR(255),
   request_type VARCHAR(255),
   start_time BIGINT NOT NULL,
-  status VARCHAR(255),
+  status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
+  display_status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
   CONSTRAINT PK_request PRIMARY KEY (request_id),
   CONSTRAINT FK_request_schedule_id FOREIGN KEY (request_schedule_id) REFERENCES requestschedule (schedule_id));
 
@@ -372,6 +373,8 @@ CREATE TABLE stage (
   command_params LONGBLOB,
   host_params LONGBLOB,
   command_execution_type VARCHAR(32) NOT NULL DEFAULT 'STAGE',
+  status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
+  display_status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
   CONSTRAINT PK_stage PRIMARY KEY (stage_id, request_id),
   CONSTRAINT FK_stage_request_id FOREIGN KEY (request_id) REFERENCES request (request_id));
 
@@ -390,7 +393,7 @@ CREATE TABLE host_role_command (
   start_time BIGINT NOT NULL,
   original_start_time BIGINT NOT NULL,
   end_time BIGINT,
-  status VARCHAR(100),
+  status VARCHAR(100) NOT NULL DEFAULT 'PENDING',
   auto_skip_on_failure SMALLINT DEFAULT 0 NOT NULL,
   std_error LONGBLOB,
   std_out LONGBLOB,

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/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 19253e8..884eb06 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -336,7 +336,8 @@ CREATE TABLE request (
   request_context VARCHAR(255),
   request_type VARCHAR(255),
   start_time NUMBER(19) NOT NULL,
-  status VARCHAR(255),
+  status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
+  display_status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
   CONSTRAINT PK_request PRIMARY KEY (request_id),
   CONSTRAINT FK_request_schedule_id FOREIGN KEY (request_schedule_id) REFERENCES requestschedule (schedule_id));
 
@@ -352,6 +353,8 @@ CREATE TABLE stage (
   command_params BLOB,
   host_params BLOB,
   command_execution_type VARCHAR2(32) DEFAULT 'STAGE' NOT NULL,
+  status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
+  display_status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
   CONSTRAINT PK_stage PRIMARY KEY (stage_id, request_id),
   CONSTRAINT FK_stage_request_id FOREIGN KEY (request_id) REFERENCES request (request_id));
 
@@ -370,7 +373,7 @@ CREATE TABLE host_role_command (
   start_time NUMBER(19) NOT NULL,
   original_start_time NUMBER(19) NOT NULL,
   end_time NUMBER(19),
-  status VARCHAR2(255) NULL,
+  status VARCHAR2(255) NOT NULL DEFAULT 'PENDING',
   auto_skip_on_failure NUMBER(1) DEFAULT 0 NOT NULL,
   std_error BLOB NULL,
   std_out BLOB NULL,

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/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 b13a9e3..7e57d9f 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -345,7 +345,8 @@ CREATE TABLE request (
   request_type VARCHAR(255),
   request_schedule_id BIGINT,
   start_time BIGINT NOT NULL,
-  status VARCHAR(255),
+  status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
+  display_status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
   CONSTRAINT PK_request PRIMARY KEY (request_id),
   CONSTRAINT FK_request_schedule_id FOREIGN KEY (request_schedule_id) REFERENCES requestschedule (schedule_id));
 
@@ -361,6 +362,8 @@ CREATE TABLE stage (
   command_params BYTEA,
   host_params BYTEA,
   command_execution_type VARCHAR(32) DEFAULT 'STAGE' NOT NULL,
+  status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
+  display_status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
   CONSTRAINT PK_stage PRIMARY KEY (stage_id, request_id),
   CONSTRAINT FK_stage_request_id FOREIGN KEY (request_id) REFERENCES request (request_id));
 
@@ -378,7 +381,7 @@ CREATE TABLE host_role_command (
   start_time BIGINT NOT NULL,
   original_start_time BIGINT NOT NULL,
   end_time BIGINT,
-  status VARCHAR(255),
+  status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
   auto_skip_on_failure SMALLINT DEFAULT 0 NOT NULL,
   std_error BYTEA,
   std_out BYTEA,

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/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 cf2954a..2c4bd55 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
@@ -334,7 +334,8 @@ CREATE TABLE request (
   request_context VARCHAR(255),
   request_type VARCHAR(255),
   start_time NUMERIC(19) NOT NULL,
-  status VARCHAR(255),
+  status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
+  display_status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
   CONSTRAINT PK_request PRIMARY KEY (request_id),
   CONSTRAINT FK_request_schedule_id FOREIGN KEY (request_schedule_id) REFERENCES requestschedule (schedule_id));
 
@@ -350,6 +351,8 @@ CREATE TABLE stage (
   command_params IMAGE,
   host_params IMAGE,
   command_execution_type VARCHAR(32) NOT NULL DEFAULT 'STAGE',
+  status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
+  display_status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
   CONSTRAINT PK_stage PRIMARY KEY (stage_id, request_id),
   CONSTRAINT FK_stage_request_id FOREIGN KEY (request_id) REFERENCES request (request_id));
 
@@ -368,7 +371,7 @@ CREATE TABLE host_role_command (
   start_time NUMERIC(19) NOT NULL,
   original_start_time NUMERIC(19) NOT NULL,
   end_time NUMERIC(19),
-  status VARCHAR(255),
+  status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
   auto_skip_on_failure SMALLINT DEFAULT 0 NOT NULL,
   std_error IMAGE,
   std_out IMAGE,

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/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 16c269a..a86a767 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
@@ -350,7 +350,8 @@ CREATE TABLE request (
   request_type VARCHAR(255),
   request_schedule_id BIGINT,
   start_time BIGINT NOT NULL,
-  status VARCHAR(255),
+  status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
+  display_status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
   CONSTRAINT PK_request PRIMARY KEY CLUSTERED (request_id),
   CONSTRAINT FK_request_schedule_id FOREIGN KEY (request_schedule_id) REFERENCES requestschedule (schedule_id));
 
@@ -366,6 +367,8 @@ CREATE TABLE stage (
   command_params VARBINARY(MAX),
   host_params VARBINARY(MAX),
   command_execution_type VARCHAR(32) NOT NULL DEFAULT 'STAGE',
+  status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
+  display_status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
   CONSTRAINT PK_stage PRIMARY KEY CLUSTERED (stage_id, request_id),
   CONSTRAINT FK_stage_request_id FOREIGN KEY (request_id) REFERENCES request (request_id));
 
@@ -383,7 +386,7 @@ CREATE TABLE host_role_command (
   start_time BIGINT NOT NULL,
   original_start_time BIGINT NOT NULL,
   end_time BIGINT,
-  status VARCHAR(255),
+  status VARCHAR(255) NOT NULL DEFAULT 'PENDING',
   auto_skip_on_failure SMALLINT DEFAULT 0 NOT NULL,
   std_error VARBINARY(max),
   std_out VARBINARY(max),

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
index 177ac70..edc5683 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
@@ -55,6 +55,7 @@ import org.apache.ambari.server.utils.CommandUtils;
 import org.apache.ambari.server.utils.StageUtils;
 import org.easymock.EasyMock;
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -67,8 +68,6 @@ import com.google.inject.Injector;
 import com.google.inject.Singleton;
 import com.google.inject.util.Modules;
 
-import junit.framework.Assert;
-
 public class TestActionDBAccessorImpl {
   private static final Logger log = LoggerFactory.getLogger(TestActionDBAccessorImpl.class);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
index 6519126..526ca7c 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
@@ -27,6 +27,7 @@ import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyBoolean;
 import static org.mockito.Matchers.anyCollectionOf;
+import static org.mockito.Matchers.anyListOf;
 import static org.mockito.Matchers.anyLong;
 import static org.mockito.Matchers.anyString;
 import static org.mockito.Matchers.eq;
@@ -100,9 +101,11 @@ import org.apache.ambari.server.utils.StageUtils;
 import org.easymock.Capture;
 import org.easymock.EasyMock;
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
+import org.mockito.Mockito;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.slf4j.Logger;
@@ -119,8 +122,6 @@ import com.google.inject.Injector;
 import com.google.inject.Provider;
 import com.google.inject.persist.UnitOfWork;
 
-import junit.framework.Assert;
-
 public class TestActionScheduler {
 
   private static final Logger log = LoggerFactory.getLogger(TestActionScheduler.class);
@@ -207,6 +208,8 @@ public class TestActionScheduler {
     when(host.getHostName()).thenReturn(hostname);
 
     ActionDBAccessor db = mock(ActionDBAccessorImpl.class);
+    HostRoleCommandDAO hostRoleCommandDAOMock = mock(HostRoleCommandDAO.class);
+    Mockito.doNothing().when(hostRoleCommandDAOMock).publishTaskCreateEvent(anyListOf(HostRoleCommand.class));
     List<Stage> stages = new ArrayList<Stage>();
     Stage s = StageUtils.getATestStage(1, 977, hostname, CLUSTER_HOST_INFO,
       "{\"host_param\":\"param_value\"}", "{\"stage_param\":\"param_value\"}");
@@ -222,7 +225,7 @@ public class TestActionScheduler {
     //Keep large number of attempts so that the task is not expired finally
     //Small action timeout to test rescheduling
     ActionScheduler scheduler = new ActionScheduler(100, 5, db, aq, fsm,
-        10000, new HostsMap((String) null), unitOfWork, null, conf, entityManagerProviderMock, null, null);
+        10000, new HostsMap((String) null), unitOfWork, null, conf, entityManagerProviderMock, hostRoleCommandDAOMock, null);
     scheduler.setTaskTimeoutAdjustment(false);
 
     List<AgentCommand> ac = waitForQueueSize(hostname, aq, 1, scheduler);
@@ -314,6 +317,8 @@ public class TestActionScheduler {
     stages.add(s);
 
     ActionDBAccessor db = mock(ActionDBAccessor.class);
+    HostRoleCommandDAO hostRoleCommandDAOMock = mock(HostRoleCommandDAO.class);
+    Mockito.doNothing().when(hostRoleCommandDAOMock).publishTaskCreateEvent(anyListOf(HostRoleCommand.class));
     when(db.getCommandsInProgressCount()).thenReturn(stages.size());
     when(db.getStagesInProgress()).thenReturn(stages);
 
@@ -335,7 +340,7 @@ public class TestActionScheduler {
 
     //Small action timeout to test rescheduling
     ActionScheduler scheduler = new ActionScheduler(100, 0, db, aq, fsm, 3,
-        new HostsMap((String) null), unitOfWork, null, conf, entityManagerProviderMock, null, null);
+        new HostsMap((String) null), unitOfWork, null, conf, entityManagerProviderMock, hostRoleCommandDAOMock, null);
     scheduler.setTaskTimeoutAdjustment(false);
     // Start the thread
 
@@ -405,6 +410,8 @@ public class TestActionScheduler {
 
     when(db.getCommandsInProgressCount()).thenReturn(stages.size());
     when(db.getStagesInProgress()).thenReturn(stages);
+    HostRoleCommandDAO hostRoleCommandDAOMock = mock(HostRoleCommandDAO.class);
+    Mockito.doNothing().when(hostRoleCommandDAOMock).publishTaskCreateEvent(anyListOf(HostRoleCommand.class));
 
     doAnswer(new Answer<Void>() {
       @Override
@@ -508,6 +515,8 @@ public class TestActionScheduler {
 
     when(db.getCommandsInProgressCount()).thenReturn(stages.size());
     when(db.getStagesInProgress()).thenReturn(stages);
+    HostRoleCommandDAO hostRoleCommandDAOMock = mock(HostRoleCommandDAO.class);
+    Mockito.doNothing().when(hostRoleCommandDAOMock).publishTaskCreateEvent(anyListOf(HostRoleCommand.class));
 
     doAnswer(new Answer<Collection<HostRoleCommandEntity>>() {
       @Override
@@ -543,7 +552,7 @@ public class TestActionScheduler {
     // Make sure the NN install doesn't timeout
     ActionScheduler scheduler = new ActionScheduler(100, 50000, db, aq, fsm, 3,
         new HostsMap((String) null), unitOfWork, null, conf, entityManagerProviderMock,
-        (HostRoleCommandDAO)null, (HostRoleCommandFactory)null);
+        hostRoleCommandDAOMock, (HostRoleCommandFactory)null);
     scheduler.setTaskTimeoutAdjustment(false);
 
     int cycleCount=0;
@@ -606,6 +615,8 @@ public class TestActionScheduler {
     stages.add(s);
 
     ActionDBAccessor db = mock(ActionDBAccessor.class);
+    HostRoleCommandDAO hostRoleCommandDAOMock = mock(HostRoleCommandDAO.class);
+    Mockito.doNothing().when(hostRoleCommandDAOMock).publishTaskCreateEvent(anyListOf(HostRoleCommand.class));
 
     RequestEntity request = mock(RequestEntity.class);
     when(request.isExclusive()).thenReturn(false);
@@ -658,7 +669,7 @@ public class TestActionScheduler {
     ServerActionExecutor.init(injector);
     ActionScheduler scheduler = new ActionScheduler(100, 50, db, aq, fsm, 3,
         new HostsMap((String) null), unitOfWork, null, conf, entityManagerProviderMock,
-        (HostRoleCommandDAO)null, (HostRoleCommandFactory)null);
+        hostRoleCommandDAOMock, (HostRoleCommandFactory)null);
 
     int cycleCount = 0;
     while (!stages.get(0).getHostRoleStatus(null, "AMBARI_SERVER_ACTION")
@@ -721,6 +732,8 @@ public class TestActionScheduler {
     stages.add(stage12);
 
     ActionDBAccessor db = mock(ActionDBAccessor.class);
+    HostRoleCommandDAO hostRoleCommandDAOMock = mock(HostRoleCommandDAO.class);
+    Mockito.doNothing().when(hostRoleCommandDAOMock).publishTaskCreateEvent(anyListOf(HostRoleCommand.class));
 
     RequestEntity request = mock(RequestEntity.class);
     when(request.isExclusive()).thenReturn(false);
@@ -735,7 +748,7 @@ public class TestActionScheduler {
     ActionScheduler scheduler = new ActionScheduler(100, 50, db, aq, fsm, 3,
         new HostsMap((String) null),
         unitOfWork, EasyMock.createNiceMock(AmbariEventPublisher.class), conf,
-        entityManagerProviderMock, (HostRoleCommandDAO)null, (HostRoleCommandFactory)null);
+        entityManagerProviderMock, hostRoleCommandDAOMock, (HostRoleCommandFactory)null);
 
     scheduler.doWork();
 
@@ -763,6 +776,8 @@ public class TestActionScheduler {
     stages.add(s);
 
     ActionDBAccessor db = mock(ActionDBAccessor.class);
+    HostRoleCommandDAO hostRoleCommandDAOMock = mock(HostRoleCommandDAO.class);
+    Mockito.doNothing().when(hostRoleCommandDAOMock).publishTaskCreateEvent(anyListOf(HostRoleCommand.class));
 
     RequestEntity request = mock(RequestEntity.class);
     when(request.isExclusive()).thenReturn(false);
@@ -816,7 +831,7 @@ public class TestActionScheduler {
     ServerActionExecutor.init(injector);
     ActionScheduler scheduler = new ActionScheduler(100, 50, db, aq, fsm, 3,
         new HostsMap((String) null), unitOfWork, null, conf, entityManagerProviderMock,
-        (HostRoleCommandDAO)null, (HostRoleCommandFactory)null);
+        hostRoleCommandDAOMock, (HostRoleCommandFactory)null);
 
     int cycleCount = 0;
     while (!stages.get(0).getHostRoleStatus(null, "AMBARI_SERVER_ACTION").isCompletedState()
@@ -976,6 +991,8 @@ public class TestActionScheduler {
     stages.add(s);
 
     ActionDBAccessor db = mock(ActionDBAccessor.class);
+    HostRoleCommandDAO hostRoleCommandDAOMock = mock(HostRoleCommandDAO.class);
+    Mockito.doNothing().when(hostRoleCommandDAOMock).publishTaskCreateEvent(anyListOf(HostRoleCommand.class));
 
     RequestEntity request = mock(RequestEntity.class);
     when(request.isExclusive()).thenReturn(false);
@@ -1028,7 +1045,7 @@ public class TestActionScheduler {
 
     ActionScheduler scheduler = new ActionScheduler(100, 50, db, aq, fsm, 3,
         new HostsMap((String) null), unitOfWork, null, conf, entityManagerProviderMock,
-        (HostRoleCommandDAO)null, (HostRoleCommandFactory)null);
+        hostRoleCommandDAOMock, (HostRoleCommandFactory)null);
 
     int cycleCount = 0;
     while (!stages.get(0).getHostRoleStatus(null, "AMBARI_SERVER_ACTION")
@@ -1124,6 +1141,8 @@ public class TestActionScheduler {
             RoleCommand.START, Service.Type.GANGLIA, 5, 5, 4));
 
     ActionDBAccessor db = mock(ActionDBAccessor.class);
+    HostRoleCommandDAO hostRoleCommandDAOMock = mock(HostRoleCommandDAO.class);
+    Mockito.doNothing().when(hostRoleCommandDAOMock).publishTaskCreateEvent(anyListOf(HostRoleCommand.class));
 
     RequestEntity request = mock(RequestEntity.class);
     when(request.isExclusive()).thenReturn(false);
@@ -1136,7 +1155,7 @@ public class TestActionScheduler {
     Configuration conf = new Configuration(properties);
     ActionScheduler scheduler = spy(new ActionScheduler(100, 50, db, aq, fsm, 3,
         new HostsMap((String) null), unitOfWork, null, conf, entityManagerProviderMock,
-        (HostRoleCommandDAO)null, (HostRoleCommandFactory)null));
+        hostRoleCommandDAOMock, (HostRoleCommandFactory)null));
 
     doReturn(false).when(scheduler).wasAgentRestartedDuringOperation(any(Host.class), any(Stage.class), anyString());
 
@@ -1214,6 +1233,8 @@ public class TestActionScheduler {
             RoleCommand.START, Service.Type.GANGLIA, 5, 5, 4));
 
     ActionDBAccessor db = mock(ActionDBAccessor.class);
+    HostRoleCommandDAO hostRoleCommandDAOMock = mock(HostRoleCommandDAO.class);
+    Mockito.doNothing().when(hostRoleCommandDAOMock).publishTaskCreateEvent(anyListOf(HostRoleCommand.class));
 
     RequestEntity request = mock(RequestEntity.class);
     when(request.isExclusive()).thenReturn(false);
@@ -1228,7 +1249,7 @@ public class TestActionScheduler {
     ActionScheduler scheduler = spy(new ActionScheduler(100, 50, db, aq, fsm, 3,
             new HostsMap((String) null),
         unitOfWork, null, conf, entityManagerProviderMock,
-        (HostRoleCommandDAO)null, (HostRoleCommandFactory)null));
+        hostRoleCommandDAOMock, (HostRoleCommandFactory)null));
 
 
     doReturn(false).when(scheduler).wasAgentRestartedDuringOperation(any(Host.class), any(Stage.class), anyString());
@@ -1289,6 +1310,8 @@ public class TestActionScheduler {
 
 
     ActionDBAccessor db = mock(ActionDBAccessor.class);
+    HostRoleCommandDAO hostRoleCommandDAOMock = mock(HostRoleCommandDAO.class);
+    Mockito.doNothing().when(hostRoleCommandDAOMock).publishTaskCreateEvent(anyListOf(HostRoleCommand.class));
 
     RequestEntity request = mock(RequestEntity.class);
     when(request.isExclusive()).thenReturn(false);
@@ -1303,7 +1326,7 @@ public class TestActionScheduler {
     ActionScheduler scheduler = spy(new ActionScheduler(100, 50, db, aq, fsm, 3,
         new HostsMap((String) null),
         unitOfWork, null, conf, entityManagerProviderMock,
-        (HostRoleCommandDAO)null, (HostRoleCommandFactory)null));
+        hostRoleCommandDAOMock, (HostRoleCommandFactory)null));
 
     doReturn(false).when(scheduler).wasAgentRestartedDuringOperation(any(Host.class), any(Stage.class), anyString());
 
@@ -1544,6 +1567,8 @@ public class TestActionScheduler {
     stage.setLastAttemptTime(host2, Role.HBASE_CLIENT.toString(), now);
 
     ActionDBAccessor db = mock(ActionDBAccessor.class);
+    HostRoleCommandDAO hostRoleCommandDAOMock = mock(HostRoleCommandDAO.class);
+    Mockito.doNothing().when(hostRoleCommandDAOMock).publishTaskCreateEvent(anyListOf(HostRoleCommand.class));
 
     RequestEntity request = mock(RequestEntity.class);
     when(request.isExclusive()).thenReturn(false);
@@ -1616,7 +1641,7 @@ public class TestActionScheduler {
     ActionScheduler scheduler = new ActionScheduler(100, 10000, db, aq, fsm, 3,
         new HostsMap((String) null),
         unitOfWork, null, conf, entityManagerProviderMock,
-        (HostRoleCommandDAO)null, (HostRoleCommandFactory)null);
+        hostRoleCommandDAOMock, (HostRoleCommandFactory)null);
 
     scheduler.doWork();
 
@@ -1729,6 +1754,8 @@ public class TestActionScheduler {
             "host1", "cluster1", Role.HDFS_CLIENT, RoleCommand.UPGRADE, Service.Type.HDFS, 4, 2, 1));
 
     ActionDBAccessor db = mock(ActionDBAccessor.class);
+    HostRoleCommandDAO hostRoleCommandDAOMock = mock(HostRoleCommandDAO.class);
+    Mockito.doNothing().when(hostRoleCommandDAOMock).publishTaskCreateEvent(anyListOf(HostRoleCommand.class));
 
     RequestEntity request = mock(RequestEntity.class);
     when(request.isExclusive()).thenReturn(false);
@@ -1808,7 +1835,7 @@ public class TestActionScheduler {
     ActionScheduler scheduler = new ActionScheduler(100, 50, db, aq, fsm, 3,
         new HostsMap((String) null),
         unitOfWork, null, conf, entityManagerProviderMock,
-        (HostRoleCommandDAO)null, (HostRoleCommandFactory)null);
+        hostRoleCommandDAOMock, (HostRoleCommandFactory)null);
 
     ActionManager am = new ActionManager(db, requestFactory, scheduler);
 
@@ -1976,6 +2003,8 @@ public class TestActionScheduler {
     when(host.getHostName()).thenReturn(hostname);
 
     ActionDBAccessor db = mock(ActionDBAccessorImpl.class);
+    HostRoleCommandDAO hostRoleCommandDAOMock = mock(HostRoleCommandDAO.class);
+    Mockito.doNothing().when(hostRoleCommandDAOMock).publishTaskCreateEvent(anyListOf(HostRoleCommand.class));
 
     RequestEntity request = mock(RequestEntity.class);
     when(request.isExclusive()).thenReturn(false);
@@ -1993,7 +2022,7 @@ public class TestActionScheduler {
     //Small action timeout to test rescheduling
     ActionScheduler scheduler = new ActionScheduler(100, 100, db, aq, fsm,
         10000, new HostsMap((String) null), unitOfWork, null, conf, entityManagerProviderMock,
-        (HostRoleCommandDAO)null, (HostRoleCommandFactory)null);
+        hostRoleCommandDAOMock, (HostRoleCommandFactory)null);
     scheduler.setTaskTimeoutAdjustment(false);
 
     List<AgentCommand> ac = waitForQueueSize(hostname, aq, 1, scheduler);
@@ -2135,6 +2164,8 @@ public class TestActionScheduler {
     stages.add(s);
 
     ActionDBAccessor db = mock(ActionDBAccessor.class);
+    HostRoleCommandDAO hostRoleCommandDAOMock = mock(HostRoleCommandDAO.class);
+    Mockito.doNothing().when(hostRoleCommandDAOMock).publishTaskCreateEvent(anyListOf(HostRoleCommand.class));
 
     RequestEntity request = mock(RequestEntity.class);
     when(request.isExclusive()).thenReturn(false);
@@ -2187,7 +2218,7 @@ public class TestActionScheduler {
     ServerActionExecutor.init(injector);
     ActionScheduler scheduler = new ActionScheduler(100, 50, db, aq, fsm, 3,
         new HostsMap((String) null), unitOfWork, null, conf, entityManagerProviderMock,
-        (HostRoleCommandDAO)null, (HostRoleCommandFactory)null);
+        hostRoleCommandDAOMock, (HostRoleCommandFactory)null);
 
     int cycleCount = 0;
     while (!stages.get(0).getHostRoleStatus(null, "AMBARI_SERVER_ACTION")
@@ -2467,6 +2498,8 @@ public class TestActionScheduler {
     when(host3.getHostName()).thenReturn(hostname);
 
     ActionDBAccessor db = mock(ActionDBAccessor.class);
+    HostRoleCommandDAO hostRoleCommandDAOMock = mock(HostRoleCommandDAO.class);
+    Mockito.doNothing().when(hostRoleCommandDAOMock).publishTaskCreateEvent(anyListOf(HostRoleCommand.class));
     when(db.getCommandsInProgressCount()).thenReturn(stagesInProgress.size());
     when(db.getStagesInProgress()).thenReturn(stagesInProgress);
 
@@ -2542,7 +2575,7 @@ public class TestActionScheduler {
 
     ActionScheduler scheduler = spy(new ActionScheduler(100, 50, db, aq, fsm, 3,
         new HostsMap((String) null), unitOfWork, null, conf, entityManagerProviderMock,
-        (HostRoleCommandDAO)null, (HostRoleCommandFactory)null));
+        hostRoleCommandDAOMock, (HostRoleCommandFactory)null));
 
     doReturn(false).when(scheduler).wasAgentRestartedDuringOperation(any(Host.class), any(Stage.class), anyString());
 
@@ -2706,6 +2739,8 @@ public class TestActionScheduler {
     command.setStatus(HostRoleStatus.FAILED);
 
     ActionDBAccessor db = mock(ActionDBAccessor.class);
+    HostRoleCommandDAO hostRoleCommandDAOMock = mock(HostRoleCommandDAO.class);
+    Mockito.doNothing().when(hostRoleCommandDAOMock).publishTaskCreateEvent(anyListOf(HostRoleCommand.class));
 
     RequestEntity request = mock(RequestEntity.class);
     when(request.isExclusive()).thenReturn(false);
@@ -2776,7 +2811,7 @@ public class TestActionScheduler {
 
     ActionScheduler scheduler = spy(new ActionScheduler(100, 50, db, aq, fsm, 3,
         new HostsMap((String) null), unitOfWork, null, conf, entityManagerProviderMock,
-        (HostRoleCommandDAO)null, (HostRoleCommandFactory)null));
+        hostRoleCommandDAOMock, (HostRoleCommandFactory)null));
 
     doReturn(false).when(scheduler).wasAgentRestartedDuringOperation(any(Host.class), any(Stage.class), anyString());
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/test/java/org/apache/ambari/server/alerts/AmbariPerformanceRunnableTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/alerts/AmbariPerformanceRunnableTest.java b/ambari-server/src/test/java/org/apache/ambari/server/alerts/AmbariPerformanceRunnableTest.java
index 7b1a5a2..facd802 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/alerts/AmbariPerformanceRunnableTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/alerts/AmbariPerformanceRunnableTest.java
@@ -18,12 +18,13 @@
 
 package org.apache.ambari.server.alerts;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertTrue;
 import static org.easymock.EasyMock.createNiceMock;
 import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
 
 import java.lang.reflect.Field;
 import java.util.ArrayList;
@@ -34,6 +35,7 @@ import java.util.Map;
 import javax.persistence.EntityManager;
 
 import org.apache.ambari.server.actionmanager.ActionManager;
+import org.apache.ambari.server.actionmanager.HostRoleCommandFactory;
 import org.apache.ambari.server.alerts.AmbariPerformanceRunnable.PerformanceArea;
 import org.apache.ambari.server.controller.AmbariManagementController;
 import org.apache.ambari.server.controller.internal.ClusterResourceProvider;
@@ -287,6 +289,7 @@ public class AmbariPerformanceRunnableTest {
       binder.bind(AlertsDAO.class).toInstance(createNiceMock(AlertsDAO.class));
       binder.bind(EntityManager.class).toInstance(createNiceMock(EntityManager.class));
       binder.bind(ActionManager.class).toInstance(createNiceMock(ActionManager.class));
+      binder.bind(HostRoleCommandFactory.class).toInstance(createNiceMock(HostRoleCommandFactory.class));
       binder.bind(HostRoleCommandDAO.class).toInstance(createNiceMock(HostRoleCommandDAO.class));
       binder.bind(AmbariManagementController.class).toInstance(createNiceMock(AmbariManagementController.class));
       binder.bind(AlertDefinitionFactory.class).toInstance(createNiceMock(AlertDefinitionFactory.class));

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
index a0701b6..f8b57e5 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderTest.java
@@ -624,7 +624,6 @@ public class UpgradeResourceProviderTest {
     RequestEntity requestEntity = new RequestEntity();
     requestEntity.setRequestId(2L);
     requestEntity.setClusterId(cluster.getClusterId());
-    requestEntity.setStatus(HostRoleStatus.PENDING);
     requestEntity.setStages(new ArrayList<StageEntity>());
     requestDao.create(requestEntity);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeSummaryResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeSummaryResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeSummaryResourceProviderTest.java
index 619e367..f009767 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeSummaryResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeSummaryResourceProviderTest.java
@@ -205,7 +205,6 @@ public class UpgradeSummaryResourceProviderTest {
     RequestEntity requestEntity = new RequestEntity();
     requestEntity.setRequestId(upgradeRequestId);
     requestEntity.setClusterId(cluster.getClusterId());
-    requestEntity.setStatus(HostRoleStatus.PENDING);
     requestDAO.create(requestEntity);
 
     // Create the stage and add it to the request

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/tasks/TaskStatusListenerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/tasks/TaskStatusListenerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/tasks/TaskStatusListenerTest.java
new file mode 100644
index 0000000..64a731b
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/tasks/TaskStatusListenerTest.java
@@ -0,0 +1,164 @@
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.events.listeners.tasks;
+
+import static org.easymock.EasyMock.anyLong;
+import static org.easymock.EasyMock.anyObject;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.ambari.server.Role;
+import org.apache.ambari.server.RoleCommand;
+import org.apache.ambari.server.actionmanager.ExecutionCommandWrapperFactory;
+import org.apache.ambari.server.actionmanager.HostRoleCommand;
+import org.apache.ambari.server.actionmanager.HostRoleStatus;
+import org.apache.ambari.server.events.TaskCreateEvent;
+import org.apache.ambari.server.events.TaskUpdateEvent;
+import org.apache.ambari.server.events.publishers.TaskEventPublisher;
+import org.apache.ambari.server.orm.dao.ExecutionCommandDAO;
+import org.apache.ambari.server.orm.dao.HostDAO;
+import org.apache.ambari.server.orm.dao.RequestDAO;
+import org.apache.ambari.server.orm.dao.StageDAO;
+import org.apache.ambari.server.orm.entities.RequestEntity;
+import org.apache.ambari.server.orm.entities.RoleSuccessCriteriaEntity;
+import org.apache.ambari.server.orm.entities.StageEntity;
+import org.apache.ambari.server.orm.entities.StageEntityPK;
+import org.apache.ambari.server.state.ServiceComponentHostEvent;
+import org.easymock.EasyMock;
+import org.easymock.EasyMockSupport;
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.google.inject.Inject;
+
+
+public class TaskStatusListenerTest extends EasyMockSupport {
+
+  private TaskEventPublisher publisher = new TaskEventPublisher();
+
+  @Inject
+  private ExecutionCommandDAO executionCommandDAO;
+
+  @Inject
+  private ExecutionCommandWrapperFactory ecwFactory;
+
+
+  @Test
+  public void testOnTaskUpdateEvent() {
+    List<HostRoleCommand> hostRoleCommands = new ArrayList<HostRoleCommand>();
+    ServiceComponentHostEvent serviceComponentHostEvent = createNiceMock(ServiceComponentHostEvent.class);
+    HostDAO hostDAO = createNiceMock(HostDAO.class);
+    replayAll();
+
+    int hostRoleCommandSize = 3;
+    int hrcCounter = 1;
+    for (int stageCounter = 0; stageCounter < 2; stageCounter++) {
+      for (int i = 1; i <= hostRoleCommandSize; i++,hrcCounter++) {
+        String hostname = "hostname-" + hrcCounter;
+        HostRoleCommand hostRoleCommand = new HostRoleCommand(hostname, Role.DATANODE,
+            serviceComponentHostEvent, RoleCommand.EXECUTE, hostDAO, executionCommandDAO, ecwFactory);
+        hostRoleCommand.setStatus(HostRoleStatus.PENDING);
+        hostRoleCommand.setRequestId(1L);
+        hostRoleCommand.setStageId(stageCounter);
+        hostRoleCommand.setTaskId(hrcCounter);
+        hostRoleCommands.add(hostRoleCommand);
+      }
+    }
+
+    HostRoleStatus hostRoleStatus = HostRoleStatus.PENDING;
+    StageDAO stageDAO = createNiceMock(StageDAO.class);
+    RequestDAO requestDAO = createNiceMock(RequestDAO.class);
+    StageEntity stageEntity = createNiceMock(StageEntity.class);
+    RequestEntity requestEntity = createNiceMock(RequestEntity.class);
+    EasyMock.expect(stageEntity.getStatus()).andReturn(hostRoleStatus).anyTimes();;
+    EasyMock.expect(stageEntity.getDisplayStatus()).andReturn(hostRoleStatus).anyTimes();
+    EasyMock.expect(stageEntity.isSkippable()).andReturn(Boolean.FALSE).anyTimes();;
+    EasyMock.expect(stageEntity.getRoleSuccessCriterias()).andReturn(Collections.<RoleSuccessCriteriaEntity>emptyList()).anyTimes();
+    EasyMock.expect(stageDAO.findByPK(anyObject(StageEntityPK.class))).andReturn(stageEntity).anyTimes();
+    EasyMock.expect(requestEntity.getStatus()).andReturn(hostRoleStatus).anyTimes();;
+    EasyMock.expect(requestEntity.getDisplayStatus()).andReturn(hostRoleStatus).anyTimes();
+    EasyMock.expect(requestDAO.findByPK(anyLong())).andReturn(requestEntity).anyTimes();
+
+    requestDAO.updateStatus(1L,HostRoleStatus.COMPLETED,HostRoleStatus.SKIPPED_FAILED);
+    EasyMock.expectLastCall().times(1);
+
+
+
+    EasyMock.replay(stageEntity);
+    EasyMock.replay(requestEntity);
+    EasyMock.replay(stageDAO);
+    EasyMock.replay(requestDAO);
+
+    TaskCreateEvent event = new TaskCreateEvent(hostRoleCommands);
+    TaskStatusListener listener = new TaskStatusListener(publisher,stageDAO,requestDAO);
+
+    Assert.assertTrue(listener.getActiveTasksMap().isEmpty());
+    Assert.assertTrue(listener.getActiveStageMap().isEmpty());
+    Assert.assertTrue(listener.getActiveRequestMap().isEmpty());
+
+    listener.onTaskCreateEvent(event);
+    Assert.assertEquals(listener.getActiveTasksMap().size(),6);
+    Assert.assertEquals(listener.getActiveStageMap().size(),2);
+    Assert.assertEquals(listener.getActiveRequestMap().size(),1);
+    Assert.assertEquals(listener.getActiveRequestMap().get(1L).getStatus(), hostRoleStatus);
+
+
+
+    // update of a task status of IN_PROGRESS should cascade into an update of request status
+    String hostname = "hostname-1";
+    HostRoleCommand hostRoleCommand = new HostRoleCommand(hostname, Role.DATANODE,
+        serviceComponentHostEvent, RoleCommand.EXECUTE, hostDAO, executionCommandDAO, ecwFactory);
+    hostRoleCommand.setStatus(HostRoleStatus.IN_PROGRESS);
+    hostRoleCommand.setRequestId(1L);
+    hostRoleCommand.setStageId(0);
+    hostRoleCommand.setTaskId(1L);
+    listener.onTaskUpdateEvent(new TaskUpdateEvent(Collections.singletonList(hostRoleCommand)));
+    Assert.assertEquals(HostRoleStatus.IN_PROGRESS, listener.getActiveRequestMap().get(1L).getStatus());
+
+    // update of all tasks status of skip_failed and  completed states should cascade into request status of completed
+    // and request display status to be of skip_failed
+    hrcCounter = 1;
+    List<HostRoleCommand> finalHostRoleCommands = new ArrayList<HostRoleCommand>();
+    HostRoleStatus finalHostRoleStatus = HostRoleStatus.COMPLETED;
+    for (int stageCounter = 0; stageCounter < 2; stageCounter++) {
+      for (int i = 1; i <= hostRoleCommandSize; i++,hrcCounter++) {
+        String finalHostname = "hostname-" + hrcCounter;
+        HostRoleCommand finalHostRoleCommand = new HostRoleCommand(finalHostname, Role.DATANODE,
+            serviceComponentHostEvent, RoleCommand.EXECUTE, hostDAO, executionCommandDAO, ecwFactory);
+        finalHostRoleCommand.setStatus(finalHostRoleStatus);
+        finalHostRoleCommand.setRequestId(1L);
+        finalHostRoleCommand.setStageId(stageCounter);
+        finalHostRoleCommand.setTaskId(hrcCounter);
+        finalHostRoleCommands.add(finalHostRoleCommand);
+      }
+      finalHostRoleStatus = HostRoleStatus.SKIPPED_FAILED;
+    }
+
+    listener.onTaskUpdateEvent(new TaskUpdateEvent(finalHostRoleCommands));
+
+    //Once request status and display status are in completed state, it should no longer be tracked by TaskStatusListener
+    Assert.assertNull(listener.getActiveRequestMap().get(1L));
+
+    // verify request status = completed and display_status = skip_failed
+    verifyAll();
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
index b1c10f5..1709da8 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
@@ -38,6 +38,7 @@ import javax.persistence.EntityManager;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.H2DatabaseCleaner;
+import org.apache.ambari.server.actionmanager.HostRoleCommandFactory;
 import org.apache.ambari.server.actionmanager.RequestFactory;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.controller.AmbariCustomCommandExecutionHelper;
@@ -980,6 +981,7 @@ public class ConfigHelperTest {
           bind(Clusters.class).toInstance(createNiceMock(Clusters.class));
           bind(ClusterController.class).toInstance(clusterController);
           bind(StackManagerFactory.class).toInstance(createNiceMock(StackManagerFactory.class));
+          bind(HostRoleCommandFactory.class).toInstance(createNiceMock(HostRoleCommandFactory.class));
           bind(HostRoleCommandDAO.class).toInstance(createNiceMock(HostRoleCommandDAO.class));
         }
       });

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterEffectiveVersionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterEffectiveVersionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterEffectiveVersionTest.java
index 9d339e2..d3c8acf 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterEffectiveVersionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterEffectiveVersionTest.java
@@ -24,6 +24,7 @@ import java.util.List;
 import javax.persistence.EntityManager;
 
 import org.apache.ambari.server.actionmanager.ActionManager;
+import org.apache.ambari.server.actionmanager.HostRoleCommandFactory;
 import org.apache.ambari.server.actionmanager.RequestFactory;
 import org.apache.ambari.server.actionmanager.StageFactory;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
@@ -68,6 +69,7 @@ import org.apache.ambari.server.state.stack.upgrade.UpgradeType;
 import org.easymock.EasyMock;
 import org.easymock.EasyMockSupport;
 import org.eclipse.jetty.server.SessionManager;
+import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -83,8 +85,6 @@ import com.google.inject.Injector;
 import com.google.inject.Module;
 import com.google.inject.assistedinject.FactoryModuleBuilder;
 
-import junit.framework.Assert;
-
 /**
  * Tests that cluster effective version is calcualted correctly during upgrades.
  */
@@ -256,6 +256,7 @@ public class ClusterEffectiveVersionTest extends EasyMockSupport {
       binder.bind(DBAccessor.class).toInstance(EasyMock.createNiceMock(DBAccessor.class));
       binder.bind(EntityManager.class).toInstance(EasyMock.createNiceMock(EntityManager.class));
       binder.bind(ActionManager.class).toInstance(EasyMock.createNiceMock(ActionManager.class));
+      binder.bind(HostRoleCommandFactory.class).toInstance(EasyMock.createNiceMock(HostRoleCommandFactory.class));
       binder.bind(HostRoleCommandDAO.class).toInstance(EasyMock.createNiceMock(HostRoleCommandDAO.class));
       binder.bind(AmbariManagementController.class).toInstance(EasyMock.createNiceMock(AmbariManagementController.class));
       binder.bind(ClusterController.class).toInstance(EasyMock.createNiceMock(ClusterController.class));

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/test/java/org/apache/ambari/server/state/services/RetryUpgradeActionServiceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/services/RetryUpgradeActionServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/services/RetryUpgradeActionServiceTest.java
index ed95b0b..e699e49 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/services/RetryUpgradeActionServiceTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/services/RetryUpgradeActionServiceTest.java
@@ -251,7 +251,6 @@ public class RetryUpgradeActionServiceTest {
     RequestEntity requestEntity = new RequestEntity();
     requestEntity.setRequestId(upgradeRequestId);
     requestEntity.setClusterId(cluster.getClusterId());
-    requestEntity.setStatus(HostRoleStatus.PENDING);
     requestDAO.create(requestEntity);
 
     // Create the stage and add it to the request

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog300Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog300Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog300Test.java
index d7979e8..ec001ec 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog300Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog300Test.java
@@ -31,15 +31,18 @@ public class UpgradeCatalog300Test {
   public void testExecuteDMLUpdates() throws Exception {
     Method addNewConfigurationsFromXml = AbstractUpgradeCatalog.class.getDeclaredMethod("addNewConfigurationsFromXml");
     Method showHcatDeletedUserMessage = UpgradeCatalog300.class.getDeclaredMethod("showHcatDeletedUserMessage");
+    Method setStatusOfStagesAndRequests = UpgradeCatalog300.class.getDeclaredMethod("setStatusOfStagesAndRequests");
 
    UpgradeCatalog300 upgradeCatalog300 = createMockBuilder(UpgradeCatalog300.class)
             .addMockedMethod(showHcatDeletedUserMessage)
             .addMockedMethod(addNewConfigurationsFromXml)
+            .addMockedMethod(setStatusOfStagesAndRequests)
             .createMock();
 
 
     upgradeCatalog300.addNewConfigurationsFromXml();
     upgradeCatalog300.showHcatDeletedUserMessage();
+    upgradeCatalog300.setStatusOfStagesAndRequests();
 
 
     replay(upgradeCatalog300);
@@ -49,4 +52,21 @@ public class UpgradeCatalog300Test {
     verify(upgradeCatalog300);
   }
 
+  @Test
+  public void testExecuteDDLUpdates() throws Exception {
+    Method updateStageTable = UpgradeCatalog300.class.getDeclaredMethod("updateStageTable");
+    UpgradeCatalog300 upgradeCatalog300 = createMockBuilder(UpgradeCatalog300.class)
+        .addMockedMethod(updateStageTable)
+        .createMock();
+
+    upgradeCatalog300.updateStageTable();
+
+    replay(upgradeCatalog300);
+
+    upgradeCatalog300.executeDDLUpdates();
+
+    verify(upgradeCatalog300);
+  }
+
+
 }


[13/15] ambari git commit: AMBARI-20058 - 'Final' is not shown correctly in config diff tool and in older versions (rzang)

Posted by jo...@apache.org.
AMBARI-20058 - 'Final' is not shown correctly in config diff tool and in older versions (rzang)


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

Branch: refs/heads/branch-feature-AMBARI-20053
Commit: 8dabd55a448120336309039a6eb9fae11295c6a0
Parents: db51ba4
Author: Richard Zang <rz...@apache.org>
Authored: Fri Feb 17 11:54:23 2017 -0800
Committer: Richard Zang <rz...@apache.org>
Committed: Fri Feb 17 11:54:23 2017 -0800

----------------------------------------------------------------------
 .../app/templates/common/configs/service_config_category.hbs     | 4 +---
 ambari-web/app/views/common/configs/controls_view.js             | 2 +-
 2 files changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8dabd55a/ambari-web/app/templates/common/configs/service_config_category.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/configs/service_config_category.hbs b/ambari-web/app/templates/common/configs/service_config_category.hbs
index fbcb828..c9bedc5 100644
--- a/ambari-web/app/templates/common/configs/service_config_category.hbs
+++ b/ambari-web/app/templates/common/configs/service_config_category.hbs
@@ -73,9 +73,7 @@
                         &nbsp;{{t services.service.config.configHistory.configGroup}}</span>
                     {{/if}}
                   {{/if}}
-                  {{#if controller.canEdit}}
-                    {{view App.ControlsView serviceConfigPropertyBinding="this"}}
-                  {{/if}}
+                  {{view App.ControlsView serviceConfigPropertyBinding="this"}}
                   {{#if errorMessage}}
                     <span class="help-block validation-block">{{errorMessage}}</span>
                   {{/if}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/8dabd55a/ambari-web/app/views/common/configs/controls_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/controls_view.js b/ambari-web/app/views/common/configs/controls_view.js
index 8894ea6..e9464a3 100644
--- a/ambari-web/app/views/common/configs/controls_view.js
+++ b/ambari-web/app/views/common/configs/controls_view.js
@@ -35,7 +35,7 @@ App.ControlsView = Ember.View.extend({
 
 	showRemove: Em.computed.and('showActions', 'serviceConfigProperty.isEditable', 'serviceConfigProperty.isRemovable'),
 
-	showOverride: Em.computed.and('showActions', 'serviceConfigProperty.isPropertyOverridable'),
+	showOverride: Em.computed.and('showActions', 'serviceConfigProperty.isPropertyOverridable', 'controller.canEdit'),
 
 	showUndo: Em.computed.and('showActions', 'serviceConfigProperty.isEditable', '!serviceConfigProperty.cantBeUndone', 'serviceConfigProperty.isNotDefaultValue'),
 


[03/15] ambari git commit: AMBARI-20059 Storm config change results in Consistency check failed (dbuzhor)

Posted by jo...@apache.org.
AMBARI-20059 Storm config change results in Consistency check failed (dbuzhor)


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

Branch: refs/heads/branch-feature-AMBARI-20053
Commit: 984b35e9c1f3121f6688dc797e93b710db69d6b5
Parents: ce404d6
Author: Denys Buzhor <bd...@hortonworks.com>
Authored: Fri Feb 17 00:48:26 2017 +0200
Committer: Denys Buzhor <bd...@hortonworks.com>
Committed: Fri Feb 17 10:20:25 2017 +0200

----------------------------------------------------------------------
 .../controllers/main/service/info/configs.js    | 35 +++++++++++++--
 .../app/mixins/common/track_request_mixin.js    |  5 +++
 .../main/service/info/config_test.js            | 45 ++++++++++++++++++++
 3 files changed, 81 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/984b35e9/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index d95a2d2..786c6f9 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -278,6 +278,36 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.AddSecurityConfi
   isInit: true,
 
   /**
+   * Returns dependencies at all levels for service including dependencies for its childs, children dependencies
+   * and so on.
+   *
+   * @param  {String} serviceName name of services to get dependencies
+   * @returns {String[]}
+   */
+  getServicesDependencies: function(serviceName) {
+    var dependencies = Em.getWithDefault(App.StackService.find(serviceName), 'dependentServiceNames', []);
+    var loop = function(dependentServices, allDependencies) {
+      return dependentServices.reduce(function(all, name) {
+        var service = App.StackService.find(name);
+        if (!service) {
+          return all;
+        }
+        var serviceDependencies = service.get('dependentServiceNames');
+        if (!serviceDependencies.length) {
+          return all.concat(name);
+        }
+        var missed = _.intersection(_.difference(serviceDependencies, all), serviceDependencies);
+        if (missed.length) {
+          return loop(missed, all.concat(missed));
+        }
+        return all;
+      }, allDependencies || dependentServices);
+    };
+
+    return loop(dependencies).uniq().without(serviceName).toArray();
+  },
+
+  /**
    * On load function
    * @method loadStep
    */
@@ -285,10 +315,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.AddSecurityConfi
     var serviceName = this.get('content.serviceName'), self = this;
     App.router.get('mainController').stopPolling();
     this.clearStep();
-    this.set('dependentServiceNames', (App.StackService.find(serviceName).get('dependentServiceNames') || []).reduce(function(acc, i) {
-      acc.push(i);
-      return Array.prototype.concat.apply(acc, App.StackService.find(i).get('dependentServiceNames').toArray()).without(serviceName).uniq();
-    }, []));
+    this.set('dependentServiceNames', this.getServicesDependencies(serviceName));
     this.trackRequestChain(this.loadConfigTheme(serviceName).always(function () {
       if (self.get('preSelectedConfigVersion')) {
         self.loadPreSelectedConfigVersion();

http://git-wip-us.apache.org/repos/asf/ambari/blob/984b35e9/ambari-web/app/mixins/common/track_request_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/track_request_mixin.js b/ambari-web/app/mixins/common/track_request_mixin.js
index 4efcecb..c665253 100644
--- a/ambari-web/app/mixins/common/track_request_mixin.js
+++ b/ambari-web/app/mixins/common/track_request_mixin.js
@@ -22,6 +22,11 @@ App.TrackRequestMixin = Em.Mixin.create({
 
   requestsInProgress: [],
 
+  init: function() {
+    this.set('requestsInProgress', []);
+    this._super([].slice.call(arguments));
+  },
+
   /**
    * register request to view to track his progress
    * @param {$.ajax} request

http://git-wip-us.apache.org/repos/asf/ambari/blob/984b35e9/ambari-web/test/controllers/main/service/info/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/info/config_test.js b/ambari-web/test/controllers/main/service/info/config_test.js
index 4cc2ef8..9d925be 100644
--- a/ambari-web/test/controllers/main/service/info/config_test.js
+++ b/ambari-web/test/controllers/main/service/info/config_test.js
@@ -1052,4 +1052,49 @@ describe("App.MainServiceInfoConfigsController", function () {
 
   });
 
+  describe('#getServicesDependencies', function() {
+    var createService = function(serviceName, dependencies) {
+      return Em.Object.create({
+        serviceName: serviceName,
+        dependentServiceNames: dependencies || []
+      });
+    };
+    var stackServices = [
+      createService('STORM', ['RANGER', 'ATLAS', 'ZOOKEEPER']),
+      createService('RANGER', ['HIVE', 'HDFS']),
+      createService('HIVE', ['YARN']),
+      createService('ZOOKEEPER', ['HDFS']),
+      createService('ATLAS'),
+      createService('HDFS', ['ZOOKEEPER']),
+      createService('YARN', ['HIVE'])
+    ];
+    beforeEach(function() {
+      sinon.stub(App.StackService, 'find', function(serviceName) {
+        return stackServices.findProperty('serviceName', serviceName);
+      });
+    });
+    afterEach(function() {
+      App.StackService.find.restore();
+    });
+
+    it('should returns all service dependencies STORM service', function() {
+      var result = mainServiceInfoConfigsController.getServicesDependencies('STORM');
+      expect(result).to.be.eql(['RANGER', 'ATLAS', 'ZOOKEEPER', 'HIVE', 'HDFS', 'YARN']);
+    });
+
+    it('should returns all service dependencies for ATLAS', function() {
+      var result = mainServiceInfoConfigsController.getServicesDependencies('ATLAS');
+      expect(result).to.be.eql([]);
+    });
+
+    it('should returns all service dependencies for RANGER', function() {
+      var result = mainServiceInfoConfigsController.getServicesDependencies('RANGER');
+      expect(result).to.be.eql(['HIVE', 'HDFS', 'YARN', 'ZOOKEEPER']);
+    });
+
+    it('should returns all service dependencies for YARN', function() {
+      var result = mainServiceInfoConfigsController.getServicesDependencies('YARN');
+      expect(result).to.be.eql(['HIVE']);
+    });
+  });
 });


[11/15] ambari git commit: AMBARI-18868. Stage and Request status should be persisted in the database. (jaimin)

Posted by jo...@apache.org.
AMBARI-18868. Stage and Request status should be persisted in the database. (jaimin)


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

Branch: refs/heads/branch-feature-AMBARI-20053
Commit: 0fc7a6671feb10dc0e8475dc4878942cf19f46cc
Parents: dd174f4
Author: Jaimin Jetly <ja...@hortonworks.com>
Authored: Fri Feb 17 09:31:10 2017 -0800
Committer: Jaimin Jetly <ja...@hortonworks.com>
Committed: Fri Feb 17 09:31:10 2017 -0800

----------------------------------------------------------------------
 .../actionmanager/ActionDBAccessorImpl.java     | 108 ++--
 .../server/actionmanager/ActionScheduler.java   |  31 +
 .../ambari/server/actionmanager/Request.java    |   8 +-
 .../ambari/server/actionmanager/Stage.java      |  25 +
 .../controller/internal/CalculatedStatus.java   | 390 +++++++++++-
 .../ambari/server/events/TaskCreateEvent.java   |  48 ++
 .../apache/ambari/server/events/TaskEvent.java  |  66 ++
 .../ambari/server/events/TaskUpdateEvent.java   |  35 ++
 .../listeners/tasks/TaskStatusListener.java     | 609 +++++++++++++++++++
 .../events/publishers/TaskEventPublisher.java   |  62 ++
 .../server/orm/dao/HostRoleCommandDAO.java      |  67 +-
 .../ambari/server/orm/dao/RequestDAO.java       |   8 +
 .../apache/ambari/server/orm/dao/StageDAO.java  |  32 +-
 .../orm/entities/HostRoleCommandEntity.java     |   4 +-
 .../server/orm/entities/RequestEntity.java      |  49 +-
 .../ambari/server/orm/entities/StageEntity.java |  70 ++-
 .../server/orm/entities/StageEntityPK.java      |  12 +
 .../server/upgrade/UpgradeCatalog300.java       |  70 +++
 .../main/resources/Ambari-DDL-Derby-CREATE.sql  |   7 +-
 .../main/resources/Ambari-DDL-MySQL-CREATE.sql  |   7 +-
 .../main/resources/Ambari-DDL-Oracle-CREATE.sql |   7 +-
 .../resources/Ambari-DDL-Postgres-CREATE.sql    |   7 +-
 .../resources/Ambari-DDL-SQLAnywhere-CREATE.sql |   7 +-
 .../resources/Ambari-DDL-SQLServer-CREATE.sql   |   7 +-
 .../actionmanager/TestActionDBAccessorImpl.java |   3 +-
 .../actionmanager/TestActionScheduler.java      |  71 ++-
 .../alerts/AmbariPerformanceRunnableTest.java   |   7 +-
 .../internal/UpgradeResourceProviderTest.java   |   1 -
 .../UpgradeSummaryResourceProviderTest.java     |   1 -
 .../listeners/tasks/TaskStatusListenerTest.java | 164 +++++
 .../ambari/server/state/ConfigHelperTest.java   |   2 +
 .../cluster/ClusterEffectiveVersionTest.java    |   5 +-
 .../services/RetryUpgradeActionServiceTest.java |   1 -
 .../server/upgrade/UpgradeCatalog300Test.java   |  20 +
 34 files changed, 1892 insertions(+), 119 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
index 7881a4b..b813fe6 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java
@@ -45,7 +45,9 @@ import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.internal.CalculatedStatus;
 import org.apache.ambari.server.events.HostsRemovedEvent;
 import org.apache.ambari.server.events.RequestFinishedEvent;
+import org.apache.ambari.server.events.TaskCreateEvent;
 import org.apache.ambari.server.events.publishers.AmbariEventPublisher;
+import org.apache.ambari.server.events.publishers.TaskEventPublisher;
 import org.apache.ambari.server.orm.dao.ClusterDAO;
 import org.apache.ambari.server.orm.dao.ExecutionCommandDAO;
 import org.apache.ambari.server.orm.dao.HostDAO;
@@ -130,6 +132,9 @@ public class ActionDBAccessorImpl implements ActionDBAccessor {
   AmbariEventPublisher ambariEventPublisher;
 
   @Inject
+  TaskEventPublisher taskEventPublisher;
+
+  @Inject
   AuditLogger auditLogger;
 
   /**
@@ -205,8 +210,6 @@ public class ActionDBAccessorImpl implements ActionDBAccessor {
   public Collection<HostRoleCommandEntity> abortOperation(long requestId) {
     long now = System.currentTimeMillis();
 
-    endRequest(requestId);
-
     // only request commands which actually need to be aborted; requesting all
     // commands here can cause OOM problems during large requests like upgrades
     List<HostRoleCommandEntity> commands = hostRoleCommandDAO.findByRequestIdAndStatuses(requestId,
@@ -228,7 +231,7 @@ public class ActionDBAccessorImpl implements ActionDBAccessor {
     if (!commands.isEmpty()) {
       return hostRoleCommandDAO.mergeAll(commands);
     }
-
+    endRequest(requestId);
     return Collections.emptyList();
   }
 
@@ -283,7 +286,7 @@ public class ActionDBAccessorImpl implements ActionDBAccessor {
   @Override
   @Experimental(feature = ExperimentalFeature.PARALLEL_PROCESSING)
   public List<Stage> getStagesInProgress() {
-    List<StageEntity> stageEntities = stageDAO.findByCommandStatuses(
+    List<StageEntity> stageEntities = stageDAO.findByStatuses(
       HostRoleStatus.IN_PROGRESS_STATUSES);
     return getStagesForEntities(stageEntities);
   }
@@ -343,6 +346,7 @@ public class ActionDBAccessorImpl implements ActionDBAccessor {
     RequestEntity requestEntity = request.constructNewPersistenceEntity();
 
     Long clusterId = -1L;
+    Long requestId = requestEntity.getRequestId();
     ClusterEntity clusterEntity = clusterDAO.findById(request.getClusterId());
     if (clusterEntity != null) {
       clusterId = clusterEntity.getClusterId();
@@ -356,8 +360,11 @@ public class ActionDBAccessorImpl implements ActionDBAccessor {
 
     addRequestToAuditlogCache(request);
 
+    List<HostRoleCommand> hostRoleCommands = new ArrayList<>();
+
     for (Stage stage : request.getStages()) {
       StageEntity stageEntity = stage.constructNewPersistenceEntity();
+      Long stageId = stageEntity.getStageId();
       stageEntities.add(stageEntity);
       stageEntity.setClusterId(clusterId);
       stageEntity.setRequest(requestEntity);
@@ -366,6 +373,8 @@ public class ActionDBAccessorImpl implements ActionDBAccessor {
       List<HostRoleCommand> orderedHostRoleCommands = stage.getOrderedHostRoleCommands();
 
       for (HostRoleCommand hostRoleCommand : orderedHostRoleCommands) {
+        hostRoleCommand.setRequestId(requestId);
+        hostRoleCommand.setStageId(stageId);
         HostRoleCommandEntity hostRoleCommandEntity = hostRoleCommand.constructNewPersistenceEntity();
         hostRoleCommandEntity.setStage(stageEntity);
         hostRoleCommandDAO.create(hostRoleCommandEntity);
@@ -415,11 +424,12 @@ public class ActionDBAccessorImpl implements ActionDBAccessor {
         hostRoleCommandEntity.setExecutionCommand(executionCommandEntity);
 
         executionCommandDAO.create(hostRoleCommandEntity.getExecutionCommand());
-        hostRoleCommandEntity = hostRoleCommandDAO.merge(hostRoleCommandEntity);
+        hostRoleCommandEntity = hostRoleCommandDAO.mergeWithoutPublishEvent(hostRoleCommandEntity);
 
         if (null != hostEntity) {
           hostEntity = hostDAO.merge(hostEntity);
         }
+        hostRoleCommands.add(hostRoleCommand);
       }
 
       for (RoleSuccessCriteriaEntity roleSuccessCriteriaEntity : stageEntity.getRoleSuccessCriterias()) {
@@ -431,6 +441,9 @@ public class ActionDBAccessorImpl implements ActionDBAccessor {
 
     requestEntity.setStages(stageEntities);
     requestDAO.merge(requestEntity);
+
+    TaskCreateEvent taskCreateEvent = new TaskCreateEvent(hostRoleCommands);
+    taskEventPublisher.publish(taskCreateEvent);
   }
 
   @Override
@@ -497,66 +510,55 @@ public class ActionDBAccessorImpl implements ActionDBAccessor {
     long now = System.currentTimeMillis();
 
     List<Long> requestsToCheck = new ArrayList<Long>();
-    List<Long> abortedCommandUpdates = new ArrayList<Long>();
 
     List<HostRoleCommandEntity> commandEntities = hostRoleCommandDAO.findByPKs(taskReports.keySet());
+    List<HostRoleCommandEntity> commandEntitiesToMerge = new ArrayList<HostRoleCommandEntity>();
     for (HostRoleCommandEntity commandEntity : commandEntities) {
       CommandReport report = taskReports.get(commandEntity.getTaskId());
-
-      boolean statusChanged = false;
-
-      switch (commandEntity.getStatus()) {
-        case ABORTED:
-          // We don't want to overwrite statuses for ABORTED tasks with
-          // statuses that have been received from the agent after aborting task
-          abortedCommandUpdates.add(commandEntity.getTaskId());
-          break;
-        default:
-          HostRoleStatus status = HostRoleStatus.valueOf(report.getStatus());
-          // if FAILED and marked for holding then set status = HOLDING_FAILED
-          if (status == HostRoleStatus.FAILED && commandEntity.isRetryAllowed()) {
-            status = HostRoleStatus.HOLDING_FAILED;
-
-            // tasks can be marked as skipped when they fail
-            if (commandEntity.isFailureAutoSkipped()) {
-              status = HostRoleStatus.SKIPPED_FAILED;
-            }
+      HostRoleStatus existingTaskStatus = commandEntity.getStatus();
+      HostRoleStatus reportedTaskStatus = HostRoleStatus.valueOf(report.getStatus());
+      if (!existingTaskStatus.isCompletedState() || existingTaskStatus == HostRoleStatus.ABORTED) {
+        // if FAILED and marked for holding then set reportedTaskStatus = HOLDING_FAILED
+        if (reportedTaskStatus == HostRoleStatus.FAILED && commandEntity.isRetryAllowed()) {
+          reportedTaskStatus = HostRoleStatus.HOLDING_FAILED;
+
+          // tasks can be marked as skipped when they fail
+          if (commandEntity.isFailureAutoSkipped()) {
+            reportedTaskStatus = HostRoleStatus.SKIPPED_FAILED;
           }
-
-          commandEntity.setStatus(status);
-          statusChanged = true;
-          break;
-      }
-
-      commandEntity.setStdOut(report.getStdOut().getBytes());
-      commandEntity.setStdError(report.getStdErr().getBytes());
-      commandEntity.setStructuredOut(report.getStructuredOut() == null ? null :
-        report.getStructuredOut().getBytes());
-      commandEntity.setExitcode(report.getExitCode());
-
-      if (HostRoleStatus.getCompletedStates().contains(commandEntity.getStatus())) {
-        commandEntity.setEndTime(now);
-
-        String actionId = report.getActionId();
-        long[] requestStageIds = StageUtils.getRequestStage(actionId);
-        long requestId = requestStageIds[0];
-        long stageId = requestStageIds[1];
-        if(statusChanged) {
-          auditLog(commandEntity, requestId);
         }
-        if (requestDAO.getLastStageId(requestId).equals(stageId)) {
-          requestsToCheck.add(requestId);
+        if (!existingTaskStatus.isCompletedState()) {
+          commandEntity.setStatus(reportedTaskStatus);
         }
+        commandEntity.setStdOut(report.getStdOut().getBytes());
+        commandEntity.setStdError(report.getStdErr().getBytes());
+        commandEntity.setStructuredOut(report.getStructuredOut() == null ? null :
+            report.getStructuredOut().getBytes());
+        commandEntity.setExitcode(report.getExitCode());
+        if (HostRoleStatus.getCompletedStates().contains(commandEntity.getStatus())) {
+          commandEntity.setEndTime(now);
+
+          String actionId = report.getActionId();
+          long[] requestStageIds = StageUtils.getRequestStage(actionId);
+          long requestId = requestStageIds[0];
+          long stageId = requestStageIds[1];
+          auditLog(commandEntity, requestId);
+          if (requestDAO.getLastStageId(requestId).equals(stageId)) {
+            requestsToCheck.add(requestId);
+          }
+        }
+        commandEntitiesToMerge.add(commandEntity);
+      } else {
+       LOG.warn(String.format("Request for invalid transition of host role command status received for task id %d from " +
+           "agent: %s -> %s",commandEntity.getTaskId(),existingTaskStatus,reportedTaskStatus));
       }
     }
 
     // no need to merge if there's nothing to merge
-    if (!commandEntities.isEmpty()) {
-      hostRoleCommandDAO.mergeAll(commandEntities);
+    if (!commandEntitiesToMerge.isEmpty()) {
+      hostRoleCommandDAO.mergeAll(commandEntitiesToMerge);
     }
 
-    // Invalidate cache because of updates to ABORTED commands
-    hostRoleCommandCache.invalidateAll(abortedCommandUpdates);
 
     for (Long requestId : requestsToCheck) {
       endRequestIfCompleted(requestId);
@@ -923,7 +925,7 @@ public class ActionDBAccessorImpl implements ActionDBAccessor {
       return HostRoleStatus.QUEUED;
     }
     Collection<HostRoleStatus> taskStatuses = details.getTaskStatuses();
-    return CalculatedStatus.calculateSummaryStatusOfStage(CalculatedStatus.calculateStatusCounts(taskStatuses), numberOfTasks, false);
+    return CalculatedStatus.calculateSummaryStatus(CalculatedStatus.calculateStatusCounts(taskStatuses), numberOfTasks, false);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
index 680c0a6..a92c03c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
@@ -30,6 +30,7 @@ import java.util.Set;
 import java.util.TreeMap;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import javax.persistence.EntityManager;
 
@@ -49,6 +50,7 @@ import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.HostsMap;
 import org.apache.ambari.server.events.ActionFinalReportReceivedEvent;
 import org.apache.ambari.server.events.jpa.EntityManagerCacheInvalidationEvent;
+import org.apache.ambari.server.events.listeners.tasks.TaskStatusListener;
 import org.apache.ambari.server.events.publishers.AmbariEventPublisher;
 import org.apache.ambari.server.events.publishers.JPAEventPublisher;
 import org.apache.ambari.server.metadata.RoleCommandOrder;
@@ -75,10 +77,13 @@ import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Function;
 import com.google.common.cache.Cache;
 import com.google.common.cache.CacheBuilder;
 import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.ListMultimap;
+import com.google.common.collect.Lists;
 import com.google.common.collect.Multimap;
 import com.google.common.eventbus.Subscribe;
 import com.google.common.reflect.TypeToken;
@@ -179,6 +184,9 @@ class ActionScheduler implements Runnable {
    * we receive awake() request during running a scheduler iteration.
    */
   private boolean activeAwakeRequest = false;
+
+  private AtomicBoolean taskStatusLoaded = new AtomicBoolean();
+
   //Cache for clusterHostinfo, key - stageId-requestId
   private Cache<String, Map<String, Set<String>>> clusterHostInfoCache;
   private Cache<String, Map<String, String>> commandParamsStageCache;
@@ -353,6 +361,8 @@ class ActionScheduler implements Runnable {
         LOG.debug("Processing {} in progress stages ", stages.size());
       }
 
+      publishInProgressTasks(stages);
+
       if (stages.isEmpty()) {
         // Nothing to do
         if (LOG.isDebugEnabled()) {
@@ -532,6 +542,27 @@ class ActionScheduler implements Runnable {
     }
   }
 
+  /**
+   * publish event to load {@link TaskStatusListener#activeTasksMap} {@link TaskStatusListener#activeStageMap}
+   * and {@link TaskStatusListener#activeRequestMap} for all running request once during server startup.
+   * This is required as some tasks may have been in progress when server was last stopped
+   * @param stages list of stages
+   */
+  private void publishInProgressTasks(List<Stage> stages) {
+    if (taskStatusLoaded.compareAndSet(false, true)) {
+      if (!stages.isEmpty()) {
+        Function<Stage, Long> transform = new Function<Stage, Long>() {
+          @Override
+          public Long apply(Stage stage) {
+            return stage.getRequestId();
+          }
+        };
+        Set<Long> runningRequestID = ImmutableSet.copyOf(Lists.transform(stages, transform));
+        List<HostRoleCommand> hostRoleCommands = db.getAllTasksByRequestIds(runningRequestID);
+        hostRoleCommandDAO.publishTaskCreateEvent(hostRoleCommands);
+      }
+    }
+  }
 
   /**
    * Returns the list of hosts that have a task assigned

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Request.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Request.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Request.java
index 31e11c1..502c016 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Request.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Request.java
@@ -71,7 +71,8 @@ public class Request {
    * As of now, this field is not used. Request status is
    * calculated at RequestResourceProvider on the fly.
    */
-  private HostRoleStatus status; // not persisted yet
+  private HostRoleStatus status = HostRoleStatus.PENDING;
+  private HostRoleStatus displayStatus = HostRoleStatus.PENDING;
   private String inputs;
   private List<RequestResourceFilter> resourceFilters;
   private RequestOperationLevel operationLevel;
@@ -186,6 +187,7 @@ public class Request {
     this.requestType = entity.getRequestType();
     this.commandName = entity.getCommandName();
     this.status = entity.getStatus();
+    this.displayStatus = entity.getDisplayStatus();
     if (entity.getRequestScheduleEntity() != null) {
       this.requestScheduleId = entity.getRequestScheduleEntity().getScheduleId();
     }
@@ -241,6 +243,8 @@ public class Request {
     requestEntity.setInputs(inputs);
     requestEntity.setRequestType(requestType);
     requestEntity.setRequestScheduleId(requestScheduleId);
+    requestEntity.setStatus(status);
+    requestEntity.setDisplayStatus(displayStatus);
     //TODO set all fields
 
     if (resourceFilters != null) {
@@ -381,6 +385,8 @@ public class Request {
         ", startTime=" + startTime +
         ", endTime=" + endTime +
         ", inputs='" + inputs + '\'' +
+        ", status='" + status + '\'' +
+        ", displayStatus='" + displayStatus + '\'' +
         ", resourceFilters='" + resourceFilters + '\'' +
         ", operationLevel='" + operationLevel + '\'' +
         ", requestType=" + requestType +

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java
index 4a05b32..f7ceca2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java
@@ -74,6 +74,8 @@ public class Stage {
   private long stageId = -1;
   private final String logDir;
   private final String requestContext;
+  private HostRoleStatus status = HostRoleStatus.PENDING;
+  private HostRoleStatus displayStatus = HostRoleStatus.PENDING;
   private String clusterHostInfo;
   private String commandParamsStage;
   private String hostParamsStage;
@@ -157,6 +159,8 @@ public class Stage {
     commandParamsStage = stageEntity.getCommandParamsStage();
     hostParamsStage = stageEntity.getHostParamsStage();
     commandExecutionType = stageEntity.getCommandExecutionType();
+    status = stageEntity.getStatus();
+    displayStatus = stageEntity.getDisplayStatus();
 
     List<Long> taskIds = hostRoleCommandDAO.findTaskIdsByStage(requestId, stageId);
     Collection<HostRoleCommand> commands = dbAccessor.getTasks(taskIds);
@@ -197,6 +201,8 @@ public class Stage {
     stageEntity.setCommandParamsStage(commandParamsStage);
     stageEntity.setHostParamsStage(hostParamsStage);
     stageEntity.setCommandExecutionType(commandExecutionType);
+    stageEntity.setStatus(status);
+    stageEntity.setDisplayStatus(displayStatus);
 
     for (Role role : successFactors.keySet()) {
       RoleSuccessCriteriaEntity roleSuccessCriteriaEntity = new RoleSuccessCriteriaEntity();
@@ -290,6 +296,23 @@ public class Stage {
     this.commandExecutionType = commandExecutionType;
   }
 
+  /**
+   * get current status of the stage
+   * @return {@link HostRoleStatus}
+   */
+  public HostRoleStatus getStatus() {
+    return status;
+  }
+
+  /**
+   * sets status of the stage
+   * @param status {@link HostRoleStatus}
+   */
+  public void setStatus(HostRoleStatus status) {
+    this.status = status;
+  }
+
+
   public synchronized void setStageId(long stageId) {
     if (this.stageId != -1) {
       throw new RuntimeException("Attempt to set stageId again! Not allowed.");
@@ -915,6 +938,8 @@ public class Stage {
     builder.append("clusterHostInfo="+clusterHostInfo+"\n");
     builder.append("commandParamsStage="+commandParamsStage+"\n");
     builder.append("hostParamsStage="+hostParamsStage+"\n");
+    builder.append("status="+status+"\n");
+    builder.append("displayStatus="+displayStatus+"\n");
     builder.append("Success Factors:\n");
     for (Role r : successFactors.keySet()) {
       builder.append("  role: "+r+", factor: "+successFactors.get(r)+"\n");

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java
index 3c415df..32dd03d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/CalculatedStatus.java
@@ -26,12 +26,20 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.ambari.server.Role;
 import org.apache.ambari.server.actionmanager.HostRoleCommand;
 import org.apache.ambari.server.actionmanager.HostRoleStatus;
+import org.apache.ambari.server.actionmanager.Request;
 import org.apache.ambari.server.actionmanager.Stage;
+import org.apache.ambari.server.events.listeners.tasks.TaskStatusListener;
 import org.apache.ambari.server.orm.dao.HostRoleCommandStatusSummaryDTO;
 import org.apache.ambari.server.orm.entities.HostRoleCommandEntity;
 import org.apache.ambari.server.orm.entities.StageEntity;
+import org.apache.ambari.server.orm.entities.StageEntityPK;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.FluentIterable;
 
 /**
  * Status of a request resource, calculated from a set of tasks or stages.
@@ -142,7 +150,7 @@ public class CalculatedStatus {
 
     Map<HostRoleStatus, Integer> taskStatusCounts = CalculatedStatus.calculateTaskEntityStatusCounts(tasks);
 
-    HostRoleStatus status = calculateSummaryStatusOfStage(taskStatusCounts, size, skippable);
+    HostRoleStatus status = calculateSummaryStatus(taskStatusCounts, size, skippable);
 
     double progressPercent = calculateProgressPercent(taskStatusCounts, size);
 
@@ -167,7 +175,7 @@ public class CalculatedStatus {
 
       // calculate the stage status from the task status counts
       HostRoleStatus stageStatus =
-          calculateSummaryStatusOfStage(calculateTaskEntityStatusCounts(stageTasks), stageTasks.size(), stage.isSkippable());
+          calculateSummaryStatus(calculateTaskEntityStatusCounts(stageTasks), stageTasks.size(), stage.isSkippable());
 
       stageStatuses.add(stageStatus);
 
@@ -203,7 +211,7 @@ public class CalculatedStatus {
 
       // calculate the stage status from the task status counts
       HostRoleStatus stageStatus =
-          calculateSummaryStatusOfStage(calculateTaskStatusCounts(stageTasks), stageTasks.size(), stage.isSkippable());
+          calculateSummaryStatus(calculateTaskStatusCounts(stageTasks), stageTasks.size(), stage.isSkippable());
 
       stageStatuses.add(stageStatus);
 
@@ -256,6 +264,126 @@ public class CalculatedStatus {
   }
 
   /**
+   * Returns counts of tasks that are in various states.
+   *
+   * @param hostRoleCommands  collection of beans {@link HostRoleCommand}
+   *
+   * @return a map of counts of tasks keyed by the task status
+   */
+  public static Map<HostRoleStatus, Integer> calculateStatusCountsForTasks(Collection<HostRoleCommand> hostRoleCommands) {
+    Map<HostRoleStatus, Integer> counters = new HashMap<>();
+    // initialize
+    for (HostRoleStatus hostRoleStatus : HostRoleStatus.values()) {
+      counters.put(hostRoleStatus, 0);
+    }
+    // calculate counts
+    for (HostRoleCommand hrc : hostRoleCommands) {
+      // count tasks where isCompletedState() == true as COMPLETED
+      // but don't count tasks with COMPLETED status twice
+      if (hrc.getStatus().isCompletedState() && hrc.getStatus() != HostRoleStatus.COMPLETED) {
+        // Increase total number of completed tasks;
+        counters.put(HostRoleStatus.COMPLETED, counters.get(HostRoleStatus.COMPLETED) + 1);
+      }
+      // Increment counter for particular status
+      counters.put(hrc.getStatus(), counters.get(hrc.getStatus()) + 1);
+    }
+
+    // We overwrite the value to have the sum converged
+    counters.put(HostRoleStatus.IN_PROGRESS,
+        hostRoleCommands.size() -
+            counters.get(HostRoleStatus.COMPLETED) -
+            counters.get(HostRoleStatus.QUEUED) -
+            counters.get(HostRoleStatus.PENDING));
+
+    return counters;
+  }
+
+  /**
+   * Returns map for counts of stages that are in various states.
+   *
+   * @param stages  collection of beans {@link org.apache.ambari.server.events.listeners.tasks.TaskStatusListener.ActiveStage}
+   *
+   * @return a map of counts of tasks keyed by the task status
+   */
+  public static Map<StatusType,Map<HostRoleStatus, Integer>> calculateStatusCountsForStage(Collection<TaskStatusListener.ActiveStage> stages) {
+
+    Map<StatusType,Map<HostRoleStatus, Integer>> counters = new HashMap<>();
+    for (StatusType statusType : StatusType.values()) {
+      Map <HostRoleStatus, Integer> statusMap = new HashMap<HostRoleStatus, Integer>();
+      counters.put(statusType,statusMap);
+      // initialize
+      for (HostRoleStatus hostRoleStatus : HostRoleStatus.values()) {
+        statusMap.put(hostRoleStatus, 0);
+      }
+      for (TaskStatusListener.ActiveStage stage : stages) {
+        // count tasks where isCompletedState() == true as COMPLETED
+        // but don't count tasks with COMPLETED status twice
+        HostRoleStatus status;
+        if (statusType == StatusType.DISPLAY_STATUS) {
+          status = stage.getDisplayStatus();
+        } else {
+          status = stage.getStatus();
+        }
+        if (status.isCompletedState() && status != HostRoleStatus.COMPLETED) {
+          // Increase total number of completed tasks;
+          statusMap.put(HostRoleStatus.COMPLETED, statusMap.get(HostRoleStatus.COMPLETED) + 1);
+        }
+
+        // Increment counter for particular status
+        statusMap.put(status, statusMap.get(status) + 1);
+      }
+      statusMap.put(HostRoleStatus.IN_PROGRESS,
+          stages.size() -
+              statusMap.get(HostRoleStatus.COMPLETED) -
+              statusMap.get(HostRoleStatus.QUEUED) -
+              statusMap.get(HostRoleStatus.PENDING));
+    }
+    return counters;
+  }
+
+
+  /**
+   * Returns counts of tasks that are in various states.
+   *
+   * @param hostRoleCommands  collection of beans {@link HostRoleCommand}
+   *
+   * @return a map of counts of tasks keyed by the task status
+   */
+  public static Map<HostRoleStatus, Integer> calculateStatusCountsForTasks(Collection<HostRoleCommand> hostRoleCommands, StageEntityPK stage) {
+    Map<HostRoleStatus, Integer> counters = new HashMap<>();
+    List<HostRoleCommand> hostRoleCommandsOfStage = new ArrayList<>();
+    // initialize
+    for (HostRoleStatus hostRoleStatus : HostRoleStatus.values()) {
+      counters.put(hostRoleStatus, 0);
+    }
+    // calculate counts
+    for (HostRoleCommand hrc : hostRoleCommands) {
+      if (stage.getStageId() == hrc.getStageId() && stage.getRequestId() == hrc.getRequestId()) {
+        // count tasks where isCompletedState() == true as COMPLETED
+        // but don't count tasks with COMPLETED status twice
+        if (hrc.getStatus().isCompletedState() && hrc.getStatus() != HostRoleStatus.COMPLETED) {
+          // Increase total number of completed tasks;
+          counters.put(HostRoleStatus.COMPLETED, counters.get(HostRoleStatus.COMPLETED) + 1);
+        }
+
+        // Increment counter for particular status
+        counters.put(hrc.getStatus(), counters.get(hrc.getStatus()) + 1);
+
+        hostRoleCommandsOfStage.add(hrc);
+      }
+    }
+
+    // We overwrite the value to have the sum converged
+    counters.put(HostRoleStatus.IN_PROGRESS,
+        hostRoleCommandsOfStage.size() -
+            counters.get(HostRoleStatus.COMPLETED) -
+            counters.get(HostRoleStatus.QUEUED) -
+            counters.get(HostRoleStatus.PENDING));
+
+    return counters;
+  }
+
+  /**
    * Returns counts of task entities that are in various states.
    *
    * @param tasks  the collection of task entities
@@ -329,7 +457,7 @@ public class CalculatedStatus {
       int total = summary.getTaskTotal();
       boolean skip = summary.isStageSkippable();
       Map<HostRoleStatus, Integer> counts = calculateStatusCounts(summary.getTaskStatuses());
-      HostRoleStatus stageStatus = calculateSummaryStatusOfStage(counts, total, skip);
+      HostRoleStatus stageStatus = calculateSummaryStatus(counts, total, skip);
       HostRoleStatus stageDisplayStatus = calculateSummaryDisplayStatus(counts, total, skip);
 
       stageStatuses.add(stageStatus);
@@ -392,7 +520,7 @@ public class CalculatedStatus {
    *
    * @return summary request status based on statuses of tasks in different states.
    */
-  public static HostRoleStatus calculateSummaryStatusOfStage(Map<HostRoleStatus, Integer> counters,
+  public static HostRoleStatus calculateSummaryStatus(Map<HostRoleStatus, Integer> counters,
       int total, boolean skippable) {
 
     // when there are 0 tasks, return COMPLETED
@@ -435,6 +563,230 @@ public class CalculatedStatus {
   }
 
   /**
+   *
+   * @param counters counts of resources that are in various states
+   * @param skippable {Boolean} <code>TRUE<code/> if failure of any of the task should not fail the stage
+   * @return {@link HostRoleStatus}
+   */
+  public static HostRoleStatus calculateSummaryStatusFromPartialSet(Map<HostRoleStatus, Integer> counters,
+                                                      boolean skippable) {
+
+    HostRoleStatus status = HostRoleStatus.PENDING;
+    // By definition, any tasks in a future stage must be held in a PENDING status.
+    if (counters.get(HostRoleStatus.HOLDING) > 0 || counters.get(HostRoleStatus.HOLDING_FAILED) > 0 || counters.get(HostRoleStatus.HOLDING_TIMEDOUT) > 0) {
+      status =  counters.get(HostRoleStatus.HOLDING) > 0 ? HostRoleStatus.HOLDING :
+          counters.get(HostRoleStatus.HOLDING_FAILED) > 0 ? HostRoleStatus.HOLDING_FAILED :
+              HostRoleStatus.HOLDING_TIMEDOUT;
+    }
+
+    // Because tasks are not skippable, guaranteed to be FAILED
+    if (counters.get(HostRoleStatus.FAILED) > 0 && !skippable) {
+      status = HostRoleStatus.FAILED;
+    }
+
+    // Because tasks are not skippable, guaranteed to be TIMEDOUT
+    if (counters.get(HostRoleStatus.TIMEDOUT) > 0  && !skippable) {
+      status = HostRoleStatus.TIMEDOUT;
+    }
+
+    int inProgressTasks =  counters.get(HostRoleStatus.QUEUED) + counters.get(HostRoleStatus.IN_PROGRESS);
+    if (inProgressTasks > 0) {
+      status = HostRoleStatus.IN_PROGRESS;
+    }
+
+    return status;
+  }
+
+
+  /**
+   *
+   * @param hostRoleCommands list of {@link HostRoleCommand} for a stage
+   * @param counters counts of resources that are in various states
+   * @param successFactors Map of roles to their successfactor for a stage
+   * @param skippable {Boolean} <code>TRUE<code/> if failure of any of the task should not fail the stage
+   * @return {@link HostRoleStatus} based on success factor
+   */
+  public static HostRoleStatus calculateStageStatus(List <HostRoleCommand> hostRoleCommands, Map<HostRoleStatus, Integer> counters, Map<Role, Float> successFactors,
+                                                    boolean skippable) {
+
+    // when there are 0 tasks, return COMPLETED
+    int total = hostRoleCommands.size();
+    if (total == 0) {
+      return HostRoleStatus.COMPLETED;
+    }
+
+    if (counters.get(HostRoleStatus.PENDING) == total) {
+      return HostRoleStatus.PENDING;
+    }
+
+    // By definition, any tasks in a future stage must be held in a PENDING status.
+    if (counters.get(HostRoleStatus.HOLDING) > 0 || counters.get(HostRoleStatus.HOLDING_FAILED) > 0 || counters.get(HostRoleStatus.HOLDING_TIMEDOUT) > 0) {
+      return counters.get(HostRoleStatus.HOLDING) > 0 ? HostRoleStatus.HOLDING :
+          counters.get(HostRoleStatus.HOLDING_FAILED) > 0 ? HostRoleStatus.HOLDING_FAILED :
+              HostRoleStatus.HOLDING_TIMEDOUT;
+    }
+
+
+    if (counters.get(HostRoleStatus.FAILED) > 0 && !skippable) {
+      Set<Role> rolesWithFailedTasks = getRolesOfFailedTasks(hostRoleCommands);
+      Boolean didStageFailed = didStageFailed(hostRoleCommands, rolesWithFailedTasks, successFactors);
+      if (didStageFailed) return HostRoleStatus.FAILED;
+    }
+
+
+    if (counters.get(HostRoleStatus.TIMEDOUT) > 0  && !skippable) {
+      Set<Role> rolesWithTimedOutTasks = getRolesOfTimedOutTasks(hostRoleCommands);
+      Boolean didStageFailed = didStageFailed(hostRoleCommands, rolesWithTimedOutTasks, successFactors);
+      if (didStageFailed) return HostRoleStatus.TIMEDOUT;
+    }
+
+    int numActiveTasks = counters.get(HostRoleStatus.PENDING) + counters.get(HostRoleStatus.QUEUED) + counters.get(HostRoleStatus.IN_PROGRESS);
+
+    if (numActiveTasks > 0) {
+      return HostRoleStatus.IN_PROGRESS;
+    } else if (counters.get(HostRoleStatus.ABORTED) > 0) {
+      Set<Role> rolesWithTimedOutTasks = getRolesOfAbortedTasks(hostRoleCommands);
+      Boolean didStageFailed = didStageFailed(hostRoleCommands, rolesWithTimedOutTasks, successFactors);
+      if (didStageFailed) return HostRoleStatus.ABORTED;
+    }
+
+    return HostRoleStatus.COMPLETED;
+  }
+
+  /**
+   *  Get all {@link Role} any of whose tasks is in {@link HostRoleStatus#FAILED}
+   * @param hostRoleCommands list of {@link HostRoleCommand}
+   * @return Set of {@link Role}
+   */
+  protected static Set<Role> getRolesOfFailedTasks(List <HostRoleCommand> hostRoleCommands) {
+    return getRolesOfTasks(hostRoleCommands, HostRoleStatus.FAILED);
+  }
+
+  /**
+   *  Get all {@link Role} any of whose tasks is in {@link HostRoleStatus#TIMEDOUT}
+   * @param hostRoleCommands list of {@link HostRoleCommand}
+   * @return Set of {@link Role}
+   */
+  protected static Set<Role> getRolesOfTimedOutTasks(List <HostRoleCommand> hostRoleCommands) {
+    return getRolesOfTasks(hostRoleCommands, HostRoleStatus.TIMEDOUT);
+  }
+
+  /**
+   *  Get all {@link Role} any of whose tasks is in {@link HostRoleStatus#ABORTED}
+   * @param hostRoleCommands list of {@link HostRoleCommand}
+   * @return Set of {@link Role}
+   */
+  protected static Set<Role> getRolesOfAbortedTasks(List <HostRoleCommand> hostRoleCommands) {
+    return getRolesOfTasks(hostRoleCommands, HostRoleStatus.ABORTED);
+  }
+
+  /**
+   * Get all {@link Role} any of whose tasks are in given {@code status}
+   * @param hostRoleCommands list of {@link HostRoleCommand}
+   * @param status {@link HostRoleStatus}
+   * @return Set of {@link Role}
+   */
+  protected static Set<Role> getRolesOfTasks(List <HostRoleCommand> hostRoleCommands, final HostRoleStatus status) {
+
+    Predicate<HostRoleCommand> predicate = new Predicate<HostRoleCommand>() {
+      @Override
+      public boolean apply(HostRoleCommand hrc) {
+        return hrc.getStatus() ==  status;
+      }
+    };
+
+    Function<HostRoleCommand, Role> transform = new Function<HostRoleCommand, Role>() {
+      @Override
+      public Role apply(HostRoleCommand hrc) {
+        return hrc.getRole();
+      }
+    };
+    return FluentIterable.from(hostRoleCommands)
+        .filter(predicate)
+        .transform(transform)
+        .toSet();
+  }
+
+  /**
+   *
+   * @param hostRoleCommands list of {@link HostRoleCommand} for a stage
+   * @param roles  set of roles to be checked for meeting success criteria
+   * @param successFactors  map of role to it's success factor
+   * @return {Boolean} <code>TRUE</code> if stage failed due to hostRoleCommands of any role not meeting success criteria
+   */
+  protected static Boolean didStageFailed(List<HostRoleCommand> hostRoleCommands, Set<Role> roles, Map<Role, Float> successFactors) {
+    Boolean isFailed = Boolean.FALSE;
+    for (Role role: roles) {
+      List <HostRoleCommand> hostRoleCommandsOfRole = getHostRoleCommandsOfRole(hostRoleCommands, role);
+      List <HostRoleCommand> failedHostRoleCommands =  getFailedHostRoleCommands(hostRoleCommandsOfRole);
+      float successRatioForRole = (hostRoleCommandsOfRole.size() - failedHostRoleCommands.size())/hostRoleCommandsOfRole.size();
+      Float successFactorForRole =  successFactors.get(role) == null ? 1.0f : successFactors.get(role);
+      if (successRatioForRole  < successFactorForRole) {
+        isFailed = Boolean.TRUE;
+        break;
+      }
+    }
+    return isFailed;
+  }
+
+  /**
+   *
+   * @param hostRoleCommands list of {@link HostRoleCommand}
+   * @param role {@link Role}
+   * @return list of {@link HostRoleCommand} that belongs to {@link Role}
+   */
+  protected static List<HostRoleCommand> getHostRoleCommandsOfRole(List <HostRoleCommand> hostRoleCommands, final Role role) {
+    Predicate<HostRoleCommand> predicate = new Predicate<HostRoleCommand>() {
+      @Override
+      public boolean apply(HostRoleCommand hrc) {
+        return hrc.getRole() ==  role;
+      }
+    };
+    return FluentIterable.from(hostRoleCommands)
+        .filter(predicate)
+        .toList();
+  }
+
+  /**
+   *
+   * @param hostRoleCommands list of {@link HostRoleCommand}
+   * @return list of {@link HostRoleCommand} with failed status
+   */
+  protected static List<HostRoleCommand> getFailedHostRoleCommands(List <HostRoleCommand> hostRoleCommands) {
+    Predicate<HostRoleCommand> predicate = new Predicate<HostRoleCommand>() {
+      @Override
+      public boolean apply(HostRoleCommand hrc) {
+        return hrc.getStatus().isFailedAndNotSkippableState();
+      }
+    };
+    return FluentIterable.from(hostRoleCommands)
+        .filter(predicate)
+        .toList();
+  }
+
+
+  /**
+   * Calculate overall status from collection of statuses
+   * @param hostRoleStatuses list of all stage's {@link HostRoleStatus}
+   * @return overall status of a request
+   */
+  public static HostRoleStatus getOverallStatusForRequest (Collection<HostRoleStatus> hostRoleStatuses) {
+    Map<HostRoleStatus, Integer> statusCount = calculateStatusCounts(hostRoleStatuses);
+    return calculateSummaryStatus(statusCount, hostRoleStatuses.size(), false);
+  }
+
+  /**
+   * Calculate overall display status from collection of statuses
+   * @param hostRoleStatuses list of all stage's {@link HostRoleStatus}
+   * @return overall display status of a request
+   */
+  public static HostRoleStatus getOverallDisplayStatusForRequest (Collection<HostRoleStatus> hostRoleStatuses) {
+    Map<HostRoleStatus, Integer> statusCount = calculateStatusCounts(hostRoleStatuses);
+    return calculateSummaryDisplayStatus(statusCount, hostRoleStatuses.size(), false);
+  }
+
+
+  /**
    * Calculate overall status of an upgrade.
    *
    * @param counters   counts of resources that are in various states
@@ -444,7 +796,7 @@ public class CalculatedStatus {
    */
   protected static HostRoleStatus calculateSummaryStatusOfUpgrade(
       Map<HostRoleStatus, Integer> counters, int total) {
-    return calculateSummaryStatusOfStage(counters, total, false);
+    return calculateSummaryStatus(counters, total, false);
   }
 
   /**
@@ -456,10 +808,28 @@ public class CalculatedStatus {
    *
    * @return summary request status based on statuses of tasks in different states.
    */
-  protected static HostRoleStatus calculateSummaryDisplayStatus(
+  public static HostRoleStatus calculateSummaryDisplayStatus(
       Map<HostRoleStatus, Integer> counters, int total, boolean skippable) {
-    return counters.get(HostRoleStatus.SKIPPED_FAILED) > 0 ? HostRoleStatus.SKIPPED_FAILED :
-           counters.get(HostRoleStatus.FAILED) > 0 ? HostRoleStatus.FAILED:
-           calculateSummaryStatusOfStage(counters, total, skippable);
+    return counters.get(HostRoleStatus.FAILED) > 0 ? HostRoleStatus.FAILED:
+           counters.get(HostRoleStatus.TIMEDOUT) > 0 ? HostRoleStatus.TIMEDOUT:
+           counters.get(HostRoleStatus.SKIPPED_FAILED) > 0 ? HostRoleStatus.SKIPPED_FAILED :
+           calculateSummaryStatus(counters, total, skippable);
+  }
+
+  /**
+   * kind of {@link HostRoleStatus} persisted by {@link Stage} and {@link Request}
+   */
+  public enum StatusType {
+    STATUS("status"),
+    DISPLAY_STATUS("display_status");
+    private String value;
+
+    StatusType(String value) {
+      this.value = value;
+    }
+
+    public String getValue() {
+      return value;
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/main/java/org/apache/ambari/server/events/TaskCreateEvent.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/events/TaskCreateEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/events/TaskCreateEvent.java
new file mode 100644
index 0000000..9d73122
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/events/TaskCreateEvent.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.events;
+
+
+import java.util.List;
+
+import org.apache.ambari.server.actionmanager.HostRoleCommand;
+import org.apache.ambari.server.events.listeners.tasks.TaskStatusListener;
+
+/**
+ * The {@link TaskCreateEvent} is to be fired every time
+ * when any request is to be tracked as running requests in
+ * {@link TaskStatusListener}
+ * This usually happens when new request is created by user action or
+ * when ambari-server starts with some stages in non-completed state
+ */
+public class TaskCreateEvent extends TaskEvent {
+
+
+  /**
+   * Constructor.
+   *
+   * @param hostRoleCommandList
+   *          all hostRoleCommands for all requests
+   */
+  public TaskCreateEvent(List<HostRoleCommand> hostRoleCommandList) {
+    super(hostRoleCommandList);
+  }
+
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/main/java/org/apache/ambari/server/events/TaskEvent.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/events/TaskEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/events/TaskEvent.java
new file mode 100644
index 0000000..ca351d7
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/events/TaskEvent.java
@@ -0,0 +1,66 @@
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.events;
+
+import java.util.List;
+
+import org.apache.ambari.server.actionmanager.HostRoleCommand;
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * {@link TaskEvent} is the base for all events related to create/update of tasks
+ * that might result in update of stage/request status
+ */
+public class TaskEvent {
+  /**
+   * List of {@link HostRoleCommand}
+   */
+  private List<HostRoleCommand> hostRoleCommands;
+
+  /**
+   * Constructor.
+   *
+   * @param hostRoleCommands
+   *          list of HRCs which have been reported back by the agents.
+   */
+  public TaskEvent(List<HostRoleCommand> hostRoleCommands) {
+    this.hostRoleCommands = hostRoleCommands;
+  }
+
+  /**
+   *  Gets hostRoleCommands that created event
+   * @return List of {@link HostRoleCommand}
+   */
+  public List<HostRoleCommand> getHostRoleCommands() {
+    return hostRoleCommands;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String toString() {
+    String hostRoleCommands = StringUtils.join(this.hostRoleCommands, ", ");
+    StringBuilder buffer = new StringBuilder("TaskEvent{");
+    buffer.append("hostRoleCommands=").append(hostRoleCommands);
+    buffer.append("}");
+    return buffer.toString();
+  }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/main/java/org/apache/ambari/server/events/TaskUpdateEvent.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/events/TaskUpdateEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/events/TaskUpdateEvent.java
new file mode 100644
index 0000000..84f67f5
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/events/TaskUpdateEvent.java
@@ -0,0 +1,35 @@
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.events;
+
+import java.util.List;
+
+import org.apache.ambari.server.actionmanager.HostRoleCommand;
+
+/**
+ * The {@link TaskUpdateEvent} is to be fired every time
+ * when host role commands are merged to the database
+ */
+public class TaskUpdateEvent extends TaskEvent{
+
+  public TaskUpdateEvent(List<HostRoleCommand> hostRoleCommandList) {
+    super(hostRoleCommandList);
+  }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/tasks/TaskStatusListener.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/tasks/TaskStatusListener.java b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/tasks/TaskStatusListener.java
new file mode 100644
index 0000000..bc146ef
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/tasks/TaskStatusListener.java
@@ -0,0 +1,609 @@
+
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.events.listeners.tasks;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ambari.server.EagerSingleton;
+import org.apache.ambari.server.Role;
+import org.apache.ambari.server.actionmanager.HostRoleCommand;
+import org.apache.ambari.server.actionmanager.HostRoleStatus;
+import org.apache.ambari.server.actionmanager.Request;
+import org.apache.ambari.server.actionmanager.Stage;
+import org.apache.ambari.server.controller.internal.CalculatedStatus;
+import org.apache.ambari.server.events.TaskCreateEvent;
+import org.apache.ambari.server.events.TaskUpdateEvent;
+import org.apache.ambari.server.events.publishers.TaskEventPublisher;
+import org.apache.ambari.server.orm.dao.RequestDAO;
+import org.apache.ambari.server.orm.dao.StageDAO;
+import org.apache.ambari.server.orm.entities.RequestEntity;
+import org.apache.ambari.server.orm.entities.RoleSuccessCriteriaEntity;
+import org.apache.ambari.server.orm.entities.StageEntity;
+import org.apache.ambari.server.orm.entities.StageEntityPK;
+import org.jboss.netty.util.internal.ConcurrentHashMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.Sets;
+import com.google.common.eventbus.Subscribe;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+
+/**
+ * The {@link TaskStatusListener} is used to constantly update status of running Stages and Requests
+ * {@link TaskUpdateEvent} listens for all incoming events. These events are fired when either host role commands are created/updated
+ * This listener maintains map of all running tasks, stages and requests
+ */
+@Singleton
+@EagerSingleton
+public class TaskStatusListener {
+  /**
+   * Logger.
+   */
+  private final static Logger LOG = LoggerFactory.getLogger(TaskStatusListener.class);
+
+  /**
+   * Maps task id to its {@link HostRoleCommand} Object.
+   * Map has entries of all tasks of all active(ongoing) requests
+   * NOTE: Partial loading of tasks for any request may lead to incorrect update of the request status
+   */
+  private Map<Long,HostRoleCommand> activeTasksMap = new ConcurrentHashMap<>();
+
+  /**
+   * Maps all ongoing request id to its {@link ActiveRequest}
+   */
+  private Map<Long, ActiveRequest> activeRequestMap = new ConcurrentHashMap<>();
+
+  /**
+   * Maps {@link StageEntityPK} of all ongoing requests to its {@link ActiveStage}
+   * with updated {@link ActiveStage#status} and {@link ActiveStage#displayStatus}.
+   */
+  private Map<StageEntityPK, ActiveStage> activeStageMap = new ConcurrentHashMap<>();
+
+  private StageDAO stageDAO;
+
+  private RequestDAO requestDAO;
+
+
+  @Inject
+  public TaskStatusListener(TaskEventPublisher taskEventPublisher, StageDAO stageDAO, RequestDAO requestDAO) {
+    this.stageDAO = stageDAO;
+    this.requestDAO = requestDAO;
+    taskEventPublisher.register(this);
+  }
+
+  public Map<Long,HostRoleCommand> getActiveTasksMap() {
+    return activeTasksMap;
+  }
+
+  public Map<Long, ActiveRequest> getActiveRequestMap() {
+    return activeRequestMap;
+  }
+
+  public Map<StageEntityPK, ActiveStage> getActiveStageMap() {
+    return activeStageMap;
+  }
+
+  /**
+   * On receiving task update event, update related entries of the running request, stage and task in the maps
+   * Event containing newly created tasks is expected to contain complete set of all tasks for a request
+   * @param event Consumes {@link TaskUpdateEvent}.
+   */
+  @Subscribe
+  public void onTaskUpdateEvent(TaskUpdateEvent event) {
+    LOG.debug("Received task update event {}", event);
+    List<HostRoleCommand> hostRoleCommandListAll = event.getHostRoleCommands();
+    List<HostRoleCommand>  hostRoleCommandWithReceivedStatus =  new ArrayList<>();
+    Set<StageEntityPK> stagesWithReceivedTaskStatus = new HashSet<>();
+    Set<Long> requestIdsWithReceivedTaskStatus =  new HashSet<>();
+    for (HostRoleCommand hostRoleCommand : hostRoleCommandListAll) {
+      Long reportedTaskId = hostRoleCommand.getTaskId();
+      HostRoleCommand activeTask =  activeTasksMap.get(reportedTaskId);
+      if (activeTask == null) {
+        LOG.error(String.format("Received update for a task %d which is not being tracked as running task", reportedTaskId));
+      } else  {
+        hostRoleCommandWithReceivedStatus.add(hostRoleCommand);
+        StageEntityPK stageEntityPK = new StageEntityPK();
+        stageEntityPK.setRequestId(hostRoleCommand.getRequestId());
+        stageEntityPK.setStageId(hostRoleCommand.getStageId());
+        stagesWithReceivedTaskStatus.add(stageEntityPK);
+        requestIdsWithReceivedTaskStatus.add(hostRoleCommand.getRequestId());
+      }
+    }
+
+    updateActiveTasksMap(hostRoleCommandWithReceivedStatus);
+    Boolean didAnyStageStatusUpdated = updateActiveStagesStatus(stagesWithReceivedTaskStatus, hostRoleCommandListAll);
+    // Presumption: If there is no update in any of the running stage's status
+    // then none of the running request status needs to be updated
+    if (didAnyStageStatusUpdated) {
+      updateActiveRequestsStatus(requestIdsWithReceivedTaskStatus, stagesWithReceivedTaskStatus);
+    }
+
+  }
+
+  /**
+   * On receiving task create event, create entries in the running request, stage and task in the maps
+   * @param event Consumes {@link TaskCreateEvent}.
+   */
+  @Subscribe
+  public void onTaskCreateEvent(TaskCreateEvent event) {
+    LOG.debug("Received task create event {}", event);
+    List<HostRoleCommand> hostRoleCommandListAll = event.getHostRoleCommands();
+
+    for (HostRoleCommand hostRoleCommand : hostRoleCommandListAll) {
+      activeTasksMap.put(hostRoleCommand.getTaskId(), hostRoleCommand);
+      addStagePK(hostRoleCommand);
+      addRequestId(hostRoleCommand);
+    }
+  }
+
+
+  /**
+   * update changed host role command status
+   * @param hostRoleCommandWithReceivedStatus list of host role commands reported
+   */
+  private void updateActiveTasksMap(List<HostRoleCommand> hostRoleCommandWithReceivedStatus) {
+    for (HostRoleCommand hostRoleCommand : hostRoleCommandWithReceivedStatus) {
+      Long taskId = hostRoleCommand.getTaskId();
+      activeTasksMap.put(taskId , hostRoleCommand);
+    }
+  }
+
+
+  /**
+   * Adds new {@link StageEntityPK} to be tracked as running stage in {@link #activeStageMap}
+   * @param hostRoleCommand newly created {@link HostRoleCommand} in {@link #activeTasksMap}
+   */
+  private void addStagePK(HostRoleCommand hostRoleCommand) {
+    StageEntityPK stageEntityPK = new StageEntityPK();
+    stageEntityPK.setRequestId(hostRoleCommand.getRequestId());
+    stageEntityPK.setStageId(hostRoleCommand.getStageId());
+    if (activeStageMap.containsKey(stageEntityPK)) {
+      activeStageMap.get(stageEntityPK).addTaskId(hostRoleCommand.getTaskId());
+    } else {
+      StageEntity stageEntity = stageDAO.findByPK(stageEntityPK);
+      // Stage entity of the hostrolecommand should be persisted before publishing task create event
+      assert stageEntity != null;
+      Map<Role, Float> successFactors = new HashMap<>();
+      Collection<RoleSuccessCriteriaEntity> roleSuccessCriteriaEntities = stageEntity.getRoleSuccessCriterias();
+      for (RoleSuccessCriteriaEntity successCriteriaEntity : roleSuccessCriteriaEntities) {
+        successFactors.put(successCriteriaEntity.getRole(), successCriteriaEntity.getSuccessFactor().floatValue());
+      }
+      Set<Long> taskIdSet =  Sets.newHashSet(hostRoleCommand.getTaskId());
+
+      ActiveStage reportedStage = new ActiveStage(stageEntity.getStatus(), stageEntity.getDisplayStatus(),
+          successFactors, stageEntity.isSkippable(), taskIdSet);
+      activeStageMap.put(stageEntityPK, reportedStage);
+    }
+  }
+
+  /**
+   * update and persist all changed stage status
+   * @param stagesWithReceivedTaskStatus set of stages that has received task status
+   * @param hostRoleCommandListAll list of all task updates received from agent
+   * @return  <code>true</code> if any of the stage has changed it's existing status;
+   *          <code>false</code> otherwise
+   */
+  private Boolean updateActiveStagesStatus(final Set<StageEntityPK> stagesWithReceivedTaskStatus, List<HostRoleCommand> hostRoleCommandListAll) {
+    Boolean didAnyStageStatusUpdated = Boolean.FALSE;
+    for (StageEntityPK reportedStagePK : stagesWithReceivedTaskStatus) {
+      if (activeStageMap.containsKey(reportedStagePK)) {
+        Boolean didStatusChange = updateStageStatus(reportedStagePK, hostRoleCommandListAll);
+        if (didStatusChange) {
+          ActiveStage reportedStage = activeStageMap.get(reportedStagePK);
+          stageDAO.updateStatus(reportedStagePK, reportedStage.getStatus(), reportedStage.getDisplayStatus());
+          didAnyStageStatusUpdated = Boolean.TRUE;
+        }
+      } else {
+        LOG.error(String.format("Received update for a task whose stage is not being tracked as running stage: %s", reportedStagePK.toString()));
+      }
+
+    }
+    return didAnyStageStatusUpdated;
+  }
+
+  /**
+   * Adds new request id to be tracked as running request in {@link #activeRequestMap}
+   * @param hostRoleCommand newly created {@link HostRoleCommand} in {@link #activeTasksMap}
+   */
+  private void addRequestId(HostRoleCommand hostRoleCommand) {
+    Long requestId = hostRoleCommand.getRequestId();
+    StageEntityPK stageEntityPK = new StageEntityPK();
+    stageEntityPK.setRequestId(hostRoleCommand.getRequestId());
+    stageEntityPK.setStageId(hostRoleCommand.getStageId());
+    if (activeRequestMap.containsKey(requestId)) {
+      activeRequestMap.get(requestId).addStageEntityPK(stageEntityPK);
+    } else {
+      RequestEntity requestEntity = requestDAO.findByPK(requestId);
+      // Request entity of the hostrolecommand should be persisted before publishing task create event
+      assert requestEntity != null;
+      Set<StageEntityPK> stageEntityPKs =  Sets.newHashSet(stageEntityPK);
+      ActiveRequest request = new ActiveRequest(requestEntity.getStatus(),requestEntity.getDisplayStatus(), stageEntityPKs);
+      activeRequestMap.put(requestId, request);
+    }
+  }
+
+
+  /**
+   * update and persist changed request status
+   * @param requestIdsWithReceivedTaskStatus set of request ids that has received tasks status
+   * @param stagesWithChangedTaskStatus set of stages that have received tasks with changed status
+   */
+  private void updateActiveRequestsStatus(final Set<Long> requestIdsWithReceivedTaskStatus, Set<StageEntityPK> stagesWithChangedTaskStatus) {
+    for (Long reportedRequestId : requestIdsWithReceivedTaskStatus) {
+      if (activeRequestMap.containsKey(reportedRequestId)) {
+        ActiveRequest request =  activeRequestMap.get(reportedRequestId);
+        Boolean didStatusChange = updateRequestStatus(reportedRequestId, stagesWithChangedTaskStatus);
+        if (didStatusChange) {
+          requestDAO.updateStatus(reportedRequestId, request.getStatus(), request.getDisplayStatus());
+        }
+        if (request.isCompleted() && isAllTasksCompleted(reportedRequestId)) {
+          // Request is considered ton have been finished if request status and all of it's tasks status are completed
+          // in that case, request and it's stages
+          // and tasks should no longer be tracked as active(running)
+          removeRequestStageAndTasks(reportedRequestId);
+        }
+      } else {
+        LOG.error(String.format("Received update for a task whose request %d is not being tracked as running request", reportedRequestId));
+      }
+
+    }
+  }
+
+  /**
+   *
+   * @param requestId request Id
+   * @return  <code>false</code> if any of the task belonging to requestId has incomplete status
+   *          <code>true</code> otherwise
+   */
+  private Boolean isAllTasksCompleted(Long requestId) {
+    Boolean result = Boolean.TRUE;
+    for (Map.Entry<Long, HostRoleCommand> entry : activeTasksMap.entrySet()) {
+      if (entry.getValue().getRequestId() == requestId && !entry.getValue().getStatus().isCompletedState()) {
+        result = Boolean.FALSE;
+      }
+    }
+    return result;
+  }
+
+  /**
+   * Removes entries from {@link #activeTasksMap},{@link #activeStageMap} and {@link #activeRequestMap}
+   * @param requestId request id whose entry and it's stage and task entries is to be removed
+   */
+  private void removeRequestStageAndTasks(Long requestId) {
+    removeTasks(requestId);
+    removeStages(requestId);
+    removeRequest(requestId);
+  }
+
+
+  /**
+   * Filters list of {@link Stage} to list of {@link StageEntityPK}
+   * @param requestID requestId
+   * @return  list of StageEntityPK
+   */
+  private List<StageEntityPK> getAllStageEntityPKForRequest(final Long requestID) {
+    Predicate<StageEntityPK> predicate = new Predicate<StageEntityPK>() {
+      @Override
+      public boolean apply(StageEntityPK stageEntityPK) {
+        return stageEntityPK.getRequestId().equals(requestID);
+      }
+    };
+    return  FluentIterable.from(activeStageMap.keySet())
+        .filter(predicate)
+        .toList();
+  }
+
+
+
+  /**
+   * Returns the computed status of the stage from the status of it's host role commands
+   * @param stagePK {@link StageEntityPK} primary key for the stage entity
+   * @param hostRoleCommandListAll list of all hrc received whose status has been received from agent
+   * @return {@link Boolean} <code>TRUE</code> if status of the given stage changed.
+   */
+  private Boolean updateStageStatus(final StageEntityPK stagePK, List<HostRoleCommand> hostRoleCommandListAll) {
+    Boolean didAnyStatusChanged = Boolean.FALSE;
+    ActiveStage reportedStage = activeStageMap.get(stagePK);
+    HostRoleStatus stageCurrentStatus = reportedStage.getStatus();
+    HostRoleStatus stageCurrentDisplayStatus = reportedStage.getDisplayStatus();
+
+
+    // if stage is already marked to be completed then do not calculate reported status from host role commands
+    // Presumption: There will be no status transition of the host role command from one completed state to another
+    if (!stageCurrentDisplayStatus.isCompletedState() || !stageCurrentStatus.isCompletedState()) {
+      Map<HostRoleStatus, Integer> receivedTaskStatusCount = CalculatedStatus.calculateStatusCountsForTasks(hostRoleCommandListAll, stagePK);
+      HostRoleStatus statusFromPartialSet = CalculatedStatus.calculateSummaryStatusFromPartialSet(receivedTaskStatusCount, reportedStage.getSkippable());
+      HostRoleStatus displayStatusFromPartialSet = CalculatedStatus.calculateSummaryStatusFromPartialSet(receivedTaskStatusCount, Boolean.FALSE);
+      if (statusFromPartialSet == HostRoleStatus.PENDING || displayStatusFromPartialSet == HostRoleStatus.PENDING) {
+        Function<Long,HostRoleCommand> transform = new Function<Long,HostRoleCommand>(){
+          @Override
+          public HostRoleCommand apply(Long taskId) {
+            return activeTasksMap.get(taskId);
+          }
+        };
+
+        List<HostRoleCommand> activeHostRoleCommandsOfStage = FluentIterable.from(reportedStage.getTaskIds())
+            .transform(transform).toList();
+        Map<HostRoleStatus, Integer> statusCount = CalculatedStatus.calculateStatusCountsForTasks(activeHostRoleCommandsOfStage);
+        if (displayStatusFromPartialSet == HostRoleStatus.PENDING) {
+          // calculate and get new display status of the stage as per the new status of received host role commands
+          HostRoleStatus display_status = CalculatedStatus.calculateSummaryDisplayStatus(statusCount, activeHostRoleCommandsOfStage.size(), reportedStage.getSkippable());
+          if (display_status != stageCurrentDisplayStatus) {
+            reportedStage.setDisplayStatus(display_status);
+            didAnyStatusChanged = Boolean.TRUE;
+          }
+
+        } else {
+          reportedStage.setDisplayStatus(displayStatusFromPartialSet);
+          didAnyStatusChanged = Boolean.TRUE;
+        }
+
+        if (statusFromPartialSet == HostRoleStatus.PENDING) {
+          // calculate status of the stage as per the new status of received host role commands
+          HostRoleStatus status = CalculatedStatus.calculateStageStatus(activeHostRoleCommandsOfStage, statusCount, reportedStage.getSuccessFactors(), reportedStage.getSkippable());
+          if (status != stageCurrentStatus) {
+            reportedStage.setStatus(status);
+            didAnyStatusChanged = Boolean.TRUE;
+          }
+        } else {
+          reportedStage.setDisplayStatus(displayStatusFromPartialSet);
+          didAnyStatusChanged = Boolean.TRUE;
+        }
+      } else {
+        reportedStage.setStatus(statusFromPartialSet);
+        reportedStage.setDisplayStatus(displayStatusFromPartialSet);
+        didAnyStatusChanged = Boolean.TRUE;
+      }
+    }
+
+    return didAnyStatusChanged;
+  }
+
+  /**
+   *
+   * @param requestId {@link Request} whose status is to be updated
+   * @param stagesWithChangedTaskStatus set of stages that have received tasks with changed status
+   * @return {Boolean} <code>TRUE</code> if request status has changed from existing
+   */
+  private Boolean updateRequestStatus (final Long requestId, Set<StageEntityPK> stagesWithChangedTaskStatus) {
+    Boolean didStatusChanged = Boolean.FALSE;
+    ActiveRequest request = activeRequestMap.get(requestId);
+    HostRoleStatus requestCurrentStatus = request.getStatus();
+    HostRoleStatus requestCurrentDisplayStatus = request.getDisplayStatus();
+
+    if (!requestCurrentDisplayStatus.isCompletedState() || !requestCurrentStatus.isCompletedState()) {
+      List <ActiveStage>  activeStagesWithChangesTaskStatus = new ArrayList<>();
+      for (StageEntityPK stageEntityPK:stagesWithChangedTaskStatus) {
+        if (requestId.equals(stageEntityPK.getRequestId())) {
+          ActiveStage activeStage = activeStageMap.get(stageEntityPK);
+          activeStagesWithChangesTaskStatus.add(activeStage);
+        }
+      }
+
+
+      Map<CalculatedStatus.StatusType,Map<HostRoleStatus, Integer>> stageStatusCountFromPartialSet = CalculatedStatus.calculateStatusCountsForStage(activeStagesWithChangesTaskStatus);
+      HostRoleStatus statusFromPartialSet = CalculatedStatus.calculateSummaryStatusFromPartialSet(stageStatusCountFromPartialSet.get(CalculatedStatus.StatusType.STATUS), Boolean.FALSE);
+      HostRoleStatus displayStatusFromPartialSet = CalculatedStatus.calculateSummaryStatusFromPartialSet(stageStatusCountFromPartialSet.get(CalculatedStatus.StatusType.DISPLAY_STATUS), Boolean.FALSE);
+
+      if (statusFromPartialSet == HostRoleStatus.PENDING || displayStatusFromPartialSet == HostRoleStatus.PENDING) {
+        List <ActiveStage> allActiveStages = new ArrayList<>();
+        for (StageEntityPK stageEntityPK:request.getStageEntityPks()) {
+          ActiveStage activeStage = activeStageMap.get(stageEntityPK);
+          allActiveStages.add(activeStage);
+        }
+        Map<CalculatedStatus.StatusType,Map<HostRoleStatus, Integer>> stageStatusCount = CalculatedStatus.calculateStatusCountsForStage(allActiveStages);
+
+        if (displayStatusFromPartialSet == HostRoleStatus.PENDING) {
+          // calculate and get new display status of the stage as per the new status of received host role commands
+
+          HostRoleStatus display_status = CalculatedStatus.calculateSummaryDisplayStatus(stageStatusCount.get(CalculatedStatus.StatusType.DISPLAY_STATUS), allActiveStages.size(), false);
+          if (display_status != requestCurrentDisplayStatus) {
+            request.setDisplayStatus(display_status);
+            didStatusChanged = Boolean.TRUE;
+          }
+
+        } else {
+          request.setDisplayStatus(displayStatusFromPartialSet);
+          didStatusChanged = Boolean.TRUE;
+        }
+
+        if (statusFromPartialSet == HostRoleStatus.PENDING) {
+          // calculate status of the stage as per the new status of received host role commands
+          HostRoleStatus status = CalculatedStatus.calculateSummaryStatus(stageStatusCount.get(CalculatedStatus.StatusType.STATUS), allActiveStages.size(), false);
+          if (status != requestCurrentStatus) {
+            request.setStatus(status);
+            didStatusChanged = Boolean.TRUE;
+          }
+        } else {
+          request.setDisplayStatus(displayStatusFromPartialSet);
+          didStatusChanged = Boolean.TRUE;
+        }
+      } else {
+        request.setStatus(statusFromPartialSet);
+        request.setDisplayStatus(displayStatusFromPartialSet);
+        didStatusChanged = Boolean.TRUE;
+      }
+    }
+
+    return didStatusChanged;
+  }
+
+
+  /**
+   * Removes list of {@link HostRoleCommand} entries from {@link #activeTasksMap}
+   * @param requestId request id
+   */
+  private void removeTasks(Long requestId) {
+    Iterator<Map.Entry<Long, HostRoleCommand>> iter = activeTasksMap.entrySet().iterator();
+    while (iter.hasNext()) {
+      Map.Entry<Long, HostRoleCommand> entry = iter.next();
+      HostRoleCommand hrc = entry.getValue();
+      if (hrc.getRequestId() == requestId) {
+        if (!hrc.getStatus().isCompletedState()) {
+          LOG.error(String.format("Task %d should have been completed before being removed from running task cache(activeTasksMap)", hrc.getTaskId()));
+        }
+        iter.remove();
+      }
+    }
+  }
+
+
+  /**
+   * Removes list of {@link StageEntityPK} entries from {@link #activeStageMap}
+   * @param requestId request Id
+   */
+  private void removeStages(Long requestId) {
+    List <StageEntityPK> stageEntityPKs = getAllStageEntityPKForRequest(requestId);
+    for (StageEntityPK stageEntityPK: stageEntityPKs) {
+      activeStageMap.remove(stageEntityPK);
+    }
+  }
+
+
+  /**
+   * Removes request id from {@link #activeRequestMap}
+   * @param requestId request Id
+   */
+  private void removeRequest(Long requestId) {
+    activeRequestMap.remove(requestId);
+  }
+
+
+  /**
+   * This class stores {@link Request#status} and {@link Request#displayStatus} information
+   * This information is cached for all running {@link Request} at {@link #activeRequestMap}
+   */
+  protected class ActiveRequest {
+    private HostRoleStatus status;
+    private HostRoleStatus displayStatus;
+    private Set <StageEntityPK> stageEntityPks;
+
+    public ActiveRequest(HostRoleStatus status, HostRoleStatus displayStatus, Set<StageEntityPK> stageEntityPks) {
+      this.status = status;
+      this.displayStatus = displayStatus;
+      this.stageEntityPks = stageEntityPks;
+    }
+
+    public HostRoleStatus getStatus() {
+      return status;
+    }
+
+    public void setStatus(HostRoleStatus status) {
+      this.status = status;
+    }
+
+    public HostRoleStatus getDisplayStatus() {
+      return displayStatus;
+    }
+
+    public void setDisplayStatus(HostRoleStatus displayStatus) {
+      this.displayStatus = displayStatus;
+    }
+
+    public Boolean isCompleted() {
+      return status.isCompletedState() && displayStatus.isCompletedState();
+    }
+
+    public Set <StageEntityPK> getStageEntityPks() {
+      return stageEntityPks;
+    }
+
+    public void addStageEntityPK(StageEntityPK stageEntityPK) {
+      stageEntityPks.add(stageEntityPK);
+    }
+
+  }
+
+  /**
+   * This class stores information needed to determine {@link Stage#status} and {@link Stage#displayStatus}
+   * This information is cached for all {@link Stage} of all running {@link Request} at {@link #activeStageMap}
+   */
+  public class ActiveStage {
+    private HostRoleStatus status;
+    private HostRoleStatus displayStatus;
+    private Boolean skippable;
+    private Set <Long> taskIds;
+
+    //Map of roles to successFactors for this stage. Default is 1 i.e. 100%
+    private Map<Role, Float> successFactors = new HashMap<Role, Float>();
+
+    public ActiveStage(HostRoleStatus status, HostRoleStatus displayStatus,
+                       Map<Role, Float> successFactors, Boolean skippable, Set<Long> taskIds) {
+      this.status = status;
+      this.displayStatus = displayStatus;
+      this.successFactors =  successFactors;
+      this.skippable = skippable;
+      this.taskIds = taskIds;
+    }
+
+    public HostRoleStatus getStatus() {
+      return status;
+    }
+
+    public void setStatus(HostRoleStatus status) {
+      this.status = status;
+    }
+
+    public HostRoleStatus getDisplayStatus() {
+      return displayStatus;
+    }
+
+    public void setDisplayStatus(HostRoleStatus displayStatus) {
+      this.displayStatus = displayStatus;
+    }
+
+    public Boolean getSkippable() {
+      return skippable;
+    }
+
+    public void setSkippable(Boolean skippable) {
+      this.skippable = skippable;
+    }
+
+    public Map<Role, Float> getSuccessFactors() {
+      return successFactors;
+    }
+
+    public void setSuccessFactors(Map<Role, Float> successFactors) {
+      this.successFactors = successFactors;
+    }
+
+    public Set <Long> getTaskIds() {
+      return taskIds;
+    }
+
+    public void addTaskId(Long taskId) {
+      taskIds.add(taskId);
+    }
+
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/main/java/org/apache/ambari/server/events/publishers/TaskEventPublisher.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/events/publishers/TaskEventPublisher.java b/ambari-server/src/main/java/org/apache/ambari/server/events/publishers/TaskEventPublisher.java
new file mode 100644
index 0000000..fdc41e5
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/events/publishers/TaskEventPublisher.java
@@ -0,0 +1,62 @@
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.events.publishers;
+
+import org.apache.ambari.server.events.TaskEvent;
+
+import com.google.common.eventbus.EventBus;
+import com.google.common.eventbus.Subscribe;
+import com.google.inject.Singleton;
+
+/**
+ * The {@link TaskEventPublisher} is used to publish instances of
+ * {@link TaskEvent} to any {@link com.google.common.eventbus.Subscribe} interested.
+ * It uses a single-threaded, serial {@link EventBus}.
+ */
+@Singleton
+public class TaskEventPublisher {
+
+  /**
+   * A single threaded, synchronous event bus for processing task events.
+   */
+  private final EventBus m_eventBus = new EventBus("ambari-task-report-event-bus");
+
+
+  /**
+   * Publishes the specified event to all registered listeners that
+   * {@link Subscribe} to  {@link TaskEvent} instances.
+   *
+   * @param event {@link TaskEvent}
+   */
+  public void publish(TaskEvent event) {
+    m_eventBus.post(event);
+  }
+
+  /**
+   * Register a listener to receive events. The listener should use the
+   * {@link Subscribe} annotation.
+   *
+   * @param object
+   *          the listener to receive events.
+   */
+  public void register(Object object) {
+    m_eventBus.register(object);
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java
index 02c4091..e834045 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java
@@ -40,6 +40,8 @@ import org.apache.ambari.annotations.TransactionalLock;
 import org.apache.ambari.annotations.TransactionalLock.LockArea;
 import org.apache.ambari.annotations.TransactionalLock.LockType;
 import org.apache.ambari.server.RoleCommand;
+import org.apache.ambari.server.actionmanager.HostRoleCommand;
+import org.apache.ambari.server.actionmanager.HostRoleCommandFactory;
 import org.apache.ambari.server.actionmanager.HostRoleStatus;
 import org.apache.ambari.server.api.query.JpaPredicateVisitor;
 import org.apache.ambari.server.api.query.JpaSortBuilder;
@@ -49,6 +51,9 @@ import org.apache.ambari.server.controller.spi.Predicate;
 import org.apache.ambari.server.controller.spi.Request;
 import org.apache.ambari.server.controller.spi.SortRequest;
 import org.apache.ambari.server.controller.utilities.PredicateHelper;
+import org.apache.ambari.server.events.TaskCreateEvent;
+import org.apache.ambari.server.events.TaskUpdateEvent;
+import org.apache.ambari.server.events.publishers.TaskEventPublisher;
 import org.apache.ambari.server.orm.RequiresSession;
 import org.apache.ambari.server.orm.TransactionalLocks;
 import org.apache.ambari.server.orm.entities.HostEntity;
@@ -58,9 +63,11 @@ import org.apache.ambari.server.orm.entities.StageEntity;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Function;
 import com.google.common.cache.Cache;
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.LoadingCache;
+import com.google.common.collect.FluentIterable;
 import com.google.common.collect.Lists;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
@@ -144,6 +151,13 @@ public class HostRoleCommandDAO {
   @Inject
   private Configuration configuration;
 
+
+  @Inject
+  HostRoleCommandFactory hostRoleCommandFactory;
+
+  @Inject
+  private TaskEventPublisher taskEventPublisher;
+
   /**
    * Used to ensure that methods which rely on the completion of
    * {@link Transactional} can detect when they are able to run.
@@ -629,11 +643,17 @@ public class HostRoleCommandDAO {
   @Transactional
   @TransactionalLock(lockArea = LockArea.HRC_STATUS_CACHE, lockType = LockType.WRITE)
   public HostRoleCommandEntity merge(HostRoleCommandEntity entity) {
+    entity = mergeWithoutPublishEvent(entity);
+    publishTaskUpdateEvent(Collections.singletonList(hostRoleCommandFactory.createExisting(entity)));
+    return entity;
+  }
+
+  @Transactional
+  @TransactionalLock(lockArea = LockArea.HRC_STATUS_CACHE, lockType = LockType.WRITE)
+  public HostRoleCommandEntity mergeWithoutPublishEvent(HostRoleCommandEntity entity) {
     EntityManager entityManager = entityManagerProvider.get();
     entity = entityManager.merge(entity);
-
     invalidateHostRoleCommandStatusSummaryCache(entity);
-
     return entity;
   }
 
@@ -667,10 +687,51 @@ public class HostRoleCommandDAO {
     }
 
     invalidateHostRoleCommandStatusSummaryCache(requestsToInvalidate);
-
+    publishTaskUpdateEvent(getHostRoleCommands(entities));
     return managedList;
   }
 
+  /**
+   *
+   * @param entities
+   */
+  public List<HostRoleCommand> getHostRoleCommands(Collection<HostRoleCommandEntity> entities) {
+    Function<HostRoleCommandEntity, HostRoleCommand> transform = new Function<HostRoleCommandEntity, HostRoleCommand> () {
+      @Override
+      public HostRoleCommand apply(HostRoleCommandEntity entity) {
+        return hostRoleCommandFactory.createExisting(entity);
+      }
+    };
+    return FluentIterable.from(entities)
+        .transform(transform)
+        .toList();
+
+  }
+
+  /**
+   *
+   * @param hostRoleCommands
+   */
+  public void publishTaskUpdateEvent(List<HostRoleCommand> hostRoleCommands) {
+    if (!hostRoleCommands.isEmpty()) {
+      TaskUpdateEvent taskUpdateEvent = new TaskUpdateEvent(hostRoleCommands);
+      taskEventPublisher.publish(taskUpdateEvent);
+    }
+  }
+
+  /**
+   *
+   * @param hostRoleCommands
+   */
+  public void publishTaskCreateEvent(List<HostRoleCommand> hostRoleCommands) {
+    if (!hostRoleCommands.isEmpty()) {
+      TaskCreateEvent taskCreateEvent = new TaskCreateEvent(hostRoleCommands);
+      taskEventPublisher.publish(taskCreateEvent);
+    }
+  }
+
+
+
   @Transactional
   @TransactionalLock(lockArea = LockArea.HRC_STATUS_CACHE, lockType = LockType.WRITE)
   public void remove(HostRoleCommandEntity entity) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/RequestDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/RequestDAO.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/RequestDAO.java
index 1c4d0a3..2696f66 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/RequestDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/RequestDAO.java
@@ -144,6 +144,14 @@ public class RequestDAO {
   }
 
   @Transactional
+  public void updateStatus(long requestId, HostRoleStatus status, HostRoleStatus displayStatus) {
+    RequestEntity requestEntity = findByPK(requestId);
+    requestEntity.setStatus(status);
+    requestEntity.setDisplayStatus(displayStatus);
+    merge(requestEntity);
+  }
+
+  @Transactional
   public void create(RequestEntity requestEntity) {
     entityManagerProvider.get().persist(requestEntity);
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java
index d2f899f..126468a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java
@@ -18,6 +18,7 @@
 
 package org.apache.ambari.server.orm.dao;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.EnumSet;
 import java.util.HashMap;
@@ -173,11 +174,15 @@ public class StageDAO {
     return daoUtils.selectList(query);
   }
 
+  /**
+   *
+   * @param statuses {@link HostRoleStatus}
+   * @return list of stage entities
+   */
   @RequiresSession
-  public List<StageEntity> findByCommandStatuses(
-      Collection<HostRoleStatus> statuses) {
+  public List<StageEntity> findByStatuses(Collection<HostRoleStatus> statuses) {
     TypedQuery<StageEntity> query = entityManagerProvider.get().createNamedQuery(
-        "StageEntity.findByCommandStatuses", StageEntity.class);
+        "StageEntity.findByStatuses", StageEntity.class);
 
     query.setParameter("statuses", statuses);
     return daoUtils.selectList(query);
@@ -280,8 +285,8 @@ public class StageDAO {
    *          the stage entity to update
    * @param desiredStatus
    *          the desired stage status
-   * @param controller
-   *          the ambari management controller
+   * @param actionManager
+   *          the action manager
    *
    * @throws java.lang.IllegalArgumentException
    *           if the transition to the desired status is not a legal transition
@@ -301,9 +306,11 @@ public class StageDAO {
     if (desiredStatus == HostRoleStatus.ABORTED) {
       actionManager.cancelRequest(stage.getRequestId(), "User aborted.");
     } else {
+      List <HostRoleCommandEntity> hrcWithChangedStatus = new ArrayList<HostRoleCommandEntity>();
       for (HostRoleCommandEntity hostRoleCommand : tasks) {
         HostRoleStatus hostRoleStatus = hostRoleCommand.getStatus();
         if (hostRoleStatus.equals(currentStatus)) {
+          hrcWithChangedStatus.add(hostRoleCommand);
           hostRoleCommand.setStatus(desiredStatus);
 
           if (desiredStatus == HostRoleStatus.PENDING) {
@@ -316,6 +323,21 @@ public class StageDAO {
   }
 
   /**
+   *
+   * @param stageEntityPK  {@link StageEntityPK}
+   * @param status {@link HostRoleStatus}
+   * @param displayStatus {@link HostRoleStatus}
+   */
+  @Transactional
+  public void updateStatus(StageEntityPK stageEntityPK, HostRoleStatus status, HostRoleStatus displayStatus) {
+    StageEntity stageEntity = findByPK(stageEntityPK);
+    stageEntity.setStatus(status);
+    stageEntity.setDisplayStatus(displayStatus);
+    merge(stageEntity);
+  }
+
+
+  /**
    * Determine whether or not it is valid to transition from this stage status
    * to the given status.
    *

http://git-wip-us.apache.org/repos/asf/ambari/blob/0fc7a667/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java
index 74271b9..a809295 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java
@@ -105,9 +105,9 @@ public class HostRoleCommandEntity {
   @Basic
   private Integer exitcode = 0;
 
-  @Column(name = "status")
+  @Column(name = "status", nullable = false)
   @Enumerated(EnumType.STRING)
-  private HostRoleStatus status;
+  private HostRoleStatus status = HostRoleStatus.PENDING;
 
   @Column(name = "std_error")
   @Lob


[05/15] ambari git commit: AMBARI-19845 Secure Ranger passwords in Ambari Stacks (mugdha)

Posted by jo...@apache.org.
AMBARI-19845 Secure Ranger passwords in Ambari Stacks (mugdha)


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

Branch: refs/heads/branch-feature-AMBARI-20053
Commit: c395f6948a1aa8bb62f65b3b7a1fe4c72f662762
Parents: 05c76ed
Author: Mugdha Varadkar <mu...@apache.org>
Authored: Fri Feb 17 15:53:43 2017 +0530
Committer: Mugdha Varadkar <mu...@apache.org>
Committed: Fri Feb 17 16:19:13 2017 +0530

----------------------------------------------------------------------
 .../libraries/functions/constants.py            |  1 +
 .../functions/setup_ranger_plugin_xml.py        | 23 ++++++-
 .../RANGER/0.4.0/package/scripts/params.py      | 18 ++++++
 .../0.4.0/package/scripts/setup_ranger_xml.py   | 67 ++++++++++++++++++--
 .../0.5.0/configuration/ranger-admin-site.xml   | 12 ++++
 .../0.7.0/configuration/ranger-admin-site.xml   | 31 +++++++++
 .../RANGER_KMS/0.5.0.2.3/package/scripts/kms.py | 29 ++++++++-
 .../0.5.0.2.3/package/scripts/params.py         |  4 ++
 .../HDP/2.0.6/properties/stack_features.json    |  5 ++
 .../stacks/2.5/RANGER/test_ranger_admin.py      | 16 ++++-
 .../stacks/2.5/RANGER/test_ranger_usersync.py   |  8 ++-
 .../stacks/2.5/RANGER_KMS/test_kms_server.py    | 50 +++++++++++++--
 .../stacks/2.6/RANGER/test_ranger_admin.py      | 40 +++++++++++-
 .../stacks/2.6/RANGER/test_ranger_tagsync.py    | 19 ++++--
 .../2.6/configs/ranger-admin-default.json       |  6 +-
 15 files changed, 302 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c395f694/ambari-common/src/main/python/resource_management/libraries/functions/constants.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/constants.py b/ambari-common/src/main/python/resource_management/libraries/functions/constants.py
index 8fd5c8d..c31b883 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/constants.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/constants.py
@@ -116,3 +116,4 @@ class StackFeature:
   ATLAS_INSTALL_HOOK_PACKAGE_SUPPORT="atlas_install_hook_package_support"
   ATLAS_HDFS_SITE_ON_NAMENODE_HA='atlas_hdfs_site_on_namenode_ha'
   HIVE_INTERACTIVE_GA_SUPPORT='hive_interactive_ga'
+  SECURE_RANGER_SSL_PASSWORD = "secure_ranger_ssl_password"

http://git-wip-us.apache.org/repos/asf/ambari/blob/c395f694/ambari-common/src/main/python/resource_management/libraries/functions/setup_ranger_plugin_xml.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/setup_ranger_plugin_xml.py b/ambari-common/src/main/python/resource_management/libraries/functions/setup_ranger_plugin_xml.py
index a12116d..56c46dd 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/setup_ranger_plugin_xml.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/setup_ranger_plugin_xml.py
@@ -131,9 +131,17 @@ def setup_ranger_plugin(component_select_name, service_name, previous_jdbc_jar,
         mode = 0644
       )
 
+    # remove plain-text password from xml configs
+    plugin_audit_password_property = 'xasecure.audit.destination.db.password'
+    plugin_audit_properties_copy = {}
+    plugin_audit_properties_copy.update(plugin_audit_properties)
+
+    if plugin_audit_password_property in plugin_audit_properties_copy:
+      plugin_audit_properties_copy[plugin_audit_password_property] = "crypted"
+
     XmlConfig(format('ranger-{service_name}-audit.xml'),
       conf_dir=component_conf_dir,
-      configurations=plugin_audit_properties,
+      configurations=plugin_audit_properties_copy,
       configuration_attributes=plugin_audit_attributes,
       owner = component_user,
       group = component_group,
@@ -147,10 +155,19 @@ def setup_ranger_plugin(component_select_name, service_name, previous_jdbc_jar,
       group = component_group,
       mode=0744)
 
+    # remove plain-text password from xml configs
+    plugin_password_properties = ['xasecure.policymgr.clientssl.keystore.password', 'xasecure.policymgr.clientssl.truststore.password']
+    plugin_policymgr_ssl_properties_copy = {}
+    plugin_policymgr_ssl_properties_copy.update(plugin_policymgr_ssl_properties)
+
+    for prop in plugin_password_properties:
+      if prop in plugin_policymgr_ssl_properties_copy:
+        plugin_policymgr_ssl_properties_copy[prop] = "crypted"
+
     if str(service_name).lower() == 'yarn' :
       XmlConfig("ranger-policymgr-ssl-yarn.xml",
         conf_dir=component_conf_dir,
-        configurations=plugin_policymgr_ssl_properties,
+        configurations=plugin_policymgr_ssl_properties_copy,
         configuration_attributes=plugin_policymgr_ssl_attributes,
         owner = component_user,
         group = component_group,
@@ -158,7 +175,7 @@ def setup_ranger_plugin(component_select_name, service_name, previous_jdbc_jar,
     else:
       XmlConfig("ranger-policymgr-ssl.xml",
         conf_dir=component_conf_dir,
-        configurations=plugin_policymgr_ssl_properties,
+        configurations=plugin_policymgr_ssl_properties_copy,
         configuration_attributes=plugin_policymgr_ssl_attributes,
         owner = component_user,
         group = component_group,

http://git-wip-us.apache.org/repos/asf/ambari/blob/c395f694/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/params.py b/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/params.py
index 49cd98b..0fae23e 100644
--- a/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/params.py
+++ b/ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/params.py
@@ -73,6 +73,7 @@ stack_supports_ranger_admin_password_change = check_stack_feature(StackFeature.R
 stack_supports_ranger_setup_db_on_start = check_stack_feature(StackFeature.RANGER_SETUP_DB_ON_START, version_for_stack_feature_checks)
 stack_supports_ranger_tagsync_ssl_xml_support = check_stack_feature(StackFeature.RANGER_TAGSYNC_SSL_XML_SUPPORT, version_for_stack_feature_checks)
 stack_supports_ranger_solr_configs = check_stack_feature(StackFeature.RANGER_SOLR_CONFIG_SUPPORT, version_for_stack_feature_checks)
+stack_supports_secure_ssl_password = check_stack_feature(StackFeature.SECURE_RANGER_SSL_PASSWORD, version_for_stack_feature_checks)
 
 downgrade_from_version = default("/commandParams/downgrade_from_version", None)
 upgrade_direction = default("/commandParams/upgrade_direction", None)
@@ -425,3 +426,20 @@ if is_hbase_ha_enabled:
 if is_namenode_ha_enabled:
   if not is_empty(config['configurations']['ranger-hdfs-plugin-properties']['ranger-hdfs-plugin-enabled']):
     ranger_hdfs_plugin_enabled = config['configurations']['ranger-hdfs-plugin-properties']['ranger-hdfs-plugin-enabled'].lower() == 'yes'
+
+ranger_admin_password_properties = ['ranger.jpa.jdbc.password', 'ranger.jpa.audit.jdbc.password', 'ranger.ldap.bind.password', 'ranger.ldap.ad.bind.password']
+ranger_usersync_password_properties = ['ranger.usersync.ldap.ldapbindpassword']
+ranger_tagsync_password_properties = ['xasecure.policymgr.clientssl.keystore.password', 'xasecure.policymgr.clientssl.truststore.password']
+if stack_supports_secure_ssl_password:
+  ranger_admin_password_properties.extend(['ranger.service.https.attrib.keystore.pass', 'ranger.truststore.password'])
+  ranger_usersync_password_properties.extend(['ranger.usersync.keystore.password', 'ranger.usersync.truststore.password'])
+
+ranger_auth_method = config['configurations']['ranger-admin-site']['ranger.authentication.method']
+ranger_ldap_password_alias = default('/configurations/ranger-admin-site/ranger.ldap.binddn.credential.alias', 'ranger.ldap.bind.password')
+ranger_ad_password_alias = default('/configurations/ranger-admin-site/ranger.ldap.ad.binddn.credential.alias', 'ranger.ldap.ad.bind.password')
+ranger_https_keystore_alias = default('/configurations/ranger-admin-site/ranger.service.https.attrib.keystore.credential.alias', 'keyStoreCredentialAlias')
+ranger_truststore_alias = default('/configurations/ranger-admin-site/ranger.truststore.alias', 'trustStoreAlias')
+https_enabled = config['configurations']['ranger-admin-site']['ranger.service.https.attrib.ssl.enabled']
+http_enabled = config['configurations']['ranger-admin-site']['ranger.service.http.enabled']
+https_keystore_password = config['configurations']['ranger-admin-site']['ranger.service.https.attrib.keystore.pass']
+truststore_password = config['configurations']['ranger-admin-site']['ranger.truststore.password']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/c395f694/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 acb5385..b3eb919 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
@@ -191,9 +191,17 @@ def setup_ranger_admin(upgrade_type=None):
     only_if=format("ls {ranger_home}/ews/ranger-admin-services.sh"),
     sudo=True)
 
+  # remove plain-text password from xml configs
+
+  ranger_admin_site_copy = {}
+  ranger_admin_site_copy.update(params.config['configurations']['ranger-admin-site'])
+  for prop in params.ranger_admin_password_properties:
+    if prop in ranger_admin_site_copy:
+      ranger_admin_site_copy[prop] = "_"
+
   XmlConfig("ranger-admin-site.xml",
     conf_dir=ranger_conf,
-    configurations=params.config['configurations']['ranger-admin-site'],
+    configurations=ranger_admin_site_copy,
     configuration_attributes=params.config['configuration_attributes']['ranger-admin-site'],
     owner=params.unix_user,
     group=params.unix_group,
@@ -321,6 +329,36 @@ def do_keystore_setup(upgrade_type=None):
       mode = 0640
     )
 
+  if params.ranger_auth_method.upper() == "LDAP":
+    ranger_credential_helper(params.cred_lib_path, params.ranger_ldap_password_alias, params.ranger_usersync_ldap_ldapbindpassword, params.ranger_credential_provider_path)
+
+    File(params.ranger_credential_provider_path,
+      owner = params.unix_user,
+      group = params.unix_group,
+      mode = 0640
+    )
+
+  if params.ranger_auth_method.upper() == "ACTIVE_DIRECTORY":
+    ranger_credential_helper(params.cred_lib_path, params.ranger_ad_password_alias, params.ranger_usersync_ldap_ldapbindpassword, params.ranger_credential_provider_path)
+
+    File(params.ranger_credential_provider_path,
+      owner = params.unix_user,
+      group = params.unix_group,
+      mode = 0640
+    )
+
+  if params.stack_supports_secure_ssl_password:
+    ranger_credential_helper(params.cred_lib_path, params.ranger_truststore_alias, params.truststore_password, params.ranger_credential_provider_path)
+
+    if params.https_enabled and not params.http_enabled:
+      ranger_credential_helper(params.cred_lib_path, params.ranger_https_keystore_alias, params.https_keystore_password, params.ranger_credential_provider_path)
+
+    File(params.ranger_credential_provider_path,
+      owner = params.unix_user,
+      group = params.unix_group,
+      mode = 0640
+    )
+
 def password_validation(password):
   import params
   if password.strip() == "":
@@ -453,9 +491,16 @@ def setup_usersync(upgrade_type=None):
     dst_file = format('{usersync_home}/conf/log4j.xml')
     Execute(('cp', '-f', src_file, dst_file), sudo=True)
 
+  # remove plain-text password from xml configs
+  ranger_ugsync_site_copy = {}
+  ranger_ugsync_site_copy.update(params.config['configurations']['ranger-ugsync-site'])
+  for prop in params.ranger_usersync_password_properties:
+    if prop in ranger_ugsync_site_copy:
+      ranger_ugsync_site_copy[prop] = "_"
+
   XmlConfig("ranger-ugsync-site.xml",
     conf_dir=ranger_ugsync_conf,
-    configurations=params.config['configurations']['ranger-ugsync-site'],
+    configurations=ranger_ugsync_site_copy,
     configuration_attributes=params.config['configuration_attributes']['ranger-ugsync-site'],
     owner=params.unix_user,
     group=params.unix_group,
@@ -750,9 +795,16 @@ def setup_tagsync_ssl_configs():
             mode=0775,
             create_parents=True)
 
+  # remove plain-text password from xml configs
+  ranger_tagsync_policymgr_ssl_copy = {}
+  ranger_tagsync_policymgr_ssl_copy.update(params.config['configurations']['ranger-tagsync-policymgr-ssl'])
+  for prop in params.ranger_tagsync_password_properties:
+    if prop in ranger_tagsync_policymgr_ssl_copy:
+      ranger_tagsync_policymgr_ssl_copy[prop] = "_"
+
   XmlConfig("ranger-policymgr-ssl.xml",
             conf_dir=params.ranger_tagsync_conf,
-            configurations=params.config['configurations']['ranger-tagsync-policymgr-ssl'],
+            configurations=ranger_tagsync_policymgr_ssl_copy,
             configuration_attributes=params.config['configuration_attributes']['ranger-tagsync-policymgr-ssl'],
             owner=params.unix_user,
             group=params.unix_group,
@@ -767,9 +819,16 @@ def setup_tagsync_ssl_configs():
        mode = 0640
        )
 
+  # remove plain-text password from xml configs
+  atlas_tagsync_ssl_copy = {}
+  atlas_tagsync_ssl_copy.update(params.config['configurations']['atlas-tagsync-ssl'])
+  for prop in params.ranger_tagsync_password_properties:
+    if prop in atlas_tagsync_ssl_copy:
+      atlas_tagsync_ssl_copy[prop] = "_"
+
   XmlConfig("atlas-tagsync-ssl.xml",
             conf_dir=params.ranger_tagsync_conf,
-            configurations=params.config['configurations']['atlas-tagsync-ssl'],
+            configurations=atlas_tagsync_ssl_copy,
             configuration_attributes=params.config['configuration_attributes']['atlas-tagsync-ssl'],
             owner=params.unix_user,
             group=params.unix_group,

http://git-wip-us.apache.org/repos/asf/ambari/blob/c395f694/ambari-server/src/main/resources/common-services/RANGER/0.5.0/configuration/ranger-admin-site.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/RANGER/0.5.0/configuration/ranger-admin-site.xml b/ambari-server/src/main/resources/common-services/RANGER/0.5.0/configuration/ranger-admin-site.xml
index c52924c..f2e23ce 100644
--- a/ambari-server/src/main/resources/common-services/RANGER/0.5.0/configuration/ranger-admin-site.xml
+++ b/ambari-server/src/main/resources/common-services/RANGER/0.5.0/configuration/ranger-admin-site.xml
@@ -548,4 +548,16 @@
     </value-attributes>
     <on-ambari-upgrade add="true"/>
   </property>
+  <property>
+    <name>ranger.ldap.binddn.credential.alias</name>
+    <value>ranger.ldap.bind.password</value>
+    <description></description>
+    <on-ambari-upgrade add="true"/>
+  </property>
+  <property>
+    <name>ranger.ldap.ad.binddn.credential.alias</name>
+    <value>ranger.ldap.ad.bind.password</value>
+    <description></description>
+    <on-ambari-upgrade add="true"/>
+  </property>
 </configuration>

http://git-wip-us.apache.org/repos/asf/ambari/blob/c395f694/ambari-server/src/main/resources/common-services/RANGER/0.7.0/configuration/ranger-admin-site.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/RANGER/0.7.0/configuration/ranger-admin-site.xml b/ambari-server/src/main/resources/common-services/RANGER/0.7.0/configuration/ranger-admin-site.xml
new file mode 100644
index 0000000..ebf8517
--- /dev/null
+++ b/ambari-server/src/main/resources/common-services/RANGER/0.7.0/configuration/ranger-admin-site.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<configuration>
+  <property>
+    <name>ranger.truststore.alias</name>
+    <value>trustStoreAlias</value>
+    <description></description>
+    <on-ambari-upgrade add="false"/>
+  </property>
+  <property>
+    <name>ranger.service.https.attrib.keystore.credential.alias</name>
+    <value>keyStoreCredentialAlias</value>
+    <description></description>
+    <on-ambari-upgrade add="false"/>
+  </property>
+</configuration>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/c395f694/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms.py b/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms.py
index 742cb93..536ba76 100755
--- a/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms.py
+++ b/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/kms.py
@@ -271,9 +271,17 @@ def kms(upgrade_type=None):
     if params.stack_support_kms_hsm and params.enable_kms_hsm:
       do_keystore_setup(params.credential_provider_path, params.hms_partition_alias, unicode(params.hms_partition_passwd))
 
+    # remove plain-text password from xml configs
+    dbks_site_copy = {}
+    dbks_site_copy.update(params.config['configurations']['dbks-site'])
+
+    for prop in params.dbks_site_password_properties:
+      if prop in dbks_site_copy:
+        dbks_site_copy[prop] = "_"
+
     XmlConfig("dbks-site.xml",
       conf_dir=params.kms_conf_dir,
-      configurations=params.config['configurations']['dbks-site'],
+      configurations=dbks_site_copy,
       configuration_attributes=params.config['configuration_attributes']['dbks-site'],
       owner=params.kms_user,
       group=params.kms_group,
@@ -421,9 +429,16 @@ def enable_kms_plugin():
       mode = 0644        
     )
 
+    # remove plain-text password from xml configs
+    plugin_audit_properties_copy = {}
+    plugin_audit_properties_copy.update(params.config['configurations']['ranger-kms-audit'])
+
+    if params.plugin_audit_password_property in plugin_audit_properties_copy:
+      plugin_audit_properties_copy[params.plugin_audit_password_property] = "crypted"
+
     XmlConfig("ranger-kms-audit.xml",
       conf_dir=params.kms_conf_dir,
-      configurations=params.config['configurations']['ranger-kms-audit'],
+      configurations=plugin_audit_properties_copy,
       configuration_attributes=params.config['configuration_attributes']['ranger-kms-audit'],
       owner=params.kms_user,
       group=params.kms_group,
@@ -437,9 +452,17 @@ def enable_kms_plugin():
       group=params.kms_group,
       mode=0744)
 
+    # remove plain-text password from xml configs
+    ranger_kms_policymgr_ssl_copy = {}
+    ranger_kms_policymgr_ssl_copy.update(params.config['configurations']['ranger-kms-policymgr-ssl'])
+
+    for prop in params.kms_plugin_password_properties:
+      if prop in ranger_kms_policymgr_ssl_copy:
+        ranger_kms_policymgr_ssl_copy[prop] = "crypted"
+
     XmlConfig("ranger-policymgr-ssl.xml",
       conf_dir=params.kms_conf_dir,
-      configurations=params.config['configurations']['ranger-kms-policymgr-ssl'],
+      configurations=ranger_kms_policymgr_ssl_copy,
       configuration_attributes=params.config['configuration_attributes']['ranger-kms-policymgr-ssl'],
       owner=params.kms_user,
       group=params.kms_group,

http://git-wip-us.apache.org/repos/asf/ambari/blob/c395f694/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/params.py b/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/params.py
index 05e8881..8473160 100755
--- a/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/params.py
+++ b/ambari-server/src/main/resources/common-services/RANGER_KMS/0.5.0.2.3/package/scripts/params.py
@@ -276,3 +276,7 @@ if security_enabled:
   spengo_keytab = config['configurations']['kms-site']['hadoop.kms.authentication.signer.secret.provider.zookeeper.kerberos.keytab']
   spnego_principal = config['configurations']['kms-site']['hadoop.kms.authentication.signer.secret.provider.zookeeper.kerberos.principal']
   spnego_principal = spnego_principal.replace('_HOST', current_host.lower())
+
+plugin_audit_password_property = 'xasecure.audit.destination.db.password'
+kms_plugin_password_properties = ['xasecure.policymgr.clientssl.keystore.password', 'xasecure.policymgr.clientssl.truststore.password']
+dbks_site_password_properties = ['ranger.db.encrypt.key.password', 'ranger.ks.jpa.jdbc.password', 'ranger.ks.hsm.partition.password']
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/c395f694/ambari-server/src/main/resources/stacks/HDP/2.0.6/properties/stack_features.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/properties/stack_features.json b/ambari-server/src/main/resources/stacks/HDP/2.0.6/properties/stack_features.json
index 0fd1766..5e173b7 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/properties/stack_features.json
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/properties/stack_features.json
@@ -382,6 +382,11 @@
       "name": "hive_interactive_ga",
       "description": "Hive Interactive GA support",
       "min_version": "2.6.0.0"
+    },
+    {
+      "name": "secure_ranger_ssl_password",
+      "description": "Securing Ranger Admin and Usersync SSL and Trustore related passwords in jceks",
+      "min_version": "2.6.0.0"
     }
   ]
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/c395f694/ambari-server/src/test/python/stacks/2.5/RANGER/test_ranger_admin.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.5/RANGER/test_ranger_admin.py b/ambari-server/src/test/python/stacks/2.5/RANGER/test_ranger_admin.py
index 1b5d7ae..0d38876 100644
--- a/ambari-server/src/test/python/stacks/2.5/RANGER/test_ranger_admin.py
+++ b/ambari-server/src/test/python/stacks/2.5/RANGER/test_ranger_admin.py
@@ -293,11 +293,17 @@ class TestRangerAdmin(RMFTestCase):
       sudo = True
     )
 
+    ranger_admin_site_copy = {}
+    ranger_admin_site_copy.update(self.getConfig()['configurations']['ranger-admin-site'])
+    for prop in ['ranger.jpa.jdbc.password', 'ranger.jpa.audit.jdbc.password', 'ranger.ldap.bind.password', 'ranger.ldap.ad.bind.password']:
+      if prop in ranger_admin_site_copy:
+        ranger_admin_site_copy[prop] = "_"
+
     self.assertResourceCalled('XmlConfig', 'ranger-admin-site.xml',
       owner = 'ranger',
       group = 'ranger',
       conf_dir = '/usr/hdp/current/ranger-admin/conf',
-      configurations = self.getConfig()['configurations']['ranger-admin-site'],
+      configurations = ranger_admin_site_copy,
       configuration_attributes = self.getConfig()['configuration_attributes']['ranger-admin-site'],
       mode = 0644
     )
@@ -443,11 +449,17 @@ class TestRangerAdmin(RMFTestCase):
       sudo = True
     )
 
+    ranger_admin_site_copy = {}
+    ranger_admin_site_copy.update(self.getConfig()['configurations']['ranger-admin-site'])
+    for prop in ['ranger.jpa.jdbc.password', 'ranger.jpa.audit.jdbc.password', 'ranger.ldap.bind.password', 'ranger.ldap.ad.bind.password']:
+      if prop in ranger_admin_site_copy:
+        ranger_admin_site_copy[prop] = "_"
+
     self.assertResourceCalled('XmlConfig', 'ranger-admin-site.xml',
       owner = 'ranger',
       group = 'ranger',
       conf_dir = '/usr/hdp/current/ranger-admin/conf',
-      configurations = self.getConfig()['configurations']['ranger-admin-site'],
+      configurations = ranger_admin_site_copy,
       configuration_attributes = self.getConfig()['configuration_attributes']['ranger-admin-site'],
       mode = 0644
     )

http://git-wip-us.apache.org/repos/asf/ambari/blob/c395f694/ambari-server/src/test/python/stacks/2.5/RANGER/test_ranger_usersync.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.5/RANGER/test_ranger_usersync.py b/ambari-server/src/test/python/stacks/2.5/RANGER/test_ranger_usersync.py
index 22e84fc..3f0d21b 100644
--- a/ambari-server/src/test/python/stacks/2.5/RANGER/test_ranger_usersync.py
+++ b/ambari-server/src/test/python/stacks/2.5/RANGER/test_ranger_usersync.py
@@ -132,11 +132,17 @@ class TestRangerUsersync(RMFTestCase):
       mode = 0644
     )
 
+    ranger_ugsync_site_copy = {}
+    ranger_ugsync_site_copy.update(self.getConfig()['configurations']['ranger-ugsync-site'])
+    for prop in ['ranger.usersync.ldap.ldapbindpassword']:
+      if prop in ranger_ugsync_site_copy:
+        ranger_ugsync_site_copy[prop] = "_"
+
     self.assertResourceCalled('XmlConfig', 'ranger-ugsync-site.xml',
       owner = 'ranger',
       group = 'ranger',
       conf_dir = '/usr/hdp/current/ranger-usersync/conf',
-      configurations = self.getConfig()['configurations']['ranger-ugsync-site'],
+      configurations = ranger_ugsync_site_copy,
       configuration_attributes = self.getConfig()['configuration_attributes']['ranger-ugsync-site'],
       mode = 0644
     )

http://git-wip-us.apache.org/repos/asf/ambari/blob/c395f694/ambari-server/src/test/python/stacks/2.5/RANGER_KMS/test_kms_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.5/RANGER_KMS/test_kms_server.py b/ambari-server/src/test/python/stacks/2.5/RANGER_KMS/test_kms_server.py
index 57f9f34..c2fc270 100644
--- a/ambari-server/src/test/python/stacks/2.5/RANGER_KMS/test_kms_server.py
+++ b/ambari-server/src/test/python/stacks/2.5/RANGER_KMS/test_kms_server.py
@@ -93,12 +93,18 @@ class TestRangerKMS(RMFTestCase):
       mode = 0644
     )
 
+    plugin_audit_properties_copy = {}
+    plugin_audit_properties_copy.update(self.getConfig()['configurations']['ranger-kms-audit'])
+
+    if 'xasecure.audit.destination.db.password' in plugin_audit_properties_copy:
+      plugin_audit_properties_copy['xasecure.audit.destination.db.password'] = "crypted"
+
     self.assertResourceCalled('XmlConfig', 'ranger-kms-audit.xml',
       mode = 0744,
       owner = 'kms',
       group = 'kms',
       conf_dir = '/usr/hdp/current/ranger-kms/conf',
-      configurations = self.getConfig()['configurations']['ranger-kms-audit'],
+      configurations = plugin_audit_properties_copy,
       configuration_attributes = self.getConfig()['configuration_attributes']['ranger-kms-audit']
     )
 
@@ -111,12 +117,19 @@ class TestRangerKMS(RMFTestCase):
       configuration_attributes = self.getConfig()['configuration_attributes']['ranger-kms-security']
     )
 
+    ranger_kms_policymgr_ssl_copy = {}
+    ranger_kms_policymgr_ssl_copy.update(self.getConfig()['configurations']['ranger-kms-policymgr-ssl'])
+
+    for prop in ['xasecure.policymgr.clientssl.keystore.password', 'xasecure.policymgr.clientssl.truststore.password']:
+      if prop in ranger_kms_policymgr_ssl_copy:
+        ranger_kms_policymgr_ssl_copy[prop] = "crypted"
+
     self.assertResourceCalled('XmlConfig', 'ranger-policymgr-ssl.xml',
       mode = 0744,
       owner = 'kms',
       group = 'kms',
       conf_dir = '/usr/hdp/current/ranger-kms/conf',
-      configurations = self.getConfig()['configurations']['ranger-kms-policymgr-ssl'],
+      configurations = ranger_kms_policymgr_ssl_copy,
       configuration_attributes = self.getConfig()['configuration_attributes']['ranger-kms-policymgr-ssl']
     )
 
@@ -349,12 +362,18 @@ class TestRangerKMS(RMFTestCase):
       mode = 0640
     )
 
+    dbks_site_copy = {}
+    dbks_site_copy.update(self.getConfig()['configurations']['dbks-site'])
+    for prop in ['ranger.db.encrypt.key.password', 'ranger.ks.jpa.jdbc.password', 'ranger.ks.hsm.partition.password']:
+      if prop in dbks_site_copy:
+        dbks_site_copy[prop] = "_"
+
     self.assertResourceCalled('XmlConfig', 'dbks-site.xml',
       mode=0644,
       owner = 'kms',
       group = 'kms',
       conf_dir = '/usr/hdp/current/ranger-kms/conf',
-      configurations = self.getConfig()['configurations']['dbks-site'],
+      configurations = dbks_site_copy,
       configuration_attributes = self.getConfig()['configuration_attributes']['dbks-site']
     )
 
@@ -442,12 +461,18 @@ class TestRangerKMS(RMFTestCase):
       mode = 0644
     )
 
+    plugin_audit_properties_copy = {}
+    plugin_audit_properties_copy.update(self.getConfig()['configurations']['ranger-kms-audit'])
+
+    if 'xasecure.audit.destination.db.password' in plugin_audit_properties_copy:
+      plugin_audit_properties_copy['xasecure.audit.destination.db.password'] = "crypted"
+
     self.assertResourceCalled('XmlConfig', 'ranger-kms-audit.xml',
       mode = 0744,
       owner = 'kms',
       group = 'kms',
       conf_dir = '/usr/hdp/current/ranger-kms/conf',
-      configurations = self.getConfig()['configurations']['ranger-kms-audit'],
+      configurations = plugin_audit_properties_copy,
       configuration_attributes = self.getConfig()['configuration_attributes']['ranger-kms-audit']
     )
 
@@ -460,12 +485,19 @@ class TestRangerKMS(RMFTestCase):
       configuration_attributes = self.getConfig()['configuration_attributes']['ranger-kms-security']
     )
 
+    ranger_kms_policymgr_ssl_copy = {}
+    ranger_kms_policymgr_ssl_copy.update(self.getConfig()['configurations']['ranger-kms-policymgr-ssl'])
+
+    for prop in ['xasecure.policymgr.clientssl.keystore.password', 'xasecure.policymgr.clientssl.truststore.password']:
+      if prop in ranger_kms_policymgr_ssl_copy:
+        ranger_kms_policymgr_ssl_copy[prop] = "crypted"
+
     self.assertResourceCalled('XmlConfig', 'ranger-policymgr-ssl.xml',
       mode = 0744,
       owner = 'kms',
       group = 'kms',
       conf_dir = '/usr/hdp/current/ranger-kms/conf',
-      configurations = self.getConfig()['configurations']['ranger-kms-policymgr-ssl'],
+      configurations = ranger_kms_policymgr_ssl_copy,
       configuration_attributes = self.getConfig()['configuration_attributes']['ranger-kms-policymgr-ssl']
     )
 
@@ -681,12 +713,18 @@ class TestRangerKMS(RMFTestCase):
       mode = 0640
     )
 
+    dbks_site_copy = {}
+    dbks_site_copy.update(self.getConfig()['configurations']['dbks-site'])
+    for prop in ['ranger.db.encrypt.key.password', 'ranger.ks.jpa.jdbc.password', 'ranger.ks.hsm.partition.password']:
+      if prop in dbks_site_copy:
+        dbks_site_copy[prop] = "_"
+
     self.assertResourceCalled('XmlConfig', 'dbks-site.xml',
       mode=0644,
       owner = 'kms',
       group = 'kms',
       conf_dir = '/usr/hdp/current/ranger-kms/conf',
-      configurations = self.getConfig()['configurations']['dbks-site'],
+      configurations = dbks_site_copy,
       configuration_attributes = self.getConfig()['configuration_attributes']['dbks-site']
     )
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/c395f694/ambari-server/src/test/python/stacks/2.6/RANGER/test_ranger_admin.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.6/RANGER/test_ranger_admin.py b/ambari-server/src/test/python/stacks/2.6/RANGER/test_ranger_admin.py
index fb1dd0e..ea3829e 100644
--- a/ambari-server/src/test/python/stacks/2.6/RANGER/test_ranger_admin.py
+++ b/ambari-server/src/test/python/stacks/2.6/RANGER/test_ranger_admin.py
@@ -336,11 +336,17 @@ class TestRangerAdmin(RMFTestCase):
       sudo = True
     )
 
+    ranger_admin_site_copy = {}
+    ranger_admin_site_copy.update(self.getConfig()['configurations']['ranger-admin-site'])
+    for prop in ['ranger.jpa.jdbc.password', 'ranger.jpa.audit.jdbc.password', 'ranger.ldap.bind.password', 'ranger.ldap.ad.bind.password', 'ranger.service.https.attrib.keystore.pass', 'ranger.truststore.password']:
+      if prop in ranger_admin_site_copy:
+        ranger_admin_site_copy[prop] = "_"
+
     self.assertResourceCalled('XmlConfig', 'ranger-admin-site.xml',
       owner = 'ranger',
       group = 'ranger',
       conf_dir = '/usr/hdp/current/ranger-admin/conf',
-      configurations = self.getConfig()['configurations']['ranger-admin-site'],
+      configurations = ranger_admin_site_copy,
       configuration_attributes = self.getConfig()['configuration_attributes']['ranger-admin-site'],
       mode = 0644
     )
@@ -370,6 +376,18 @@ class TestRangerAdmin(RMFTestCase):
       mode = 0640
     )
 
+    self.assertResourceCalled('Execute', ('/usr/jdk64/jdk1.7.0_45/bin/java', '-cp', '/usr/hdp/current/ranger-admin/cred/lib/*', 'org.apache.ranger.credentialapi.buildks', 'create', 'trustStoreAlias', '-value', 'changeit', '-provider', 'jceks://file/etc/ranger/admin/rangeradmin.jceks'),
+      environment = {'JAVA_HOME': u'/usr/jdk64/jdk1.7.0_45'},
+      logoutput=True,
+      sudo = True
+    )
+
+    self.assertResourceCalled('File', '/etc/ranger/admin/rangeradmin.jceks',
+      owner = 'ranger',
+      group = 'ranger',
+      mode = 0640
+    )
+
     self.assertResourceCalled('XmlConfig', 'core-site.xml',
       owner = 'ranger',
       group = 'ranger',
@@ -496,11 +514,17 @@ class TestRangerAdmin(RMFTestCase):
       sudo = True
     )
 
+    ranger_admin_site_copy = {}
+    ranger_admin_site_copy.update(self.getConfig()['configurations']['ranger-admin-site'])
+    for prop in ['ranger.jpa.jdbc.password', 'ranger.jpa.audit.jdbc.password', 'ranger.ldap.bind.password', 'ranger.ldap.ad.bind.password', 'ranger.service.https.attrib.keystore.pass', 'ranger.truststore.password']:
+      if prop in ranger_admin_site_copy:
+        ranger_admin_site_copy[prop] = "_"
+
     self.assertResourceCalled('XmlConfig', 'ranger-admin-site.xml',
       owner = 'ranger',
       group = 'ranger',
       conf_dir = '/usr/hdp/current/ranger-admin/conf',
-      configurations = self.getConfig()['configurations']['ranger-admin-site'],
+      configurations = ranger_admin_site_copy,
       configuration_attributes = self.getConfig()['configuration_attributes']['ranger-admin-site'],
       mode = 0644
     )
@@ -530,6 +554,18 @@ class TestRangerAdmin(RMFTestCase):
       mode = 0640
     )
 
+    self.assertResourceCalled('Execute', ('/usr/jdk64/jdk1.7.0_45/bin/java', '-cp', '/usr/hdp/current/ranger-admin/cred/lib/*', 'org.apache.ranger.credentialapi.buildks', 'create', 'trustStoreAlias', '-value', 'changeit', '-provider', 'jceks://file/etc/ranger/admin/rangeradmin.jceks'),
+      environment = {'JAVA_HOME': u'/usr/jdk64/jdk1.7.0_45'},
+      logoutput=True,
+      sudo = True
+    )
+
+    self.assertResourceCalled('File', '/etc/ranger/admin/rangeradmin.jceks',
+      owner = 'ranger',
+      group = 'ranger',
+      mode = 0640
+    )
+
     self.assertResourceCalled('XmlConfig', 'core-site.xml',
       owner = 'ranger',
       group = 'ranger',

http://git-wip-us.apache.org/repos/asf/ambari/blob/c395f694/ambari-server/src/test/python/stacks/2.6/RANGER/test_ranger_tagsync.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.6/RANGER/test_ranger_tagsync.py b/ambari-server/src/test/python/stacks/2.6/RANGER/test_ranger_tagsync.py
index bf5128e..0642428 100644
--- a/ambari-server/src/test/python/stacks/2.6/RANGER/test_ranger_tagsync.py
+++ b/ambari-server/src/test/python/stacks/2.6/RANGER/test_ranger_tagsync.py
@@ -143,11 +143,18 @@ class TestRangerTagsync(RMFTestCase):
       cd_access = 'a',
     )
 
+    ranger_tagsync_policymgr_ssl_copy = {}
+    ranger_tagsync_policymgr_ssl_copy.update(self.getConfig()['configurations']['ranger-tagsync-policymgr-ssl'])
+    ranger_tagsync_password_properties = ['xasecure.policymgr.clientssl.keystore.password', 'xasecure.policymgr.clientssl.truststore.password']
+    for prop in ranger_tagsync_password_properties:
+      if prop in ranger_tagsync_policymgr_ssl_copy:
+        ranger_tagsync_policymgr_ssl_copy[prop] = "_"
+
     self.assertResourceCalled('XmlConfig', 'ranger-policymgr-ssl.xml',
       owner = 'ranger',
       group = 'ranger',
       conf_dir = '/usr/hdp/current/ranger-tagsync/conf',
-      configurations = self.getConfig()['configurations']['ranger-tagsync-policymgr-ssl'],
+      configurations = ranger_tagsync_policymgr_ssl_copy,
       configuration_attributes = self.getConfig()['configuration_attributes']['ranger-tagsync-policymgr-ssl'],
       mode = 0644,
     )
@@ -188,17 +195,21 @@ class TestRangerTagsync(RMFTestCase):
       mode = 0640,
     )
 
+    atlas_tagsync_ssl_copy = {}
+    atlas_tagsync_ssl_copy.update(self.getConfig()['configurations']['atlas-tagsync-ssl'])
+    for prop in ranger_tagsync_password_properties:
+      if prop in atlas_tagsync_ssl_copy:
+        atlas_tagsync_ssl_copy[prop] = "_"
+
     self.assertResourceCalled('XmlConfig', 'atlas-tagsync-ssl.xml',
       group = 'ranger',
       conf_dir = '/usr/hdp/current/ranger-tagsync/conf',
       mode = 0644,
       configuration_attributes = UnknownConfigurationMock(),
       owner = 'ranger',
-      configurations = self.getConfig()['configurations']['atlas-tagsync-ssl']
+      configurations = atlas_tagsync_ssl_copy
     )
 
-
-
     self.assertResourceCalled('Execute', (u'/usr/jdk64/jdk1.7.0_45/bin/java',
       '-cp',
       u'/usr/hdp/current/ranger-tagsync/lib/*',

http://git-wip-us.apache.org/repos/asf/ambari/blob/c395f694/ambari-server/src/test/python/stacks/2.6/configs/ranger-admin-default.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.6/configs/ranger-admin-default.json b/ambari-server/src/test/python/stacks/2.6/configs/ranger-admin-default.json
index 2c4815b..abe84ab 100644
--- a/ambari-server/src/test/python/stacks/2.6/configs/ranger-admin-default.json
+++ b/ambari-server/src/test/python/stacks/2.6/configs/ranger-admin-default.json
@@ -326,7 +326,8 @@
             "ranger.service.http.port": "6080", 
             "ranger.ldap.user.searchfilter": "(uid={0})", 
             "ranger.plugins.atlas.serviceuser": "atlas", 
-            "ranger.truststore.password": "changeit", 
+            "ranger.truststore.password": "changeit",
+            "ranger.truststore.alias": "trustStoreAlias",
             "ranger.ldap.bind.password": "{{ranger_usersync_ldap_ldapbindpassword}}", 
             "ranger.audit.solr.password": "NONE", 
             "ranger.audit.solr.zookeepers": "c6401.ambari.apache.org:2181/infra-solr",
@@ -364,7 +365,8 @@
             "ranger.admin.kerberos.keytab": "", 
             "ranger.admin.kerberos.token.valid.seconds": "30", 
             "ranger.jpa.jdbc.driver": "com.mysql.jdbc.Driver", 
-            "ranger.unixauth.service.port": "5151"
+            "ranger.unixauth.service.port": "5151",
+            "ranger.service.https.attrib.keystore.credential.alias": "keyStoreCredentialAlias"
         }, 
         "ranger-hdfs-policymgr-ssl": {
             "xasecure.policymgr.clientssl.keystore": "/usr/hdp/current/hadoop-client/conf/ranger-plugin-keystore.jks", 


[08/15] ambari git commit: AMBARI-20044. NullPointerException after server restart in case not all hosts were joined (magyari_sandor)

Posted by jo...@apache.org.
AMBARI-20044. NullPointerException after server restart in case not all hosts were joined (magyari_sandor)


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

Branch: refs/heads/branch-feature-AMBARI-20053
Commit: bcf7289331765c6f67b99fd08a2674c90fa53589
Parents: c8c134e
Author: Sandor Magyari <sm...@hortonworks.com>
Authored: Thu Feb 16 16:22:59 2017 +0100
Committer: Sandor Magyari <sm...@hortonworks.com>
Committed: Fri Feb 17 17:35:42 2017 +0100

----------------------------------------------------------------------
 .../main/java/org/apache/ambari/server/topology/HostRequest.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/bcf72893/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
index a18999b..a6f677a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
@@ -313,7 +313,7 @@ public class HostRequest implements Comparable<HostRequest> {
     for (HostRoleCommand logicalTask : logicalTasks.values()) {
       // set host on command detail if it is set to null
       String commandDetail = logicalTask.getCommandDetail();
-      if (commandDetail != null && commandDetail.contains("null")) {
+      if (commandDetail != null && commandDetail.contains("null") && hostname != null) {
         logicalTask.setCommandDetail(commandDetail.replace("null", hostname));
       }
       Long physicalTaskId = physicalTasks.get(logicalTask.getTaskId());