ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject ambari git commit: AMBARI-17282. Use customized display name as version string (ncole)
Date Thu, 16 Jun 2016 21:00:13 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 e51397373 -> 178df050a


AMBARI-17282. Use customized display name as version string (ncole)


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

Branch: refs/heads/branch-2.4
Commit: 178df050aa76e8cd08ea19d3a1b2a572c67c91c9
Parents: e513973
Author: Nate Cole <ncole@hortonworks.com>
Authored: Thu Jun 16 16:59:46 2016 -0400
Committer: Nate Cole <ncole@hortonworks.com>
Committed: Thu Jun 16 16:59:46 2016 -0400

----------------------------------------------------------------------
 .../VersionDefinitionResourceProvider.java       | 19 +++++++++++++++++++
 .../VersionDefinitionResourceProviderTest.java   |  4 ++--
 2 files changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/178df050/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
index 4a061c5..02fc2ec 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProvider.java
@@ -103,6 +103,10 @@ public class VersionDefinitionResourceProvider extends AbstractAuthorizedResourc
   protected static final String VERSION_DEF_VALIDATION               = "VersionDefinition/validation";
   protected static final String SHOW_AVAILABLE                       = "VersionDefinition/show_available";
 
+  // !!! for convenience, bring over jdk compatibility information from the stack
+  protected static final String VERSION_DEF_MIN_JDK                  = "VersionDefinition/min_jdk";
+  protected static final String VERSION_DEF_MAX_JDK                  = "VersionDefinition/max_jdk";
+
   public static final String DIRECTIVE_SKIP_URL_CHECK = "skip_url_check";
 
   public static final String SUBRESOURCE_OPERATING_SYSTEMS_PROPERTY_ID  = new OperatingSystemResourceDefinition().getPluralName();
@@ -152,6 +156,8 @@ public class VersionDefinitionResourceProvider extends AbstractAuthorizedResourc
       VERSION_DEF_STACK_DEFAULT,
       VERSION_DEF_DISPLAY_NAME,
       VERSION_DEF_VALIDATION,
+      VERSION_DEF_MIN_JDK,
+      VERSION_DEF_MAX_JDK,
       SUBRESOURCE_OPERATING_SYSTEMS_PROPERTY_ID,
       SHOW_AVAILABLE);
 
@@ -262,6 +268,10 @@ public class VersionDefinitionResourceProvider extends AbstractAuthorizedResourc
     if (StringUtils.isNotBlank(ObjectUtils.toString(properties.get(VERSION_DEF_DISPLAY_NAME))))
{
       xmlHolder.xml.release.display = properties.get(VERSION_DEF_DISPLAY_NAME).toString();
       xmlHolder.entity.setDisplayName(properties.get(VERSION_DEF_DISPLAY_NAME).toString());
+      // !!! also set the version string to the name for uniqueness reasons.  this is
+      // getting replaced during install packages anyway.  this is just for the entity, the
+      // VDF should stay the same.
+      xmlHolder.entity.setVersion(properties.get(VERSION_DEF_DISPLAY_NAME).toString());
     }
 
     if (s_repoVersionDAO.findByDisplayName(xmlHolder.entity.getDisplayName()) != null) {
@@ -302,6 +312,8 @@ public class VersionDefinitionResourceProvider extends AbstractAuthorizedResourc
         VERSION_DEF_DISPLAY_NAME,
         VERSION_DEF_AVAILABLE_SERVICES,
         VERSION_DEF_VALIDATION,
+        VERSION_DEF_MIN_JDK,
+        VERSION_DEF_MAX_JDK,
         VERSION_DEF_STACK_SERVICES);
 
       res = toResource(null, xmlHolder.xml, ids, validations);
@@ -310,6 +322,9 @@ public class VersionDefinitionResourceProvider extends AbstractAuthorizedResourc
         res.setProperty(SHOW_AVAILABLE, true);
       }
 
+      // !!! for dry run, make sure the version is the entity display
+      setResourceProperty(res, VERSION_DEF_FULL_VERSION, xmlHolder.entity.getVersion(), ids);
+
       addSubresources(res, xmlHolder.entity);
     } else {
 
@@ -599,6 +614,8 @@ public class VersionDefinitionResourceProvider extends AbstractAuthorizedResourc
 
     setResourceProperty(resource, VERSION_DEF_AVAILABLE_SERVICES, xml.getAvailableServices(stack),
requestedIds);
     setResourceProperty(resource, VERSION_DEF_STACK_SERVICES, xml.getStackServices(stack),
requestedIds);
+    setResourceProperty(resource, VERSION_DEF_MIN_JDK, stack.getMinJdk(), requestedIds);
+    setResourceProperty(resource, VERSION_DEF_MAX_JDK, stack.getMaxJdk(), requestedIds);
 
     return resource;
   }
@@ -656,6 +673,8 @@ public class VersionDefinitionResourceProvider extends AbstractAuthorizedResourc
     if (null != stack) {
       setResourceProperty(resource, VERSION_DEF_AVAILABLE_SERVICES, xml.getAvailableServices(stack),
requestedIds);
       setResourceProperty(resource, VERSION_DEF_STACK_SERVICES, xml.getStackServices(stack),
requestedIds);
+      setResourceProperty(resource, VERSION_DEF_MIN_JDK, stack.getMinJdk(), requestedIds);
+      setResourceProperty(resource, VERSION_DEF_MAX_JDK, stack.getMaxJdk(), requestedIds);
     }
 
     return resource;

http://git-wip-us.apache.org/repos/asf/ambari/blob/178df050/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProviderTest.java
index 6b66f12..026fb33 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/VersionDefinitionResourceProviderTest.java
@@ -538,12 +538,12 @@ public class VersionDefinitionResourceProviderTest {
 
     res = status.getAssociatedResources().iterator().next();
     Assert.assertTrue(res.getPropertiesMap().containsKey("VersionDefinition"));
-    Assert.assertEquals("2.2.1.0", res.getPropertyValue("VersionDefinition/repository_version"));
+    Assert.assertEquals("HDP-2.2.0.4-a", res.getPropertyValue("VersionDefinition/repository_version"));
     Assert.assertEquals("HDP-2.2.0.4-a", res.getPropertyValue("VersionDefinition/display_name"));
     Assert.assertNotNull(res.getPropertyValue("VersionDefinition/show_available"));
     Assert.assertNotNull(res.getPropertyValue("VersionDefinition/validation"));
 
     validation = (Set<String>) res.getPropertyValue("VersionDefinition/validation");
-    Assert.assertEquals(2, validation.size());
+    Assert.assertEquals(1, validation.size());
   }
 }


Mime
View raw message