ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject ambari git commit: AMBARI-21552 - Pass Repository ID To Upgrade Prechecks (part2) (jonathanhurley)
Date Sun, 23 Jul 2017 03:02:49 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-feature-AMBARI-21450 eb598e855 -> 14bcadf00


AMBARI-21552 - Pass Repository ID To Upgrade Prechecks (part2) (jonathanhurley)


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

Branch: refs/heads/branch-feature-AMBARI-21450
Commit: 14bcadf008626f0914ce956f8d520236777eeca0
Parents: eb598e8
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Sat Jul 22 22:34:19 2017 -0400
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Sat Jul 22 22:34:19 2017 -0400

----------------------------------------------------------------------
 .../server/checks/AbstractCheckDescriptor.java  |  4 ++--
 .../server/checks/ConfigurationMergeCheck.java  |  2 +-
 .../checks/HostsMasterMaintenanceCheck.java     |  4 ++--
 .../checks/HostsRepositoryVersionCheck.java     |  8 +++----
 .../server/checks/InstallPackagesCheck.java     |  6 ++---
 .../server/controller/PrereqCheckRequest.java   | 11 ++++++++-
 .../PreUpgradeCheckResourceProvider.java        | 12 ++++++----
 .../internal/ReadOnlyResourceProvider.java      | 24 ++++++++++++++++++--
 .../ambari/server/state/UpgradeHelper.java      |  4 ++--
 9 files changed, 54 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/14bcadf0/ambari-server/src/main/java/org/apache/ambari/server/checks/AbstractCheckDescriptor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/AbstractCheckDescriptor.java
