You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by be...@apache.org on 2018/03/26 20:19:19 UTC
[ambari] branch branch-feature-AMBARI-14714 updated: [AMBARI-23032]
Support for Blueprint exports for MPack-based clusters (#716)
This is an automated email from the ASF dual-hosted git repository.
benyoka pushed a commit to branch branch-feature-AMBARI-14714
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/branch-feature-AMBARI-14714 by this push:
new 17e3a1d [AMBARI-23032] Support for Blueprint exports for MPack-based clusters (#716)
17e3a1d is described below
commit 17e3a1dbb284d0c70b3375bc3239da72e84723a1
Author: benyoka <be...@users.noreply.github.com>
AuthorDate: Mon Mar 26 22:19:16 2018 +0200
[AMBARI-23032] Support for Blueprint exports for MPack-based clusters (#716)
* AMBARI-23032 fix execptions, export cluster settings and single mpacks (benyoka)
* AMBARI-23032 fix review comments (benyoka)
* AMBARI-23032 better method naming (benyoka)
* AMBARI-23032 fix review comments #2 (benyoka)
* AMBARI-23032 fix review comments #3 (benyoka)
* AMBARI-23032 fix swallowed exceptions during mpack installation
* AMBARI-23032 prepare for mpack info in component
* AMBARI-23032 fix exceptions during installation and blueprint export (benyoka)
* AMBARI-23032 revert accidental changes (benyoka)
* AMBARI-23032 revert accidental changes #2 (benyoka)
* AMBARI-23032 fixed a number of unit tests (benyoka)
* AMBARI-23032 make sure Blueprints tag is exported (benyoka)
* Merge branch-feature-AMBARI-14714
* AMBARI-23032 fix import error (benyoka)
---
.../api/query/render/ClusterBlueprintRenderer.java | 55 +++++++++++++++-----
.../controller/AmbariManagementController.java | 8 +++
.../controller/AmbariManagementControllerImpl.java | 8 +++
.../ClusterStackVersionResourceProvider.java | 17 +++++--
.../internal/ComponentResourceProvider.java | 10 ++--
.../internal/ExportBlueprintRequest.java | 58 +++++++++-------------
.../ambari/server/topology/BlueprintFactory.java | 2 +-
.../ambari/server/topology/BlueprintImpl.java | 15 ++----
.../apache/ambari/server/topology/Component.java | 31 ++++++++----
.../ambari/server/topology/HostGroupImpl.java | 9 +++-
.../ambari/server/topology/ResolvedComponent.java | 2 +-
.../server/topology/StackComponentResolver.java | 11 ++--
.../query/render/ClusterBlueprintRendererTest.java | 31 +++++++++---
.../ActiveWidgetLayoutResourceProviderTest.java | 3 ++
.../internal/ExportBlueprintRequestTest.java | 4 ++
.../UserAuthorizationResourceProviderTest.java | 4 ++
.../ambari/server/topology/AmbariContextTest.java | 6 +--
17 files changed, 177 insertions(+), 97 deletions(-)
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRenderer.java b/ambari-server/src/main/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRenderer.java
index 493ea0e..a9144f4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRenderer.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRenderer.java
@@ -46,7 +46,10 @@ import org.apache.ambari.server.controller.internal.ArtifactResourceProvider;
import org.apache.ambari.server.controller.internal.BlueprintConfigurationProcessor;
import org.apache.ambari.server.controller.internal.BlueprintResourceProvider;
import org.apache.ambari.server.controller.internal.ClusterSettingResourceProvider;
+import org.apache.ambari.server.controller.internal.ClusterStackVersionResourceProvider;
+import org.apache.ambari.server.controller.internal.ComponentResourceProvider;
import org.apache.ambari.server.controller.internal.ExportBlueprintRequest;
+import org.apache.ambari.server.controller.internal.HostComponentResourceProvider;
import org.apache.ambari.server.controller.internal.RequestImpl;
import org.apache.ambari.server.controller.internal.ResourceImpl;
import org.apache.ambari.server.controller.spi.ClusterController;
@@ -59,7 +62,6 @@ import org.apache.ambari.server.controller.spi.SystemException;
import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
import org.apache.ambari.server.controller.utilities.PredicateBuilder;
import org.apache.ambari.server.state.SecurityType;
-import org.apache.ambari.server.state.StackId;
import org.apache.ambari.server.topology.AmbariContext;
import org.apache.ambari.server.topology.ClusterTopology;
import org.apache.ambari.server.topology.ClusterTopologyImpl;
@@ -112,13 +114,23 @@ public class ClusterBlueprintRenderer extends BaseRenderer implements Renderer {
TreeNode<Set<String>> serviceGroupNode = ensureChild(resultTree, Resource.Type.ServiceGroup);
TreeNode<Set<String>> serviceNode = ensureChild(serviceGroupNode, Resource.Type.Service);
ensureChild(serviceNode, Resource.Type.Component,
- "ServiceComponentInfo/cluster_name",
- "ServiceComponentInfo/service_name",
- "ServiceComponentInfo/component_name",
- "ServiceComponentInfo/recovery_enabled");
+ ComponentResourceProvider.COMPONENT_CLUSTER_NAME_PROPERTY_ID,
+ ComponentResourceProvider.COMPONENT_SERVICE_NAME_PROPERTY_ID,
+ ComponentResourceProvider.COMPONENT_SERVICE_TYPE_PROPERTY_ID,
+ ComponentResourceProvider.COMPONENT_COMPONENT_NAME_PROPERTY_ID,
+ ComponentResourceProvider.COMPONENT_RECOVERY_ENABLED_ID);
+
+ ensureChild(resultTree, Resource.Type.ClusterStackVersion,
+ ClusterStackVersionResourceProvider.CLUSTER_STACK_VERSION_STACK_PROPERTY_ID,
+ ClusterStackVersionResourceProvider.CLUSTER_STACK_VERSION_VERSION_PROPERTY_ID,
+ ClusterStackVersionResourceProvider.CLUSTER_STACK_VERSION_MPACK_URI_PROPERTY_ID);
TreeNode<Set<String>> hostNode = ensureChild(resultTree, Resource.Type.Host);
- ensureChild(hostNode, Resource.Type.HostComponent, "HostRoles/component_name");
+ ensureChild(hostNode, Resource.Type.HostComponent,
+ HostComponentResourceProvider.HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID,
+ HostComponentResourceProvider.HOST_COMPONENT_SERVICE_NAME_PROPERTY_ID,
+ HostComponentResourceProvider.HOST_COMPONENT_SERVICE_TYPE_PROPERTY_ID,
+ HostComponentResourceProvider.HOST_COMPONENT_SERVICE_GROUP_NAME_PROPERTY_ID);
return resultTree;
}
@@ -191,11 +203,7 @@ public class ClusterBlueprintRenderer extends BaseRenderer implements Renderer {
BlueprintConfigurationProcessor configProcessor = new BlueprintConfigurationProcessor(topology);
configProcessor.doUpdateForBlueprintExport();
- Set<StackId> stackIds = topology.getStackIds();
- // TODO: mpacks should come from service groups once https://github.com/apache/ambari/pull/234 will be committed
- Collection<Map<String, String>> mpackInstances = stackIds.stream().
- map( stackId -> ImmutableMap.of("name", stackId.getStackName(), "version", stackId.getStackVersion())).collect(toList());
- blueprintResource.setProperty(BlueprintResourceProvider.MPACK_INSTANCES_PROPERTY_ID, mpackInstances);
+ addMpackInstances(blueprintResource, clusterNode);
if (topology.isClusterKerberosEnabled()) {
Map<String, Object> securityConfigMap = new LinkedHashMap<>();
@@ -212,6 +220,12 @@ public class ClusterBlueprintRenderer extends BaseRenderer implements Renderer {
}
blueprintResource.setProperty(BlueprintResourceProvider.BLUEPRINT_SECURITY_PROPERTY_ID, securityConfigMap);
}
+ // This is needed so that exported 3.0+ blueprints have a "Blueprints" section in all cases (previously
+ // Blueprints/stack_name, Blueprints/stack_version provided this but in 3.0 we have mpacks instead of stacks.)
+ else {
+ blueprintResource.setProperty(BlueprintResourceProvider.BLUEPRINT_SECURITY_PROPERTY_ID,
+ ImmutableMap.of(SecurityConfigurationFactory.TYPE_PROPERTY_ID, SecurityType.NONE.name()));
+ }
List<Map<String, Object>> groupList = formatGroupsAsList(topology);
blueprintResource.setProperty("host_groups", groupList);
@@ -227,6 +241,22 @@ public class ClusterBlueprintRenderer extends BaseRenderer implements Renderer {
return blueprintResource;
}
+ /**
+ * Adds mpack instances to the exported blueprint resource.
+ */
+ private void addMpackInstances(Resource blueprintResource, TreeNode<Resource> clusterNode) {
+ List<Map<String, Object>> mpackInstances = clusterNode.getChild("stack_versions").getChildren().stream().map(
+ child -> {
+ Map<String, Object> stackVersionProps = child.getObject().getPropertiesMap().get("ClusterStackVersions");
+ return ImmutableMap.of(
+ "name", stackVersionProps.get("stack"),
+ "version", stackVersionProps.get("version"),
+ "url", stackVersionProps.get("mpack_uri"));
+ }).
+ collect(toList());
+ blueprintResource.setProperty(BlueprintResourceProvider.MPACK_INSTANCES_PROPERTY_ID, mpackInstances);
+ }
+
/***
* Constructs the Settings object of the following form:
* "settings": [ {
@@ -457,8 +487,7 @@ public class ClusterBlueprintRenderer extends BaseRenderer implements Renderer {
protected ClusterTopology createClusterTopology(TreeNode<Resource> clusterNode)
throws InvalidTopologyTemplateException, InvalidTopologyException {
-
- return new ClusterTopologyImpl(new AmbariContext(), new ExportBlueprintRequest(clusterNode));
+ return new ClusterTopologyImpl(controller.getAmbariContext(), new ExportBlueprintRequest(clusterNode));
}
/**
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
index 2f90a2b..134a445 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
@@ -75,6 +75,7 @@ import org.apache.ambari.server.state.State;
import org.apache.ambari.server.state.configgroup.ConfigGroupFactory;
import org.apache.ambari.server.state.quicklinksprofile.QuickLinkVisibilityController;
import org.apache.ambari.server.state.scheduler.RequestExecutionFactory;
+import org.apache.ambari.server.topology.AmbariContext;
/**
@@ -565,6 +566,13 @@ public interface AmbariManagementController {
AmbariMetaInfo getAmbariMetaInfo();
/**
+ * Get the ambari context for this management controller.
+ *
+ * @return the ambari context
+ */
+ AmbariContext getAmbariContext();
+
+ /**
* Get the service factory for this management controller.
*
* @return the service factory
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index 3b07476..dd580a9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -236,6 +236,7 @@ import org.apache.ambari.server.state.svccomphost.ServiceComponentHostOpSucceede
import org.apache.ambari.server.state.svccomphost.ServiceComponentHostStartEvent;
import org.apache.ambari.server.state.svccomphost.ServiceComponentHostStopEvent;
import org.apache.ambari.server.state.svccomphost.ServiceComponentHostUpgradeEvent;
+import org.apache.ambari.server.topology.AmbariContext;
import org.apache.ambari.server.topology.Setting;
import org.apache.ambari.server.topology.TopologyDeleteFormer;
import org.apache.ambari.server.utils.SecretReference;
@@ -357,6 +358,8 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
private CredentialStoreService credentialStoreService;
@Inject
private SettingDAO settingDAO;
+ @Inject
+ private AmbariContext ambariContext;
private MaintenanceStateHelper maintenanceStateHelper;
@@ -5193,6 +5196,11 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
}
@Override
+ public AmbariContext getAmbariContext() {
+ return ambariContext;
+ }
+
+ @Override
public ServiceGroupFactory getServiceGroupFactory() {
return serviceGroupFactory;
}
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 475c1b4..99be7e5 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
@@ -114,8 +114,9 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou
protected static final String CLUSTER_STACK_VERSION_ID_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "id");
protected static final String CLUSTER_STACK_VERSION_CLUSTER_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "cluster_name");
- protected static final String CLUSTER_STACK_VERSION_STACK_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "stack");
- protected static final String CLUSTER_STACK_VERSION_VERSION_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "version");
+ public static final String CLUSTER_STACK_VERSION_STACK_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "stack");
+ public static final String CLUSTER_STACK_VERSION_VERSION_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "version");
+ public static final String CLUSTER_STACK_VERSION_MPACK_URI_PROPERTY_ID = PropertyHelper.getPropertyId("ClusterStackVersions", "mpack_uri");
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");
@@ -159,9 +160,9 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou
private static Set<String> propertyIds = Sets.newHashSet(CLUSTER_STACK_VERSION_ID_PROPERTY_ID,
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_VERSION_PROPERTY_ID, CLUSTER_STACK_VERSION_MPACK_URI_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_REPO_SUMMARY_PROPERTY_ID,
CLUSTER_STACK_VERSION_REPO_SUPPORTS_REVERT, CLUSTER_STACK_VERSION_REPO_REVERT_UPGRADE_ID);
@@ -297,6 +298,12 @@ public class ClusterStackVersionResourceProvider extends AbstractControllerResou
StackEntity repoVersionStackEntity = repositoryVersion.getStack();
StackId repoVersionStackId = new StackId(repoVersionStackEntity);
+ AmbariMetaInfo ami = getManagementController().getAmbariMetaInfo();
+ ami.getMpacks().stream().
+ filter(mp -> mp.getName().equals(repoVersionStackId.getStackName()) && mp.getVersion().equals(repoVersionStackId.getStackVersion())).
+ findFirst().
+ ifPresent(mpack -> setResourceProperty(resource, CLUSTER_STACK_VERSION_MPACK_URI_PROPERTY_ID, mpack.getMpackUri(), requestedIds));
+
try {
MpackHostStateDAO mpackHostStateDAO = mpackHostStateDAOProvider.get();
List<MpackHostStateEntity> mpackInstallStates = Lists.newArrayList();
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
index 695eb58..efc4462 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
@@ -90,14 +90,14 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
// Components
protected static final String COMPONENT_CLUSTER_ID_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "cluster_id";
- protected static final String COMPONENT_CLUSTER_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "cluster_name";
+ public static final String COMPONENT_CLUSTER_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "cluster_name";
protected static final String COMPONENT_SERVICE_GROUP_ID_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "service_group_id";
protected static final String COMPONENT_SERVICE_GROUP_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "service_group_name";
protected static final String COMPONENT_SERVICE_ID_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "service_id";
- protected static final String COMPONENT_SERVICE_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "service_name";
- protected static final String COMPONENT_SERVICE_TYPE_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "service_type";
+ public static final String COMPONENT_SERVICE_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "service_name";
+ public static final String COMPONENT_SERVICE_TYPE_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "service_type";
protected static final String COMPONENT_COMPONENT_ID_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "id";
- protected static final String COMPONENT_COMPONENT_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "component_name";
+ public static final String COMPONENT_COMPONENT_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "component_name";
protected static final String COMPONENT_COMPONENT_TYPE_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "component_type";
protected static final String COMPONENT_DISPLAY_NAME_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "display_name";
protected static final String COMPONENT_STATE_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "state";
@@ -110,7 +110,7 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
protected static final String COMPONENT_INIT_COUNT_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "init_count";
protected static final String COMPONENT_UNKNOWN_COUNT_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "unknown_count";
protected static final String COMPONENT_INSTALL_FAILED_COUNT_PROPERTY_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "install_failed_count";
- protected static final String COMPONENT_RECOVERY_ENABLED_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "recovery_enabled";
+ public static final String COMPONENT_RECOVERY_ENABLED_ID = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "recovery_enabled";
protected static final String COMPONENT_DESIRED_STACK = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "desired_stack";
protected static final String COMPONENT_DESIRED_VERSION = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "desired_version";
protected static final String COMPONENT_REPOSITORY_STATE = RESPONSE_KEY + PropertyHelper.EXTERNAL_PATH_SEP + "repository_state";
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequest.java
index 151d9a7..14179f4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequest.java
@@ -19,6 +19,8 @@
package org.apache.ambari.server.controller.internal;
+import static java.util.stream.Collectors.toMap;
+
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
@@ -26,7 +28,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -34,6 +35,7 @@ import org.apache.ambari.server.StackAccessException;
import org.apache.ambari.server.api.util.TreeNode;
import org.apache.ambari.server.controller.AmbariManagementController;
import org.apache.ambari.server.controller.AmbariServer;
+import org.apache.ambari.server.controller.RootComponent;
import org.apache.ambari.server.controller.spi.Resource;
import org.apache.ambari.server.controller.utilities.PropertyHelper;
import org.apache.ambari.server.state.DesiredConfig;
@@ -67,6 +69,7 @@ public class ExportBlueprintRequest implements TopologyRequest {
private Configuration configuration;
//todo: Should this map be represented by a new class?
private Map<String, HostGroupInfo> hostGroupInfo = new HashMap<>();
+ private Map<String, StackId> serviceGroupToMpack = new HashMap<>();
public ExportBlueprintRequest(TreeNode<Resource> clusterNode) throws InvalidTopologyTemplateException {
@@ -76,6 +79,10 @@ public class ExportBlueprintRequest implements TopologyRequest {
clusterId = Long.valueOf(String.valueOf(clusterResource.getPropertyValue(
ClusterResourceProvider.CLUSTER_ID_PROPERTY_ID)));
+ // create service group to mpack map
+ serviceGroupToMpack = clusterNode.getChild("servicegroups").getChildren().stream().
+ map(tn -> tn.getObject().getPropertiesMap().get(ServiceGroupResourceProvider.RESPONSE_KEY)).
+ collect(toMap(m -> m.get("service_group_name").toString(), m -> new StackId(m.get("version").toString())));
createConfiguration(clusterNode);
//todo: should be parsing Configuration from the beginning
@@ -128,15 +135,9 @@ public class ExportBlueprintRequest implements TopologyRequest {
Collection<HostGroup> hostGroups = new ArrayList<>();
for (ExportedHostGroup exportedHostGroup : exportedHostGroups) {
-
- // create Component using component name
- List<Component> componentList = new ArrayList<>();
- for (String component : exportedHostGroup.getComponents()) {
- componentList.add(new Component(component));
- }
-
- hostGroups.add(new HostGroupImpl(exportedHostGroup.getName(), componentList,
- exportedHostGroup.getConfiguration(), String.valueOf(exportedHostGroup.getCardinality())));
+ hostGroups.add(new HostGroupImpl(exportedHostGroup.getName(),
+ exportedHostGroup.getComponents(), exportedHostGroup.getConfiguration(),
+ String.valueOf(exportedHostGroup.getCardinality())));
}
ImmutableSet<StackId> stackIds = ImmutableSet.of(stack.getStackId());
blueprint = new BlueprintImpl(bpName, hostGroups, stackIds, Collections.emptySet(), configuration, null, null);
@@ -218,31 +219,11 @@ public class ExportBlueprintRequest implements TopologyRequest {
group.setName("host_group_" + count++);
group.addHost(hostName);
}
- processHostGroupComponents(group);
}
-
return mapHostGroups.values();
}
- /**
- * Process host group component information for a specific host.
- *
- * @param group host group instance
- *
- * @return list of component names for the host
- */
- private List<Map<String, String>> processHostGroupComponents(ExportedHostGroup group) {
- List<Map<String, String>> listHostGroupComponents = new ArrayList<>();
- for (String component : group.getComponents()) {
- Map<String, String> mapComponentProperties = new HashMap<>();
- listHostGroupComponents.add(mapComponentProperties);
- mapComponentProperties.put("name", component);
- }
- return listHostGroupComponents;
- }
-
-
// ----- Host Group inner class --------------------------------------------
/**
@@ -259,7 +240,7 @@ public class ExportBlueprintRequest implements TopologyRequest {
/**
* Associated components.
*/
- private Set<String> components = new HashSet<>();
+ private Set<Component> components = new HashSet<>();
/**
* Host group scoped configurations.
@@ -284,8 +265,15 @@ public class ExportBlueprintRequest implements TopologyRequest {
public ExportedHostGroup(TreeNode<Resource> host) {
TreeNode<Resource> components = host.getChild("host_components");
for (TreeNode<Resource> component : components.getChildren()) {
- getComponents().add((String) component.getObject().getPropertyValue(
- "HostRoles/component_name"));
+ Resource resource = component.getObject();
+ String componentName =
+ String.valueOf(resource.getPropertyValue(HostComponentResourceProvider.HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID));
+ String serviceName =
+ String.valueOf(resource.getPropertyValue(HostComponentResourceProvider.HOST_COMPONENT_SERVICE_NAME_PROPERTY_ID));
+ String serviceGroupName =
+ String.valueOf(resource.getPropertyValue(HostComponentResourceProvider.HOST_COMPONENT_SERVICE_GROUP_NAME_PROPERTY_ID));
+ StackId stackId = serviceGroupToMpack.get(serviceGroupName);
+ getComponents().add(new Component(componentName, stackId, serviceName, null));
}
addAmbariComponentIfLocalhost((String) host.getObject().getPropertyValue(
PropertyHelper.getPropertyId("Hosts", "host_name")));
@@ -339,7 +327,7 @@ public class ExportBlueprintRequest implements TopologyRequest {
return name;
}
- public Set<String> getComponents() {
+ public Set<Component> getComponents() {
return components;
}
@@ -401,7 +389,7 @@ public class ExportBlueprintRequest implements TopologyRequest {
InetAddress hostAddress = InetAddress.getByName(hostname);
try {
if (hostAddress.equals(InetAddress.getLocalHost())) {
- getComponents().add("AMBARI_SERVER");
+ components.add(new Component(RootComponent.AMBARI_SERVER.name()));
}
} catch (UnknownHostException e) {
//todo: SystemException?
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintFactory.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintFactory.java
index b9c01bb..cc29551 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintFactory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintFactory.java
@@ -227,7 +227,7 @@ public class BlueprintFactory {
//TODO, might want to add some validation here, to only accept value enum types, rwn
ProvisionAction provisionAction = componentProperties.containsKey(COMPONENT_PROVISION_ACTION_PROPERTY_ID) ?
ProvisionAction.valueOf(componentProperties.get(COMPONENT_PROVISION_ACTION_PROPERTY_ID)) : null;
- components.add(new Component(componentName, mpackInstance, serviceInstance, provisionAction));
+ components.add(new Component(componentName, new StackId(mpackInstance), serviceInstance, provisionAction));
}
return components;
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java
index 7948fe0..633bcb0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImpl.java
@@ -24,7 +24,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -44,8 +43,6 @@ import org.apache.ambari.server.state.StackId;
import org.apache.ambari.server.utils.JsonUtils;
import com.fasterxml.jackson.core.type.TypeReference;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
@@ -332,15 +329,9 @@ public class BlueprintImpl implements Blueprint {
componentEntity.setHostGroupEntity(group);
componentEntity.setHostGroupName(group.getName());
componentEntity.setServiceName(component.getServiceInstance());
- if (null != component.getMpackInstance()) {
- Preconditions.checkArgument(component.getMpackInstance().contains("-"),
- "Invalid mpack instance specified for component %s: %s. Must be in {name}-{version} format.",
- component.getName(),
- component.getMpackInstance());
- Iterator<String> mpackNameAndVersion =
- Splitter.on('-').split(component.getMpackInstance()).iterator();
- componentEntity.setMpackName(mpackNameAndVersion.next());
- componentEntity.setMpackVersion(mpackNameAndVersion.next());
+ if (null != component.getStackId()) {
+ componentEntity.setMpackName(component.getStackId().getStackName());
+ componentEntity.setMpackVersion(component.getStackId().getStackVersion());
}
// add provision action (if specified) to entity type
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/Component.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/Component.java
index 3cc9c99..e44c814 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/Component.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/Component.java
@@ -24,11 +24,16 @@ import java.util.Objects;
import javax.annotation.Nullable;
import org.apache.ambari.server.controller.internal.ProvisionAction;
+import org.apache.ambari.server.state.StackId;
public class Component {
private final String name;
- private final String mpackInstance;
+
+ @Nullable
+ private final StackId stackId;
+
+ @Nullable
private final String serviceInstance;
private final ProvisionAction provisionAction;
@@ -37,9 +42,9 @@ public class Component {
this(name, null, null, null);
}
- public Component(String name, @Nullable String mpackInstance, @Nullable String serviceInstance, ProvisionAction provisionAction) {
+ public Component(String name, @Nullable StackId stackId, @Nullable String serviceInstance, ProvisionAction provisionAction) {
this.name = name;
- this.mpackInstance = mpackInstance;
+ this.stackId = stackId;
this.serviceInstance = serviceInstance;
this.provisionAction = provisionAction;
}
@@ -54,13 +59,21 @@ public class Component {
}
/**
- * @return the mpack associated with this component (can be {@code null} if component -> mpack mapping is unambiguous)
+ * @return the mpack associated with this component as {@link String} (can be {@code null} if component -> mpack mapping is unambiguous)
*/
- public String getMpackInstance() {
- return mpackInstance;
+ public String getStackIdAsString() {
+ return stackId != null ? stackId.toString() : null;
}
/**
+ * @return the mpack associated with this component as {@link StackId} (can be {@code null} if component -> mpack mapping is unambiguous)
+ */
+ public StackId getStackId() {
+ return stackId;
+ }
+
+
+ /**
* @return the service instance this component belongs to. Can be {@code null} if component does not belong to a service
* instance (there is a single service of the component's service type)
*/
@@ -82,7 +95,7 @@ public class Component {
public String toString() {
return com.google.common.base.Objects.toStringHelper(this)
.add("name", name)
- .add("mpackInstance", mpackInstance)
+ .add("stackId", stackId)
.add("serviceInstance", serviceInstance)
.add("provisionAction", provisionAction)
.toString();
@@ -95,13 +108,13 @@ public class Component {
if (o == null || getClass() != o.getClass()) return false;
Component component = (Component) o;
return Objects.equals(name, component.name) &&
- Objects.equals(mpackInstance, component.mpackInstance) &&
+ Objects.equals(stackId, component.stackId) &&
Objects.equals(serviceInstance, component.serviceInstance) &&
provisionAction == component.provisionAction;
}
@Override
public int hashCode() {
- return Objects.hash(name, mpackInstance, serviceInstance, provisionAction);
+ return Objects.hash(name, stackId, serviceInstance, provisionAction);
}
}
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupImpl.java
index be607e7..83375d5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupImpl.java
@@ -20,6 +20,7 @@
package org.apache.ambari.server.topology;
import static java.util.stream.Collectors.toList;
+import static org.apache.commons.lang3.StringUtils.isNotEmpty;
import java.util.Collection;
import java.util.HashMap;
@@ -32,6 +33,7 @@ import org.apache.ambari.server.controller.internal.ProvisionAction;
import org.apache.ambari.server.orm.entities.HostGroupComponentEntity;
import org.apache.ambari.server.orm.entities.HostGroupConfigEntity;
import org.apache.ambari.server.orm.entities.HostGroupEntity;
+import org.apache.ambari.server.state.StackId;
import com.google.gson.Gson;
@@ -132,11 +134,16 @@ public class HostGroupImpl implements HostGroup {
*/
private void parseComponents(HostGroupEntity entity) {
for (HostGroupComponentEntity componentEntity : entity.getComponents() ) {
+ StackId stackId =
+ isNotEmpty(componentEntity.getMpackName()) && isNotEmpty(componentEntity.getMpackVersion()) ?
+ new StackId(componentEntity.getMpackName(), componentEntity.getMpackVersion()) : null;
+
Component component = new Component(
componentEntity.getName(),
- componentEntity.getMpackName(),
+ stackId,
componentEntity.getServiceName(),
null == componentEntity.getProvisionAction() ? null : ProvisionAction.valueOf(componentEntity.getProvisionAction()));
+
addComponent(component);
}
}
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ResolvedComponent.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ResolvedComponent.java
index b6463ad..2b9d478 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ResolvedComponent.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ResolvedComponent.java
@@ -61,7 +61,7 @@ public interface ResolvedComponent {
.component(component)
.componentName(component.getName())
.serviceName(Optional.ofNullable(component.getServiceInstance()))
- .serviceGroupName(Optional.ofNullable(component.getMpackInstance()));
+ .serviceGroupName(Optional.ofNullable(component.getStackIdAsString()));
}
class Builder extends ResolvedComponent_Builder {
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/StackComponentResolver.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/StackComponentResolver.java
index 6db9a46..6bfd880 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/StackComponentResolver.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/StackComponentResolver.java
@@ -95,8 +95,8 @@ public class StackComponentResolver implements ComponentResolver {
.append(" found for component ").append(comp.getName())
.append(" in host group " ).append(hg.getName());
- if (!Strings.isNullOrEmpty(comp.getMpackInstance())) {
- sb.append(" mpack: ").append(comp.getMpackInstance());
+ if (!Strings.isNullOrEmpty(comp.getStackIdAsString())) {
+ sb.append(" mpack: ").append(comp.getStackIdAsString());
}
if (!Strings.isNullOrEmpty(comp.getServiceInstance())) {
sb.append(" service: ").append(comp.getServiceInstance());
@@ -113,7 +113,7 @@ public class StackComponentResolver implements ComponentResolver {
Map<String, Map<String, ServiceInstance>> mpackServices, Map<String, ServiceInstance> uniqueServices
) {
if (!Strings.isNullOrEmpty(comp.getServiceInstance())) {
- String mpackName = comp.getMpackInstance();
+ String mpackName = comp.getStackIdAsString();
Map<String, ServiceInstance> services = !Strings.isNullOrEmpty(mpackName)
? mpackServices.get(mpackName)
: uniqueServices;
@@ -131,10 +131,9 @@ public class StackComponentResolver implements ComponentResolver {
// if component references a specific mpack instance, filter the stream by the name of that mpack
private static Stream<Pair<StackId, ServiceInfo>> filterByMpackName(Component comp, Stream<Pair<StackId, ServiceInfo>> stream) {
- if (!Strings.isNullOrEmpty(comp.getMpackInstance())) {
- return stream.filter(pair -> pair.getLeft().getStackName().equals(comp.getMpackInstance()));
+ if (comp.getStackId() != null) {
+ return stream.filter(pair -> pair.getLeft().equals(comp.getStackId()));
}
-
return stream;
}
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRendererTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRendererTest.java
index 08bed11..7f74264 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRendererTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/query/render/ClusterBlueprintRendererTest.java
@@ -72,6 +72,7 @@ import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.DesiredConfig;
+import org.apache.ambari.server.state.SecurityType;
import org.apache.ambari.server.state.ServiceInfo;
import org.apache.ambari.server.state.StackId;
import org.apache.ambari.server.state.cluster.ClustersImpl;
@@ -93,6 +94,7 @@ import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
+import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
/**
@@ -257,7 +259,7 @@ public class ClusterBlueprintRendererTest {
assertNotNull(propertyTree.getChild("Host"));
assertTrue(propertyTree.getChild("Host").getObject().isEmpty());
assertNotNull(propertyTree.getChild("Host/HostComponent"));
- assertEquals(1, propertyTree.getChild("Host/HostComponent").getObject().size());
+ assertEquals(4, propertyTree.getChild("Host/HostComponent").getObject().size());
assertTrue(propertyTree.getChild("Host/HostComponent").getObject().contains("HostRoles/component_name"));
}
@@ -269,6 +271,8 @@ public class ClusterBlueprintRendererTest {
TreeNode<Resource> clusterTree = resultTree.addChild(clusterResource, "Cluster:1");
+ addStackVersions(clusterTree);
+
// Add global recovery_enabled as cluster setting
TreeNode<Resource> settingsNode = clusterTree.addChild(null, "settings");
Resource clusterSettingResource = new ResourceImpl(Resource.Type.ClusterSetting);
@@ -364,7 +368,7 @@ public class ClusterBlueprintRendererTest {
public void testGetSettings_instance(){
Result result = new ResultImpl(true);
- TreeNode<Resource> resultTree = createResultTreeSettingsObject(result.getResultTree());
+ createResultTreeSettingsObject(result.getResultTree());
ClusterBlueprintRenderer renderer = new TestBlueprintRenderer(topology);
Result blueprintResult = renderer.finalizeResult(result);
@@ -434,7 +438,7 @@ public class ClusterBlueprintRendererTest {
assertNotNull(propertyTree.getChild("Host"));
assertTrue(propertyTree.getChild("Host").getObject().isEmpty());
assertNotNull(propertyTree.getChild("Host/HostComponent"));
- assertEquals(1, propertyTree.getChild("Host/HostComponent").getObject().size());
+ assertEquals(4, propertyTree.getChild("Host/HostComponent").getObject().size());
assertTrue(propertyTree.getChild("Host/HostComponent").getObject().contains("HostRoles/component_name"));
}
@@ -459,7 +463,7 @@ public class ClusterBlueprintRendererTest {
Map<String, Object> securityProperties = (Map<String, Object>) properties.get("Blueprints").get("security");
assertNotNull(securityProperties);
- assertEquals("KERBEROS", securityProperties.get("type"));
+ assertEquals(SecurityType.KERBEROS.name(), securityProperties.get("type"));
assertNotNull(((Map<String, Object>) securityProperties.get("kerberos_descriptor")).get("properties"));
}
@@ -526,6 +530,10 @@ public class ClusterBlueprintRendererTest {
assertEquals(expectedValues, actualValues);
}
}
+
+ Map<String, Object> securityProperties = (Map<String, Object>) properties.get("Blueprints").get("security");
+ assertNotNull(securityProperties);
+ assertEquals(SecurityType.NONE.name(), securityProperties.get("type"));
}
@Test
@@ -683,10 +691,8 @@ public class ClusterBlueprintRendererTest {
originalMap.put("Clusters/desired_configs", desiredConfig);
}
-
return originalMap;
}
-
};
clusterResource.setProperty("Clusters/cluster_name", "testCluster");
@@ -694,6 +700,8 @@ public class ClusterBlueprintRendererTest {
TreeNode<Resource> clusterTree = resultTree.addChild(clusterResource, "Cluster:1");
+ addStackVersions(clusterTree);
+
// add a service group and empty services resource for basic unit testing
TreeNode<Resource> serviceGroupsTree = clusterTree.addChild(null, "servicegroups");
Resource serviceGroupResource = new ResourceImpl(Resource.Type.ServiceGroup);
@@ -805,6 +813,17 @@ public class ClusterBlueprintRendererTest {
host3ComponentsTree.addChild(ttComponentResource, "HostComponent:2");
}
+ private void addStackVersions(TreeNode<Resource> clusterTree) {
+ ResourceImpl clusterStackVersionResource = new ResourceImpl(Resource.Type.ClusterStackVersion);
+ clusterStackVersionResource.getPropertiesMap().put("ClusterStackVersions",
+ ImmutableMap.of(
+ "cluster_name", "testCluster",
+ "stack", STACK_ID.getStackName(),
+ "version", STACK_ID.getStackVersion(),
+ "mpack_uri", "http://mpacks.org/hdp-1.3.3.json"));
+ clusterTree.addChild(null, "stack_versions").addChild(clusterStackVersionResource, "ClusterStackVersion:1");
+ }
+
private void checkMpackInstance(Map<String, Map<String, Object>> blueprintProperties) {
Map<String, Object> mpackInstanceProperties =
((List<Map<String, Object>>)blueprintProperties.get("").get("mpack_instances")).get(0);
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ActiveWidgetLayoutResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ActiveWidgetLayoutResourceProviderTest.java
index cee2ef3..4f36a5e 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ActiveWidgetLayoutResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ActiveWidgetLayoutResourceProviderTest.java
@@ -86,6 +86,7 @@ import org.apache.ambari.server.state.scheduler.RequestExecutionFactory;
import org.apache.ambari.server.state.stack.OsFamily;
import org.apache.ambari.server.topology.PersistedState;
import org.apache.ambari.server.topology.PersistedStateImpl;
+import org.apache.ambari.server.topology.StackFactory;
import org.apache.ambari.server.topology.tasks.ConfigureClusterTaskFactory;
import org.easymock.Capture;
import org.easymock.EasyMockSupport;
@@ -425,6 +426,8 @@ public class ActiveWidgetLayoutResourceProviderTest extends EasyMockSupport {
bind(RegistryFactory.class).toInstance(createNiceMock(RegistryFactory.class));
bind(RootLevelSettingsManagerFactory.class).toInstance(createNiceMock(RootLevelSettingsManagerFactory.class));
bind(ClusterSettingFactory.class).toInstance(createNiceMock(ClusterSettingFactory.class));
+ bind(StackFactory.class).toInstance(createNiceMock(StackFactory.class));
+ bind(PersistedState.class).toInstance(createNiceMock(PersistedState.class));
}
});
}
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequestTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequestTest.java
index 0ab9dfb..52dc338 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequestTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ExportBlueprintRequestTest.java
@@ -98,17 +98,21 @@ public class ExportBlueprintRequestTest {
//todo: test configuration processing
@Test
+
public void testExport_noConfigs() throws Exception {
Resource clusterResource = new ResourceImpl(Resource.Type.Cluster);
clusterResource.setProperty(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, CLUSTER_NAME);
clusterResource.setProperty(ClusterResourceProvider.CLUSTER_ID_PROPERTY_ID, CLUSTER_ID);
clusterResource.setProperty(ClusterResourceProvider.CLUSTER_VERSION_PROPERTY_ID, "TEST-1.0");
+
TreeNode<Resource> clusterNode = new TreeNodeImpl<>(null, clusterResource, "cluster");
// add empty config child resource
Resource configResource = new ResourceImpl(Resource.Type.Configuration);
clusterNode.addChild(configResource, "configurations");
+ clusterNode.addChild(new ResourceImpl(Resource.Type.ServiceGroup), "servicegroups");
+
Resource hostsResource = new ResourceImpl(Resource.Type.Host);
Resource host1Resource = new ResourceImpl(Resource.Type.Host);
Resource host2Resource = new ResourceImpl(Resource.Type.Host);
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserAuthorizationResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserAuthorizationResourceProviderTest.java
index 878a259..f8badad 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserAuthorizationResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserAuthorizationResourceProviderTest.java
@@ -83,8 +83,10 @@ import org.apache.ambari.server.state.UpgradeContextFactory;
import org.apache.ambari.server.state.configgroup.ConfigGroupFactory;
import org.apache.ambari.server.state.scheduler.RequestExecutionFactory;
import org.apache.ambari.server.state.stack.OsFamily;
+import org.apache.ambari.server.topology.ComponentResolver;
import org.apache.ambari.server.topology.PersistedState;
import org.apache.ambari.server.topology.PersistedStateImpl;
+import org.apache.ambari.server.topology.StackFactory;
import org.apache.ambari.server.topology.tasks.ConfigureClusterTaskFactory;
import org.easymock.EasyMockSupport;
import org.junit.After;
@@ -438,7 +440,9 @@ public class UserAuthorizationResourceProviderTest extends EasyMockSupport {
bind(RegistryFactory.class).toInstance(createNiceMock(RegistryFactory.class));
bind(RootLevelSettingsManagerFactory.class).toInstance(createNiceMock(RootLevelSettingsManagerFactory.class));
bind(ClusterSettingFactory.class).toInstance(createNiceMock(ClusterSettingFactory.class));
+ bind(StackFactory.class).toInstance(createNiceMock(StackFactory.class));
bind(PersistedState.class).to(PersistedStateImpl.class);
+ bind(ComponentResolver.class).toInstance(createNiceMock(ComponentResolver.class));
}
});
}
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/topology/AmbariContextTest.java b/ambari-server/src/test/java/org/apache/ambari/server/topology/AmbariContextTest.java
index db8c910..a41b330 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/topology/AmbariContextTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/topology/AmbariContextTest.java
@@ -414,9 +414,9 @@ public class AmbariContextTest {
// test
Stream<ResolvedComponent> components = Stream.of(
- ResolvedComponent.builder(new Component("component1", "mpack", "service1", null)).buildPartial(),
- ResolvedComponent.builder(new Component("component2", "mpack", "service1", null)).buildPartial(),
- ResolvedComponent.builder(new Component("component3", "mpack", "service2", null)).buildPartial()
+ ResolvedComponent.builder(new Component("component1", new StackId("mpack", "1.0"), "service1", null)).buildPartial(),
+ ResolvedComponent.builder(new Component("component2", new StackId("mpack", "1.0"), "service1", null)).buildPartial(),
+ ResolvedComponent.builder(new Component("component3", new StackId("mpack", "1.0"), "service2", null)).buildPartial()
);
context.createAmbariHostResources(CLUSTER_ID, "host1", components);
--
To stop receiving notification emails like this one, please contact
benyoka@apache.org.