ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [37/50] [abbrv] ambari git commit: AMBARI-18863 - Upgrade Type Is Incorrectly Quoted When Serialized (jonathanhurley)
Date Mon, 14 Nov 2016 18:27:50 GMT
AMBARI-18863 - Upgrade Type Is Incorrectly Quoted When Serialized (jonathanhurley)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: e569e9722a89d3205a03c43efedbc6cfb7fecde7
Parents: 1807a4a
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Fri Nov 11 10:29:43 2016 -0500
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Fri Nov 11 13:27:03 2016 -0500

----------------------------------------------------------------------
 .../server/controller/internal/UpgradeResourceProvider.java  | 8 ++++++--
 .../controller/internal/UpgradeResourceProviderTest.java     | 7 +++++--
 2 files changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e569e972/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
index 1713b64..1806c64 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
@@ -126,6 +126,7 @@ import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 import com.google.gson.Gson;
 import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
@@ -1402,8 +1403,11 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
 
     Map<String, String> commandParams = getNewParameterMap(request);
     if (null != context.getType()) {
-      // use the serialized attributes of the enum to convert it to a string
-      commandParams.put(COMMAND_PARAM_UPGRADE_TYPE, s_gson.toJson(context.getType()));
+      // use the serialized attributes of the enum to convert it to a string,
+      // but first we must convert it into an element so that we don't get a
+      // quoted string - using toString() actually returns a quoted stirng which is bad
+      JsonElement json = s_gson.toJsonTree(context.getType());
+      commandParams.put(COMMAND_PARAM_UPGRADE_TYPE, json.getAsString());
     }
 
     commandParams.put(COMMAND_PARAM_VERSION, context.getVersion());

http://git-wip-us.apache.org/repos/asf/ambari/blob/e569e972/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 17e4f2d..14e3d08 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
@@ -1246,10 +1246,13 @@ public class UpgradeResourceProviderTest {
     List<StageEntity> stageEntities = stageDAO.findByRequestId(entity.getRequestId());
     Gson gson = new Gson();
     for (StageEntity se : stageEntities) {
-      Map<String, String> map = gson.<Map<String, String>> fromJson(se.getCommandParamsStage(),
-          Map.class);
+      Map<String, String> map = gson.<Map<String, String>> fromJson(se.getCommandParamsStage(),Map.class);
       assertTrue(map.containsKey("upgrade_direction"));
       assertEquals("upgrade", map.get("upgrade_direction"));
+      
+      if(map.containsKey("upgrade_type")){
+        assertEquals("rolling_upgrade", map.get("upgrade_type"));
+      }
     }
 
     List<UpgradeGroupEntity> upgradeGroups = entity.getUpgradeGroups();


Mime
View raw message