You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by mr...@apache.org on 2017/10/30 19:04:51 UTC
[15/30] ambari git commit: AMBARI-22253. Modify TopologyManager to
create service groups (magyari_sandor)
AMBARI-22253. Modify TopologyManager to create service groups (magyari_sandor)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/841cc7e1
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/841cc7e1
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/841cc7e1
Branch: refs/heads/branch-feature-AMBARI-14714-ui
Commit: 841cc7e12c9f6e689b7b97b7b75b92ed7744fa87
Parents: 37b1e6e
Author: Sandor Magyari <sm...@hortonworks.com>
Authored: Thu Oct 19 14:20:39 2017 +0200
Committer: Sandor Magyari <sm...@hortonworks.com>
Committed: Thu Oct 19 14:30:31 2017 +0200
----------------------------------------------------------------------
.../StackAdvisorBlueprintProcessor.java | 2 +-
.../ambari/server/controller/AmbariServer.java | 3 +-
.../ambari/server/controller/StackV2.java | 47 +-
.../server/controller/StackV2Factory.java | 10 +-
.../controller/internal/BaseClusterRequest.java | 8 +-
.../BlueprintConfigurationProcessor.java | 4 +-
.../internal/ConfigurationContext.java | 1 +
.../internal/ProvisionClusterRequest.java | 7 +-
.../internal/ScaleClusterRequest.java | 6 +
.../server/controller/internal/StackV2.java | 834 -------------------
.../server/controller/internal/UnitUpdater.java | 1 +
.../ambari/server/topology/AmbariContext.java | 5 +-
.../server/topology/BlueprintFactory.java | 4 +-
.../ambari/server/topology/BlueprintImplV2.java | 49 +-
.../ambari/server/topology/BlueprintV2.java | 10 +-
.../topology/ClusterConfigurationRequest.java | 5 +-
.../ambari/server/topology/ComponentV2.java | 12 +-
.../ambari/server/topology/HostGroupV2.java | 11 +-
.../ambari/server/topology/HostGroupV2Impl.java | 21 +-
.../ambari/server/topology/HostRequest.java | 2 +-
.../server/topology/PersistedStateImpl.java | 9 +-
.../apache/ambari/server/topology/Service.java | 21 +-
.../ambari/server/topology/TopologyManager.java | 2 +-
.../validators/ClusterConfigTypeValidator.java | 5 +-
.../RequiredConfigPropertiesValidator.java | 2 +-
.../validators/RequiredPasswordValidator.java | 2 +-
.../topology/validators/UnitValidator.java | 12 +-
27 files changed, 178 insertions(+), 917 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
index ba35cce..2e9ac9f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorBlueprintProcessor.java
@@ -28,8 +28,8 @@ import java.util.Set;
import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRequest.StackAdvisorRequestType;
import org.apache.ambari.server.api.services.stackadvisor.recommendations.RecommendationResponse;
import org.apache.ambari.server.api.services.stackadvisor.recommendations.RecommendationResponse.BlueprintConfigurations;
+import org.apache.ambari.server.controller.StackV2;
import org.apache.ambari.server.controller.internal.ConfigurationTopologyException;
-import org.apache.ambari.server.controller.internal.StackV2;
import org.apache.ambari.server.state.ValueAttributesInfo;
import org.apache.ambari.server.topology.AdvisedConfiguration;
import org.apache.ambari.server.topology.BlueprintV2;
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
index 6d4d1c9..f900452 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
@@ -115,6 +115,7 @@ import org.apache.ambari.server.stack.UpdateActiveRepoVersionOnStartup;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.topology.AmbariContext;
import org.apache.ambari.server.topology.BlueprintFactory;
+import org.apache.ambari.server.topology.BlueprintV2Factory;
import org.apache.ambari.server.topology.SecurityConfigurationFactory;
import org.apache.ambari.server.topology.TopologyManager;
import org.apache.ambari.server.topology.TopologyRequestFactoryImpl;
@@ -926,7 +927,7 @@ public class AmbariServer {
.class), injector.getInstance(Gson.class));
HostResourceProvider.setTopologyManager(injector.getInstance(TopologyManager.class));
BlueprintFactory.init(injector.getInstance(BlueprintDAO.class));
- BaseClusterRequest.init(injector.getInstance(BlueprintFactory.class));
+ BaseClusterRequest.init(injector.getInstance(BlueprintV2Factory.class));
AmbariContext.init(injector.getInstance(HostRoleCommandFactory.class));
PermissionResourceProvider.init(injector.getInstance(PermissionDAO.class));
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
index 8d7de5d..169bf6a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2.java
@@ -26,6 +26,7 @@ import java.util.Map;
import java.util.Set;
import org.apache.ambari.server.state.AutoDeployInfo;
+import org.apache.ambari.server.state.ComponentInfo;
import org.apache.ambari.server.state.DependencyInfo;
import org.apache.ambari.server.state.PropertyDependencyInfo;
import org.apache.ambari.server.state.PropertyInfo;
@@ -165,28 +166,28 @@ public class StackV2 {
return serviceComponents;
}
-// /**
-// * Get info for the specified component.
-// *
-// * @param component component name
-// *
-// * @return component information for the requested component
-// * or null if the component doesn't exist in the stack
-// */
-// @Deprecated
-// public ComponentInfo getComponentInfo(String component) {
-// ComponentInfo componentInfo = null;
-// String service = getServiceForComponent(component);
-// if (service != null) {
-// try {
-// componentInfo = controller.getAmbariMetaInfo().getComponent(
-// getName(), getVersion(), service, component);
-// } catch (AmbariException e) {
-// // just return null if component doesn't exist
-// }
-// }
-// return componentInfo;
-// }
+ /**
+ * Get info for the specified component.
+ *
+ * @param component component name
+ *
+ * @return component information for the requested component
+ * or null if the component doesn't exist in the stack
+ */
+ @Deprecated
+ public ComponentInfo getComponentInfo(String component) {
+ ComponentInfo componentInfo = null;
+// String service = getServiceForComponent(component);
+// if (service != null) {
+// try {
+// componentInfo = controller.getAmbariMetaInfo().getComponent(
+// getName(), getVersion(), service, component);
+// } catch (AmbariException e) {
+// // just return null if component doesn't exist
+// }
+// }
+ return componentInfo;
+ }
/**
* Get all configuration types, including excluded types for the specified service.
@@ -586,7 +587,7 @@ public class StackV2 {
this.attributes = attributes;
}
- Set<PropertyDependencyInfo> getDependsOnProperties() {
+ public Set<PropertyDependencyInfo> getDependsOnProperties() {
return this.dependsOnProperties;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
index 54e1e62..ed1bbf8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackV2Factory.java
@@ -85,14 +85,14 @@ public class StackV2Factory {
stackData.serviceConfigurations.put(service, mapServiceConfig);
stackData.requiredServiceConfigurations.put(service, mapRequiredServiceConfig);
- Set<StackConfigurationResponse> serviceConfigs = controller.getStackConfigurations(
+ Set<ReadOnlyConfigurationResponse> serviceConfigs = controller.getStackConfigurations(
Collections.singleton(new StackConfigurationRequest(stackData.stackName, stackData.stackVersion, service, null)));
- Set<StackConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
+ Set<ReadOnlyConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
Collections.singleton(new StackLevelConfigurationRequest(stackData.stackName, stackData.stackVersion, null)));
serviceConfigs.addAll(stackLevelConfigs);
// shouldn't have any required properties in stack level configuration
- for (StackConfigurationResponse config : serviceConfigs) {
+ for (ReadOnlyConfigurationResponse config : serviceConfigs) {
StackV2.ConfigProperty configProperty = new StackV2.ConfigProperty(config);
String type = configProperty.getType();
@@ -118,10 +118,10 @@ public class StackV2Factory {
}
private void parseStackConfigurations (StackData stackData) throws AmbariException {
- Set<StackConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
+ Set<ReadOnlyConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
Collections.singleton(new StackLevelConfigurationRequest(stackData.stackName, stackData.stackVersion, null)));
- for (StackConfigurationResponse config : stackLevelConfigs) {
+ for (ReadOnlyConfigurationResponse config : stackLevelConfigs) {
StackV2.ConfigProperty configProperty = new StackV2.ConfigProperty(config);
String type = configProperty.getType();
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseClusterRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseClusterRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseClusterRequest.java
index e3e0aa2..a38f478 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseClusterRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BaseClusterRequest.java
@@ -30,8 +30,8 @@ import org.apache.ambari.server.api.predicate.Token;
import org.apache.ambari.server.controller.spi.Resource;
import org.apache.ambari.server.controller.spi.ResourceProvider;
import org.apache.ambari.server.controller.utilities.ClusterControllerHelper;
-import org.apache.ambari.server.topology.BlueprintFactory;
import org.apache.ambari.server.topology.BlueprintV2;
+import org.apache.ambari.server.topology.BlueprintV2Factory;
import org.apache.ambari.server.topology.Configuration;
import org.apache.ambari.server.topology.HostGroupInfo;
import org.apache.ambari.server.topology.InvalidTopologyTemplateException;
@@ -74,7 +74,7 @@ public abstract class BaseClusterRequest implements TopologyRequest {
/**
* blueprint factory
*/
- protected static BlueprintFactory blueprintFactory;
+ protected static BlueprintV2Factory blueprintFactory;
/**
* List of services
@@ -96,7 +96,7 @@ public abstract class BaseClusterRequest implements TopologyRequest {
* inject blueprint factory
* @param factory blueprint factory
*/
- public static void init(BlueprintFactory factory) {
+ public static void init(BlueprintV2Factory factory) {
blueprintFactory = factory;
}
@@ -179,7 +179,7 @@ public abstract class BaseClusterRequest implements TopologyRequest {
/**
* Get the blueprint factory.
*/
- protected BlueprintFactory getBlueprintFactory() {
+ protected BlueprintV2Factory getBlueprintFactory() {
return blueprintFactory;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
index 8c4a5eb..953155d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintConfigurationProcessor.java
@@ -38,6 +38,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.StackV2;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.ConfigHelper;
import org.apache.ambari.server.state.PropertyDependencyInfo;
@@ -2923,7 +2924,8 @@ public class BlueprintConfigurationProcessor {
for (Service blueprintService : blueprintServices) {
LOG.debug("Handling excluded properties for blueprint service: {}", blueprintService);
- StackV2 stack = blueprintService.getStack();
+ String stackId = blueprintService.getStackId();
+ StackV2 stack = clusterTopology.getBlueprint().getStackById(stackId);
Set<String> excludedConfigTypes = stack.getExcludedConfigurationTypes(blueprintService.getType());
if (excludedConfigTypes.isEmpty()) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationContext.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationContext.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationContext.java
index a313f5e..aa63021 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationContext.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationContext.java
@@ -20,6 +20,7 @@ package org.apache.ambari.server.controller.internal;
import java.util.Map;
+import org.apache.ambari.server.controller.StackV2;
import org.apache.ambari.server.topology.Configuration;
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
index 75ec9ba..bfa46d8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
@@ -17,6 +17,7 @@
*/
package org.apache.ambari.server.controller.internal;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -295,7 +296,11 @@ public class ProvisionClusterRequest extends BaseClusterRequest {
private void parseBlueprint(Map<String, Object> properties) throws NoSuchStackException, NoSuchBlueprintException {
String blueprintName = String.valueOf(properties.get(ClusterResourceProvider.BLUEPRINT));
// set blueprint field
- setBlueprint(getBlueprintFactory().getBlueprint(blueprintName));
+ try {
+ setBlueprint(getBlueprintFactory().getBlueprint(blueprintName));
+ } catch (IOException e) {
+ throw new NoSuchBlueprintException(blueprintName);
+ }
if (blueprint == null) {
throw new NoSuchBlueprintException(blueprintName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
index c5cc061b..1284c26 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ScaleClusterRequest.java
@@ -19,6 +19,7 @@
package org.apache.ambari.server.controller.internal;
+import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
@@ -29,6 +30,7 @@ import org.apache.ambari.server.topology.BlueprintV2;
import org.apache.ambari.server.topology.Configuration;
import org.apache.ambari.server.topology.HostGroupInfo;
import org.apache.ambari.server.topology.InvalidTopologyTemplateException;
+import org.apache.ambari.server.topology.NoSuchBlueprintException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -201,6 +203,10 @@ public class ScaleClusterRequest extends BaseClusterRequest {
BlueprintV2 blueprint;
try {
blueprint = getBlueprintFactory().getBlueprint(blueprintName);
+ } catch (NoSuchBlueprintException e) {
+ throw new InvalidTopologyTemplateException("Invalid blueprint specified: " + blueprintName);
+ } catch (IOException e) {
+ throw new InvalidTopologyTemplateException("Error reading blueprint: " + blueprintName);
} catch (NoSuchStackException e) {
throw new InvalidTopologyTemplateException("Invalid stack specified in the blueprint: " + blueprintName);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackV2.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackV2.java
deleted file mode 100644
index fb5d02c..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackV2.java
+++ /dev/null
@@ -1,834 +0,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.
- */
-
-package org.apache.ambari.server.controller.internal;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.controller.AmbariManagementController;
-import org.apache.ambari.server.controller.ReadOnlyConfigurationResponse;
-import org.apache.ambari.server.controller.StackConfigurationRequest;
-import org.apache.ambari.server.controller.StackLevelConfigurationRequest;
-import org.apache.ambari.server.controller.StackServiceComponentRequest;
-import org.apache.ambari.server.controller.StackServiceComponentResponse;
-import org.apache.ambari.server.controller.StackServiceRequest;
-import org.apache.ambari.server.controller.StackServiceResponse;
-import org.apache.ambari.server.orm.entities.StackEntity;
-import org.apache.ambari.server.state.AutoDeployInfo;
-import org.apache.ambari.server.state.ComponentInfo;
-import org.apache.ambari.server.state.DependencyInfo;
-import org.apache.ambari.server.state.PropertyDependencyInfo;
-import org.apache.ambari.server.state.PropertyInfo;
-import org.apache.ambari.server.state.ValueAttributesInfo;
-import org.apache.ambari.server.topology.Cardinality;
-import org.apache.ambari.server.topology.Configuration;
-
-/**
- * Encapsulates stack information.
- */
-public class StackV2 {
- /**
- * Stack name
- */
- private String name;
-
- /**
- * Stack version
- */
- private String version;
-
- /**
- * Repo version
- */
- private String repoVersion;
-
- /**
- * Map of service name to components
- */
- private Map<String, Collection<String>> serviceComponents =
- new HashMap<>();
-
- /**
- * Map of component to service
- */
- private Map<String, String> componentService = new HashMap<>();
-
- /**
- * Map of component to dependencies
- */
- private Map<String, Collection<DependencyInfo>> dependencies =
- new HashMap<>();
-
- /**
- * Map of dependency to conditional service
- */
- private Map<DependencyInfo, String> dependencyConditionalServiceMap =
- new HashMap<>();
-
- /**
- * Map of database component name to configuration property which indicates whether
- * the database in to be managed or if it is an external non-managed instance.
- * If the value of the config property starts with 'New', the database is determined
- * to be managed, otherwise it is non-managed.
- */
- private Map<String, String> dbDependencyInfo = new HashMap<>();
-
- /**
- * Map of component to required cardinality
- */
- private Map<String, String> cardinalityRequirements = new HashMap<>();
-
- //todo: instead of all these maps from component -> * ,
- //todo: we should use a Component object with all of these attributes
- private Set<String> masterComponents = new HashSet<>();
-
- /**
- * Map of component to auto-deploy information
- */
- private Map<String, AutoDeployInfo> componentAutoDeployInfo =
- new HashMap<>();
-
- /**
- * Map of service to config type properties
- */
- private Map<String, Map<String, Map<String, ConfigProperty>>> serviceConfigurations =
- new HashMap<>();
-
- /**
- * Map of service to required type properties
- */
- private Map<String, Map<String, Map<String, ConfigProperty>>> requiredServiceConfigurations =
- new HashMap<>();
-
- /**
- * Map of service to config type properties
- */
- private Map<String, Map<String, ConfigProperty>> stackConfigurations =
- new HashMap<>();
-
- /**
- * Map of service to set of excluded config types
- */
- private Map<String, Set<String>> excludedConfigurationTypes =
- new HashMap<>();
-
- /**
- * Ambari Management Controller, used to obtain Stack definitions
- */
- private final AmbariManagementController controller;
-
-
- /**
- * Constructor.
- *
- * @param stack
- * the stack (not {@code null}).
- * @param ambariManagementController
- * the management controller (not {@code null}).
- * @throws AmbariException
- */
- public StackV2(StackEntity stack, AmbariManagementController ambariManagementController) throws AmbariException {
- this(stack.getStackName(), stack.getStackVersion(), ambariManagementController);
- }
-
- /**
- * Constructor.
- *
- * @param name stack name
- * @param version stack version
- *
- * @throws AmbariException an exception occurred getting stack information
- * for the specified name and version
- */
- //todo: don't pass management controller in constructor
- public StackV2(String name, String version, AmbariManagementController controller) throws AmbariException {
- this.name = name;
- this.version = version;
- this.controller = controller;
-
- Set<StackServiceResponse> stackServices = controller.getStackServices(
- Collections.singleton(new StackServiceRequest(name, version, null)));
-
- for (StackServiceResponse stackService : stackServices) {
- String serviceName = stackService.getServiceName();
- parseComponents(serviceName);
- parseExcludedConfigurations(stackService);
- parseConfigurations(stackService);
- registerConditionalDependencies();
- }
-
- //todo: already done for each service
- parseStackConfigurations();
- }
-
- /**
- * Obtain stack name.
- *
- * @return stack name
- */
- public String getName() {
- return name;
- }
-
- /**
- * Obtain stack version.
- *
- * @return stack version
- */
- public String getVersion() {
- return version;
- }
-
- /**
- * Obtain repo version.
- * @return
- */
- public String getRepoVersion() { return repoVersion; }
-
- Map<DependencyInfo, String> getDependencyConditionalServiceMap() {
- return dependencyConditionalServiceMap;
- }
-
- /**
- * Get services contained in the stack.
- *
- * @return collection of all services for the stack
- */
- public Collection<String> getServices() {
- return serviceComponents.keySet();
- }
-
- /**
- * Get components contained in the stack for the specified service.
- *
- * @param service service name
- *
- * @return collection of component names for the specified service
- */
- public Collection<String> getComponents(String service) {
- return serviceComponents.get(service);
- }
-
- /**
- * Get all service components
- *
- * @return map of service to associated components
- */
- public Map<String, Collection<String>> getComponents() {
- Map<String, Collection<String>> serviceComponents = new HashMap<>();
- for (String service : getServices()) {
- Collection<String> components = new HashSet<>();
- components.addAll(getComponents(service));
- serviceComponents.put(service, components);
- }
- return serviceComponents;
- }
-
- /**
- * Get info for the specified component.
- *
- * @param component component name
- *
- * @return component information for the requested component
- * or null if the component doesn't exist in the stack
- */
- public ComponentInfo getComponentInfo(String component) {
- ComponentInfo componentInfo = null;
- String service = getServiceForComponent(component);
- if (service != null) {
- try {
- componentInfo = controller.getAmbariMetaInfo().getComponent(
- getName(), getVersion(), service, component);
- } catch (AmbariException e) {
- // just return null if component doesn't exist
- }
- }
- return componentInfo;
- }
-
- /**
- * Get all configuration types, including excluded types for the specified service.
- *
- * @param service service name
- *
- * @return collection of all configuration types for the specified service
- */
- public Collection<String> getAllConfigurationTypes(String service) {
- return serviceConfigurations.get(service).keySet();
- }
-
- /**
- * Get configuration types for the specified service.
- * This doesn't include any service excluded types.
- *
- * @param service service name
- *
- * @return collection of all configuration types for the specified service
- */
- public Collection<String> getConfigurationTypes(String service) {
- Set<String> serviceTypes = new HashSet<>(serviceConfigurations.get(service).keySet());
- serviceTypes.removeAll(getExcludedConfigurationTypes(service));
-
- return serviceTypes;
- }
-
- /**
- * Get the set of excluded configuration types for this service.
- *
- * @param service service name
- *
- * @return Set of names of excluded config types. Will not return null.
- */
- public Set<String> getExcludedConfigurationTypes(String service) {
- return excludedConfigurationTypes.containsKey(service) ?
- excludedConfigurationTypes.get(service) :
- Collections.emptySet();
- }
-
- /**
- * Get config properties for the specified service and configuration type.
- *
- * @param service service name
- * @param type configuration type
- *
- * @return map of property names to values for the specified service and configuration type
- */
- public Map<String, String> getConfigurationProperties(String service, String type) {
- Map<String, String> configMap = new HashMap<>();
- Map<String, ConfigProperty> configProperties = serviceConfigurations.get(service).get(type);
- if (configProperties != null) {
- for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
- configMap.put(configProperty.getKey(), configProperty.getValue().getValue());
- }
- }
- return configMap;
- }
-
- public Map<String, ConfigProperty> getConfigurationPropertiesWithMetadata(String service, String type) {
- return serviceConfigurations.get(service).get(type);
- }
-
- /**
- * Get all required config properties for the specified service.
- *
- * @param service service name
- *
- * @return collection of all required properties for the given service
- */
- public Collection<ConfigProperty> getRequiredConfigurationProperties(String service) {
- Collection<ConfigProperty> requiredConfigProperties = new HashSet<>();
- Map<String, Map<String, ConfigProperty>> serviceProperties = requiredServiceConfigurations.get(service);
- if (serviceProperties != null) {
- for (Map.Entry<String, Map<String, ConfigProperty>> typePropertiesEntry : serviceProperties.entrySet()) {
- requiredConfigProperties.addAll(typePropertiesEntry.getValue().values());
- }
- }
- return requiredConfigProperties;
- }
-
- /**
- * Get required config properties for the specified service which belong to the specified property type.
- *
- * @param service service name
- * @param propertyType property type
- *
- * @return collection of required properties for the given service and property type
- */
- public Collection<ConfigProperty> getRequiredConfigurationProperties(String service, org.apache.ambari.server.state.PropertyInfo.PropertyType propertyType) {
- Collection<ConfigProperty> matchingProperties = new HashSet<>();
- Map<String, Map<String, ConfigProperty>> requiredProperties = requiredServiceConfigurations.get(service);
- if (requiredProperties != null) {
- for (Map.Entry<String, Map<String, ConfigProperty>> typePropertiesEntry : requiredProperties.entrySet()) {
- for (ConfigProperty configProperty : typePropertiesEntry.getValue().values()) {
- if (configProperty.getPropertyTypes().contains(propertyType)) {
- matchingProperties.add(configProperty);
- }
- }
-
- }
- }
- return matchingProperties;
- }
-
- public boolean isPasswordProperty(String service, String type, String propertyName) {
- return (serviceConfigurations.containsKey(service) &&
- serviceConfigurations.get(service).containsKey(type) &&
- serviceConfigurations.get(service).get(type).containsKey(propertyName) &&
- serviceConfigurations.get(service).get(type).get(propertyName).getPropertyTypes().
- contains(org.apache.ambari.server.state.PropertyInfo.PropertyType.PASSWORD));
- }
-
- //todo
- public Map<String, String> getStackConfigurationProperties(String type) {
- Map<String, String> configMap = new HashMap<>();
- Map<String, ConfigProperty> configProperties = stackConfigurations.get(type);
- if (configProperties != null) {
- for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
- configMap.put(configProperty.getKey(), configProperty.getValue().getValue());
- }
- }
- return configMap;
- }
-
- public boolean isKerberosPrincipalNameProperty(String service, String type, String propertyName) {
- return (serviceConfigurations.containsKey(service) &&
- serviceConfigurations.get(service).containsKey(type) &&
- serviceConfigurations.get(service).get(type).containsKey(propertyName) &&
- serviceConfigurations.get(service).get(type).get(propertyName).getPropertyTypes().
- contains(org.apache.ambari.server.state.PropertyInfo.PropertyType.KERBEROS_PRINCIPAL));
- }
- /**
- * Get config attributes for the specified service and configuration type.
- *
- * @param service service name
- * @param type configuration type
- *
- * @return map of attribute names to map of property names to attribute values
- * for the specified service and configuration type
- */
- public Map<String, Map<String, String>> getConfigurationAttributes(String service, String type) {
- Map<String, Map<String, String>> attributesMap = new HashMap<>();
- Map<String, ConfigProperty> configProperties = serviceConfigurations.get(service).get(type);
- if (configProperties != null) {
- for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
- String propertyName = configProperty.getKey();
- Map<String, String> propertyAttributes = configProperty.getValue().getAttributes();
- if (propertyAttributes != null) {
- for (Map.Entry<String, String> propertyAttribute : propertyAttributes.entrySet()) {
- String attributeName = propertyAttribute.getKey();
- String attributeValue = propertyAttribute.getValue();
- if (attributeValue != null) {
- Map<String, String> attributes = attributesMap.get(attributeName);
- if (attributes == null) {
- attributes = new HashMap<>();
- attributesMap.put(attributeName, attributes);
- }
- attributes.put(propertyName, attributeValue);
- }
- }
- }
- }
- }
- return attributesMap;
- }
-
- //todo:
- public Map<String, Map<String, String>> getStackConfigurationAttributes(String type) {
- Map<String, Map<String, String>> attributesMap = new HashMap<>();
- Map<String, ConfigProperty> configProperties = stackConfigurations.get(type);
- if (configProperties != null) {
- for (Map.Entry<String, ConfigProperty> configProperty : configProperties.entrySet()) {
- String propertyName = configProperty.getKey();
- Map<String, String> propertyAttributes = configProperty.getValue().getAttributes();
- if (propertyAttributes != null) {
- for (Map.Entry<String, String> propertyAttribute : propertyAttributes.entrySet()) {
- String attributeName = propertyAttribute.getKey();
- String attributeValue = propertyAttribute.getValue();
- Map<String, String> attributes = attributesMap.get(attributeName);
- if (attributes == null) {
- attributes = new HashMap<>();
- attributesMap.put(attributeName, attributes);
- }
- attributes.put(propertyName, attributeValue);
- }
- }
- }
- }
- return attributesMap;
- }
-
- /**
- * Get the service for the specified component.
- *
- * @param component component name
- *
- * @return service name that contains tha specified component
- */
- public String getServiceForComponent(String component) {
- return componentService.get(component);
- }
-
- /**
- * Get the names of the services which contains the specified components.
- *
- * @param components collection of components
- *
- * @return collection of services which contain the specified components
- */
- public Collection<String> getServicesForComponents(Collection<String> components) {
- Set<String> services = new HashSet<>();
- for (String component : components) {
- services.add(getServiceForComponent(component));
- }
-
- return services;
- }
-
- /**
- * Obtain the service name which corresponds to the specified configuration.
- *
- * @param config configuration type
- *
- * @return name of service which corresponds to the specified configuration type
- */
- public String getServiceForConfigType(String config) {
- for (Map.Entry<String, Map<String, Map<String, ConfigProperty>>> entry : serviceConfigurations.entrySet()) {
- Map<String, Map<String, ConfigProperty>> typeMap = entry.getValue();
- String serviceName = entry.getKey();
- if (typeMap.containsKey(config) && !getExcludedConfigurationTypes(serviceName).contains(config)) {
- return serviceName;
- }
- }
- throw new IllegalArgumentException(
- "Specified configuration type is not associated with any service: " + config);
- }
-
- /**
- * Return the dependencies specified for the given component.
- *
- * @param component component to get dependency information for
- *
- * @return collection of dependency information for the specified component
- */
- //todo: full dependency graph
- public Collection<DependencyInfo> getDependenciesForComponent(String component) {
- return dependencies.containsKey(component) ? dependencies.get(component) :
- Collections.emptySet();
- }
-
- /**
- * Get the service, if any, that a component dependency is conditional on.
- *
- * @param dependency dependency to get conditional service for
- *
- * @return conditional service for provided component or null if dependency
- * is not conditional on a service
- */
- public String getConditionalServiceForDependency(DependencyInfo dependency) {
- return dependencyConditionalServiceMap.get(dependency);
- }
-
- public String getExternalComponentConfig(String component) {
- return dbDependencyInfo.get(component);
- }
-
- /**
- * Obtain the required cardinality for the specified component.
- */
- public Cardinality getCardinality(String component) {
- return new Cardinality(cardinalityRequirements.get(component));
- }
-
- /**
- * Obtain auto-deploy information for the specified component.
- */
- public AutoDeployInfo getAutoDeployInfo(String component) {
- return componentAutoDeployInfo.get(component);
- }
-
- public boolean isMasterComponent(String component) {
- return masterComponents.contains(component);
- }
-
- public Configuration getConfiguration(Collection<String> services) {
- Map<String, Map<String, Map<String, String>>> attributes = new HashMap<>();
- Map<String, Map<String, String>> properties = new HashMap<>();
-
- for (String service : services) {
- Collection<String> serviceConfigTypes = getConfigurationTypes(service);
- for (String type : serviceConfigTypes) {
- Map<String, String> typeProps = properties.get(type);
- if (typeProps == null) {
- typeProps = new HashMap<>();
- properties.put(type, typeProps);
- }
- typeProps.putAll(getConfigurationProperties(service, type));
-
- Map<String, Map<String, String>> stackTypeAttributes = getConfigurationAttributes(service, type);
- if (!stackTypeAttributes.isEmpty()) {
- if (! attributes.containsKey(type)) {
- attributes.put(type, new HashMap<>());
- }
- Map<String, Map<String, String>> typeAttributes = attributes.get(type);
- for (Map.Entry<String, Map<String, String>> attribute : stackTypeAttributes.entrySet()) {
- String attributeName = attribute.getKey();
- Map<String, String> attributeProps = typeAttributes.get(attributeName);
- if (attributeProps == null) {
- attributeProps = new HashMap<>();
- typeAttributes.put(attributeName, attributeProps);
- }
- attributeProps.putAll(attribute.getValue());
- }
- }
- }
- }
- return new Configuration(properties, attributes);
- }
-
- public Configuration getConfiguration() {
- Map<String, Map<String, Map<String, String>>> stackAttributes = new HashMap<>();
- Map<String, Map<String, String>> stackConfigs = new HashMap<>();
-
- for (String service : getServices()) {
- for (String type : getAllConfigurationTypes(service)) {
- Map<String, String> typeProps = stackConfigs.get(type);
- if (typeProps == null) {
- typeProps = new HashMap<>();
- stackConfigs.put(type, typeProps);
- }
- typeProps.putAll(getConfigurationProperties(service, type));
-
- Map<String, Map<String, String>> stackTypeAttributes = getConfigurationAttributes(service, type);
- if (!stackTypeAttributes.isEmpty()) {
- if (! stackAttributes.containsKey(type)) {
- stackAttributes.put(type, new HashMap<>());
- }
- Map<String, Map<String, String>> typeAttrs = stackAttributes.get(type);
- for (Map.Entry<String, Map<String, String>> attribute : stackTypeAttributes.entrySet()) {
- String attributeName = attribute.getKey();
- Map<String, String> attributes = typeAttrs.get(attributeName);
- if (attributes == null) {
- attributes = new HashMap<>();
- typeAttrs.put(attributeName, attributes);
- }
- attributes.putAll(attribute.getValue());
- }
- }
- }
- }
- return new Configuration(stackConfigs, stackAttributes);
- }
-
- /**
- * Parse components for the specified service from the stack definition.
- *
- * @param service service name
- *
- * @throws AmbariException an exception occurred getting components from the stack definition
- */
- private void parseComponents(String service) throws AmbariException{
- Collection<String> componentSet = new HashSet<>();
-
- Set<StackServiceComponentResponse> components = controller.getStackComponents(
- Collections.singleton(new StackServiceComponentRequest(name, version, service, null)));
-
- // stack service components
- for (StackServiceComponentResponse component : components) {
- String componentName = component.getComponentName();
- componentSet.add(componentName);
- componentService.put(componentName, service);
- String cardinality = component.getCardinality();
- if (cardinality != null) {
- cardinalityRequirements.put(componentName, cardinality);
- }
- AutoDeployInfo autoDeploy = component.getAutoDeploy();
- if (autoDeploy != null) {
- componentAutoDeployInfo.put(componentName, autoDeploy);
- }
-
- // populate component dependencies
- //todo: remove usage of AmbariMetaInfo
- Collection<DependencyInfo> componentDependencies = controller.getAmbariMetaInfo().getComponentDependencies(
- name, version, service, componentName);
-
- if (componentDependencies != null && ! componentDependencies.isEmpty()) {
- dependencies.put(componentName, componentDependencies);
- }
- if (component.isMaster()) {
- masterComponents.add(componentName);
- }
- }
- serviceComponents.put(service, componentSet);
- }
-
- /**
- * Parse configurations for the specified service from the stack definition.
- *
- * @param stackService service to parse the stack configuration for
- *
- * @throws AmbariException an exception occurred getting configurations from the stack definition
- */
- private void parseConfigurations(StackServiceResponse stackService) throws AmbariException {
- String service = stackService.getServiceName();
- Map<String, Map<String, ConfigProperty>> mapServiceConfig = new HashMap<>();
- Map<String, Map<String, ConfigProperty>> mapRequiredServiceConfig = new HashMap<>();
-
-
- serviceConfigurations.put(service, mapServiceConfig);
- requiredServiceConfigurations.put(service, mapRequiredServiceConfig);
-
- Set<ReadOnlyConfigurationResponse> serviceConfigs = controller.getStackConfigurations(
- Collections.singleton(new StackConfigurationRequest(name, version, service, null)));
- Set<ReadOnlyConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
- Collections.singleton(new StackLevelConfigurationRequest(name, version, null)));
- serviceConfigs.addAll(stackLevelConfigs);
-
- // shouldn't have any required properties in stack level configuration
- for (ReadOnlyConfigurationResponse config : serviceConfigs) {
- ConfigProperty configProperty = new ConfigProperty(config);
- String type = configProperty.getType();
-
- Map<String, ConfigProperty> mapTypeConfig = mapServiceConfig.get(type);
- if (mapTypeConfig == null) {
- mapTypeConfig = new HashMap<>();
- mapServiceConfig.put(type, mapTypeConfig);
- }
-
- mapTypeConfig.put(config.getPropertyName(), configProperty);
- if (config.isRequired()) {
- Map<String, ConfigProperty> requiredTypeConfig = mapRequiredServiceConfig.get(type);
- if (requiredTypeConfig == null) {
- requiredTypeConfig = new HashMap<>();
- mapRequiredServiceConfig.put(type, requiredTypeConfig);
- }
- requiredTypeConfig.put(config.getPropertyName(), configProperty);
- }
- }
-
- // So far we added only config types that have properties defined
- // in stack service definition. Since there might be config types
- // with no properties defined we need to add those separately
- Set<String> configTypes = stackService.getConfigTypes().keySet();
- for (String configType: configTypes) {
- if (!mapServiceConfig.containsKey(configType)) {
- mapServiceConfig.put(configType, Collections.emptyMap());
- }
- }
- }
-
- private void parseStackConfigurations () throws AmbariException {
-
- Set<ReadOnlyConfigurationResponse> stackLevelConfigs = controller.getStackLevelConfigurations(
- Collections.singleton(new StackLevelConfigurationRequest(name, version, null)));
-
- for (ReadOnlyConfigurationResponse config : stackLevelConfigs) {
- ConfigProperty configProperty = new ConfigProperty(config);
- String type = configProperty.getType();
-
- Map<String, ConfigProperty> mapTypeConfig = stackConfigurations.get(type);
- if (mapTypeConfig == null) {
- mapTypeConfig = new HashMap<>();
- stackConfigurations.put(type, mapTypeConfig);
- }
-
- mapTypeConfig.put(config.getPropertyName(),
- configProperty);
- }
- }
-
- /**
- * Obtain the excluded configuration types from the StackServiceResponse
- *
- * @param stackServiceResponse the response object associated with this stack service
- */
- private void parseExcludedConfigurations(StackServiceResponse stackServiceResponse) {
- excludedConfigurationTypes.put(stackServiceResponse.getServiceName(), stackServiceResponse.getExcludedConfigTypes());
- }
-
- /**
- * Register conditional dependencies.
- */
- //todo: This information should be specified in the stack definition.
- void registerConditionalDependencies() {
- dbDependencyInfo.put("MYSQL_SERVER", "global/hive_database");
- }
-
- /**
- * Contains a configuration property's value and attributes.
- */
- public static class ConfigProperty {
- private ValueAttributesInfo propertyValueAttributes = null;
- private String name;
- private String value;
- private Map<String, String> attributes;
- private Set<org.apache.ambari.server.state.PropertyInfo.PropertyType> propertyTypes;
- private String type;
- private Set<PropertyDependencyInfo> dependsOnProperties =
- Collections.emptySet();
-
- public ConfigProperty(ReadOnlyConfigurationResponse config) {
- this.name = config.getPropertyName();
- this.value = config.getPropertyValue();
- this.attributes = config.getPropertyAttributes();
- this.propertyTypes = config.getPropertyType();
- this.type = normalizeType(config.getType());
- this.dependsOnProperties = config.getDependsOnProperties();
- this.propertyValueAttributes = config.getPropertyValueAttributes();
- }
-
- public ConfigProperty(String type, String name, String value) {
- this.type = type;
- this.name = name;
- this.value = value;
- }
-
- public String getName() {
- return name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public String getType() {
- return type;
- }
-
- public Set<org.apache.ambari.server.state.PropertyInfo.PropertyType> getPropertyTypes() {
- return propertyTypes;
- }
-
- public void setPropertyTypes(Set<PropertyInfo.PropertyType> propertyTypes) {
- this.propertyTypes = propertyTypes;
- }
-
- public Map<String, String> getAttributes() {
- return attributes;
- }
-
- public void setAttributes(Map<String, String> attributes) {
- this.attributes = attributes;
- }
-
- Set<PropertyDependencyInfo> getDependsOnProperties() {
- return this.dependsOnProperties;
- }
-
- private String normalizeType(String type) {
- //strip .xml from type
- if (type.endsWith(".xml")) {
- type = type.substring(0, type.length() - 4);
- }
- return type;
- }
-
- public ValueAttributesInfo getPropertyValueAttributes() {
- return propertyValueAttributes;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UnitUpdater.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UnitUpdater.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UnitUpdater.java
index a566625..3a70f81 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UnitUpdater.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UnitUpdater.java
@@ -24,6 +24,7 @@ import java.util.Collections;
import java.util.Map;
import java.util.Optional;
+import org.apache.ambari.server.controller.StackV2;
import org.apache.ambari.server.topology.ClusterTopology;
import org.apache.ambari.server.topology.validators.UnitValidatedProperty;
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
index 0434728..9270e7d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
@@ -53,6 +53,7 @@ import org.apache.ambari.server.controller.ServiceComponentHostRequest;
import org.apache.ambari.server.controller.ServiceComponentRequest;
import org.apache.ambari.server.controller.ServiceGroupRequest;
import org.apache.ambari.server.controller.ServiceRequest;
+import org.apache.ambari.server.controller.StackV2;
import org.apache.ambari.server.controller.internal.AbstractResourceProvider;
import org.apache.ambari.server.controller.internal.ComponentResourceProvider;
import org.apache.ambari.server.controller.internal.ConfigGroupResourceProvider;
@@ -62,7 +63,6 @@ import org.apache.ambari.server.controller.internal.ProvisionClusterRequest;
import org.apache.ambari.server.controller.internal.RequestImpl;
import org.apache.ambari.server.controller.internal.ServiceGroupResourceProvider;
import org.apache.ambari.server.controller.internal.ServiceResourceProvider;
-import org.apache.ambari.server.controller.internal.StackV2;
import org.apache.ambari.server.controller.internal.VersionDefinitionResourceProvider;
import org.apache.ambari.server.controller.predicate.EqualsPredicate;
import org.apache.ambari.server.controller.spi.ClusterController;
@@ -242,7 +242,8 @@ public class AmbariContext {
for (Service service : serviceGroup.getServices()) {
String credentialStoreEnabled = topology.getBlueprint().getCredentialStoreEnabled(service.getType());
- StackV2 stack = service.getStack();
+ String stackIdStr = service.getStackId();
+ StackV2 stack = topology.getBlueprint().getStackById(stackIdStr);
StackId stackId = new StackId(stack.getName(), stack.getVersion());
RepositoryVersionEntity repoVersion = repositoryVersionDAO.findByStackAndVersion(stackId, stack.getRepoVersion());
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintFactory.java
----------------------------------------------------------------------
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 fc419cb..404068d 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
@@ -82,10 +82,10 @@ public class BlueprintFactory {
this.stackFactory = stackFactory;
}
- public BlueprintV2 getBlueprint(String blueprintName) throws NoSuchStackException {
+ public Blueprint getBlueprint(String blueprintName) throws NoSuchStackException {
BlueprintEntity entity = blueprintDAO.findByName(blueprintName);
//todo: just return null?
- return entity == null ? null : new BlueprintImplV2(entity);
+ return entity == null ? null : new BlueprintImpl(entity);
}
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
index b2119e6..4b7dd32 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
@@ -135,33 +135,45 @@ public class BlueprintImplV2 implements BlueprintV2 {
@Override
@JsonIgnore
- public Collection<ServiceId> getAllServices() {
- return hostGroups.stream().flatMap(hg -> hg.getServices().stream()).collect(Collectors.toSet());
+ public Collection<ServiceId> getAllServiceIds() {
+ return hostGroups.stream().flatMap(hg -> hg.getServiceIds().stream()).collect(Collectors.toSet());
}
@Override
@JsonIgnore
- public Collection<String> getAllServiceTypes() {
+ public Collection<Service> getServicesFromServiceGroup(ServiceGroup serviceGroup, String serviceType) {
+ if (serviceType == null) {
+ return serviceGroup.getServices();
+ } else {
+ return serviceGroup.getServices().stream().filter(
+ service -> service.getType().equalsIgnoreCase(serviceType)).collect(Collectors.toList());
+ }
+ }
+
+ @Override
+ @JsonIgnore
+ public StackV2 getStackById(String stackId) {
return null;
}
@Override
@JsonIgnore
- public Collection<Service> getServicesByType(String serviceType) {
+ public Collection<Service> getAllServices() {
return null;
-// getAllServices().stream().filter(
-// service -> service.getType().equalsIgnoreCase(serviceType)).collect(Collectors.toList());
}
@Override
@JsonIgnore
- public Collection<Service> getServicesFromServiceGroup(ServiceGroup serviceGroup, String serviceType) {
- if (serviceType == null) {
- return serviceGroup.getServices();
- } else {
- return serviceGroup.getServices().stream().filter(
- service -> service.getType().equalsIgnoreCase(serviceType)).collect(Collectors.toList());
- }
+ public Collection<String> getAllServiceTypes() {
+ return null;
+ }
+
+ @Override
+ @JsonIgnore
+ public Collection<Service> getServicesByType(String serviceType) {
+ return null;
+// getAllServices().stream().filter(
+// service -> service.getType().equalsIgnoreCase(serviceType)).collect(Collectors.toList());
}
@Override
@@ -186,7 +198,7 @@ public class BlueprintImplV2 implements BlueprintV2 {
@Override
@JsonIgnore
public Collection<HostGroupV2> getHostGroupsForService(ServiceId serviceId) {
- return hostGroups.stream().filter(hg -> !hg.getComponents(serviceId).isEmpty()).collect(Collectors.toList());
+ return hostGroups.stream().filter(hg -> !hg.getComponentsByServiceId(serviceId).isEmpty()).collect(Collectors.toList());
}
@Override
@@ -205,10 +217,7 @@ public class BlueprintImplV2 implements BlueprintV2 {
return this.setting;
}
- @Override
- public String getRecoveryEnabled(ComponentV2 component) {
- return null;
- }
+
@Nonnull
@Override
@@ -224,6 +233,10 @@ public class BlueprintImplV2 implements BlueprintV2 {
}
@Override
+ public String getRecoveryEnabled(ComponentV2 component) {
+ return null;
+ }
+
public String getRecoveryEnabled(String serviceName, String componentName) {
// If component name was specified in the list of "component_settings",
// determine if recovery_enabled is true or false and return it.
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
index ea17e90..29539db 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2.java
@@ -22,11 +22,9 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
-
import javax.annotation.Nonnull;
import org.apache.ambari.server.controller.StackV2;
-
import org.apache.ambari.server.orm.entities.BlueprintEntity;
@@ -69,6 +67,8 @@ public interface BlueprintV2 {
**/
public Collection<String> getStackIds();
+ StackV2 getStackById(String stackId);
+
Collection<ServiceGroup> getServiceGroups();
/**
@@ -76,7 +76,9 @@ public interface BlueprintV2 {
*
* @return collection of all represented service names
*/
- Collection<ServiceId> getAllServices();
+ Collection<ServiceId> getAllServiceIds();
+
+ ;Collection<Service> getAllServices();
/**
* Get the names of all the services represented in the blueprint.
@@ -129,6 +131,8 @@ public interface BlueprintV2 {
*/
Collection<ComponentV2> getComponents(ServiceId serviceId);
+ Collection<ComponentV2> getComponents(Service service);
+
/**
* Get components by type from a service.
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
index 6b86ba5..b3ce044 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ClusterConfigurationRequest.java
@@ -33,11 +33,11 @@ import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorBlueprintProcessor;
import org.apache.ambari.server.controller.ClusterRequest;
import org.apache.ambari.server.controller.ConfigurationRequest;
+import org.apache.ambari.server.controller.StackV2;
import org.apache.ambari.server.controller.internal.BlueprintConfigurationProcessor;
import org.apache.ambari.server.controller.internal.ClusterResourceProvider;
import org.apache.ambari.server.controller.internal.ConfigurationContext;
import org.apache.ambari.server.controller.internal.ConfigurationTopologyException;
-import org.apache.ambari.server.controller.internal.StackV2;
import org.apache.ambari.server.serveraction.kerberos.KerberosInvalidConfigurationException;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.SecurityType;
@@ -361,7 +361,8 @@ public class ClusterConfigurationRequest {
//todo: remove intermediate request type
// one bp config request per service
BlueprintServiceConfigRequest blueprintConfigRequest = new BlueprintServiceConfigRequest(service.getType());
- StackV2 serviceStack = service.getStack();
+ String serviceStackId = service.getStackId();
+ StackV2 serviceStack = blueprint.getStackById(serviceStackId);
for (String serviceConfigType : serviceStack.getAllConfigurationTypes(service.getType())) {
Set<String> excludedConfigTypes = serviceStack.getExcludedConfigurationTypes(service.getType());
if (!excludedConfigTypes.contains(serviceConfigType)) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java
index 43dda1b..e59b1f9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/ComponentV2.java
@@ -69,6 +69,16 @@ public class ComponentV2 implements Configurable {
return serviceId;
}
+ //TODO
+ public Service getService() {
+ return null;
+ }
+
+ //TODO
+ public ServiceGroup getServiceGroup() {
+ return null;
+ }
+
public Configuration getConfiguration() {
return configuration;
}
@@ -88,7 +98,7 @@ public class ComponentV2 implements Configurable {
this.name = name;
}
- public String getServiceGroup() {
+ public String getServiceGroupName() {
return serviceId.getServiceGroup();
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java
index 0922e74..4745f59 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2.java
@@ -87,7 +87,9 @@ public interface HostGroupV2 {
*
* @return collection of component names for the specified service; will not return null
*/
- Collection<ComponentV2> getComponents(ServiceId serviceId);
+ Collection<ComponentV2> getComponentsByServiceId(ServiceId serviceId);
+
+ Collection<ComponentV2> getComponents(Service serviceId);
/**
* Determine if the host group contains a master component.
@@ -99,7 +101,12 @@ public interface HostGroupV2 {
/**
* @return collection of service ids associated with the host group components.
*/
- Collection<ServiceId> getServices();
+ Collection<ServiceId> getServiceIds();
+
+ /**
+ * @return collection of service ids associated with the host group components.
+ */
+ Collection<Service> getServices();
/**
* @return collection of service names associated with the host group components.
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
index 351351b..e9f4f4b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupV2Impl.java
@@ -67,7 +67,12 @@ public class HostGroupV2Impl implements HostGroupV2, Configurable {
}
@Override
- public Collection<ComponentV2> getComponents(ServiceId serviceId) {
+ public Collection<ComponentV2> getComponents(Service serviceId) {
+ return null;
+ }
+
+ @Override
+ public Collection<ComponentV2> getComponentsByServiceId(ServiceId serviceId) {
return components.stream().filter(c -> c.getServiceId().equals(serviceId)).collect(Collectors.toList());
}
@@ -77,13 +82,18 @@ public class HostGroupV2Impl implements HostGroupV2, Configurable {
}
@Override
- @JsonIgnore
- public Collection<ServiceId> getServices() {
+ public Collection<ServiceId> getServiceIds() {
return services;
}
@Override
@JsonIgnore
+ public Collection<Service> getServices() {
+ return null;
+ }
+
+ @Override
+ @JsonIgnore
public Collection<String> getServiceNames() {
return services.stream().map(s -> s.getName()).collect(Collectors.toList());
}
@@ -94,6 +104,11 @@ public class HostGroupV2Impl implements HostGroupV2, Configurable {
}
@Override
+ public Collection<Service> getServiceConfigs() {
+ return null;
+ }
+
+ @Override
public String getCardinality() {
return cardinality;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
index 3243359..685d208 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostRequest.java
@@ -31,9 +31,9 @@ import java.util.Map;
import org.apache.ambari.server.actionmanager.HostRoleCommand;
import org.apache.ambari.server.api.predicate.InvalidQueryException;
import org.apache.ambari.server.api.predicate.PredicateCompiler;
+import org.apache.ambari.server.controller.StackV2;
import org.apache.ambari.server.controller.internal.HostResourceProvider;
import org.apache.ambari.server.controller.internal.ResourceImpl;
-import org.apache.ambari.server.controller.internal.StackV2;
import org.apache.ambari.server.controller.spi.Predicate;
import org.apache.ambari.server.controller.spi.Resource;
import org.apache.ambari.server.orm.entities.HostRoleCommandEntity;
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
index 8b51fab..a9a132b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
@@ -18,6 +18,7 @@
package org.apache.ambari.server.topology;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -93,7 +94,7 @@ public class PersistedStateImpl implements PersistedState {
private HostRoleCommandDAO physicalTaskDAO;
@Inject
- private BlueprintFactory blueprintFactory;
+ private BlueprintV2Factory blueprintFactory;
@Inject
private LogicalRequestFactory logicalRequestFactory;
@@ -382,13 +383,17 @@ public class PersistedStateImpl implements PersistedState {
private final Collection<Service> services;
private final Map<String, HostGroupInfo> hostGroupInfoMap = new HashMap<>();
- public ReplayedTopologyRequest(TopologyRequestEntity entity, BlueprintFactory blueprintFactory) {
+ public ReplayedTopologyRequest(TopologyRequestEntity entity, BlueprintV2Factory blueprintFactory) {
clusterId = entity.getClusterId();
type = Type.valueOf(entity.getAction());
description = entity.getDescription();
try {
blueprint = blueprintFactory.getBlueprint(entity.getBlueprintName());
+ } catch (NoSuchBlueprintException e) {
+ throw new RuntimeException("Unable to load blueprint while replaying topology request: " + e, e);
+ } catch (IOException e) {
+ throw new RuntimeException("Unable to load blueprint while replaying topology request: " + e, e);
} catch (NoSuchStackException e) {
throw new RuntimeException("Unable to load blueprint while replaying topology request: " + e, e);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
index 1dde7ea..81f235c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/Service.java
@@ -21,6 +21,8 @@ package org.apache.ambari.server.topology;
import java.util.Set;
+import org.apache.ambari.server.controller.StackV2;
+
import com.fasterxml.jackson.annotation.JsonProperty;
public class Service implements Configurable {
@@ -44,10 +46,15 @@ public class Service implements Configurable {
return this.id.getName();
}
- public String getServiceGroup() {
+ public String getServiceGroupId() {
return this.id.getServiceGroup();
}
+ //TODO
+ public ServiceGroup getServiceGroup() {
+ return null;
+ }
+
public String getType() {
return type;
}
@@ -56,10 +63,20 @@ public class Service implements Configurable {
return stackId;
}
- public Set<ServiceId> getDependencies() {
+ //TODO
+ public StackV2 getStack() {
+ return null;
+ }
+
+ public Set<ServiceId> getDependentServiceIds() {
return dependencies;
}
+ //TODO
+ public Set<Service> getDependencies() {
+ return null;
+ }
+
public Configuration getConfiguration() {
return configuration;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
index 7691619..3b7dcc8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
@@ -42,6 +42,7 @@ import org.apache.ambari.server.configuration.Configuration;
import org.apache.ambari.server.controller.AmbariServer;
import org.apache.ambari.server.controller.RequestStatusResponse;
import org.apache.ambari.server.controller.ShortTaskStatus;
+import org.apache.ambari.server.controller.StackV2;
import org.apache.ambari.server.controller.internal.ArtifactResourceProvider;
import org.apache.ambari.server.controller.internal.BaseClusterRequest;
import org.apache.ambari.server.controller.internal.CalculatedStatus;
@@ -49,7 +50,6 @@ import org.apache.ambari.server.controller.internal.CredentialResourceProvider;
import org.apache.ambari.server.controller.internal.ProvisionClusterRequest;
import org.apache.ambari.server.controller.internal.RequestImpl;
import org.apache.ambari.server.controller.internal.ScaleClusterRequest;
-import org.apache.ambari.server.controller.internal.StackV2;
import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
import org.apache.ambari.server.controller.spi.RequestStatus;
import org.apache.ambari.server.controller.spi.Resource;
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java
index 94a1a5c..7ac75e9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/ClusterConfigTypeValidator.java
@@ -16,6 +16,7 @@ package org.apache.ambari.server.topology.validators;
import java.util.HashSet;
import java.util.Set;
+import org.apache.ambari.server.controller.StackV2;
import org.apache.ambari.server.topology.ClusterTopology;
import org.apache.ambari.server.topology.InvalidTopologyException;
import org.apache.ambari.server.topology.Service;
@@ -46,7 +47,9 @@ public class ClusterConfigTypeValidator implements TopologyValidator {
// collecting all config types for services in the blueprint (from the related stack)
Set<String> stackServiceConfigTypes = new HashSet<>();
for (Service service : topology.getBlueprint().getAllServices()) {
- stackServiceConfigTypes.addAll(service.getStack().getConfigurationTypes(service.getType()));
+ String stackId = service.getStackId();
+ StackV2 stack = topology.getBlueprint().getStackById(stackId);
+ stackServiceConfigTypes.addAll(stack.getConfigurationTypes(service.getType()));
}
// identifying invalid config types
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java
index 05c063c..fd07572 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredConfigPropertiesValidator.java
@@ -21,7 +21,7 @@ import java.util.Map;
import java.util.TreeMap;
import java.util.TreeSet;
-import org.apache.ambari.server.controller.internal.StackV2;
+import org.apache.ambari.server.controller.StackV2;
import org.apache.ambari.server.state.PropertyInfo;
import org.apache.ambari.server.topology.ClusterTopology;
import org.apache.ambari.server.topology.HostGroupV2;
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredPasswordValidator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredPasswordValidator.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredPasswordValidator.java
index 41dee07..2258d97 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredPasswordValidator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/RequiredPasswordValidator.java
@@ -19,7 +19,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
-import org.apache.ambari.server.controller.internal.StackV2;
+import org.apache.ambari.server.controller.StackV2;
import org.apache.ambari.server.state.PropertyInfo;
import org.apache.ambari.server.topology.BlueprintV2;
import org.apache.ambari.server.topology.ClusterTopology;
http://git-wip-us.apache.org/repos/asf/ambari/blob/841cc7e1/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/UnitValidator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/UnitValidator.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/UnitValidator.java
index 8c8475a..00b9838 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/UnitValidator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/validators/UnitValidator.java
@@ -22,7 +22,7 @@ import static org.apache.ambari.server.controller.internal.UnitUpdater.PropertyV
import java.util.Map;
import java.util.Set;
-import org.apache.ambari.server.controller.internal.StackV2;
+import org.apache.ambari.server.controller.StackV2;
import org.apache.ambari.server.controller.internal.UnitUpdater.PropertyUnit;
import org.apache.ambari.server.topology.ClusterTopology;
import org.apache.ambari.server.topology.InvalidTopologyException;
@@ -42,11 +42,13 @@ public class UnitValidator implements TopologyValidator {
@Override
public void validate(ClusterTopology topology) throws InvalidTopologyException {
topology.getServiceConfigs().forEach(service -> {
- validateConfig(service.getConfiguration().getFullProperties(), service.getStack());
- topology.getHostGroupInfo().values().forEach(hostGroup ->
- validateConfig(hostGroup.getConfiguration().getFullProperties(), service.getStack()));
+ String stackId = service.getStackId();
+ validateConfig(service.getConfiguration().getFullProperties(), topology.getBlueprint().getStackById(stackId));
+ topology.getHostGroupInfo().values().forEach(hostGroup -> {
+ String stackId2 = service.getStackId();
+ validateConfig(hostGroup.getConfiguration().getFullProperties(), topology.getBlueprint().getStackById(stackId2));
+ });
});
-
}
private void validateConfig(Map<String, Map<String, String>> configuration, StackV2 stack) {