Repository: ambari
Updated Branches:
  refs/heads/trunk 6a906e630 -> 0b02517ad


AMBARI-16128. Ambari 2.2.1.1 reporting ACID off on slider, but actually 
on.(vbrodetskyi)


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

Branch: refs/heads/trunk
Commit: 0b02517ad0b44a4b90d2fd856fd86dd61634f4d8
Parents: 6a906e6
Author: Vitaly Brodetskyi <[email protected]>
Authored: Wed Apr 27 10:19:31 2016 +0300
Committer: Vitaly Brodetskyi <[email protected]>
Committed: Wed Apr 27 10:19:31 2016 +0300

----------------------------------------------------------------------
 .../server/upgrade/UpgradeCatalog240.java       | 39 ++++++++++++++++++++
 .../server/upgrade/UpgradeCatalog240Test.java   |  3 ++
 2 files changed, 42 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0b02517a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
index 14cb42c..eb8700e 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
@@ -219,6 +219,7 @@ public class UpgradeCatalog240 extends 
AbstractUpgradeCatalog {
     addSettingPermission();
     addManageUserPersistedDataPermission();
     updateHDFSConfigs();
+    updateHIVEConfigs();
     updateAMSConfigs();
     updateClusterEnv();
     updateHostRoleCommandTableDML();
@@ -1321,6 +1322,44 @@ public class UpgradeCatalog240 extends 
AbstractUpgradeCatalog {
     }
   }
 
+
+  protected void updateHIVEConfigs() throws AmbariException {
+    AmbariManagementController ambariManagementController = 
injector.getInstance(AmbariManagementController.class);
+    Clusters clusters = ambariManagementController.getClusters();
+
+    if (clusters != null) {
+      Map<String, Cluster> clusterMap = clusters.getClusters();
+
+      if (clusterMap != null && !clusterMap.isEmpty()) {
+        for (final Cluster cluster : clusterMap.values()) {
+          Set<String> installedServices = cluster.getServices().keySet();
+
+          if (installedServices.contains("HIVE")) {
+            Config hiveSite = cluster.getDesiredConfigByType("hive-site");
+            if (hiveSite != null) {
+              Map<String, String> hiveSiteProperties = 
hiveSite.getProperties();
+              String txn_manager = hiveSiteProperties.get("hive.txn.manager");
+              String concurrency = 
hiveSiteProperties.get("hive.support.concurrency");
+              String initiator_on = 
hiveSiteProperties.get("hive.compactor.initiator.on");
+              String partition_mode = 
hiveSiteProperties.get("hive.exec.dynamic.partition.mode");
+              boolean acid_enabled =
+                  txn_manager != null && 
txn_manager.equals("org.apache.hadoop.hive.ql.lockmgr.DbTxnManager") &&
+                  concurrency != null && 
concurrency.toLowerCase().equals("true") &&
+                  initiator_on != null && 
initiator_on.toLowerCase().equals("true") &&
+                  partition_mode != null && partition_mode.equals("nonstrict");
+
+              Config hiveEnv = cluster.getDesiredConfigByType("hive-env");
+              if(hiveEnv != null){
+                if(acid_enabled)
+                  updateConfigurationProperties("hive-env", 
Collections.singletonMap("hive_txn_acid", "on"), true, false);
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+
   protected void updateAMSConfigs() throws AmbariException {
     AmbariManagementController ambariManagementController = 
injector.getInstance(AmbariManagementController.class);
     Clusters clusters = ambariManagementController.getClusters();

http://git-wip-us.apache.org/repos/asf/ambari/blob/0b02517a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
index cdecc4d..542c324 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
@@ -375,6 +375,7 @@ public class UpgradeCatalog240Test {
     Method addManageUserPersistedDataPermission = 
UpgradeCatalog240.class.getDeclaredMethod("addManageUserPersistedDataPermission");
     Method addSettingPermission = 
UpgradeCatalog240.class.getDeclaredMethod("addSettingPermission");
     Method updateHDFSConfigs = 
UpgradeCatalog240.class.getDeclaredMethod("updateHDFSConfigs");
+    Method updateHIVEConfigs = 
UpgradeCatalog240.class.getDeclaredMethod("updateHIVEConfigs");
     Method updateAmsConfigs = 
UpgradeCatalog240.class.getDeclaredMethod("updateAMSConfigs");
     Method updateClusterEnv = 
UpgradeCatalog240.class.getDeclaredMethod("updateClusterEnv");
     Method updateHostRoleCommandTableDML = 
UpgradeCatalog240.class.getDeclaredMethod("updateHostRoleCommandTableDML");
@@ -395,6 +396,7 @@ public class UpgradeCatalog240Test {
             .addMockedMethod(addSettingPermission)
             .addMockedMethod(addManageUserPersistedDataPermission)
             .addMockedMethod(updateHDFSConfigs)
+            .addMockedMethod(updateHIVEConfigs)
             .addMockedMethod(updateAmsConfigs)
             .addMockedMethod(updateClusterEnv)
             .addMockedMethod(updateHostRoleCommandTableDML)
@@ -413,6 +415,7 @@ public class UpgradeCatalog240Test {
     upgradeCatalog240.addSettingPermission();
     upgradeCatalog240.addManageUserPersistedDataPermission();
     upgradeCatalog240.updateHDFSConfigs();
+    upgradeCatalog240.updateHIVEConfigs();
     upgradeCatalog240.updateAMSConfigs();
     upgradeCatalog240.updateClusterEnv();
     upgradeCatalog240.updateHostRoleCommandTableDML();

Reply via email to