-
Notifications
You must be signed in to change notification settings - Fork 1.7k
AMBARI-23107 - Deprecate Repo Versions And Start Tracking Repo OS's F… #515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jonathan-hurley
merged 3 commits into
apache:branch-feature-AMBARI-14714
from
jonathan-hurley:AMBARI-23107
Mar 1, 2018
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,18 +34,22 @@ | |
| import org.apache.ambari.server.agent.ExecutionCommand; | ||
| import org.apache.ambari.server.api.services.AmbariMetaInfo; | ||
| import org.apache.ambari.server.configuration.Configuration; | ||
| import org.apache.ambari.server.controller.spi.SystemException; | ||
| import org.apache.ambari.server.orm.dao.HostRoleCommandDAO; | ||
| import org.apache.ambari.server.orm.dao.MpackDAO; | ||
| import org.apache.ambari.server.orm.dao.ServiceGroupDAO; | ||
| import org.apache.ambari.server.orm.entities.MpackEntity; | ||
| import org.apache.ambari.server.orm.entities.RepoOsEntity; | ||
| import org.apache.ambari.server.orm.entities.RepositoryVersionEntity; | ||
| import org.apache.ambari.server.orm.entities.ServiceGroupEntity; | ||
| import org.apache.ambari.server.orm.entities.StackEntity; | ||
| import org.apache.ambari.server.orm.entities.UpgradeEntity; | ||
| import org.apache.ambari.server.state.Cluster; | ||
| import org.apache.ambari.server.state.Clusters; | ||
| import org.apache.ambari.server.state.ConfigHelper; | ||
| import org.apache.ambari.server.state.DesiredConfig; | ||
| import org.apache.ambari.server.state.Host; | ||
| import org.apache.ambari.server.state.ModuleComponent; | ||
| import org.apache.ambari.server.state.Mpack; | ||
| import org.apache.ambari.server.state.Service; | ||
| import org.apache.ambari.server.state.ServiceComponent; | ||
| import org.apache.ambari.server.state.ServiceInfo; | ||
| import org.apache.ambari.server.state.StackId; | ||
| import org.apache.ambari.server.state.StackInfo; | ||
|
|
@@ -96,6 +100,19 @@ public class ExecutionCommandWrapper { | |
| @Inject | ||
| private Configuration configuration; | ||
|
|
||
| /** | ||
| * Used to get service groups (and from them mpacks) so that we can set the | ||
| * right information on the command. | ||
| */ | ||
| @Inject | ||
| private ServiceGroupDAO serviceGroupDAO; | ||
|
|
||
| /** | ||
| * Used for retrieving mpack entities by their ID. | ||
| */ | ||
| @Inject | ||
| private MpackDAO mpackDAO; | ||
|
|
||
| @AssistedInject | ||
| public ExecutionCommandWrapper(@Assisted String jsonExecutionCommand) { | ||
| this.jsonExecutionCommand = jsonExecutionCommand; | ||
|
|
@@ -232,28 +249,18 @@ public ExecutionCommand getExecutionCommand() { | |
|
|
||
| // setting repositoryFile | ||
| final Host host = cluster.getHost(executionCommand.getHostname()); // can be null on internal commands | ||
| final String serviceName = executionCommand.getServiceName(); // can be null on executing special RU tasks | ||
|
|
||
| if (null == executionCommand.getRepositoryFile() && null != host && null != serviceName) { | ||
| if (null == executionCommand.getRepositoryFile() && null != host) { | ||
| final CommandRepository commandRepository; | ||
| final Service service = cluster.getService(serviceName); | ||
| final String componentName = executionCommand.getComponentName(); | ||
|
|
||
| try { | ||
| ServiceGroupEntity serviceGroupEntity = serviceGroupDAO.find(clusterId, executionCommand.getServiceGroupName()); | ||
| long mpackId = serviceGroupEntity.getStack().getMpackId(); | ||
| Mpack mpack = ambariMetaInfo.getMpack(mpackId); | ||
| MpackEntity mpackEntity = mpackDAO.findById(mpackId); | ||
|
|
||
| if (null != componentName) { | ||
| ServiceComponent serviceComponent = service.getServiceComponent(componentName); | ||
| commandRepository = repoVersionHelper.getCommandRepository(null, serviceComponent, host); | ||
| } else { | ||
| RepositoryVersionEntity repoVersion = service.getDesiredRepositoryVersion(); | ||
| RepoOsEntity osEntity = repoVersionHelper.getOSEntityForHost(host, repoVersion); | ||
| commandRepository = repoVersionHelper.getCommandRepository(repoVersion, osEntity); | ||
| } | ||
| executionCommand.setRepositoryFile(commandRepository); | ||
|
|
||
| } catch (SystemException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| RepoOsEntity osEntity = repoVersionHelper.getOSEntityForHost(mpackEntity, host); | ||
| commandRepository = repoVersionHelper.getCommandRepository(mpack, osEntity); | ||
| executionCommand.setRepositoryFile(commandRepository); | ||
| } | ||
|
|
||
| } catch (ClusterNotFoundException cnfe) { | ||
|
|
@@ -264,52 +271,53 @@ public ExecutionCommand getExecutionCommand() { | |
| cnfe.getMessage()); | ||
|
|
||
| return executionCommand; | ||
| } catch (AmbariException e) { | ||
| } catch (Exception e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
|
|
||
| return executionCommand; | ||
| } | ||
|
|
||
| public void setVersions(Cluster cluster) { | ||
| // set the repository version for the component this command is for - | ||
| // always use the current desired version | ||
| String serviceGroupName = executionCommand.getServiceGroupName(); | ||
| String serviceName = executionCommand.getServiceName(); | ||
| String componentName = executionCommand.getComponentName(); | ||
|
|
||
| String serviceType = null; | ||
|
|
||
| try { | ||
| RepositoryVersionEntity repositoryVersion = null; | ||
| if (!StringUtils.isEmpty(serviceName)) { | ||
| Service service = cluster.getService(serviceName); | ||
| if (null != service) { | ||
| serviceType = service.getServiceType(); | ||
| repositoryVersion = service.getDesiredRepositoryVersion(); | ||
|
|
||
| String componentName = executionCommand.getComponentName(); | ||
| if (!StringUtils.isEmpty(componentName)) { | ||
| ServiceComponent serviceComponent = service.getServiceComponent(componentName); | ||
| if (null != serviceComponent) { | ||
| repositoryVersion = serviceComponent.getDesiredRepositoryVersion(); | ||
| } | ||
| } | ||
| } | ||
| Mpack mpack = null; | ||
| StackEntity stackEntity = null; | ||
|
|
||
| if (StringUtils.isNotBlank(serviceGroupName)) { | ||
| ServiceGroupEntity serviceGroupEntity = serviceGroupDAO.find(cluster.getClusterId(), serviceGroupName); | ||
| stackEntity = serviceGroupEntity.getStack(); | ||
| mpack = ambariMetaInfo.getMpack(stackEntity.getMpackId()); | ||
| } | ||
|
|
||
| Map<String, String> commandParams = executionCommand.getCommandParams(); | ||
| Service service = cluster.getService(serviceGroupName, serviceName); | ||
| if (null != service) { | ||
| serviceType = service.getServiceType(); | ||
| } | ||
|
|
||
| if (null != repositoryVersion) { | ||
| ModuleComponent moduleComponent = null; | ||
| Map<String, String> commandParams = executionCommand.getCommandParams(); | ||
| if (null != mpack && StringUtils.isNotBlank(serviceName) && StringUtils.isNotBlank(componentName)) { | ||
| // only set the version if it's not set and this is NOT an install | ||
| // command | ||
| // Some stack scripts use version for path purposes. Sending unresolved version first (for | ||
| // blueprints) and then resolved one would result in various issues: duplicate directories | ||
| // (/hdp/apps/2.6.3.0 + /hdp/apps/2.6.3.0-235), parent directory not found, and file not | ||
| // found, etc. Hence requiring repositoryVersion to be resolved. | ||
|
|
||
| moduleComponent = mpack.getModuleComponent(serviceName, componentName); | ||
| } | ||
|
|
||
| if( null != moduleComponent ) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: formatting |
||
| if (!commandParams.containsKey(VERSION) | ||
| && repositoryVersion.isResolved() | ||
| && executionCommand.getRoleCommand() != RoleCommand.INSTALL) { | ||
| commandParams.put(VERSION, repositoryVersion.getVersion()); | ||
| } | ||
| && executionCommand.getRoleCommand() != RoleCommand.INSTALL) { | ||
| commandParams.put(VERSION, moduleComponent.getVersion()); | ||
| } | ||
| } | ||
|
|
||
| StackId stackId = repositoryVersion.getStackId(); | ||
| if (null != stackEntity) { | ||
| StackId stackId = new StackId(stackEntity); | ||
| StackInfo stackInfo = ambariMetaInfo.getStack(stackId.getStackName(), | ||
| stackId.getStackVersion()); | ||
|
|
||
|
|
@@ -327,6 +335,7 @@ public void setVersions(Cluster cluster) { | |
| } | ||
| } | ||
|
|
||
|
|
||
| // set the desired versions of versionable components. This is safe even during an upgrade because | ||
| // we are "loading-late": components that have not yet upgraded in an EU will have the correct versions. | ||
| executionCommand.setComponentVersions(cluster); | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should consider renaming the enum RepositoryVersionState to some other "thing" - InstallState or something similar. Doesn't need to be in this change, just bringing it up. We can use it for multiple things, possibly for mpacks, modules, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I'm trying to keep the number of files changed manageable, so I didn't want to do it as part of this commit.