You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jl...@apache.org on 2015/08/26 17:48:53 UTC

ambari git commit: AMBARI-12811: Disable old APIs to manage baseurl values (Nahappan Somasundaram via jluniya)

Repository: ambari
Updated Branches:
  refs/heads/trunk 7819edfd1 -> bbb042f32


AMBARI-12811: Disable old APIs to manage baseurl values (Nahappan Somasundaram via jluniya)


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

Branch: refs/heads/trunk
Commit: bbb042f32d5b7bb3937d6426f16243fd27effb45
Parents: 7819edf
Author: Jayush Luniya <jl...@hortonworks.com>
Authored: Wed Aug 26 08:48:49 2015 -0700
Committer: Jayush Luniya <jl...@hortonworks.com>
Committed: Wed Aug 26 08:48:49 2015 -0700

----------------------------------------------------------------------
 ambari-server/conf/unix/ambari.properties       |  3 ++
 .../server/configuration/Configuration.java     |  9 +++++
 .../AmbariManagementControllerImpl.java         | 23 +++++++++--
 .../AmbariManagementControllerTest.java         | 42 ++++++++++++++++++++
 4 files changed, 73 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/bbb042f3/ambari-server/conf/unix/ambari.properties
----------------------------------------------------------------------
diff --git a/ambari-server/conf/unix/ambari.properties b/ambari-server/conf/unix/ambari.properties
index 75e0fe1..43faa2f 100644
--- a/ambari-server/conf/unix/ambari.properties
+++ b/ambari-server/conf/unix/ambari.properties
@@ -92,3 +92,6 @@ skip.service.checks=false
 
 rolling.upgrade.min.stack=HDP-2.2
 rolling.upgrade.max.stack=
+
+# stack version for deprecating base url in metainfo table
+baseurl.api.metainfo.deprecate.min.version=2.2

http://git-wip-us.apache.org/repos/asf/ambari/blob/bbb042f3/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
index 0b0ee95..67fb08e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
@@ -438,6 +438,12 @@ public class Configuration {
   public static final String ALERTS_EXECUTION_SCHEDULER_THREADS_KEY = "alerts.execution.scheduler.maxThreads";
   public static final String ALERTS_EXECUTION_SCHEDULER_THREADS_DEFAULT = "2";
 
+  /**
+   * Repository Base URL is no longer stored in metainfo table starting HDP version 2.2. It is in repo_version table.
+   */
+  public static final String BASEURL_API_DEPRECATED_STACK_VERSION = "baseurl.api.metainfo.deprecate.min.version";
+  public static final String BASEURL_API_DEPRECATED_STACK_VERSION_DEFAULT = "2.2";
+
   private static final Logger LOG = LoggerFactory.getLogger(
       Configuration.class);
 
@@ -636,6 +642,9 @@ public class Configuration {
     configsMap.put(PROXY_ALLOWED_HOST_PORTS, properties.getProperty(
         PROXY_ALLOWED_HOST_PORTS, PROXY_ALLOWED_HOST_PORTS_DEFAULT));
 
+    configsMap.put(BASEURL_API_DEPRECATED_STACK_VERSION, properties.getProperty(
+            BASEURL_API_DEPRECATED_STACK_VERSION, BASEURL_API_DEPRECATED_STACK_VERSION_DEFAULT));
+
     File passFile = new File(configsMap.get(SRVR_KSTR_DIR_KEY) + File.separator
         + configsMap.get(SRVR_CRT_PASS_FILE_KEY));
     String password = null;

http://git-wip-us.apache.org/repos/asf/ambari/blob/bbb042f3/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index ef6fc58..fe7f369 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -160,6 +160,7 @@ import org.apache.ambari.server.state.svccomphost.ServiceComponentHostStartEvent
 import org.apache.ambari.server.state.svccomphost.ServiceComponentHostStopEvent;
 import org.apache.ambari.server.state.svccomphost.ServiceComponentHostUpgradeEvent;
 import org.apache.ambari.server.utils.StageUtils;
+import org.apache.ambari.server.utils.VersionUtils;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.MultiMap;
 import org.apache.commons.io.IOUtils;
@@ -3501,14 +3502,28 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
   @Override
   public void updateRepositories(Set<RepositoryRequest> requests) throws AmbariException {
     for (RepositoryRequest rr : requests) {
-      if (null == rr.getStackName() || rr.getStackName().isEmpty()) {
-        throw new AmbariException("Stack name must be specified.");
-      }
-
       if (null == rr.getStackVersion() || rr.getStackVersion().isEmpty()) {
         throw new AmbariException("Stack version must be specified.");
       }
 
+      //
+      // If stack version is 2.2.0.0 or greater, error out.
+      //
+      String stackVersion = rr.getStackVersion();
+      String baseUrlDeprecatedStackVersion = configs.getConfigsMap().get(Configuration.BASEURL_API_DEPRECATED_STACK_VERSION);
+      try {
+        if (VersionUtils.compareVersions(stackVersion, baseUrlDeprecatedStackVersion) >= 0) {
+          throw new AmbariException("Stack version (" + stackVersion + ") is not supported");
+        }
+      }
+      catch (NumberFormatException e) {
+        throw new AmbariException("Stack version (" + stackVersion + ") is not supported");
+      }
+
+      if (null == rr.getStackName() || rr.getStackName().isEmpty()) {
+        throw new AmbariException("Stack name must be specified.");
+      }
+
       if (null == rr.getOsType() || rr.getOsType().isEmpty()) {
         throw new AmbariException("OS type must be specified.");
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/bbb042f3/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index 599a1f7..a2c5a6b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -8481,6 +8481,48 @@ public class AmbariManagementControllerTest {
       LOG.error("Can not complete test. " + exceptionMsg);
     }
 
+    //
+    // HDP stack version 2.2 and above are not supported since the base_url information is stored in repo_version table
+    //
+
+    // Test with stack version 2.2
+    requests.clear();
+    request = new RepositoryRequest(STACK_NAME, "2.2", OS_TYPE, REPO_ID);
+    request.setBaseUrl(baseUrl);
+    requests.add(request);
+    try {
+      controller.updateRepositories(requests);
+    } catch (Exception e) {
+      String exceptionMsg = e.getMessage();
+      assertTrue(exceptionMsg.contains("is not supported"));
+      LOG.error("Can not complete test. " + exceptionMsg);
+    }
+
+    // Test with stack version 2.3 (minor version bumped up)
+    requests.clear();
+    request = new RepositoryRequest(STACK_NAME, "2.3", OS_TYPE, REPO_ID);
+    request.setBaseUrl(baseUrl);
+    requests.add(request);
+    try {
+      controller.updateRepositories(requests);
+    } catch (Exception e) {
+      String exceptionMsg = e.getMessage();
+      assertTrue(exceptionMsg.contains("is not supported"));
+      LOG.error("Can not complete test. " + exceptionMsg);
+    }
+
+    // Test with stack version 3.2 (major version bumped up)
+    requests.clear();
+    request = new RepositoryRequest(STACK_NAME, "3.2", OS_TYPE, REPO_ID);
+    request.setBaseUrl(baseUrl);
+    requests.add(request);
+    try {
+      controller.updateRepositories(requests);
+    } catch (Exception e) {
+      String exceptionMsg = e.getMessage();
+      assertTrue(exceptionMsg.contains("is not supported"));
+      LOG.error("Can not complete test. " + exceptionMsg);
+    }
   }
 
   @Test