ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [09/50] [abbrv] ambari git commit: Revert "AMBARI-14520. BE: Install packages call takes more than 3 minutes on 900 node cluster (dlysnichenko)"
Date Fri, 08 Jan 2016 18:15:26 GMT
Revert "AMBARI-14520. BE: Install packages call takes more than 3 minutes on 900 node cluster
(dlysnichenko)"

This reverts commit 09b55dfe70776a6ae1dc8d79b31ec739ee5400c7 due to UT failures.


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 5d8a97cfb4e846d8319e6225465f1668584ab14c
Parents: 215c21c
Author: Yusaku Sako <yusaku@hortonworks.com>
Authored: Tue Jan 5 15:24:56 2016 -0800
Committer: Yusaku Sako <yusaku@hortonworks.com>
Committed: Tue Jan 5 15:24:56 2016 -0800

----------------------------------------------------------------------
 .../controller/AmbariActionExecutionHelper.java |  3 +
 .../ClusterStackVersionResourceProvider.java    | 18 ++---
 .../HostStackVersionResourceProvider.java       | 18 ++---
 .../server/state/cluster/ClusterImpl.java       | 71 +++++++-------------
 .../ambari/server/state/host/HostImpl.java      |  5 +-
 5 files changed, 36 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5d8a97cf/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
index 2a8fde1..f137996 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariActionExecutionHelper.java
@@ -433,6 +433,9 @@ public class AmbariActionExecutionHelper {
       }
 
       if (null != cluster) {
+        // Generate cluster host info
+        execCmd.setClusterHostInfo(
+          StageUtils.getClusterHostInfo(cluster));
         // Generate localComponents
         for (ServiceComponentHost sch : cluster.getServiceComponentHosts(hostName)) {
           execCmd.getLocalComponents().add(sch.getServiceComponentName());

http://git-wip-us.apache.org/repos/asf/ambari/blob/5d8a97cf/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
index 3a1ac62..606ccce 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProvider.java
@@ -367,15 +367,6 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou
     hostLevelParams.put(JDK_LOCATION, getManagementController().getJdkResourceUrl());
     String hostParamsJson = StageUtils.getGson().toJson(hostLevelParams);
 
-    // Generate cluster host info
-    String clusterHostInfoJson;
-    try {
-      clusterHostInfoJson = StageUtils.getGson().toJson(
-        StageUtils.getClusterHostInfo(cluster));
-    } catch (AmbariException e) {
-      throw new SystemException("Could not build cluster topology", e);
-    }
-
     int maxTasks = configuration.getAgentPackageParallelCommandsLimit();
     int hostCount = hosts.size();
     int batchCount = (int) (Math.ceil((double)hostCount / maxTasks));
@@ -399,7 +390,7 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou
       }
 
       Stage stage = stageFactory.createNew(req.getId(), "/tmp/ambari", cluster.getClusterName(),
-          cluster.getClusterId(), stageName, clusterHostInfoJson, "{}", hostParamsJson);
+          cluster.getClusterId(), stageName, "{}", "{}", hostParamsJson);
 
       // if you have 1000 hosts (10 stages with 100 installs), we want to ensure
       // that a single failure doesn't cause all other stages to abort; set the
@@ -476,12 +467,11 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou
       final StackId stackId, Map<String, List<RepositoryEntity>> perOsRepos,
Stage stage, Host host)
           throws SystemException {
     // Determine repositories for host
-    String osFamily = host.getOsFamily();
-    final List<RepositoryEntity> repoInfo = perOsRepos.get(osFamily);
+    final List<RepositoryEntity> repoInfo = perOsRepos.get(host.getOsFamily());
     if (repoInfo == null) {
       throw new SystemException(String.format("Repositories for os type %s are " +
                       "not defined. Repo version=%s, stackId=%s",
-        osFamily, desiredRepoVersion, stackId));
+              host.getOsFamily(), desiredRepoVersion, stackId));
     }
 
     // determine packages for all services that are installed on host
@@ -502,7 +492,7 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou
 
       List<ServiceOsSpecific.Package> packagesForService = managementController.getPackagesForServiceHost(info,
               new HashMap<String, String>(), // Contents are ignored
-        osFamily);
+              host.getOsFamily());
       for (ServiceOsSpecific.Package aPackage : packagesForService) {
         if (! aPackage.getSkipUpgrade()) {
           boolean blacklisted = false;

http://git-wip-us.apache.org/repos/asf/ambari/blob/5d8a97cf/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
index c7e3ca9..43a4423 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/HostStackVersionResourceProvider.java
@@ -354,12 +354,11 @@ public class HostStackVersionResourceProvider extends AbstractControllerResource
     }
 
     // Determine repositories for host
-    String osFamily = host.getOsFamily();
-    final List<RepositoryEntity> repoInfo = perOsRepos.get(osFamily);
+    final List<RepositoryEntity> repoInfo = perOsRepos.get(host.getOsFamily());
     if (repoInfo == null) {
       throw new SystemException(String.format("Repositories for os type %s are " +
                       "not defined. Repo version=%s, stackId=%s",
-        osFamily, desiredRepoVersion, stackId));
+              host.getOsFamily(), desiredRepoVersion, stackId));
     }
     // For every host at cluster, determine packages for all installed services
     List<ServiceOsSpecific.Package> packages = new ArrayList<ServiceOsSpecific.Package>();
