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-9498. RU: hosts master check is not checking all masters (Yurii Shylov via ncole)
Date Mon, 09 Feb 2015 19:53:03 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 0d1272764 -> 2f3020c7e


AMBARI-9498. RU: hosts master check is not checking all masters (Yurii Shylov via ncole)


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

Branch: refs/heads/trunk
Commit: 2f3020c7e377cc7b3f253d20a82754e1ef9799f6
Parents: 0d12727
Author: Nate Cole <ncole@hortonworks.com>
Authored: Mon Feb 9 14:52:31 2015 -0500
Committer: Nate Cole <ncole@hortonworks.com>
Committed: Mon Feb 9 14:52:31 2015 -0500

----------------------------------------------------------------------
 .../server/checks/AbstractCheckDescriptor.java  | 14 +++++---
 .../checks/HostsMasterMaintenanceCheck.java     | 38 ++++++++++++++------
 2 files changed, 37 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2f3020c7/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 647f2d1..4e2e2ab 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
@@ -19,15 +19,16 @@ package org.apache.ambari.server.checks;
 
 import com.google.inject.Inject;
 import com.google.inject.Provider;
+
 import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.configuration.Configuration;
+import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.controller.PrereqCheckRequest;
 import org.apache.ambari.server.orm.dao.HostVersionDAO;
 import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
 import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.state.ConfigHelper;
 import org.apache.ambari.server.state.stack.PrerequisiteCheck;
 import org.apache.ambari.server.state.stack.PrereqCheckType;
+import org.apache.ambari.server.state.stack.upgrade.RepositoryVersionHelper;
 
 /**
  * Describes prerequisite check.
@@ -42,14 +43,17 @@ public abstract class AbstractCheckDescriptor {
   Provider<Clusters> clustersProvider;
 
   @Inject
-  Provider<ConfigHelper> configHelperProvider;
-
-  @Inject
   Provider<HostVersionDAO> hostVersionDaoProvider;
 
   @Inject
   Provider<RepositoryVersionDAO> repositoryVersionDaoProvider;
 
+  @Inject
+  Provider<RepositoryVersionHelper> repositoryVersionHelper;
+
+  @Inject
+  Provider<AmbariMetaInfo> ambariMetaInfo;
+
   /**
    * Constructor.
    *

http://git-wip-us.apache.org/repos/asf/ambari/blob/2f3020c7/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 91ca65a..f12b473 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
@@ -19,12 +19,12 @@ package org.apache.ambari.server.checks;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.controller.PrereqCheckRequest;
-import org.apache.ambari.server.stack.HostsType;
-import org.apache.ambari.server.stack.MasterHostResolver;
 import org.apache.ambari.server.state.*;
 import org.apache.ambari.server.state.stack.PrereqCheckStatus;
 import org.apache.ambari.server.state.stack.PrerequisiteCheck;
 import org.apache.ambari.server.state.stack.PrereqCheckType;
+import org.apache.ambari.server.state.stack.UpgradePack;
+import org.apache.ambari.server.state.stack.UpgradePack.ProcessingComponent;
 
 import java.util.HashSet;
 import java.util.Map;
@@ -43,18 +43,36 @@ public class HostsMasterMaintenanceCheck extends AbstractCheckDescriptor
{
   }
 
   @Override
+  public boolean isApplicable(PrereqCheckRequest request) throws AmbariException {
+    return request.getRepositoryVersion() != null;
+  }
+
+  @Override
   public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws
AmbariException {
     final String clusterName = request.getClusterName();
     final Cluster cluster = clustersProvider.get().getCluster(clusterName);
-    final MasterHostResolver masterHostResolver = new MasterHostResolver(configHelperProvider.get(),
cluster);
+    final StackId stackId = cluster.getDesiredStackVersion();
     final Set<String> hostsWithMasterComponent = new HashSet<String>();
-    for (Map.Entry<String, Service> serviceEntry: cluster.getServices().entrySet())
{
-      final Service service = serviceEntry.getValue();
-      for (Map.Entry<String, ServiceComponent> serviceComponentEntry: service.getServiceComponents().entrySet())
{
-        final ServiceComponent serviceComponent = serviceComponentEntry.getValue();
-        final HostsType hostsType = masterHostResolver.getMasterAndHosts(service.getName(),
serviceComponent.getName());
-        if (hostsType != null && hostsType.master != null) {
-          hostsWithMasterComponent.add(hostsType.master);
+    final String upgradePackName = repositoryVersionHelper.get().getUpgradePackageName(stackId.getStackName(),
stackId.getStackVersion(), request.getRepositoryVersion());
+    if (upgradePackName == null) {
+      prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL);
+      prerequisiteCheck.setFailReason("Could not find suitable upgrade pack for " + stackId.getStackName()
+ " " + stackId.getStackVersion() + " to version " + request.getRepositoryVersion());
+      return;
+    }
+    final UpgradePack upgradePack = ambariMetaInfo.get().getUpgradePacks(stackId.getStackName(),
stackId.getStackVersion()).get(upgradePackName);
+    if (upgradePack == null) {
+      prerequisiteCheck.setStatus(PrereqCheckStatus.FAIL);
+      prerequisiteCheck.setFailReason("Could not find upgrade pack named " + upgradePackName);
+      return;
+    }
+    final Set<String> componentsFromUpgradePack = new HashSet<String>();
+    for (Map<String, ProcessingComponent> task: upgradePack.getTasks().values()) {
+      componentsFromUpgradePack.addAll(task.keySet());
+    }
+    for (Service service: cluster.getServices().values()) {
+      for (ServiceComponent serviceComponent: service.getServiceComponents().values()) {
+        if (serviceComponent.isMasterComponent() && componentsFromUpgradePack.contains(serviceComponent.getName()))
{
+          hostsWithMasterComponent.addAll(serviceComponent.getServiceComponentHosts().keySet());
         }
       }
     }


Mime
View raw message