Repository: ambari Updated Branches: refs/heads/branch-2.6 4e69090c4 -> a1f8e9fe5
AMBARI-22219 - Set current_version for Backward Compatibility (jonathanhurley) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/a1f8e9fe Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a1f8e9fe Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a1f8e9fe Branch: refs/heads/branch-2.6 Commit: a1f8e9fe59eaeaade2a508518b7abb8e3a009556 Parents: 4e69090 Author: Jonathan Hurley <jhur...@hortonworks.com> Authored: Thu Oct 12 09:55:33 2017 -0400 Committer: Jonathan Hurley <jhur...@hortonworks.com> Committed: Thu Oct 12 10:11:01 2017 -0400 ---------------------------------------------------------------------- .../actionmanager/ExecutionCommandWrapper.java | 15 +++++++++++++++ .../apache/ambari/server/agent/ExecutionCommand.java | 14 ++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/a1f8e9fe/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 f37bdd5..054ab47 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 @@ -31,6 +31,7 @@ import org.apache.ambari.server.RoleCommand; import org.apache.ambari.server.ServiceNotFoundException; import org.apache.ambari.server.agent.AgentCommand.AgentCommandType; import org.apache.ambari.server.agent.ExecutionCommand; +import org.apache.ambari.server.agent.ExecutionCommand.KeyNames; import org.apache.ambari.server.api.services.AmbariMetaInfo; import org.apache.ambari.server.orm.dao.HostRoleCommandDAO; import org.apache.ambari.server.orm.entities.RepositoryVersionEntity; @@ -233,6 +234,12 @@ public class ExecutionCommandWrapper { return executionCommand; } + /** + * Sets the repository version and hooks information on the execution command. + * + * @param cluster + * the cluster (not {@code null}). + */ public void setVersions(Cluster cluster) { // set the repository version for the component this command is for - // always use the current desired version @@ -255,6 +262,7 @@ public class ExecutionCommandWrapper { } Map<String, String> commandParams = executionCommand.getCommandParams(); + Map<String, String> hostParams = executionCommand.getHostLevelParams(); if (null != repositoryVersion) { // only set the version if it's not set and this is NOT an install @@ -264,6 +272,13 @@ public class ExecutionCommandWrapper { commandParams.put(VERSION, repositoryVersion.getVersion()); } + // !!! although not used anymore since the cluster has more than 1 version, this + // property might be needed by legacy mpacks or extension services, so + // continue to include it for backward compatibility + if (repositoryVersion.isResolved()) { + hostParams.put(KeyNames.CURRENT_VERSION, repositoryVersion.getVersion()); + } + StackId stackId = repositoryVersion.getStackId(); StackInfo stackInfo = ambariMetaInfo.getStack(stackId.getStackName(), stackId.getStackVersion()); http://git-wip-us.apache.org/repos/asf/ambari/blob/a1f8e9fe/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java index 6ffc9c1..b3f9130 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/ExecutionCommand.java @@ -505,10 +505,20 @@ public class ExecutionCommand extends AgentCommand { * upgrades, this value may change depending on the progress of the upgrade * and the type/direction. */ + String VERSION = "version"; + + /** + * Previously used to represent the version of a cluster, this singular + * value is no longer valid. However, to maintain backward compatibility + * with Python code inside of management packs and extension services it + * will be still be provided. It should be set to the repository version of + * the command, if th repository has been resolved. + */ + @Deprecated @Experimental( feature = ExperimentalFeature.PATCH_UPGRADES, - comment = "Change this to reflect the component version") - String VERSION = "version"; + comment = "This value is still around purely for backward compatibility with mpacks") + String CURRENT_VERSION = "current_version"; } /**