AMBARI-21671. Expose via API whether a service will participate in an upgrade (ncole)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f01c32ed Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f01c32ed Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f01c32ed Branch: refs/heads/feature-branch-AMBARI-21307 Commit: f01c32ed4c9e7ef0068aec741de5371e280ebccb Parents: 153e03a Author: Nate Cole <nc...@hortonworks.com> Authored: Mon Aug 7 10:38:50 2017 -0400 Committer: Nate Cole <nc...@hortonworks.com> Committed: Mon Aug 7 11:11:48 2017 -0400 ---------------------------------------------------------------------- .../ClusterStackVersionResourceProvider.java | 22 +++- .../org/apache/ambari/server/state/Service.java | 2 + .../apache/ambari/server/state/ServiceImpl.java | 10 +- .../state/repository/ClusterVersionSummary.java | 56 ++++++++ .../state/repository/ServiceVersionSummary.java | 79 ++++++++++++ .../state/repository/VersionDefinitionXml.java | 127 ++++++++++++++----- .../state/repository/VersionDefinitionTest.java | 55 +++++++- .../resources/version_definition_test_maint.xml | 2 +- .../version_definition_test_maint_partial.xml | 54 ++++++++ 9 files changed, 371 insertions(+), 36 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/f01c32ed/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 9ecea95..979124e 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 @@ -75,6 +75,7 @@ import org.apache.ambari.server.state.RepositoryVersionState; import org.apache.ambari.server.state.ServiceComponentHost; import org.apache.ambari.server.state.ServiceOsSpecific; import org.apache.ambari.server.state.StackId; +import org.apache.ambari.server.state.repository.ClusterVersionSummary; import org.apache.ambari.server.state.repository.VersionDefinitionXml; import org.apache.ambari.server.state.stack.upgrade.RepositoryVersionHelper; import org.apache.ambari.server.utils.StageUtils; @@ -104,6 +105,8 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou protected static final String CLUSTER_STACK_VERSION_VERSION_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "version"); protected static final String CLUSTER_STACK_VERSION_STATE_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "state"); protected static final String CLUSTER_STACK_VERSION_HOST_STATES_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "host_states"); + protected static final String CLUSTER_STACK_VERSION_REPO_SUMMARY_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "repository_summary"); + protected static final String CLUSTER_STACK_VERSION_REPOSITORY_VERSION_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "repository_version"); protected static final String CLUSTER_STACK_VERSION_STAGE_SUCCESS_FACTOR = PropertyHelper.getPropertyId("ClusterStackVersions", "success_factor"); @@ -143,7 +146,8 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou CLUSTER_STACK_VERSION_CLUSTER_NAME_PROPERTY_ID, CLUSTER_STACK_VERSION_STACK_PROPERTY_ID, CLUSTER_STACK_VERSION_VERSION_PROPERTY_ID, CLUSTER_STACK_VERSION_HOST_STATES_PROPERTY_ID, CLUSTER_STACK_VERSION_STATE_PROPERTY_ID, CLUSTER_STACK_VERSION_REPOSITORY_VERSION_PROPERTY_ID, - CLUSTER_STACK_VERSION_STAGE_SUCCESS_FACTOR, CLUSTER_STACK_VERSION_FORCE); + CLUSTER_STACK_VERSION_STAGE_SUCCESS_FACTOR, + CLUSTER_STACK_VERSION_FORCE, CLUSTER_STACK_VERSION_REPO_SUMMARY_PROPERTY_ID); private static Map<Type, String> keyPropertyIds = ImmutableMap.<Type, String> builder() .put(Type.Cluster, CLUSTER_STACK_VERSION_CLUSTER_NAME_PROPERTY_ID) @@ -264,8 +268,21 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou allStates.add(hostVersionEntity.getState()); } + ClusterVersionSummary versionSummary = null; + try { + VersionDefinitionXml vdf = repositoryVersion.getRepositoryXml(); + + versionSummary = vdf.getClusterSummary(cluster); + } catch (Exception e) { + throw new IllegalArgumentException( + String.format("Version %s is backed by a version definition, but it could not be parsed", repositoryVersion.getVersion()), e); + } + setResourceProperty(resource, CLUSTER_STACK_VERSION_CLUSTER_NAME_PROPERTY_ID, clusterName, requestedIds); setResourceProperty(resource, CLUSTER_STACK_VERSION_HOST_STATES_PROPERTY_ID, hostStates, requestedIds); + setResourceProperty(resource, CLUSTER_STACK_VERSION_REPO_SUMMARY_PROPERTY_ID, versionSummary, requestedIds); + + setResourceProperty(resource, CLUSTER_STACK_VERSION_ID_PROPERTY_ID, repositoryVersion.getId(), requestedIds); setResourceProperty(resource, CLUSTER_STACK_VERSION_STACK_PROPERTY_ID, repoVersionStackId.getStackName(), requestedIds); setResourceProperty(resource, CLUSTER_STACK_VERSION_VERSION_PROPERTY_ID, repoVersionStackId.getStackVersion(), requestedIds); @@ -536,7 +553,8 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou // !!! limit the serviceNames to those that are detailed for the repository. // TODO packages don't have component granularity if (RepositoryType.STANDARD != repoVersionEnt.getType()) { - serviceNames.addAll(desiredVersionDefinition.getAvailableServiceNames()); + ClusterVersionSummary clusterSummary = desiredVersionDefinition.getClusterSummary(cluster); + serviceNames.addAll(clusterSummary.getAvailableServiceNames()); } // Populate with commands for host http://git-wip-us.apache.org/repos/asf/ambari/blob/f01c32ed/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java b/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java index 8651fee..65189ca 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java @@ -28,6 +28,8 @@ public interface Service { String getName(); + String getDisplayName(); + long getClusterId(); Cluster getCluster(); http://git-wip-us.apache.org/repos/asf/ambari/blob/f01c32ed/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java index 4ed0429..0247774 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java @@ -52,6 +52,7 @@ import org.apache.ambari.server.orm.entities.ServiceDesiredStateEntity; import org.apache.ambari.server.orm.entities.ServiceDesiredStateEntityPK; import org.apache.ambari.server.orm.entities.StackEntity; import org.apache.ambari.server.serveraction.kerberos.Component; +import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -93,6 +94,7 @@ public class ServiceImpl implements Service { * The name of the service. */ private final String serviceName; + private final String displayName; @AssistedInject ServiceImpl(@Assisted Cluster cluster, @Assisted String serviceName, @@ -127,8 +129,8 @@ public class ServiceImpl implements Service { ServiceInfo sInfo = ambariMetaInfo.getService(stackId.getStackName(), stackId.getStackVersion(), serviceName); + displayName = sInfo.getDisplayName(); isClientOnlyService = sInfo.isClientOnlyService(); - isCredentialStoreSupported = sInfo.isCredentialStoreSupported(); isCredentialStoreRequired = sInfo.isCredentialStoreRequired(); @@ -177,6 +179,7 @@ public class ServiceImpl implements Service { isClientOnlyService = sInfo.isClientOnlyService(); isCredentialStoreSupported = sInfo.isCredentialStoreSupported(); isCredentialStoreRequired = sInfo.isCredentialStoreRequired(); + displayName = sInfo.getDisplayName(); } @@ -208,6 +211,11 @@ public class ServiceImpl implements Service { } @Override + public String getDisplayName() { + return StringUtils.isBlank(displayName) ? serviceName : displayName; + } + + @Override public long getClusterId() { return cluster.getClusterId(); } http://git-wip-us.apache.org/repos/asf/ambari/blob/f01c32ed/ambari-server/src/main/java/org/apache/ambari/server/state/repository/ClusterVersionSummary.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/repository/ClusterVersionSummary.java b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/ClusterVersionSummary.java new file mode 100644 index 0000000..e9d9920 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/ClusterVersionSummary.java @@ -0,0 +1,56 @@ +/* + * 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. + */ +package org.apache.ambari.server.state.repository; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.codehaus.jackson.annotate.JsonIgnore; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * For a version, collects summary information for a cluster. + */ +public class ClusterVersionSummary { + + @JsonProperty("services") + private Map<String, ServiceVersionSummary> m_services; + + private transient Set<String> m_available = new HashSet<>(); + + ClusterVersionSummary(Map<String, ServiceVersionSummary> services) { + m_services = services; + + for (Map.Entry<String, ServiceVersionSummary> entry : services.entrySet()) { + if (entry.getValue().isUpgrade()) { + m_available.add(entry.getKey()); + } + } + } + + /** + * @return service names that should participate in an upgrade, based on + * the VDF contents. + */ + @JsonIgnore + public Set<String> getAvailableServiceNames() { + return m_available; + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/f01c32ed/ambari-server/src/main/java/org/apache/ambari/server/state/repository/ServiceVersionSummary.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/repository/ServiceVersionSummary.java b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/ServiceVersionSummary.java new file mode 100644 index 0000000..29505c8 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/ServiceVersionSummary.java @@ -0,0 +1,79 @@ +/* + * 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. + */ +package org.apache.ambari.server.state.repository; + +import org.codehaus.jackson.annotate.JsonIgnore; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * Used to hold information about Service's ability to upgrade for a repository version. + */ +public class ServiceVersionSummary { + + @JsonProperty("display_name") + private String m_displayName; + + @JsonProperty("version") + private String m_version; + + @JsonProperty("release_version") + private String m_releaseVersion; + + @JsonProperty("upgrade") + private boolean m_upgrade = false; + + ServiceVersionSummary(String displayName) { + m_displayName = displayName; + } + + /** + * Sets the version information + * + * @param binaryVersion the binary version of the service + * @param releaseVersion the release version of the service + */ + void setVersions(String binaryVersion, String releaseVersion) { + m_version = binaryVersion; + m_releaseVersion = releaseVersion; + } + + @JsonIgnore + /** + * @return {@code true} if the service will be included in an upgrade + */ + public boolean isUpgrade() { + return m_upgrade; + } + + /** + * @param upgrade {@code true} if the service will be included in an upgrade + */ + public void setUpgrade(boolean upgrade) { + m_upgrade = upgrade; + } + + /** + * @return the relase version field + */ + @JsonIgnore + public String getReleaseVersion() { + return m_releaseVersion; + } + + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/f01c32ed/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 f48c723..45d8e8e 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 @@ -47,14 +47,18 @@ import javax.xml.transform.stream.StreamSource; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; +import org.apache.ambari.server.AmbariException; +import org.apache.ambari.server.state.Cluster; import org.apache.ambari.server.state.ComponentInfo; import org.apache.ambari.server.state.RepositoryType; +import org.apache.ambari.server.state.Service; 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.repository.AvailableVersion.Component; import org.apache.ambari.server.state.stack.RepositoryXml; import org.apache.ambari.server.state.stack.RepositoryXml.Os; +import org.apache.ambari.server.utils.VersionUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; @@ -67,7 +71,6 @@ public class VersionDefinitionXml { public static String SCHEMA_LOCATION = "version_definition.xsd"; - /** * Release details. */ @@ -114,6 +117,7 @@ public class VersionDefinitionXml { private Map<String, String> m_packageVersions = null; + /** * @param stack the stack info needed to lookup service and component display names * @return a collection of AvailableServices used for web service consumption. This @@ -163,6 +167,7 @@ public class VersionDefinitionXml { } } + /** * Gets if the version definition was built as the default for a stack * @return {@code true} if default for a stack @@ -225,7 +230,97 @@ public class VersionDefinitionXml { return m_packageVersions.get(osFamily); } + /** + * Returns the XML representation of this instance. + */ + public String toXml() throws Exception { + + JAXBContext ctx = JAXBContext.newInstance(VersionDefinitionXml.class); + Marshaller marshaller = ctx.createMarshaller(); + SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + + InputStream xsdStream = VersionDefinitionXml.class.getClassLoader().getResourceAsStream(xsdLocation); + + if (null == xsdStream) { + throw new Exception(String.format("Could not load XSD identified by '%s'", xsdLocation)); + } + + try { + Schema schema = factory.newSchema(new StreamSource(xsdStream)); + marshaller.setSchema(schema); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + marshaller.setProperty("jaxb.noNamespaceSchemaLocation", xsdLocation); + + StringWriter w = new StringWriter(); + marshaller.marshal(this, w); + + return w.toString(); + } finally { + IOUtils.closeQuietly(xsdStream); + } + } + + /** + * Gets a summary for cluster given the version information in this version. + * @param cluster the cluster by which to iterate services + * @return a summary instance + * @throws AmbariException + */ + public ClusterVersionSummary getClusterSummary(Cluster cluster) throws AmbariException { + + Map<String, ManifestService> manifests = buildManifestByService(); + Set<String> available = getAvailableServiceNames(); + + available = available.isEmpty() ? manifests.keySet() : available; + + Map<String, ServiceVersionSummary> summaries = new HashMap<>(); + for (String serviceName : available) { + Service service = cluster.getServices().get(serviceName); + if (null == service) { + // !!! service is not installed + continue; + } + + ServiceVersionSummary summary = new ServiceVersionSummary(service.getDisplayName()); + summaries.put(service.getName(), summary); + + String serviceVersion = service.getDesiredRepositoryVersion().getVersion(); + + // !!! currently only one version is supported (unique service names) + ManifestService manifest = manifests.get(serviceName); + + summary.setVersions(manifest.version, StringUtils.isEmpty(manifest.releaseVersion) ? + release.version : manifest.releaseVersion); + + // !!! installed service already meets the release version, then nothing to upgrade + // !!! TODO should this be using the release compatible-with field? + if (VersionUtils.compareVersions(summary.getReleaseVersion(), serviceVersion, 4) > 0) { + summary.setUpgrade(true); + } + } + + return new ClusterVersionSummary(summaries); + } + + /** + * Structures the manifest by service name. + * <p/> + * !!! WARNING. This is currently based on the assumption that there is one and only + * one version for a service in the VDF. This may have to change in the future. + * </p> + * @return + */ + private Map<String, ManifestService> buildManifestByService() { + Map<String, ManifestService> manifests = new HashMap<>(); + + for (ManifestService manifest : manifestServices) { + if (!manifests.containsKey(manifest.serviceName)) { + manifests.put(manifest.serviceName, manifest); + } + } + return manifests; + } /** * Helper method to use a {@link ManifestService} to generate the available services structure @@ -281,36 +376,6 @@ public class VersionDefinitionXml { } /** - * Returns the XML representation of this instance. - */ - public String toXml() throws Exception { - - JAXBContext ctx = JAXBContext.newInstance(VersionDefinitionXml.class); - Marshaller marshaller = ctx.createMarshaller(); - SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - - InputStream xsdStream = VersionDefinitionXml.class.getClassLoader().getResourceAsStream(xsdLocation); - - if (null == xsdStream) { - throw new Exception(String.format("Could not load XSD identified by '%s'", xsdLocation)); - } - - try { - Schema schema = factory.newSchema(new StreamSource(xsdStream)); - marshaller.setSchema(schema); - marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); - marshaller.setProperty("jaxb.noNamespaceSchemaLocation", xsdLocation); - - StringWriter w = new StringWriter(); - marshaller.marshal(this, w); - - return w.toString(); - } finally { - IOUtils.closeQuietly(xsdStream); - } - } - - /** * Parses a URL for a definition XML file into the object graph. * @param url the URL to load. Can be a file URL reference also. * @return the definition http://git-wip-us.apache.org/repos/asf/ambari/blob/f01c32ed/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 89e8016..8433518 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 @@ -17,6 +17,9 @@ */ package org.apache.ambari.server.state.repository; +import static org.easymock.EasyMock.createNiceMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -29,14 +32,19 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.ambari.server.orm.entities.RepositoryVersionEntity; +import org.apache.ambari.server.state.Cluster; import org.apache.ambari.server.state.ComponentInfo; import org.apache.ambari.server.state.RepositoryType; +import org.apache.ambari.server.state.Service; import org.apache.ambari.server.state.ServiceInfo; import org.apache.ambari.server.state.StackInfo; import org.apache.ambari.server.state.stack.RepositoryXml; import org.apache.commons.io.FileUtils; import org.junit.Test; +import com.google.common.collect.ImmutableMap; + /** * Tests for repository definitions. */ @@ -347,7 +355,7 @@ public class VersionDefinitionTest { assertNotNull(hdfs); assertNotNull(hive); - assertEquals("2.3.3", hdfs.releaseVersion); + assertEquals("2.3.4.0", hdfs.releaseVersion); assertNull(hive.releaseVersion); StackInfo stack = new StackInfo() { @@ -379,6 +387,51 @@ public class VersionDefinitionTest { assertTrue("Found available version for HIVE", found); } + @Test + public void testAvailableFull() throws Exception { + + Cluster cluster = createNiceMock(Cluster.class); + RepositoryVersionEntity repositoryVersion = createNiceMock(RepositoryVersionEntity.class); + expect(repositoryVersion.getVersion()).andReturn("2.3.4.0").atLeastOnce(); + + Service serviceHdfs = createNiceMock(Service.class); + expect(serviceHdfs.getName()).andReturn("HDFS").atLeastOnce(); + expect(serviceHdfs.getDisplayName()).andReturn("HDFS").atLeastOnce(); + expect(serviceHdfs.getDesiredRepositoryVersion()).andReturn(repositoryVersion).atLeastOnce(); + + Service serviceHBase = createNiceMock(Service.class); + expect(serviceHBase.getName()).andReturn("HBASE").atLeastOnce(); + expect(serviceHBase.getDisplayName()).andReturn("HBase").atLeastOnce(); + expect(serviceHBase.getDesiredRepositoryVersion()).andReturn(repositoryVersion).atLeastOnce(); + + // !!! should never be accessed as it's not in any VDF + Service serviceAMS = createNiceMock(Service.class); + + expect(cluster.getServices()).andReturn(ImmutableMap.<String, Service>builder() + .put("HDFS", serviceHdfs) + .put("HBASE", serviceHBase) + .put("AMBARI_METRICS", serviceAMS).build()).atLeastOnce(); + + + replay(cluster, repositoryVersion, serviceHdfs, serviceHBase); + + File f = new File("src/test/resources/version_definition_test_all_services.xml"); + VersionDefinitionXml xml = VersionDefinitionXml.load(f.toURI().toURL()); + ClusterVersionSummary summary = xml.getClusterSummary(cluster); + assertEquals(2, summary.getAvailableServiceNames().size()); + + f = new File("src/test/resources/version_definition_test_maint.xml"); + xml = VersionDefinitionXml.load(f.toURI().toURL()); + summary = xml.getClusterSummary(cluster); + assertEquals(0, summary.getAvailableServiceNames().size()); + + f = new File("src/test/resources/version_definition_test_maint_partial.xml"); + xml = VersionDefinitionXml.load(f.toURI().toURL()); + summary = xml.getClusterSummary(cluster); + assertEquals(1, summary.getAvailableServiceNames().size()); + + } + private static ServiceInfo makeService(final String name) { return new ServiceInfo() { http://git-wip-us.apache.org/repos/asf/ambari/blob/f01c32ed/ambari-server/src/test/resources/version_definition_test_maint.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/resources/version_definition_test_maint.xml b/ambari-server/src/test/resources/version_definition_test_maint.xml index ac21045..430182c 100644 --- a/ambari-server/src/test/resources/version_definition_test_maint.xml +++ b/ambari-server/src/test/resources/version_definition_test_maint.xml @@ -29,7 +29,7 @@ </release> <manifest> - <service id="HDFS-271" name="HDFS" version="2.7.1" version-id="10" release-version="2.3.3" /> + <service id="HDFS-271" name="HDFS" version="2.7.1" version-id="10" release-version="2.3.4.0" /> <service id="HIVE-200" name="HIVE" version="2.0.0" /> <service id="HIVE-110" name="HIVE" version="1.1.0" release-version="1.0.9" /> <service id="HBASE-899" name="HBASE" version="8.9.9" /> http://git-wip-us.apache.org/repos/asf/ambari/blob/f01c32ed/ambari-server/src/test/resources/version_definition_test_maint_partial.xml ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/resources/version_definition_test_maint_partial.xml b/ambari-server/src/test/resources/version_definition_test_maint_partial.xml new file mode 100644 index 0000000..c8692c9 --- /dev/null +++ b/ambari-server/src/test/resources/version_definition_test_maint_partial.xml @@ -0,0 +1,54 @@ +<?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>MAINT</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" release-version="2.3.4.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> + <unique>true</unique> + </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> + <unique>false</unique> + </repo> + </os> + </repository-info> +</repository-version>