ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlun...@apache.org
Subject ambari git commit: AMBARI-13872: Rolling Upgrade: Configuration Groups not applied for upgrades across stack versions (jluniya)
Date Mon, 16 Nov 2015 23:24:06 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 14746eb87 -> 4b12f0106


AMBARI-13872: Rolling Upgrade: Configuration Groups not applied for upgrades across stack
versions (jluniya)


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

Branch: refs/heads/branch-2.1
Commit: 4b12f0106b58e9f9184cc4f69537d44fae420ad6
Parents: 14746eb
Author: Jayush Luniya <jluniya@hortonworks.com>
Authored: Mon Nov 16 15:23:09 2015 -0800
Committer: Jayush Luniya <jluniya@hortonworks.com>
Committed: Mon Nov 16 15:24:02 2015 -0800

----------------------------------------------------------------------
 .../actionmanager/ExecutionCommandWrapper.java  | 18 ++++-----
 .../UpgradeResourceProviderHDP22Test.java       | 39 ++++++++++++++++----
 2 files changed, 41 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4b12f010/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java
b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java
index 40038eb..99d61af 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java
@@ -25,6 +25,8 @@ import java.util.TreeMap;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.agent.ExecutionCommand;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.AmbariServer;
 import org.apache.ambari.server.orm.dao.HostRoleCommandDAO;
 import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
@@ -86,7 +88,9 @@ public class ExecutionCommandWrapper {
           // tags to be refreshed to the latest cluster desired-configs.
           Set<String> refreshConfigTagsBeforeExecution = executionCommand.getForceRefreshConfigTagsBeforeExecution();
           if (refreshConfigTagsBeforeExecution != null && !refreshConfigTagsBeforeExecution.isEmpty())
{
-            Map<String, DesiredConfig> desiredConfigs = cluster.getDesiredConfigs();
+            AmbariManagementController managementController = AmbariServer.getController();
+            Map<String, Map<String, String>> configTags = managementController.findConfigurationTagsWithOverrides(
+                cluster, executionCommand.getHostname());
             for (String refreshConfigTag : refreshConfigTagsBeforeExecution) {
               if ("*".equals(refreshConfigTag)) {
                 // if forcing a refresh of *, then clear out any existing
@@ -94,15 +98,11 @@ public class ExecutionCommandWrapper {
                 // forcefully applied
                 LOG.debug("ExecutionCommandWrapper.getExecutionCommand: refreshConfigTag
set to {}, so clearing config for full refresh.", refreshConfigTag);
                 executionCommand.getConfigurations().clear();
-
-                for (final Entry<String, DesiredConfig> desiredConfig : desiredConfigs.entrySet())
{
-                  configurationTags.put(desiredConfig.getKey(), new HashMap<String, String>()
{{
-                    put("tag", desiredConfig.getValue().getTag());
-                  }});
-                }
+                configurationTags = configTags;
+                executionCommand.setConfigurationTags(configTags);
                 break;
-              } else if (configurationTags.containsKey(refreshConfigTag) && desiredConfigs.containsKey(refreshConfigTag))
{
-                configurationTags.get(refreshConfigTag).put("tag", desiredConfigs.get(refreshConfigTag).getTag());
+              } else if (configurationTags.containsKey(refreshConfigTag) && configTags.containsKey(refreshConfigTag))
{
+                configurationTags.put(refreshConfigTag, configTags.get(refreshConfigTag));
               }
             }
           }

http://git-wip-us.apache.org/repos/asf/ambari/blob/4b12f010/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderHDP22Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderHDP22Test.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderHDP22Test.java
index c6fd6f7..a8fa393 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderHDP22Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderHDP22Test.java
@@ -114,6 +114,12 @@ public class UpgradeResourceProviderHDP22Test {
     }
   };
 
+  private static final Map<String, String> configTagVersion2Properties = new HashMap<String,
String>() {
+    {
+      put("hive.server2.thrift.port", "10010");
+    }
+  };
+
   @SuppressWarnings({ "serial", "unchecked" })
   @Before
   public void before() throws Exception {
@@ -138,14 +144,31 @@ public class UpgradeResourceProviderHDP22Test {
           }
         });
       }
-    }).anyTimes();
+    }).times(3);
+
+    expect(configHelper.getEffectiveDesiredTags(EasyMock.anyObject(Cluster.class), EasyMock.eq("h1"))).andReturn(new
HashMap<String, Map<String, String>>() {
+      {
+        put("hive-site", new HashMap<String, String>() {
+          {
+            put("tag", configTagVersion2);
+          }
+        });
+      }
+    }).times(2);
 
     expect(configHelper.getEffectiveConfigProperties(EasyMock.anyObject(Cluster.class), EasyMock.anyObject(Map.class))).andReturn(
         new HashMap<String, Map<String, String>>() {
           {
             put("hive-site", configTagVersion1Properties);
           }
-        }).anyTimes();
+        }).times(1);
+
+    expect(configHelper.getEffectiveConfigProperties(EasyMock.anyObject(Cluster.class), EasyMock.anyObject(Map.class))).andReturn(
+        new HashMap<String, Map<String, String>>() {
+          {
+            put("hive-site", configTagVersion2Properties);
+          }
+        }).times(2);
 
     expect(configHelper.getMergedConfig(EasyMock.anyObject(Map.class),
         EasyMock.anyObject(Map.class))).andReturn(new HashMap<String, String>()).anyTimes();
@@ -233,6 +256,10 @@ public class UpgradeResourceProviderHDP22Test {
     injector = null;
   }
 
+  private void setupConfigHelper() {
+
+  }
+
   /**
    * Tests upgrades from HDP-2.2.x to HDP-2.2.y
    *
@@ -314,11 +341,7 @@ public class UpgradeResourceProviderHDP22Test {
     // Change the new desired config tag and verify execution command picks up new tag
     assertEquals(configTagVersion1, cluster.getDesiredConfigByType("hive-site").getTag());
     final Config newConfig = new ConfigImpl("hive-site");
-    newConfig.setProperties(new HashMap<String, String>() {
-      {
-        put("hive.server2.thrift.port", "10010");
-      }
-    });
+    newConfig.setProperties(configTagVersion2Properties);
     newConfig.setTag(configTagVersion2);
     Set<Config> desiredConfigs = new HashSet<Config>() {
       {
@@ -358,6 +381,8 @@ public class UpgradeResourceProviderHDP22Test {
         ExecutionCommand executionCommand = executionCommandWrapper.getExecutionCommand();
         Map<String, Map<String, String>> configurationTags = executionCommand.getConfigurationTags();
         assertEquals(configTagVersion2, configurationTags.get("hive-site").get("tag"));
+        Map<String, Map<String, String>> configurations = executionCommand.getConfigurations();
+        assertEquals("10010", configurations.get("hive-site").get("hive.server2.thrift.port"));
       }
     }
   }


Mime
View raw message