You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2015/04/21 04:09:43 UTC
ambari git commit: AMBARI-10610 - Expose Stack to Configuration
Endpoints (jonathanhurley)
Repository: ambari
Updated Branches:
refs/heads/trunk eeea2eebe -> 3fd5c16e3
AMBARI-10610 - Expose Stack to Configuration Endpoints (jonathanhurley)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3fd5c16e
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3fd5c16e
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3fd5c16e
Branch: refs/heads/trunk
Commit: 3fd5c16e3a070bd4dd6a6529d5dff70c7be81cc1
Parents: eeea2ee
Author: Jonathan Hurley <jh...@hortonworks.com>
Authored: Mon Apr 20 15:52:42 2015 -0400
Committer: Jonathan Hurley <jh...@hortonworks.com>
Committed: Mon Apr 20 22:09:37 2015 -0400
----------------------------------------------------------------------
.../AmbariManagementControllerImpl.java | 12 +-
.../controller/ConfigurationResponse.java | 63 ++++++--
.../ServiceConfigVersionResponse.java | 148 +++++++++++--------
.../AbstractControllerResourceProvider.java | 4 +-
.../internal/ConfigurationResourceProvider.java | 79 ++++++----
.../ServiceConfigVersionResourceProvider.java | 98 +++++++++---
.../org/apache/ambari/server/state/Config.java | 9 +-
.../apache/ambari/server/state/ConfigImpl.java | 19 ++-
.../server/state/cluster/ClusterImpl.java | 44 ++----
.../src/main/resources/key_properties.json | 8 -
.../src/main/resources/properties.json | 18 ---
.../ConfigurationResourceProviderTest.java | 50 +++++--
.../internal/JMXHostProviderTest.java | 22 ++-
.../controller/internal/RequestImplTest.java | 11 --
14 files changed, 353 insertions(+), 232 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/3fd5c16e/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
----------------------------------------------------------------------
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 614134e..fedf18e 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
@@ -706,8 +706,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
Config config = createConfig(cluster, request.getType(), request.getProperties(),
request.getVersionTag(), propertiesAttributes);
- return new ConfigurationResponse(cluster.getClusterName(), config.getType(), config.getTag(), config.getVersion(),
- config.getProperties(), config.getPropertiesAttributes());
+ return new ConfigurationResponse(cluster.getClusterName(), config);
}
private void handleGlobalsBackwardsCompability(ConfigurationRequest request,
@@ -1151,8 +1150,7 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
request.getVersionTag());
if (null != config) {
ConfigurationResponse response = new ConfigurationResponse(
- cluster.getClusterName(), config.getType(), config.getTag(), config.getVersion(),
- config.getProperties(), config.getPropertiesAttributes());
+ cluster.getClusterName(), config);
responses.add(response);
}
}
@@ -1166,7 +1164,8 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
for (Entry<String, Config> entry : configs.entrySet()) {
Config config = entry.getValue();
ConfigurationResponse response = new ConfigurationResponse(
- cluster.getClusterName(), request.getType(),
+ cluster.getClusterName(), config.getStackId(),
+ request.getType(),
config.getTag(), entry.getValue().getVersion(),
includeProps ? config.getProperties() : new HashMap<String, String>(),
includeProps ? config.getPropertiesAttributes() : new HashMap<String, Map<String,String>>());
@@ -1179,7 +1178,8 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
for (Config config : all) {
ConfigurationResponse response = new ConfigurationResponse(
- cluster.getClusterName(), config.getType(), config.getTag(), config.getVersion(),
+ cluster.getClusterName(), config.getStackId(), config.getType(),
+ config.getTag(), config.getVersion(),
includeProps ? config.getProperties() : new HashMap<String, String>(),
includeProps ? config.getPropertiesAttributes() : new HashMap<String, Map<String,String>>());
http://git-wip-us.apache.org/repos/asf/ambari/blob/3fd5c16e/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigurationResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigurationResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigurationResponse.java
index dd5c667..d6b95c8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigurationResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigurationResponse.java
@@ -20,6 +20,9 @@ package org.apache.ambari.server.controller;
import java.util.List;
import java.util.Map;
+import org.apache.ambari.server.state.Config;
+import org.apache.ambari.server.state.StackId;
+
/**
* This class encapsulates a configuration update request.
* The configuration properties are grouped at service level. It is assumed that
@@ -29,6 +32,8 @@ public class ConfigurationResponse {
private final String clusterName;
+ private final StackId stackId;
+
private final String type;
private String versionTag;
@@ -41,13 +46,12 @@ public class ConfigurationResponse {
private Map<String, Map<String, String>> configAttributes;
- public ConfigurationResponse(String clusterName,
- String type, String versionTag,
- Long version,
- Map<String, String> configs,
- Map<String, Map<String, String>> configAttributes) {
- super();
+ public ConfigurationResponse(String clusterName, StackId stackId,
+ String type, String versionTag, Long version,
+ Map<String, String> configs,
+ Map<String, Map<String, String>> configAttributes) {
this.clusterName = clusterName;
+ this.stackId = stackId;
this.configs = configs;
this.type = type;
this.versionTag = versionTag;
@@ -56,6 +60,17 @@ public class ConfigurationResponse {
this.configAttributes = configAttributes;
}
+ /**
+ * Constructor.
+ *
+ * @param clusterName
+ * @param config
+ */
+ public ConfigurationResponse(String clusterName, Config config) {
+ this(clusterName, config.getStackId(), config.getType(), config.getTag(),
+ config.getVersion(), config.getProperties(),
+ config.getPropertiesAttributes());
+ }
/**
* @return the versionTag
@@ -115,16 +130,41 @@ public class ConfigurationResponse {
this.version = version;
}
+ /**
+ * Gets the Stack ID that this configuration is scoped for.
+ *
+ * @return
+ */
+ public StackId getStackId() {
+ return stackId;
+ }
+
@Override
public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
ConfigurationResponse that = (ConfigurationResponse) o;
- if (clusterName != null ? !clusterName.equals(that.clusterName) : that.clusterName != null) return false;
- if (type != null ? !type.equals(that.type) : that.type != null) return false;
- if (version != null ? !version.equals(that.version) : that.version != null) return false;
+ if (clusterName != null ? !clusterName.equals(that.clusterName) : that.clusterName != null) {
+ return false;
+ }
+
+ if (stackId != null ? !stackId.equals(that.stackId) : that.stackId != null) {
+ return false;
+ }
+
+ if (type != null ? !type.equals(that.type) : that.type != null) {
+ return false;
+ }
+
+ if (version != null ? !version.equals(that.version) : that.version != null) {
+ return false;
+ }
return true;
}
@@ -132,6 +172,7 @@ public class ConfigurationResponse {
@Override
public int hashCode() {
int result = clusterName != null ? clusterName.hashCode() : 0;
+ result = 31 * result + (stackId != null ? stackId.hashCode() : 0);
result = 31 * result + (type != null ? type.hashCode() : 0);
result = 31 * result + (version != null ? version.hashCode() : 0);
return result;
http://git-wip-us.apache.org/repos/asf/ambari/blob/3fd5c16e/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigVersionResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigVersionResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigVersionResponse.java
index 7aea65e..b478be8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigVersionResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigVersionResponse.java
@@ -19,73 +19,105 @@
package org.apache.ambari.server.controller;
+import java.util.List;
+
+import org.apache.ambari.server.orm.entities.ClusterEntity;
+import org.apache.ambari.server.orm.entities.ServiceConfigEntity;
+import org.apache.ambari.server.orm.entities.StackEntity;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
-import java.util.List;
-
public class ServiceConfigVersionResponse {
- private String clusterName;
- private String serviceName;
- private Long version;
- private Long createTime;
- private Long groupId;
- private String groupName;
- private String userName;
- private String note;
- private Boolean isCurrent = false;
- private List<ConfigurationResponse> configurations;
- private List<String> hosts;
+ @JsonProperty("cluster_name")
+ @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+ private final String clusterName;
@JsonProperty("service_name")
- public String getServiceName() {
- return serviceName;
+ private final String serviceName;
+
+ @JsonProperty("service_config_version")
+ private final Long version;
+
+ @JsonProperty("createtime")
+ @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+ private final Long createTime;
+
+ @JsonProperty("group_id")
+ private final Long groupId;
+
+ @JsonProperty("group_name")
+ private final String groupName;
+
+ @JsonProperty("user")
+ @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+ private final String userName;
+
+ @JsonProperty("service_config_version_note")
+ @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+ private final String note;
+
+ @JsonProperty("is_current")
+ private Boolean isCurrent = Boolean.FALSE;
+
+ @JsonProperty("is_cluster_compatible")
+ private final Boolean isCompatibleWithCurrentStack;
+
+ @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+ private List<ConfigurationResponse> configurations;
+
+ @JsonProperty("hosts")
+ private final List<String> hosts;
+
+ /**
+ * Constructor.
+ *
+ * @param clusterName
+ * @param serviceName
+ * @param version
+ * @param isCurrent
+ * @param isCompatibleWithCurrentStack
+ * @param configurations
+ */
+ public ServiceConfigVersionResponse(ServiceConfigEntity serviceConfigEntity,
+ String configGroupName) {
+ super();
+ ClusterEntity clusterEntity = serviceConfigEntity.getClusterEntity();
+
+ clusterName = clusterEntity.getClusterName();
+ serviceName = serviceConfigEntity.getServiceName();
+ version = serviceConfigEntity.getVersion();
+ userName = serviceConfigEntity.getUser();
+ createTime = serviceConfigEntity.getCreateTimestamp();
+ note = serviceConfigEntity.getNote();
+ groupId = serviceConfigEntity.getGroupId();
+ groupName = configGroupName;
+ hosts = serviceConfigEntity.getHostNames();
+
+ StackEntity serviceConfigStackEntity = serviceConfigEntity.getStack();
+ StackEntity clusterStackEntity = clusterEntity.getClusterStateEntity().getCurrentStack();
+
+ isCompatibleWithCurrentStack = clusterStackEntity.equals(serviceConfigStackEntity);
}
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
+ public String getServiceName() {
+ return serviceName;
}
- @JsonProperty("service_config_version")
public Long getVersion() {
return version;
}
- public void setVersion(Long version) {
- this.version = version;
- }
-
- @JsonProperty("createtime")
- @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public Long getCreateTime() {
return createTime;
}
- public void setCreateTime(Long createTime) {
- this.createTime = createTime;
- }
-
- @JsonProperty("user")
- @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public String getUserName() {
return userName;
}
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- @JsonProperty("cluster_name")
- @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public String getClusterName() {
return clusterName;
}
- public void setClusterName(String clusterName) {
- this.clusterName = clusterName;
- }
-
- @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public List<ConfigurationResponse> getConfigurations() {
return configurations;
}
@@ -94,44 +126,22 @@ public class ServiceConfigVersionResponse {
this.configurations = configurations;
}
- @JsonProperty("service_config_version_note")
- @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public String getNote() {
return note;
}
- public void setNote(String note) {
- this.note = note;
- }
-
public List<String> getHosts() {
return hosts;
}
- @JsonProperty("hosts")
- public void setHosts(List<String> hosts) {
- this.hosts = hosts;
- }
-
- @JsonProperty("group_name")
public String getGroupName() {
return groupName;
}
- public void setGroupName(String groupName) {
- this.groupName = groupName;
- }
-
- @JsonProperty("group_id")
public Long getGroupId() {
return groupId;
}
- public void setGroupId(Long groupId) {
- this.groupId = groupId;
- }
-
- @JsonProperty("is_current")
public Boolean getIsCurrent() {
return isCurrent;
}
@@ -139,5 +149,15 @@ public class ServiceConfigVersionResponse {
public void setIsCurrent(Boolean isCurrent) {
this.isCurrent = isCurrent;
}
+
+ /**
+ * Gets whether this service configuration is compatible with the cluster's
+ * current stack version.
+ *
+ * @return {@code true} if compatible, {@code false} otherwise.
+ */
+ public Boolean isCompatibleWithCurrentStack() {
+ return isCompatibleWithCurrentStack;
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3fd5c16e/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
index 20f15c0..0b34ada 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
@@ -100,9 +100,9 @@ public abstract class AbstractControllerResourceProvider extends AbstractResourc
case HostComponent:
return resourceProviderFactory.getHostComponentResourceProvider(propertyIds, keyPropertyIds, managementController);
case Configuration:
- return new ConfigurationResourceProvider(propertyIds, keyPropertyIds, managementController);
+ return new ConfigurationResourceProvider(managementController);
case ServiceConfigVersion:
- return new ServiceConfigVersionResourceProvider(propertyIds, keyPropertyIds, managementController);
+ return new ServiceConfigVersionResourceProvider(managementController);
case Action:
return new ActionResourceProvider(propertyIds, keyPropertyIds, managementController);
case Request:
http://git-wip-us.apache.org/repos/asf/ambari/blob/3fd5c16e/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationResourceProvider.java
index 98d1a46..4b5ee00 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigurationResourceProvider.java
@@ -18,6 +18,14 @@
package org.apache.ambari.server.controller.internal;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.regex.Pattern;
+
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.controller.AmbariManagementController;
import org.apache.ambari.server.controller.ConfigurationRequest;
@@ -33,34 +41,47 @@ import org.apache.ambari.server.controller.spi.SystemException;
import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
import org.apache.ambari.server.controller.utilities.PropertyHelper;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-import java.util.regex.Pattern;
-
/**
* Resource provider for configuration resources.
*/
public class ConfigurationResourceProvider extends
- AbstractControllerResourceProvider {
+ AbstractControllerResourceProvider {
- private static Pattern propertiesAttributesPattern = Pattern.compile("^" + PROPERTIES_ATTRIBUTES_REGEX);
+ private static final Pattern PROPERTIES_ATTRIBUTES_PATTERN = Pattern.compile("^"
+ + PROPERTIES_ATTRIBUTES_REGEX);
// ----- Property ID constants ---------------------------------------------
-
- // Configurations (values are part of query strings and body post, so they don't have defined categories)
protected static final String CONFIGURATION_CLUSTER_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("Config", "cluster_name");
- // TODO : should these be Config/type and Config/tag to be consistent?
- public static final String CONFIGURATION_CONFIG_TYPE_PROPERTY_ID =
- PropertyHelper.getPropertyId(null, "type");
- public static final String CONFIGURATION_CONFIG_TAG_PROPERTY_ID =
- PropertyHelper.getPropertyId(null, "tag");
- public static final String CONFIGURATION_CONFIG_VERSION_PROPERTY_ID =
- PropertyHelper.getPropertyId(null, "version");
+ protected static final String CONFIGURATION_STACK_ID_PROPERTY_ID = PropertyHelper.getPropertyId("Config", "stack_id");
+
+ // !!! values are part of query strings and body post, so they
+ // don't have defined categories (like Config)
+ public static final String CONFIGURATION_CONFIG_TYPE_PROPERTY_ID = PropertyHelper.getPropertyId(null, "type");
+ public static final String CONFIGURATION_CONFIG_TAG_PROPERTY_ID = PropertyHelper.getPropertyId(null, "tag");
+ public static final String CONFIGURATION_CONFIG_VERSION_PROPERTY_ID = PropertyHelper.getPropertyId(null, "version");
+
+ /**
+ * The property ids for a configuration resource.
+ */
+ private static final Set<String> PROPERTY_IDS = new HashSet<String>();
+ /**
+ * The key property ids for a configuration resource.
+ */
+ private static final Map<Resource.Type, String> KEY_PROPERTY_IDS = new HashMap<Resource.Type, String>();
+
+ static {
+ // properties
+ PROPERTY_IDS.add(CONFIGURATION_CLUSTER_NAME_PROPERTY_ID);
+ PROPERTY_IDS.add(CONFIGURATION_STACK_ID_PROPERTY_ID);
+ PROPERTY_IDS.add(CONFIGURATION_CONFIG_TYPE_PROPERTY_ID);
+ PROPERTY_IDS.add(CONFIGURATION_CONFIG_TAG_PROPERTY_ID);
+ PROPERTY_IDS.add(CONFIGURATION_CONFIG_VERSION_PROPERTY_ID);
+
+ // keys
+ KEY_PROPERTY_IDS.put(Resource.Type.Configuration,CONFIGURATION_CONFIG_TYPE_PROPERTY_ID);
+ KEY_PROPERTY_IDS.put(Resource.Type.Cluster,CONFIGURATION_CLUSTER_NAME_PROPERTY_ID);
+ }
/**
* The primary key property ids for the configuration resource type.
@@ -76,15 +97,11 @@ public class ConfigurationResourceProvider extends
/**
* Constructor
*
- * @param propertyIds the property ids supported by this provider
- * @param keyPropertyIds the key properties for this provider
* @param managementController the associated management controller
*/
- ConfigurationResourceProvider(Set<String> propertyIds,
- Map<Resource.Type, String> keyPropertyIds,
- AmbariManagementController managementController) {
+ ConfigurationResourceProvider(AmbariManagementController managementController) {
- super(propertyIds, keyPropertyIds, managementController);
+ super(PROPERTY_IDS, KEY_PROPERTY_IDS, managementController);
}
@@ -110,7 +127,9 @@ public class ConfigurationResourceProvider extends
if (propertyCategory != null && propertyCategory.equals("properties") && null != entry.getValue()) {
configMap.put(PropertyHelper.getPropertyName(entry.getKey()), entry.getValue().toString());
}
- if (propertyCategory != null && propertiesAttributesPattern.matcher(propertyCategory).matches() && null != entry.getValue()) {
+ if (propertyCategory != null
+ && PROPERTIES_ATTRIBUTES_PATTERN.matcher(propertyCategory).matches()
+ && null != entry.getValue()) {
if (null == configAttributesMap) {
configAttributesMap = new HashMap<String, Map<String,String>>();
}
@@ -157,8 +176,12 @@ public class ConfigurationResourceProvider extends
Set<Resource> resources = new HashSet<Resource>();
for (ConfigurationResponse response : responses) {
+ // don't use the StackId object here; we just want the stack ID string
+ String stackId = response.getStackId().getStackId();
+
Resource resource = new ResourceImpl(Resource.Type.Configuration);
resource.setProperty(CONFIGURATION_CLUSTER_NAME_PROPERTY_ID, response.getClusterName());
+ resource.setProperty(CONFIGURATION_STACK_ID_PROPERTY_ID, stackId);
resource.setProperty(CONFIGURATION_CONFIG_TYPE_PROPERTY_ID, response.getType());
resource.setProperty(CONFIGURATION_CONFIG_TAG_PROPERTY_ID, response.getVersionTag());
resource.setProperty(CONFIGURATION_CONFIG_VERSION_PROPERTY_ID, response.getVersion());
@@ -220,7 +243,9 @@ public class ConfigurationResourceProvider extends
String propertyCategory = PropertyHelper.getPropertyCategory(propertyId);
- if (propertyCategory == null || !(propertyCategory.equals("properties") || propertiesAttributesPattern.matcher(propertyCategory).matches())) {
+ if (propertyCategory == null
+ || !(propertyCategory.equals("properties") || PROPERTIES_ATTRIBUTES_PATTERN.matcher(
+ propertyCategory).matches())) {
unsupportedProperties.add(propertyId);
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3fd5c16e/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java
index f055375..aa4087d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java
@@ -19,18 +19,35 @@
package org.apache.ambari.server.controller.internal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.controller.AmbariManagementController;
import org.apache.ambari.server.controller.ConfigurationResponse;
import org.apache.ambari.server.controller.ServiceConfigVersionRequest;
import org.apache.ambari.server.controller.ServiceConfigVersionResponse;
-import org.apache.ambari.server.controller.spi.*;
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
+import org.apache.ambari.server.controller.spi.NoSuchResourceException;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.RequestStatus;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
import org.apache.ambari.server.controller.utilities.PropertyHelper;
-import java.util.*;
-
public class ServiceConfigVersionResourceProvider extends
AbstractControllerResourceProvider {
+
public static final String SERVICE_CONFIG_VERSION_CLUSTER_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(null, "cluster_name");
public static final String SERVICE_CONFIG_VERSION_PROPERTY_ID = PropertyHelper.getPropertyId(null, "service_config_version");
public static final String SERVICE_CONFIG_VERSION_SERVICE_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(null, "service_name");
@@ -40,10 +57,42 @@ public class ServiceConfigVersionResourceProvider extends
public static final String SERVICE_CONFIG_VERSION_GROUP_ID_PROPERTY_ID = PropertyHelper.getPropertyId(null, "group_id");
public static final String SERVICE_CONFIG_VERSION_GROUP_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(null, "group_name");
public static final String SERVICE_CONFIG_VERSION_IS_CURRENT_PROPERTY_ID = PropertyHelper.getPropertyId(null, "is_current");
+ public static final String SERVICE_CONFIG_VERSION_IS_COMPATIBLE_PROPERTY_ID = PropertyHelper.getPropertyId(null, "is_cluster_compatible");
public static final String SERVICE_CONFIG_VERSION_HOSTS_PROPERTY_ID = PropertyHelper.getPropertyId(null, "hosts");
public static final String SERVICE_CONFIG_VERSION_CONFIGURATIONS_PROPERTY_ID = PropertyHelper.getPropertyId(null, "configurations");
/**
+ * The property ids for a service configuration resource.
+ */
+ private static final Set<String> PROPERTY_IDS = new HashSet<String>();
+
+ /**
+ * The key property ids for a service configuration resource.
+ */
+ private static final Map<Resource.Type, String> KEY_PROPERTY_IDS = new HashMap<Resource.Type, String>();
+
+ static {
+ // properties
+ PROPERTY_IDS.add(SERVICE_CONFIG_VERSION_CLUSTER_NAME_PROPERTY_ID);
+ PROPERTY_IDS.add(SERVICE_CONFIG_VERSION_PROPERTY_ID);
+ PROPERTY_IDS.add(SERVICE_CONFIG_VERSION_SERVICE_NAME_PROPERTY_ID);
+ PROPERTY_IDS.add(SERVICE_CONFIG_VERSION_CREATE_TIME_PROPERTY_ID);
+ PROPERTY_IDS.add(SERVICE_CONFIG_VERSION_USER_PROPERTY_ID);
+ PROPERTY_IDS.add(SERVICE_CONFIG_VERSION_NOTE_PROPERTY_ID);
+ PROPERTY_IDS.add(SERVICE_CONFIG_VERSION_GROUP_ID_PROPERTY_ID);
+ PROPERTY_IDS.add(SERVICE_CONFIG_VERSION_GROUP_NAME_PROPERTY_ID);
+ PROPERTY_IDS.add(SERVICE_CONFIG_VERSION_IS_CURRENT_PROPERTY_ID);
+ PROPERTY_IDS.add(SERVICE_CONFIG_VERSION_HOSTS_PROPERTY_ID);
+ PROPERTY_IDS.add(SERVICE_CONFIG_VERSION_CONFIGURATIONS_PROPERTY_ID);
+ PROPERTY_IDS.add(SERVICE_CONFIG_VERSION_IS_COMPATIBLE_PROPERTY_ID);
+
+ // keys
+ KEY_PROPERTY_IDS.put(Resource.Type.ServiceConfigVersion,SERVICE_CONFIG_VERSION_SERVICE_NAME_PROPERTY_ID);
+ KEY_PROPERTY_IDS.put(Resource.Type.Cluster,SERVICE_CONFIG_VERSION_CLUSTER_NAME_PROPERTY_ID);
+ }
+
+
+ /**
* The primary key property ids for the service config version resource type.
*/
private static Set<String> pkPropertyIds =
@@ -57,15 +106,11 @@ public class ServiceConfigVersionResourceProvider extends
/**
* Constructor
*
- * @param propertyIds the property ids supported by this provider
- * @param keyPropertyIds the key properties for this provider
* @param managementController the associated management controller
*/
- ServiceConfigVersionResourceProvider(Set<String> propertyIds,
- Map<Resource.Type, String> keyPropertyIds,
- AmbariManagementController managementController) {
-
- super(propertyIds, keyPropertyIds, managementController);
+ ServiceConfigVersionResourceProvider(
+ AmbariManagementController managementController) {
+ super(PROPERTY_IDS, KEY_PROPERTY_IDS, managementController);
}
@@ -95,19 +140,23 @@ public class ServiceConfigVersionResourceProvider extends
Set<Resource> resources = new HashSet<Resource>();
for (ServiceConfigVersionResponse response : responses) {
+ String clusterName = response.getClusterName();
+ List<ConfigurationResponse> configurationResponses = response.getConfigurations();
+ List<Map<String,Object>> configVersionConfigurations = convertToSubResources(clusterName, configurationResponses);
+
Resource resource = new ResourceImpl(Resource.Type.ServiceConfigVersion);
- resource.setProperty(SERVICE_CONFIG_VERSION_CLUSTER_NAME_PROPERTY_ID, response.getClusterName());
+ resource.setProperty(SERVICE_CONFIG_VERSION_CLUSTER_NAME_PROPERTY_ID, clusterName);
resource.setProperty(SERVICE_CONFIG_VERSION_SERVICE_NAME_PROPERTY_ID, response.getServiceName());
resource.setProperty(SERVICE_CONFIG_VERSION_USER_PROPERTY_ID, response.getUserName());
resource.setProperty(SERVICE_CONFIG_VERSION_PROPERTY_ID, response.getVersion());
resource.setProperty(SERVICE_CONFIG_VERSION_CREATE_TIME_PROPERTY_ID, response.getCreateTime());
- resource.setProperty(SERVICE_CONFIG_VERSION_CONFIGURATIONS_PROPERTY_ID,
- convertToSubResources(response.getClusterName(), response.getConfigurations()));
+ resource.setProperty(SERVICE_CONFIG_VERSION_CONFIGURATIONS_PROPERTY_ID, configVersionConfigurations);
resource.setProperty(SERVICE_CONFIG_VERSION_NOTE_PROPERTY_ID, response.getNote());
resource.setProperty(SERVICE_CONFIG_VERSION_GROUP_ID_PROPERTY_ID, response.getGroupId());
resource.setProperty(SERVICE_CONFIG_VERSION_GROUP_NAME_PROPERTY_ID, response.getGroupName());
resource.setProperty(SERVICE_CONFIG_VERSION_HOSTS_PROPERTY_ID, response.getHosts());
resource.setProperty(SERVICE_CONFIG_VERSION_IS_CURRENT_PROPERTY_ID, response.getIsCurrent());
+ resource.setProperty(SERVICE_CONFIG_VERSION_IS_COMPATIBLE_PROPERTY_ID, response.isCompatibleWithCurrentStack());
resources.add(resource);
}
@@ -165,14 +214,21 @@ public class ServiceConfigVersionResourceProvider extends
private List<Map<String, Object>> convertToSubResources(final String clusterName, List<ConfigurationResponse> configs) {
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
for (final ConfigurationResponse config : configs) {
- Map<String, Object> configMap = new LinkedHashMap<String, Object>();
- configMap.put("Config", new HashMap<String, String>(){{put("cluster_name", clusterName);}});
- configMap.put("type", config.getType());
- configMap.put("tag", config.getVersionTag());
- configMap.put("version", config.getVersion());
- configMap.put("properties", new TreeMap(config.getConfigs()));
- configMap.put("properties_attributes", config.getConfigAttributes());
- result.add(configMap);
+ Map<String, Object> subResourceMap = new LinkedHashMap<String, Object>();
+ Map<String,String> configMap = new HashMap<String, String>();
+
+ String stackId = config.getStackId().getStackId();
+
+ configMap.put("cluster_name", clusterName);
+ configMap.put("stack_id", stackId);
+
+ subResourceMap.put("Config", configMap);
+ subResourceMap.put("type", config.getType());
+ subResourceMap.put("tag", config.getVersionTag());
+ subResourceMap.put("version", config.getVersion());
+ subResourceMap.put("properties", new TreeMap(config.getConfigs()));
+ subResourceMap.put("properties_attributes", config.getConfigAttributes());
+ result.add(subResourceMap);
}
return result;
http://git-wip-us.apache.org/repos/asf/ambari/blob/3fd5c16e/ambari-server/src/main/java/org/apache/ambari/server/state/Config.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/Config.java b/ambari-server/src/main/java/org/apache/ambari/server/state/Config.java
index bdfe1bd..7eeea7d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/Config.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/Config.java
@@ -37,6 +37,13 @@ public interface Config {
public String getTag();
/**
+ * Gets the stack that this configuration belongs to.
+ *
+ * @return the stack (not {@code null).
+ */
+ public StackId getStackId();
+
+ /**
*
* @return version of config by type
*/
@@ -93,7 +100,7 @@ public interface Config {
* @param properties Property keys to be deleted
*/
public void deleteProperties(List<String> properties);
-
+
/**
* Persist the configuration.
*/
http://git-wip-us.apache.org/repos/asf/ambari/blob/3fd5c16e/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigImpl.java
index 5176d69..ff11e70 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigImpl.java
@@ -40,6 +40,7 @@ public class ConfigImpl implements Config {
public static final String GENERATED_TAG_PREFIX = "generatedTag_";
private Cluster cluster;
+ private StackId stackId;
private String type;
private String tag;
private Long version;
@@ -59,6 +60,7 @@ public class ConfigImpl implements Config {
public ConfigImpl(@Assisted Cluster cluster, @Assisted String type, @Assisted Map<String, String> properties,
@Assisted Map<String, Map<String, String>> propertiesAttributes, Injector injector) {
this.cluster = cluster;
+ stackId = cluster.getCurrentStackVersion();
this.type = type;
this.properties = properties;
this.propertiesAttributes = propertiesAttributes;
@@ -69,6 +71,7 @@ public class ConfigImpl implements Config {
@AssistedInject
public ConfigImpl(@Assisted Cluster cluster, @Assisted ClusterConfigEntity entity, Injector injector) {
this.cluster = cluster;
+ stackId = cluster.getCurrentStackVersion();
type = entity.getType();
tag = entity.getTag();
version = entity.getVersion();
@@ -83,6 +86,14 @@ public class ConfigImpl implements Config {
this.type = type;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public StackId getStackId() {
+ return stackId;
+ }
+
@Override
public String getType() {
return type;
@@ -163,10 +174,9 @@ public class ConfigImpl implements Config {
}
}
- @Transactional
@Override
+ @Transactional
public synchronized void persist() {
-
ClusterEntity clusterEntity = clusterDAO.findById(cluster.getClusterId());
ClusterConfigEntity entity = new ClusterConfigEntity();
@@ -182,14 +192,11 @@ public class ConfigImpl implements Config {
if (null != getPropertiesAttributes()) {
entity.setAttributes(gson.toJson(getPropertiesAttributes()));
}
+
clusterDAO.createConfig(entity);
clusterEntity.getClusterConfigEntities().add(entity);
clusterDAO.merge(clusterEntity);
cluster.refresh();
-
}
-
-
-
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3fd5c16e/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
index 0d9c36a..496eda5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
@@ -1962,17 +1962,10 @@ public class ClusterImpl implements Cluster {
configGroup==null?"-1":configGroup.getId(),
serviceConfigEntity.getVersion());
- ServiceConfigVersionResponse response = new ServiceConfigVersionResponse();
- response.setUserName(user);
- response.setClusterName(getClusterName());
- response.setVersion(serviceConfigEntity.getVersion());
- response.setServiceName(serviceConfigEntity.getServiceName());
- response.setCreateTime(serviceConfigEntity.getCreateTimestamp());
- response.setUserName(serviceConfigEntity.getUser());
- response.setNote(serviceConfigEntity.getNote());
- response.setGroupId(serviceConfigEntity.getGroupId());
- response.setHosts(serviceConfigEntity.getHostNames());
- response.setGroupName(configGroup != null ? configGroup.getName() : null);
+ String configGroupName = configGroup != null ? configGroup.getName() : null;
+
+ ServiceConfigVersionResponse response = new ServiceConfigVersionResponse(
+ serviceConfigEntity, configGroupName);
return response;
}
@@ -2059,7 +2052,6 @@ public class ClusterImpl implements Cluster {
for (ServiceConfigEntity serviceConfigEntity : serviceConfigDAO.getServiceConfigs(getClusterId())) {
ServiceConfigVersionResponse serviceConfigVersionResponse = convertToServiceConfigVersionResponse(serviceConfigEntity);
- serviceConfigVersionResponse.setHosts(serviceConfigEntity.getHostNames());
serviceConfigVersionResponse.setConfigurations(new ArrayList<ConfigurationResponse>());
serviceConfigVersionResponse.setIsCurrent(activeIds.contains(serviceConfigEntity.getServiceConfigId()));
@@ -2067,10 +2059,11 @@ public class ClusterImpl implements Cluster {
for (ClusterConfigEntity clusterConfigEntity : clusterConfigEntities) {
Config config = allConfigs.get(clusterConfigEntity.getType()).get(
clusterConfigEntity.getTag());
+
serviceConfigVersionResponse.getConfigurations().add(
- new ConfigurationResponse(getClusterName(), config.getType(),
- config.getTag(), config.getVersion(), config.getProperties(),
- config.getPropertiesAttributes()));
+ new ConfigurationResponse(getClusterName(), config.getStackId(),
+ config.getType(), config.getTag(), config.getVersion(),
+ config.getProperties(), config.getPropertiesAttributes()));
}
serviceConfigVersionResponses.add(serviceConfigVersionResponse);
@@ -2128,34 +2121,27 @@ public class ClusterImpl implements Cluster {
@RequiresSession
ServiceConfigVersionResponse convertToServiceConfigVersionResponse(ServiceConfigEntity serviceConfigEntity) {
- ServiceConfigVersionResponse serviceConfigVersionResponse = new ServiceConfigVersionResponse();
-
- serviceConfigVersionResponse.setClusterName(getClusterName());
- serviceConfigVersionResponse.setServiceName(serviceConfigEntity.getServiceName());
- serviceConfigVersionResponse.setVersion(serviceConfigEntity.getVersion());
- serviceConfigVersionResponse.setCreateTime(serviceConfigEntity.getCreateTimestamp());
- serviceConfigVersionResponse.setUserName(serviceConfigEntity.getUser());
- serviceConfigVersionResponse.setNote(serviceConfigEntity.getNote());
-
Long groupId = serviceConfigEntity.getGroupId();
+ String groupName;
if (groupId != null) {
- serviceConfigVersionResponse.setGroupId(groupId);
ConfigGroup configGroup = null;
if (clusterConfigGroups != null) {
configGroup = clusterConfigGroups.get(groupId);
}
if (configGroup != null) {
- serviceConfigVersionResponse.setGroupName(configGroup.getName());
+ groupName = configGroup.getName();
} else {
- serviceConfigVersionResponse.setGroupName("deleted");
+ groupName = "deleted";
}
} else {
- serviceConfigVersionResponse.setGroupId(-1L); // -1 if no group
- serviceConfigVersionResponse.setGroupName("default");
+ groupName = "default";
}
+ ServiceConfigVersionResponse serviceConfigVersionResponse = new ServiceConfigVersionResponse(
+ serviceConfigEntity, groupName);
+
return serviceConfigVersionResponse;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3fd5c16e/ambari-server/src/main/resources/key_properties.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/key_properties.json b/ambari-server/src/main/resources/key_properties.json
index 3898963..cd9b617 100644
--- a/ambari-server/src/main/resources/key_properties.json
+++ b/ambari-server/src/main/resources/key_properties.json
@@ -22,14 +22,6 @@
"HostComponent": "HostRoles/component_name",
"Component": "HostRoles/component_name"
},
- "Configuration": {
- "Cluster": "Config/cluster_name",
- "Configuration": "Config/type"
- },
- "ServiceConfigVersion" : {
- "Cluster" : "cluster_name",
- "ServiceConfigVersion" : "service_name"
- },
"Action": {
"Action": "Actions/action_name"
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/3fd5c16e/ambari-server/src/main/resources/properties.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/properties.json b/ambari-server/src/main/resources/properties.json
index 149d8bc..9357be3 100644
--- a/ambari-server/src/main/resources/properties.json
+++ b/ambari-server/src/main/resources/properties.json
@@ -83,24 +83,6 @@
"HostRoles/service_name",
"_"
],
- "Configuration":[
- "Config/tag",
- "Config/type",
- "Config/cluster_name",
- "Config/version"
- ],
- "ServiceConfigVersion":[
- "ServiceConfigVersion/cluster_name",
- "ServiceConfigVersion/service_name",
- "ServiceConfigVersion/group_id",
- "ServiceConfigVersion/group_name",
- "ServiceConfigVersion/hosts",
- "ServiceConfigVersion/service_config_version",
- "ServiceConfigVersion/is_current",
- "ServiceConfigVersion/createtime",
- "ServiceConfigVersion/user",
- "ServiceConfigVersion/service_config_version_note"
- ],
"ConfigGroup": [
"ConfigGroup/id",
"ConfigGroup/cluster_name",
http://git-wip-us.apache.org/repos/asf/ambari/blob/3fd5c16e/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ConfigurationResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ConfigurationResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ConfigurationResourceProviderTest.java
index 4cdf9cb..8d4dc9b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ConfigurationResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ConfigurationResourceProviderTest.java
@@ -18,6 +18,24 @@
package org.apache.ambari.server.controller.internal;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNull;
+import static junit.framework.Assert.assertTrue;
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
import org.apache.ambari.server.controller.AmbariManagementController;
import org.apache.ambari.server.controller.ConfigurationRequest;
import org.apache.ambari.server.controller.ConfigurationResponse;
@@ -28,17 +46,11 @@ import org.apache.ambari.server.controller.spi.Resource;
import org.apache.ambari.server.controller.spi.ResourceProvider;
import org.apache.ambari.server.controller.utilities.PredicateBuilder;
import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.apache.ambari.server.state.StackId;
import org.easymock.Capture;
import org.junit.Assert;
import org.junit.Test;
-import java.util.*;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNull;
-import static junit.framework.Assert.assertTrue;
-import static org.easymock.EasyMock.*;
-
/**
* Tests for the configuration resource provider.
*/
@@ -57,8 +69,6 @@ public class ConfigurationResourceProviderTest {
replay(managementController, response);
ConfigurationResourceProvider provider = new ConfigurationResourceProvider(
- PropertyHelper.getPropertyIds(Resource.Type.Configuration ),
- PropertyHelper.getKeyPropertyIds(Resource.Type.Configuration),
managementController);
Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
@@ -106,8 +116,6 @@ public class ConfigurationResourceProviderTest {
replay(managementController, response);
ConfigurationResourceProvider provider = new ConfigurationResourceProvider(
- PropertyHelper.getPropertyIds(Resource.Type.Configuration ),
- PropertyHelper.getKeyPropertyIds(Resource.Type.Configuration),
managementController);
Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
@@ -134,17 +142,23 @@ public class ConfigurationResourceProviderTest {
@Test
public void testGetResources() throws Exception {
Resource.Type type = Resource.Type.Configuration;
+ StackId stackId = new StackId("HDP", "0.1");
AmbariManagementController managementController = createMock(AmbariManagementController.class);
Set<ConfigurationResponse> allResponse = new HashSet<ConfigurationResponse>();
- allResponse.add(new ConfigurationResponse("Cluster100", "type", "tag1", 1L, null, null));
- allResponse.add(new ConfigurationResponse("Cluster100", "type", "tag2", 2L, null, null));
- allResponse.add(new ConfigurationResponse("Cluster100", "type", "tag3", 3L, null, null));
+ allResponse.add(new ConfigurationResponse("Cluster100", stackId, "type",
+ "tag1", 1L, null, null));
+ allResponse.add(new ConfigurationResponse("Cluster100", stackId, "type",
+ "tag2", 2L, null, null));
+ allResponse.add(new ConfigurationResponse("Cluster100", stackId, "type",
+ "tag3", 3L, null, null));
Set<ConfigurationResponse> orResponse = new HashSet<ConfigurationResponse>();
- orResponse.add(new ConfigurationResponse("Cluster100", "type", "tag1", 1L, null, null));
- orResponse.add(new ConfigurationResponse("Cluster100", "type", "tag2", 2L, null, null));
+ orResponse.add(new ConfigurationResponse("Cluster100", stackId, "type",
+ "tag1", 1L, null, null));
+ orResponse.add(new ConfigurationResponse("Cluster100", stackId, "type",
+ "tag2", 2L, null, null));
Capture<Set<ConfigurationRequest>> configRequestCapture1 = new Capture<Set<ConfigurationRequest>>();
Capture<Set<ConfigurationRequest>> configRequestCapture2 = new Capture<Set<ConfigurationRequest>>();
@@ -193,7 +207,11 @@ public class ConfigurationResourceProviderTest {
for (Resource resource : resources) {
String clusterName = (String) resource.getPropertyValue(
ConfigurationResourceProvider.CONFIGURATION_CLUSTER_NAME_PROPERTY_ID);
+
+ String stackIdProperty = (String) resource.getPropertyValue(ConfigurationResourceProvider.CONFIGURATION_STACK_ID_PROPERTY_ID);
+
Assert.assertEquals("Cluster100", clusterName);
+ Assert.assertEquals(stackId.getStackId(), stackIdProperty);
String tag = (String) resource.getPropertyValue(
ConfigurationResourceProvider.CONFIGURATION_CONFIG_TAG_PROPERTY_ID);
http://git-wip-us.apache.org/repos/asf/ambari/blob/3fd5c16e/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
index 122b9a9..74f19e0 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
@@ -153,7 +153,7 @@ public class JMXHostProviderTest {
State.INIT);
String host1 = "h1";
- clusters.addHost(host1);
+ clusters.addHost(host1);
Map<String, String> hostAttributes = new HashMap<String, String>();
hostAttributes.put("os_family", "redhat");
hostAttributes.put("os_release_version", "5.9");
@@ -179,20 +179,20 @@ public class JMXHostProviderTest {
host1, null);
createServiceComponentHost(clusterName, serviceName, componentName3,
host2, null);
-
+
// Create configs
if (version1) {
Map<String, String> configs = new HashMap<String, String>();
configs.put(NAMENODE_PORT_V1, "localhost:${ambari.dfs.datanode.http.port}");
configs.put(DATANODE_PORT, "localhost:70075");
configs.put("ambari.dfs.datanode.http.port", "70070");
-
+
ConfigurationRequest cr = new ConfigurationRequest(clusterName,
"hdfs-site", "version1", configs, null);
ClusterRequest crequest = new ClusterRequest(cluster.getClusterId(), clusterName, null, null);
crequest.setDesiredConfig(Collections.singletonList(cr));
controller.updateClusters(Collections.singleton(crequest), new HashMap<String,String>());
-
+
} else {
Map<String, String> configs = new HashMap<String, String>();
configs.put(NAMENODE_PORT_V2, "localhost:70071");
@@ -200,7 +200,7 @@ public class JMXHostProviderTest {
ConfigurationRequest cr = new ConfigurationRequest(clusterName,
"hdfs-site", "version2", configs, null);
-
+
ClusterRequest crequest = new ClusterRequest(cluster.getClusterId(), clusterName, null, null);
crequest.setDesiredConfig(Collections.singletonList(cr));
controller.updateClusters(Collections.singleton(crequest), new HashMap<String,String>());
@@ -314,7 +314,7 @@ public class JMXHostProviderTest {
Assert.assertEquals(null, providerModule.getPort("c1", "TASKTRACKER"));
Assert.assertEquals(null, providerModule.getPort("c1", "HBASE_MASTER"));
}
-
+
@Test
public void testJMXPortMapInitAtServiceLevelVersion2() throws
NoSuchParentResourceException,
@@ -333,7 +333,7 @@ public class JMXHostProviderTest {
Assert.assertEquals(null, providerModule.getPort("c1", "JOBTRACKER"));
Assert.assertEquals(null, providerModule.getPort("c1", "TASKTRACKER"));
Assert.assertEquals(null, providerModule.getPort("c1", "HBASE_MASTER"));
- }
+ }
@Test
public void testJMXPortMapInitAtClusterLevel() throws
@@ -451,10 +451,8 @@ public class JMXHostProviderTest {
.Type.HostComponent), PropertyHelper.getKeyPropertyIds(Resource.Type
.HostComponent), controller, injector);
- ResourceProvider configResourceProvider = new
- ConfigurationResourceProvider(PropertyHelper.getPropertyIds(Resource
- .Type.Configuration), PropertyHelper.getKeyPropertyIds(Resource.Type
- .Configuration), controller);
+ ResourceProvider configResourceProvider = new ConfigurationResourceProvider(
+ controller);
@Override
protected ResourceProvider createResourceProvider(Resource.Type type) {
@@ -470,6 +468,6 @@ public class JMXHostProviderTest {
}
return null;
}
-
+
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3fd5c16e/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestImplTest.java
index bf82a85..93fe36f 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestImplTest.java
@@ -26,7 +26,6 @@ import junit.framework.Assert;
import org.apache.ambari.server.controller.spi.Request;
import org.apache.ambari.server.controller.spi.Resource;
import org.apache.ambari.server.controller.utilities.PropertyHelper;
-import org.junit.Ignore;
import org.junit.Test;
/**
@@ -131,16 +130,6 @@ public class RequestImplTest {
Assert.assertTrue(validPropertyIds.contains("ServiceComponents/description"));
Assert.assertTrue(validPropertyIds.contains("params/run_smoke_test"));
-
- request = PropertyHelper.getReadRequest(PropertyHelper.getPropertyIds(Resource.Type.Configuration));
- validPropertyIds = request.getPropertyIds();
-
- //Configuration resource properties
- Assert.assertFalse(validPropertyIds.contains("Config/unsupported_property_id"));
- Assert.assertTrue(validPropertyIds.contains("Config/tag"));
- Assert.assertTrue(validPropertyIds.contains("Config/type"));
- Assert.assertTrue(validPropertyIds.contains("Config/cluster_name"));
-
request = PropertyHelper.getReadRequest(PropertyHelper.getPropertyIds(Resource.Type.Action));
validPropertyIds = request.getPropertyIds();