You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by vb...@apache.org on 2015/09/21 12:26:30 UTC
ambari git commit: AMBARI-13165. Oozie service have "Database host"
required config after ambari upgrade from 1.7.0 to 2.1.2.(vbrodetskyi)
Repository: ambari
Updated Branches:
refs/heads/branch-2.1 2b31859c1 -> db89de8f2
AMBARI-13165. Oozie service have "Database host" required config after ambari upgrade from 1.7.0 to 2.1.2.(vbrodetskyi)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/db89de8f
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/db89de8f
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/db89de8f
Branch: refs/heads/branch-2.1
Commit: db89de8f213a0af84e61cdfe1583932e35de01b6
Parents: 2b31859
Author: Vitaly Brodetskyi <vb...@hortonworks.com>
Authored: Mon Sep 21 13:26:06 2015 +0300
Committer: Vitaly Brodetskyi <vb...@hortonworks.com>
Committed: Mon Sep 21 13:26:06 2015 +0300
----------------------------------------------------------------------
.../server/upgrade/AbstractUpgradeCatalog.java | 13 ++++++
.../server/upgrade/UpgradeCatalog212.java | 46 ++++++++++++++++++++
.../server/upgrade/UpgradeCatalog212Test.java | 42 +++++++++++++++++-
3 files changed, 100 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/db89de8f/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java
index f4023b2..62cd868 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/AbstractUpgradeCatalog.java
@@ -469,6 +469,19 @@ public abstract class AbstractUpgradeCatalog implements UpgradeCatalog {
}
/**
+ * Remove properties from the cluster
+ * @param cluster cluster object
+ * @param configType config to be updated
+ * @param removePropertiesList properties to be removed. Could be <code>null</code>
+ * @throws AmbariException
+ */
+ protected void removeConfigurationPropertiesFromCluster(Cluster cluster, String configType, Set<String> removePropertiesList)
+ throws AmbariException {
+
+ updateConfigurationPropertiesForCluster(cluster, configType, new HashMap<String, String>(), removePropertiesList, false, true);
+ }
+
+ /**
* Create a new cluster scoped configuration with the new properties added
* to the existing set of properties.
* @param configType Configuration type. (hdfs-site, etc.)
http://git-wip-us.apache.org/repos/asf/ambari/blob/db89de8f/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog212.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog212.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog212.java
index b97a7f4..610ab14 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog212.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog212.java
@@ -54,6 +54,7 @@ public class UpgradeCatalog212 extends AbstractUpgradeCatalog {
private static final String HBASE_ENV = "hbase-env";
private static final String HBASE_SITE = "hbase-site";
private static final String CLUSTER_ENV = "cluster-env";
+ private static final String OOZIE_ENV = "oozie-env";
private static final String TOPOLOGY_REQUEST_TABLE = "topology_request";
private static final String CLUSTERS_TABLE = "clusters";
@@ -193,6 +194,7 @@ public class UpgradeCatalog212 extends AbstractUpgradeCatalog {
protected void addMissingConfigs() throws AmbariException {
updateHiveConfigs();
+ updateOozieConfigs();
updateHbaseAndClusterConfigurations();
}
@@ -279,6 +281,50 @@ public class UpgradeCatalog212 extends AbstractUpgradeCatalog {
}
}
+ protected void updateOozieConfigs() 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()) {
+ Config oozieEnv = cluster.getDesiredConfigByType(OOZIE_ENV);
+ if (oozieEnv != null) {
+ Map<String, String> oozieEnvProperties = oozieEnv.getProperties();
+
+ String hostname = oozieEnvProperties.get("oozie_hostname");
+ String db_type = oozieEnvProperties.get("oozie_ambari_database");
+ String final_db_host = null;
+ // fix for empty hostname after 1.7 -> 2.1.x+ upgrade
+ if (hostname != null && db_type != null && hostname.equals("")) {
+ switch (db_type.toUpperCase()) {
+ case "MYSQL":
+ final_db_host = oozieEnvProperties.get("oozie_existing_mysql_host");
+ break;
+ case "POSTGRESQL":
+ final_db_host = oozieEnvProperties.get("oozie_existing_postgresql_host");
+ break;
+ case "ORACLE":
+ final_db_host = oozieEnvProperties.get("oozie_existing_oracle_host");
+ break;
+ default:
+ final_db_host = null;
+ break;
+ }
+ if (final_db_host != null) {
+ Map<String, String> newProperties = new HashMap<>();
+ newProperties.put("oozie_hostname", final_db_host);
+ updateConfigurationPropertiesForCluster(cluster, OOZIE_ENV, newProperties, true, true);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
protected String updateHiveEnvContent(String hiveEnvContent) {
if(hiveEnvContent == null) {
return null;
http://git-wip-us.apache.org/repos/asf/ambari/blob/db89de8f/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog212Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog212Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog212Test.java
index 5a947e3..f786052 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog212Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog212Test.java
@@ -132,7 +132,7 @@ public class UpgradeCatalog212Test {
dbAccessor.dropColumn(eq("topology_request"), eq("cluster_name"));
dbAccessor.setColumnNullable(eq("topology_request"), eq("cluster_id"), eq(false));
dbAccessor.addFKConstraint(eq("topology_request"), eq("FK_topology_request_cluster_id"), eq("cluster_id"),
- eq("clusters"), eq("cluster_id"), eq(false));
+ eq("clusters"), eq("cluster_id"), eq(false));
replay(dbAccessor);
Module module = new Module() {
@@ -324,6 +324,46 @@ public class UpgradeCatalog212Test {
}
@Test
+ public void testUpdateOozieConfigs() throws Exception {
+ EasyMockSupport easyMockSupport = new EasyMockSupport();
+ final AmbariManagementController mockAmbariManagementController = easyMockSupport.createNiceMock(AmbariManagementController.class);
+ final ConfigHelper mockConfigHelper = easyMockSupport.createMock(ConfigHelper.class);
+
+ final Clusters mockClusters = easyMockSupport.createStrictMock(Clusters.class);
+ final Cluster mockClusterExpected = easyMockSupport.createNiceMock(Cluster.class);
+ final Config mockOozieEnv = easyMockSupport.createNiceMock(Config.class);
+
+ final Map<String, String> propertiesExpectedOozieEnv = new HashMap<String, String>() {{
+ put("oozie_hostname", "");
+ put("oozie_ambari_database", "123");
+ }};
+
+ final Injector mockInjector = Guice.createInjector(new AbstractModule() {
+ @Override
+ protected void configure() {
+ bind(AmbariManagementController.class).toInstance(mockAmbariManagementController);
+ bind(ConfigHelper.class).toInstance(mockConfigHelper);
+ bind(Clusters.class).toInstance(mockClusters);
+
+ bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
+ bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
+ }
+ });
+
+ expect(mockAmbariManagementController.getClusters()).andReturn(mockClusters).once();
+ expect(mockClusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
+ put("normal", mockClusterExpected);
+ }}).once();
+
+ expect(mockClusterExpected.getDesiredConfigByType("oozie-env")).andReturn(mockOozieEnv).atLeastOnce();
+ expect(mockOozieEnv.getProperties()).andReturn(propertiesExpectedOozieEnv).atLeastOnce();
+
+ easyMockSupport.replayAll();
+ mockInjector.getInstance(UpgradeCatalog212.class).updateOozieConfigs();
+ easyMockSupport.verifyAll();
+ }
+
+ @Test
public void testUpdateHiveEnvContent() throws Exception {
final Injector mockInjector = Guice.createInjector(new AbstractModule() {
@Override