ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject git commit: AMBARI-6891 Ambari upgrade: Accomodate renaming pig-content to content in 1.7.0 ugradeCatalog (dsen)
Date Mon, 18 Aug 2014 16:08:10 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 1730dc5b8 -> f0be435e0


AMBARI-6891 Ambari upgrade: Accomodate renaming pig-content to content in 1.7.0 ugradeCatalog
(dsen)


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

Branch: refs/heads/trunk
Commit: f0be435e07349e53fb2b9ecf33952efd25d0c90d
Parents: 1730dc5
Author: Dmytro Sen <dsen@hortonworks.com>
Authored: Mon Aug 18 19:08:04 2014 +0300
Committer: Dmytro Sen <dsen@hortonworks.com>
Committed: Mon Aug 18 19:08:04 2014 +0300

----------------------------------------------------------------------
 .../server/upgrade/UpgradeCatalog170.java       | 33 ++++++++++++++++++++
 .../server/upgrade/UpgradeCatalog170Test.java   |  9 +++++-
 2 files changed, 41 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f0be435e/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
index 9888177..33a87a7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog170.java
@@ -83,8 +83,11 @@ import com.google.inject.Injector;
  */
 public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
   private static final String CONTENT_FIELD_NAME = "content";
+  private static final String PIG_CONTENT_FIELD_NAME = "pig-content";
   private static final String ENV_CONFIGS_POSTFIX = "-env";
 
+  private static final String PIG_PROPERTIES_CONFIG_TYPE = "pig-properties";
+
   private static final String ALERT_TABLE_DEFINITION = "alert_definition";
   private static final String ALERT_TABLE_HISTORY = "alert_history";
   private static final String ALERT_TABLE_CURRENT = "alert_current";
@@ -560,6 +563,7 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
     moveGlobalsToEnv();
     addEnvContentFields();
     addMissingConfigs();
+    renamePigProperties();
     upgradePermissionModel();
   }
 
@@ -744,6 +748,35 @@ public class UpgradeCatalog170 extends AbstractUpgradeCatalog {
         false);
   }
 
+  /**
+   * Rename pig-content to content in pig-properties config
+   * @throws AmbariException
+   */
+  protected void renamePigProperties() throws AmbariException {
+    ConfigHelper configHelper = injector.getInstance(ConfigHelper.class);
+    AmbariManagementController ambariManagementController = injector.getInstance(
+      AmbariManagementController.class);
+
+    Clusters clusters = ambariManagementController.getClusters();
+    if (clusters == null) {
+      return;
+    }
+
+    Map<String, Cluster> clusterMap = clusters.getClusters();
+
+    if (clusterMap != null && !clusterMap.isEmpty()) {
+      for (final Cluster cluster : clusterMap.values()) {
+        Config oldConfig = cluster.getDesiredConfigByType(PIG_PROPERTIES_CONFIG_TYPE);
+        if (oldConfig != null) {
+          Map<String, String> properties = oldConfig.getProperties();
+          String value = properties.remove(PIG_CONTENT_FIELD_NAME);
+          properties.put(CONTENT_FIELD_NAME, value);
+          configHelper.createConfigType(cluster, ambariManagementController, PIG_PROPERTIES_CONFIG_TYPE,
properties, "ambari-upgrade");
+        }
+      }
+    }
+  }
+
   protected void addEnvContentFields() throws AmbariException {
     ConfigHelper configHelper = injector.getInstance(ConfigHelper.class);
     AmbariManagementController ambariManagementController = injector.getInstance(

http://git-wip-us.apache.org/repos/asf/ambari/blob/f0be435e/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
index 9325e9f..4033f03 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog170Test.java
@@ -219,6 +219,7 @@ public class UpgradeCatalog170Test {
     Cluster cluster = createStrictMock(Cluster.class);
     Clusters clusters = createStrictMock(Clusters.class);
     Config config = createStrictMock(Config.class);
+    Config pigConfig = createStrictMock(Config.class);
 
     UserDAO userDAO = createNiceMock(UserDAO.class);
     PrincipalDAO principalDAO = createNiceMock(PrincipalDAO.class);
@@ -256,6 +257,9 @@ public class UpgradeCatalog170Test {
     globalConfigs.put("prop1", "val1");
     globalConfigs.put("smokeuser_keytab", "val2");
 
+    Map<String, String> pigSettings = new HashMap<String, String>();
+    pigSettings.put("pig-content", "foo");
+
     Set<String> envDicts = new HashSet<String>();
     envDicts.add("hadoop-env");
     envDicts.add("global");
@@ -331,8 +335,11 @@ public class UpgradeCatalog170Test {
     expect(permissionDAO.findClusterOperatePermission()).andReturn(null);
     expect(permissionDAO.findClusterReadPermission()).andReturn(null);
 
+    expect(cluster.getDesiredConfigByType("pig-properties")).andReturn(pigConfig).anyTimes();
+    expect(pigConfig.getProperties()).andReturn(pigSettings).anyTimes();
+
     replay(entityManager, trans, upgradeCatalog, cb, cq, hrc, q);
-    replay(dbAccessor, configuration, injector, cluster, clusters, amc, config, configHelper);
+    replay(dbAccessor, configuration, injector, cluster, clusters, amc, config, configHelper,
pigConfig);
     replay(userDAO, clusterDAO, viewDAO, viewInstanceDAO, permissionDAO);
 
     Class<?> c = AbstractUpgradeCatalog.class;


Mime
View raw message