@@ -378,7 +377,7 @@ public class HostStackVersionResourceProvider extends AbstractControllerResource
       }
       List<ServiceOsSpecific.Package> packagesForService = managementController.getPackagesForServiceHost(info,
               new HashMap<String, String>(), // Contents are ignored
-        osFamily);
+              host.getOsFamily());
       for (ServiceOsSpecific.Package aPackage : packagesForService) {
         if (! aPackage.getSkipUpgrade()) {
           boolean blacklisted = false;
@@ -420,21 +419,12 @@ public class HostStackVersionResourceProvider extends AbstractControllerResource
     Map<String, String> hostLevelParams = new HashMap<String, String>();
     hostLevelParams.put(JDK_LOCATION, getManagementController().getJdkResourceUrl());
 
-    // Generate cluster host info
-    String clusterHostInfoJson;
-    try {
-      clusterHostInfoJson = StageUtils.getGson().toJson(
-        StageUtils.getClusterHostInfo(cluster));
-    } catch (AmbariException e) {
-      throw new SystemException("Could not build cluster topology", e);
-    }
-
     Stage stage = stageFactory.createNew(req.getId(),
             "/tmp/ambari",
             cluster.getClusterName(),
             cluster.getClusterId(),
             caption,
-            clusterHostInfoJson,
+            "{}",
             "{}",
             StageUtils.getGson().toJson(hostLevelParams));
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/5d8a97cf/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
index 35c10e9..a0c6cfc 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
@@ -1208,56 +1208,31 @@ public class ClusterImpl implements Cluster {
       Sets.SetView<String> hostsMissingRepoVersion = Sets.difference(
         hosts.keySet(), existingHostsWithClusterStackAndVersion);
 
-      createOrUpdateHostVersionToState(sourceClusterVersion, hosts,
-        existingHostStackVersions, hostsMissingRepoVersion,
-        RepositoryVersionState.INSTALLING);
-    } finally {
-      clusterGlobalLock.writeLock().unlock();
-    }
-  }
-
-  /**
-   * Moved out to a separate method due to performance reasons
-   * Iterates over all hosts and creates or transitions existing host versions
-   * to a given state. If host version for desired stack/version does not exist,
-   * host version is created and initialized to a given state. Otherwise, existing
-   * host version state is updated
-   * Hosts in maintenance mode are auto skipped.
-   *
-   * @param sourceClusterVersion cluster version to be queried for a stack
-   *                             name/version info when creating a new host version
-   * @param hosts list of all hosts
-   * @param existingHostStackVersions map of existing host versions to be updated
-   * @param hostsMissingRepoVersion set of hostnames of hosts that have no desired host version
-   * @param newState target host version state for transition
-   */
-  @Transactional
-  void createOrUpdateHostVersionToState(ClusterVersionEntity sourceClusterVersion, Map<String,
Host> hosts,
-                                        HashMap<String, HostVersionEntity> existingHostStackVersions,
-                                        Sets.SetView<String> hostsMissingRepoVersion,
-                                                RepositoryVersionState newState) {
-    for (String hostname : hosts.keySet()) {
-      // if the host is in maintenance mode, that's an explicit marker which
-      // indicates that it should not be transitioned to newState; these
-      // hosts are excluded from being transitioned into newState
-      Host host = hosts.get(hostname);
-      if (host.getMaintenanceState(getClusterId()) != MaintenanceState.OFF) {
-        continue;
-      }
+      for (String hostname : hosts.keySet()) {
+        // if the host is in maintenance mode, that's an explicit marker which
+        // indicates that it should not be transitioned to INSTALLING; these
+        // hosts are excluded from being transitioned into INSTALLING
+        Host host = hosts.get(hostname);
+        if (host.getMaintenanceState(getClusterId()) != MaintenanceState.OFF) {
+          continue;
+        }
 
-      if (hostsMissingRepoVersion.contains(hostname)) {
-        // Create new host stack version
-        HostEntity hostEntity = hostDAO.findByName(hostname);
-        HostVersionEntity hostVersionEntity = new HostVersionEntity(hostEntity,
-            sourceClusterVersion.getRepositoryVersion(),
-          newState);
-        hostVersionDAO.create(hostVersionEntity);
-      } else {
-        // Update existing host stack version
-        HostVersionEntity hostVersionEntity = existingHostStackVersions.get(hostname);
-        hostVersionEntity.setState(newState);
-        hostVersionDAO.merge(hostVersionEntity);
+        if (hostsMissingRepoVersion.contains(hostname)) {
+          // Create new host stack version
+          HostEntity hostEntity = hostDAO.findByName(hostname);
+          HostVersionEntity hostVersionEntity = new HostVersionEntity(hostEntity,
+              sourceClusterVersion.getRepositoryVersion(),
+              RepositoryVersionState.INSTALLING);
+          hostVersionDAO.create(hostVersionEntity);
+        } else {
+          // Update existing host stack version
+          HostVersionEntity hostVersionEntity = existingHostStackVersions.get(hostname);
+          hostVersionEntity.setState(RepositoryVersionState.INSTALLING);
+          hostVersionDAO.merge(hostVersionEntity);
+        }
       }
+    } finally {
+      clusterGlobalLock.writeLock().unlock();
     }
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/5d8a97cf/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
index f946771..d121bb5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
@@ -869,9 +869,8 @@ public class HostImpl implements Host {
 
   @Override
   public String getOsFamily() {
-    Map<String, String> hostAttributes = getHostAttributes();
-    String majorVersion = hostAttributes.get(OS_RELEASE_VERSION).split("\\.")[0];
-	  return hostAttributes.get(OSFAMILY) + majorVersion;
+	  String majorVersion = getHostAttributes().get(OS_RELEASE_VERSION).split("\\.")[0];
+	  return getHostAttributes().get(OSFAMILY) + majorVersion;
   }
 
   @Override


Mime
View raw message