b/ambari-server/src/main/java/org/apache/ambari/server/checks/AbstractCheckDescriptor.java
index fe28471..4f8a39d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/AbstractCheckDescriptor.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/AbstractCheckDescriptor.java
@@ -218,8 +218,8 @@ public abstract class AbstractCheckDescriptor {
       PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) {
     String fail = m_description.getFail(key);
 
-    if (fail.contains("{{version}}") && null != request.getRepositoryVersion()) {
-      fail = fail.replace("{{version}}", request.getRepositoryVersion());
+    if (fail.contains("{{version}}") && null != request.getTargetVersion()) {
+      fail = fail.replace("{{version}}", request.getTargetVersion());
     }
 
     if (fail.contains("{{fails}}")) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/14bcadf0/ambari-server/src/main/java/org/apache/ambari/server/checks/ConfigurationMergeCheck.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/ConfigurationMergeCheck.java
b/ambari-server/src/main/java/org/apache/ambari/server/checks/ConfigurationMergeCheck.java
index 5f4b974..28d7d78 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/ConfigurationMergeCheck.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/ConfigurationMergeCheck.java
@@ -65,7 +65,7 @@ public class ConfigurationMergeCheck extends AbstractCheckDescriptor {
       throws AmbariException {
 
     String stackName = request.getTargetStackId().getStackName();
-    RepositoryVersionEntity rve = repositoryVersionDaoProvider.get().findByStackNameAndVersion(stackName,
request.getRepositoryVersion());
+    RepositoryVersionEntity rve = repositoryVersionDaoProvider.get().findByStackNameAndVersion(stackName,
request.getTargetVersion());
 
     Map<String, Map<String, ThreeWayValue>> changes =
         m_mergeHelper.getConflicts(request.getClusterName(), rve.getStackId());

http://git-wip-us.apache.org/repos/asf/ambari/blob/14bcadf0/ambari-server/src/main/java/org/apache/ambari/server/checks/HostsMasterMaintenanceCheck.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/HostsMasterMaintenanceCheck.java
b/ambari-server/src/main/java/org/apache/ambari/server/checks/HostsMasterMaintenanceCheck.java
index 01bf6ae..8cd935b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/HostsMasterMaintenanceCheck.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/HostsMasterMaintenanceCheck.java
@@ -59,7 +59,7 @@ public class HostsMasterMaintenanceCheck extends AbstractCheckDescriptor
{
 
   @Override
   public boolean isApplicable(PrereqCheckRequest request) throws AmbariException {
-      return super.isApplicable(request) && request.getRepositoryVersion() != null;
+      return super.isApplicable(request) && request.getTargetVersion() != null;
   }
 
   @Override
@@ -70,7 +70,7 @@ public class HostsMasterMaintenanceCheck extends AbstractCheckDescriptor
{
     final Set<String> hostsWithMasterComponent = new HashSet<String>();
 
     // TODO AMBARI-12698, need to pass the upgrade pack to use in the request, or at least
the type.
-    final String upgradePackName = repositoryVersionHelper.get().getUpgradePackageName(stackId.getStackName(),
stackId.getStackVersion(), request.getRepositoryVersion(), null);
+    final String upgradePackName = repositoryVersionHelper.get().getUpgradePackageName(stackId.getStackName(),
stackId.getStackVersion(), request.getTargetVersion(), null);
     if (upgradePackName == null) {
       prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL);
       String fail = getFailReason(KEY_NO_UPGRADE_NAME, prerequisiteCheck, request);

http://git-wip-us.apache.org/repos/asf/ambari/blob/14bcadf0/ambari-server/src/main/java/org/apache/ambari/server/checks/HostsRepositoryVersionCheck.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/HostsRepositoryVersionCheck.java
b/ambari-server/src/main/java/org/apache/ambari/server/checks/HostsRepositoryVersionCheck.java
index a4cea31..613c5fc 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/HostsRepositoryVersionCheck.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/HostsRepositoryVersionCheck.java
@@ -58,7 +58,7 @@ public class HostsRepositoryVersionCheck extends AbstractCheckDescriptor
{
 
   @Override
   public boolean isApplicable(PrereqCheckRequest request) throws AmbariException {
-    return super.isApplicable(request) && request.getRepositoryVersion() != null;
+    return super.isApplicable(request) && request.getTargetVersion() != null;
   }
 
   @Override
@@ -76,11 +76,11 @@ public class HostsRepositoryVersionCheck extends AbstractCheckDescriptor
{
         continue;
       }
 
-      if (null != request.getRepositoryVersion()) {
+      if (null != request.getTargetVersion()) {
         boolean found = false;
         for (HostVersionEntity hve : hostVersionDaoProvider.get().findByHost(host.getHostName()))
{
 
-          if (hve.getRepositoryVersion().getVersion().equals(request.getRepositoryVersion())
+          if (hve.getRepositoryVersion().getVersion().equals(request.getTargetVersion())
               && (hve.getState() == RepositoryVersionState.INSTALLED || hve.getState()
== RepositoryVersionState.NOT_REQUIRED)) {
             found = true;
             break;
@@ -92,7 +92,7 @@ public class HostsRepositoryVersionCheck extends AbstractCheckDescriptor
{
         }
       } else {
         final RepositoryVersionEntity repositoryVersion = repositoryVersionDaoProvider.get().findByStackAndVersion(
-            stackId, request.getRepositoryVersion());
+            stackId, request.getTargetVersion());
         if (repositoryVersion == null) {
           prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL);
           prerequisiteCheck.setFailReason(

http://git-wip-us.apache.org/repos/asf/ambari/blob/14bcadf0/ambari-server/src/main/java/org/apache/ambari/server/checks/InstallPackagesCheck.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/InstallPackagesCheck.java
b/ambari-server/src/main/java/org/apache/ambari/server/checks/InstallPackagesCheck.java
index ac2116f..7c84e5c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/InstallPackagesCheck.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/InstallPackagesCheck.java
@@ -61,9 +61,9 @@ public class InstallPackagesCheck extends AbstractCheckDescriptor {
     final Cluster cluster = clustersProvider.get().getCluster(clusterName);
     final StackId targetStackId = request.getTargetStackId();
     final String stackName = targetStackId.getStackName();
-    final String repoVersion = request.getRepositoryVersion();
+    final String repoVersion = request.getTargetVersion();
 
-    final RepositoryVersionEntity rve = repositoryVersionDaoProvider.get().findByStackNameAndVersion(stackName,
request.getRepositoryVersion());
+    final RepositoryVersionEntity rve = repositoryVersionDaoProvider.get().findByStackNameAndVersion(stackName,
request.getTargetVersion());
     if (StringUtils.isBlank(rve.getVersion()) || !rve.getVersion().matches("^\\d+(\\.\\d+)*\\-\\d+$"))
{
       String message = MessageFormat.format("The Repository Version {0} for Stack {1} must
contain a \"-\" followed by a build number. " +
               "Make sure that another registered repository does not have the same repo URL
or " +
@@ -79,7 +79,7 @@ public class InstallPackagesCheck extends AbstractCheckDescriptor {
     for (Host host : cluster.getHosts()) {
       if (host.getMaintenanceState(cluster.getClusterId()) != MaintenanceState.ON) {
         for (HostVersionEntity hve : hostVersionDaoProvider.get().findByHost(host.getHostName()))
{
-          if (hve.getRepositoryVersion().getVersion().equals(request.getRepositoryVersion())
+          if (hve.getRepositoryVersion().getVersion().equals(request.getTargetVersion())
               && hve.getState() == RepositoryVersionState.INSTALL_FAILED) {
             failedHosts.add(host.getHostName());
           }

http://git-wip-us.apache.org/repos/asf/ambari/blob/14bcadf0/ambari-server/src/main/java/org/apache/ambari/server/controller/PrereqCheckRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/PrereqCheckRequest.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/PrereqCheckRequest.java
index e501bb8..8f15479 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/PrereqCheckRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/PrereqCheckRequest.java
@@ -64,7 +64,7 @@ public class PrereqCheckRequest {
     return m_upgradeType;
   }
 
-  public String getRepositoryVersion() {
+  public String getTargetVersion() {
     return m_targetRepositoryVersion.getVersion();
   }
 
@@ -115,6 +115,15 @@ public class PrereqCheckRequest {
   }
 
   /**
+   * Gets the target repository of the upgrade.
+   *
+   * @return the target repository.
+   */
+  public RepositoryVersionEntity getTargetRepositoryVersion() {
+    return m_targetRepositoryVersion;
+  }
+
+  /**
    * Sets the target of the upgrade.
    *
    * @param targetRepositoryVersion

http://git-wip-us.apache.org/repos/asf/ambari/blob/14bcadf0/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProvider.java
index 8a10fb7..8a0769a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/PreUpgradeCheckResourceProvider.java
@@ -81,6 +81,7 @@ public class PreUpgradeCheckResourceProvider extends ReadOnlyResourceProvider
{
   public static final String UPGRADE_CHECK_CLUSTER_NAME_PROPERTY_ID        = PropertyHelper.getPropertyId("UpgradeChecks",
"cluster_name");
   public static final String UPGRADE_CHECK_UPGRADE_TYPE_PROPERTY_ID        = PropertyHelper.getPropertyId("UpgradeChecks",
"upgrade_type");
   public static final String UPGRADE_CHECK_TARGET_REPOSITORY_VERSION_ID_ID = PropertyHelper.getPropertyId("UpgradeChecks",
"repository_version_id");
+  public static final String UPGRADE_CHECK_TARGET_REPOSITORY_VERSION       = PropertyHelper.getPropertyId("UpgradeChecks",
"repository_version");
 
   /**
    * Optional parameter to specify the preferred Upgrade Pack to use.
@@ -137,7 +138,7 @@ public class PreUpgradeCheckResourceProvider extends ReadOnlyResourceProvider
{
    * @param managementController management controller
    */
   public PreUpgradeCheckResourceProvider(AmbariManagementController managementController)
{
-    super(propertyIds, keyPropertyIds, managementController);
+    super(Type.PreUpgradeCheck, propertyIds, keyPropertyIds, managementController);
   }
 
   @Override
@@ -208,8 +209,9 @@ public class PreUpgradeCheckResourceProvider extends ReadOnlyResourceProvider
{
       }
 
       if (upgradePack == null) {
-        throw new SystemException(String.format("Upgrade pack not found for the target repository
version %s",
-          upgradeCheckRequest.getRepositoryVersion()));
+        throw new SystemException(
+            String.format("Upgrade pack not found for the target repository version %s",
+                upgradeCheckRequest.getTargetRepositoryVersion()));
       }
 
       // ToDo: properly handle exceptions, i.e. create fake check with error description
@@ -242,7 +244,9 @@ public class PreUpgradeCheckResourceProvider extends ReadOnlyResourceProvider
{
         setResourceProperty(resource, UPGRADE_CHECK_CHECK_TYPE_PROPERTY_ID, prerequisiteCheck.getType(),
requestedIds);
         setResourceProperty(resource, UPGRADE_CHECK_CLUSTER_NAME_PROPERTY_ID, prerequisiteCheck.getClusterName(),
requestedIds);
         setResourceProperty(resource, UPGRADE_CHECK_UPGRADE_TYPE_PROPERTY_ID, upgradeType,
requestedIds);
-        setResourceProperty(resource, UPGRADE_CHECK_TARGET_REPOSITORY_VERSION_ID_ID, upgradeCheckRequest.getRepositoryVersion(),
requestedIds);
+
+        setResourceProperty(resource, UPGRADE_CHECK_TARGET_REPOSITORY_VERSION_ID_ID, repositoryVersion.getId(),
requestedIds);
+        setResourceProperty(resource, UPGRADE_CHECK_TARGET_REPOSITORY_VERSION, repositoryVersion.getVersion(),
requestedIds);
 
         resources.add(resource);
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/14bcadf0/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ReadOnlyResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ReadOnlyResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ReadOnlyResourceProvider.java
index 342983f..505ec63 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ReadOnlyResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ReadOnlyResourceProvider.java
@@ -1,4 +1,4 @@
-/**
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -43,6 +43,26 @@ public abstract class ReadOnlyResourceProvider extends AbstractControllerResourc
     super(propertyIds, keyPropertyIds, managementController);
   }
 
+  /**
+   * Create a new resource provider for the given management controller. This
+   * constructor will initialize the specified {@link Resource.Type} with the
+   * provided keys. It should be used in cases where the provider declares its
+   * own keys instead of reading them from a JSON file.
+   *
+   * @param type
+   *          the type to set the properties for (not {@code null}).
+   * @param propertyIds
+   *          the property ids
+   * @param keyPropertyIds
+   *          the key property ids
+   * @param managementController
+   *          the management controller
+   */
+  ReadOnlyResourceProvider(Resource.Type type, Set<String> propertyIds,
+      Map<Resource.Type, String> keyPropertyIds, AmbariManagementController managementController)
{
+    super(type, propertyIds, keyPropertyIds, managementController);
+  }
+
   @Override
   public RequestStatus createResources(Request request) throws SystemException,
       UnsupportedPropertyException, ResourceAlreadyExistsException,
@@ -82,4 +102,4 @@ public abstract class ReadOnlyResourceProvider extends AbstractControllerResourc
     // TODO Auto-generated method stub
     return null;
   }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/14bcadf0/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
index 7ca6976..a5881d2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeHelper.java
@@ -231,10 +231,10 @@ public class UpgradeHelper {
     Cluster cluster = m_clusters.get().getCluster(clusterName);
     StackId currentStack = cluster.getCurrentStackVersion();
 
-    StackId stackForUpgradePack = sourceStackId;
+    StackId stackForUpgradePack = targetStackId;
 
     if (direction.isDowngrade()) {
-      stackForUpgradePack = targetStackId;
+      stackForUpgradePack = sourceStackId;
     }
 
     Map<String, UpgradePack> packs = m_ambariMetaInfoProvider.get().getUpgradePacks(


Mime
View raw message