ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [32/50] [abbrv] ambari git commit: AMBARI-15097. Remove targeted orchestration for patches (ncole)
Date Wed, 24 Feb 2016 15:08:19 GMT
AMBARI-15097. Remove targeted orchestration for patches (ncole)


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

Branch: refs/heads/trunk
Commit: 9873e69624ca429446312dfdb736f8b3d3d572cf
Parents: 4b5a250
Author: Nate Cole <ncole@hortonworks.com>
Authored: Thu Feb 18 14:36:26 2016 -0500
Committer: Nate Cole <ncole@hortonworks.com>
Committed: Fri Feb 19 08:31:44 2016 -0500

----------------------------------------------------------------------
 .../ambari/annotations/ExperimentalFeature.java |  7 +-
 .../ClusterStackVersionResourceProvider.java    | 27 +-------
 .../internal/UpgradeResourceProvider.java       | 32 +--------
 .../ambari/server/state/UpgradeContext.java     |  6 ++
 .../state/repository/VersionDefinitionXml.java  | 43 ++++++++----
 .../src/main/resources/version_definition.xsd   |  2 +-
 ...ClusterStackVersionResourceProviderTest.java |  6 +-
 .../state/repository/VersionDefinitionTest.java | 22 ++++++
 .../version_definition_test_all_services.xml    | 73 ++++++++++++++++++++
 9 files changed, 148 insertions(+), 70 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9873e696/ambari-server/src/main/java/org/apache/ambari/annotations/ExperimentalFeature.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/annotations/ExperimentalFeature.java
b/ambari-server/src/main/java/org/apache/ambari/annotations/ExperimentalFeature.java
index f29ed40..1d5ba0e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/annotations/ExperimentalFeature.java
+++ b/ambari-server/src/main/java/org/apache/ambari/annotations/ExperimentalFeature.java
@@ -35,5 +35,10 @@ public enum ExperimentalFeature {
    * The caching of current alert information in order to reduce overall load on
    * the database by preventing frequent updates and JPA entity invalidation.
    */
-  ALERT_CACHING
+  ALERT_CACHING,
+
+  /**
+   * Used for code that is targeted for patch upgrades
+   */
+  PATCH_UPGRADES
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/9873e696/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 ce5606e..07e62b3 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
@@ -73,14 +73,11 @@ import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.ComponentInfo;
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.MaintenanceState;
-import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.RepositoryVersionState;
 import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.ServiceInfo;
 import org.apache.ambari.server.state.ServiceOsSpecific;
 import org.apache.ambari.server.state.StackId;
-import org.apache.ambari.server.state.repository.AvailableService;
-import org.apache.ambari.server.state.repository.VersionDefinitionXml;
 import org.apache.ambari.server.utils.StageUtils;
 import org.apache.commons.lang.StringUtils;
 
@@ -418,27 +415,9 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou
 
       // determine services for the repo
       Set<String> serviceNames = new HashSet<>();
-      if (RepositoryType.STANDARD != repoVersionEnt.getType() && null != repoVersionEnt.getVersionXsd())
{
-        VersionDefinitionXml xml = null;
-        try {
-         xml = repoVersionEnt.getRepositoryXml();
-
-         Collection<AvailableService> available = xml.getAvailableServices(
-             ami.getStack(stackId.getStackName(), stackId.getStackVersion()));
-
-         // check if the service is part of the cluster
-         for (AvailableService as : available) {
-           if (cluster.getServices().containsKey(as.getName())) {
-             serviceNames.add(as.getName());
-           }
-         }
-
-        } catch (Exception e) {
-          String msg = String.format("Could not load repo xml for %s", repoVersionEnt.getDisplayName());
-          LOG.error(msg, e);
-          throw new SystemException (msg);
-        }
-      }
+
+      // !!! TODO for patch upgrades, we need to limit the serviceNames to those
+      // that are detailed for the repository
 
       // Populate with commands for host
       for (int i = 0; i < maxTasks && hostIterator.hasNext(); i++) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/9873e696/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
index 33b496f..860ba88 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
@@ -24,7 +24,6 @@ import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.VERSION;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.EnumSet;
 import java.util.HashMap;
@@ -85,15 +84,12 @@ import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Config;
 import org.apache.ambari.server.state.ConfigHelper;
 import org.apache.ambari.server.state.DesiredConfig;
-import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.ServiceInfo;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.StackInfo;
 import org.apache.ambari.server.state.UpgradeContext;
 import org.apache.ambari.server.state.UpgradeHelper;
 import org.apache.ambari.server.state.UpgradeHelper.UpgradeGroupHolder;
-import org.apache.ambari.server.state.repository.AvailableService;
-import org.apache.ambari.server.state.repository.VersionDefinitionXml;
 import org.apache.ambari.server.state.stack.ConfigUpgradePack;
 import org.apache.ambari.server.state.stack.PrereqCheckStatus;
 import org.apache.ambari.server.state.stack.UpgradePack;
@@ -718,31 +714,9 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
         RepositoryVersionEntity targetRepositoryVersion = s_repoVersionDAO.findByStackNameAndVersion(
             sourceStackId.getStackName(), version);
 
-        EnumSet<RepositoryType> serviceAware = EnumSet.of(RepositoryType.PATCH, RepositoryType.SERVICE);
-        if (serviceAware.contains(targetRepositoryVersion.getType())) {
-
-          VersionDefinitionXml xml = null;
-          StackInfo stackInfo = s_metaProvider.get().getStack(sourceStackId.getStackName(),
-              sourceStackId.getStackVersion());
-
-          try {
-            xml = targetRepositoryVersion.getRepositoryXml();
-          } catch (Exception e) {
-            throw new AmbariException(String.format("Could not load repository definition
for version %s", version));
-          }
-
-          if (null != xml) {
-            Collection<AvailableService> services = xml.getAvailableServices(stackInfo);
-
-            for (AvailableService available : services) {
-              supportedServices.add(available.getName());
-            }
-
-            if (!services.isEmpty()) {
-              scope = UpgradeScope.PARTIAL;
-            }
-          }
-        }
+        // !!! TODO check the repo_version for patch-ness and restrict the context
+        // to those services that require it.  Consult the version definition and add the
+        // service names to supportedServices
 
         targetStackId = targetRepositoryVersion.getStackId();
         break;

http://git-wip-us.apache.org/repos/asf/ambari/blob/9873e696/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
index 49b2b45..2f616e7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/UpgradeContext.java
@@ -24,6 +24,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.ambari.annotations.Experimental;
+import org.apache.ambari.annotations.ExperimentalFeature;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.stack.MasterHostResolver;
 import org.apache.ambari.server.state.stack.upgrade.Direction;
@@ -364,6 +366,7 @@ public class UpgradeContext {
    *
    * @param services  the set of specific services
    */
+  @Experimental(feature=ExperimentalFeature.PATCH_UPGRADES)
   public void setSupportedServices(Set<String> services) {
     m_supported = services;
   }
@@ -374,6 +377,7 @@ public class UpgradeContext {
    * @param serviceName the service name to check.
    * @return {@code true} when the service is supported
    */
+  @Experimental(feature=ExperimentalFeature.PATCH_UPGRADES)
   public boolean isServiceSupported(String serviceName) {
     if (m_supported.isEmpty() || m_supported.contains(serviceName)) {
       return true;
@@ -382,10 +386,12 @@ public class UpgradeContext {
     return false;
   }
 
+  @Experimental(feature=ExperimentalFeature.PATCH_UPGRADES)
   public void setScope(UpgradeScope scope) {
     m_scope = scope;
   }
 
+  @Experimental(feature=ExperimentalFeature.PATCH_UPGRADES)
   public boolean isScoped(UpgradeScope scope) {
     return m_scope.isScoped(scope);
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/9873e696/ambari-server/src/main/java/org/apache/ambari/server/state/repository/VersionDefinitionXml.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/repository/VersionDefinitionXml.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/VersionDefinitionXml.java
index a610bd0..93ac767 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/repository/VersionDefinitionXml.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/VersionDefinitionXml.java
@@ -100,27 +100,21 @@ public class VersionDefinitionXml {
    * @return a collection of AvailableServices used for web service consumption
    */
   public Collection<AvailableService> getAvailableServices(StackInfo stack) {
-    if (availableServices.isEmpty()) {
-      return Collections.emptyList();
-    }
-
     if (null == availableMap) {
       Map<String, ManifestService> manifests = buildManifest();
       availableMap = new HashMap<>();
 
-      for (AvailableServiceReference ref : availableServices) {
-        ManifestService ms = manifests.get(ref.serviceIdReference);
-        ServiceInfo service = stack.getService(ms.serviceName);
+      if (availableServices.isEmpty()) {
+        for (ManifestService ms : manifests.values()) {
+          addToAvailable(ms, stack, Collections.<String>emptySet());
+        }
 
-        if (!availableMap.containsKey(ms.serviceName)) {
-          String display = (null == service) ? ms.serviceName: service.getDisplayName();
+      } else {
+        for (AvailableServiceReference ref : availableServices) {
+          ManifestService ms = manifests.get(ref.serviceIdReference);
 
-          availableMap.put(ms.serviceName, new AvailableService(ms.serviceName, display));
+          addToAvailable(ms, stack, ref.components);
         }
-
-        AvailableService as = availableMap.get(ms.serviceName);
-        as.getVersions().add(new AvailableVersion(ms.version, ms.versionId,
-            buildComponents(service, ref.components)));
       }
     }
 
@@ -128,6 +122,27 @@ public class VersionDefinitionXml {
   }
 
   /**
+   * Helper method to use a {@link ManifestService} to generate the available services structure
+   * @param ms          the ManifestService instance
+   * @param stack       the stack object
+   * @param components  the set of components for the service
+   */
+  private void addToAvailable(ManifestService ms, StackInfo stack, Set<String> components)
{
+    ServiceInfo service = stack.getService(ms.serviceName);
+
+    if (!availableMap.containsKey(ms.serviceName)) {
+      String display = (null == service) ? ms.serviceName: service.getDisplayName();
+
+      availableMap.put(ms.serviceName, new AvailableService(ms.serviceName, display));
+    }
+
+    AvailableService as = availableMap.get(ms.serviceName);
+    as.getVersions().add(new AvailableVersion(ms.version, ms.versionId,
+        buildComponents(service, components)));
+  }
+
+
+  /**
    * @return the list of manifest services to a map for easier access.
    */
   private Map<String, ManifestService> buildManifest() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/9873e696/ambari-server/src/main/resources/version_definition.xsd
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/version_definition.xsd b/ambari-server/src/main/resources/version_definition.xsd
index 42035de..de0efd8 100644
--- a/ambari-server/src/main/resources/version_definition.xsd
+++ b/ambari-server/src/main/resources/version_definition.xsd
@@ -96,7 +96,7 @@
       </xs:documentation>
     </xs:annotation>
     <xs:sequence>
-      <xs:element name="service" maxOccurs="unbounded">
+      <xs:element name="service" minOccurs="0" maxOccurs="unbounded">
         <xs:complexType>
           <xs:sequence>
             <xs:element name="component" minOccurs="0" maxOccurs="unbounded" />

http://git-wip-us.apache.org/repos/asf/ambari/blob/9873e696/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java
index c6d0c57..69ed9d7 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java
@@ -43,6 +43,8 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 
+import org.apache.ambari.annotations.Experimental;
+import org.apache.ambari.annotations.ExperimentalFeature;
 import org.apache.ambari.server.Role;
 import org.apache.ambari.server.actionmanager.ActionManager;
 import org.apache.ambari.server.actionmanager.ExecutionCommandWrapper;
@@ -102,6 +104,7 @@ import org.easymock.IAnswer;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 
 import com.google.inject.AbstractModule;
@@ -355,7 +358,8 @@ public class ClusterStackVersionResourceProviderTest {
 
   }
 
-  @Test
+  @Experimental(feature=ExperimentalFeature.PATCH_UPGRADES)
+  @Ignore
   public void testCreateResourcesForPatch() throws Exception {
     Resource.Type type = Resource.Type.ClusterStackVersion;
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/9873e696/ambari-server/src/test/java/org/apache/ambari/server/state/repository/VersionDefinitionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/repository/VersionDefinitionTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/state/repository/VersionDefinitionTest.java
index 4ba5967..f2939c7 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/repository/VersionDefinitionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/repository/VersionDefinitionTest.java
@@ -23,6 +23,8 @@ import static org.junit.Assert.assertNotNull;
 import java.io.File;
 
 import org.apache.ambari.server.state.RepositoryType;
+import org.apache.ambari.server.state.ServiceInfo;
+import org.apache.ambari.server.state.StackInfo;
 import org.apache.commons.io.FileUtils;
 import org.junit.Test;
 
@@ -80,4 +82,24 @@ public class VersionDefinitionTest {
     assertEquals("HDP", xml.repositoryInfo.getOses().get(0).getRepos().get(0).getRepoName());
   }
 
+  @Test
+  public void testAllServices() throws Exception {
+
+    File f = new File("src/test/resources/version_definition_test_all_services.xml");
+
+    VersionDefinitionXml xml = VersionDefinitionXml.load(f.toURI().toURL());
+
+    StackInfo stack = new StackInfo() {
+      @Override
+      public ServiceInfo getService(String name) {
+        return null;
+      }
+    };
+
+    // the file does not define available services, which
+    assertEquals(4, xml.manifestServices.size());
+    assertEquals(3, xml.getAvailableServices(stack).size());
+  }
+
+
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/9873e696/ambari-server/src/test/resources/version_definition_test_all_services.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/version_definition_test_all_services.xml b/ambari-server/src/test/resources/version_definition_test_all_services.xml
new file mode 100644
index 0000000..7557f7a
--- /dev/null
+++ b/ambari-server/src/test/resources/version_definition_test_all_services.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0"?>
+<!--
+   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 regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
+<repository-version xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:noNamespaceSchemaLocation="version_definition.xsd">
+  
+  <release>
+    <type>PATCH</type>
+    <stack-id>HDP-2.3</stack-id>
+    <version>2.3.4.1</version>
+    <build>1234</build>
+    <compatible-with>2.3.4.[1-9]</compatible-with>
+    <release-notes>http://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.3.4/</release-notes>
+  </release>
+  
+  <manifest>
+    <service id="HDFS-271" name="HDFS" version="2.7.1" version-id="10" />
+    <service id="HIVE-110" name="HIVE" version="1.1.0" />
+    <service id="HIVE-200" name="HIVE" version="2.0.0" />
+    <service id="HBASE-899" name="HBASE" version="8.9.9" />
+  </manifest>
+  
+  <available-services />
+  
+  <repository-info>
+    <os family="redhat6">
+      <repo>
+        <baseurl>http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.3.0.0</baseurl>
+        <repoid>HDP-2.3</repoid>
+        <reponame>HDP</reponame>
+      </repo>
+      <repo>
+        <baseurl>http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/centos6</baseurl>
+        <repoid>HDP-UTILS-1.1.0.20</repoid>
+        <reponame>HDP-UTILS</reponame>
+      </repo>
+    </os>
+    <os family="redhat7">
+      <repo>
+        <baseurl>http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.3.0.0</baseurl>
+        <repoid>HDP-2.3</repoid>
+        <reponame>HDP</reponame>
+      </repo>
+      <repo>
+        <baseurl>http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/centos7</baseurl>
+        <repoid>HDP-UTILS-1.1.0.20</repoid>
+        <reponame>HDP-UTILS</reponame>
+      </repo>
+    </os>
+
+  </repository-info>
+  
+  <upgrade>
+    <configuration type="hdfs-site">
+      <set key="foo" value="bar" />
+    </configuration>
+  </upgrade>
+</repository-version>


Mime
View raw message