You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sr...@apache.org on 2015/04/24 19:45:53 UTC
ambari git commit: AMBARI-10658. Refactor stack-config's
'property_depended_by' information into a sub-resource (dsen via srimanth)
Repository: ambari
Updated Branches:
refs/heads/trunk 00ea69653 -> 4bd764ed7
AMBARI-10658. Refactor stack-config's 'property_depended_by' information into a sub-resource (dsen via srimanth)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4bd764ed
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4bd764ed
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4bd764ed
Branch: refs/heads/trunk
Commit: 4bd764ed70d7b0b1ce5102cbf521fee0f27022ca
Parents: 00ea696
Author: Srimanth Gunturi <sg...@hortonworks.com>
Authored: Fri Apr 24 10:42:54 2015 -0700
Committer: Srimanth Gunturi <sg...@hortonworks.com>
Committed: Fri Apr 24 10:42:54 2015 -0700
----------------------------------------------------------------------
.../resources/ResourceInstanceFactoryImpl.java | 4 +
...nfigurationDependencyResourceDefinition.java | 44 ++++++
.../StackConfigurationResourceDefinition.java | 10 ++
.../server/api/services/StacksService.java | 25 ++++
.../commands/StackAdvisorCommand.java | 3 +-
.../controller/AmbariManagementController.java | 7 +
.../AmbariManagementControllerImpl.java | 48 +++++++
.../StackConfigurationDependencyRequest.java | 44 ++++++
.../StackConfigurationDependencyResponse.java | 90 ++++++++++++
.../controller/StackConfigurationResponse.java | 24 +---
.../StackLevelConfigurationResponse.java | 5 +-
.../AbstractControllerResourceProvider.java | 2 +
...ConfigurationDependencyResourceProvider.java | 143 +++++++++++++++++++
.../StackConfigurationResourceProvider.java | 6 -
...StackLevelConfigurationResourceProvider.java | 6 -
.../ambari/server/controller/spi/Resource.java | 2 +
.../server/state/PropertyDependencyInfo.java | 7 +
.../ambari/server/state/PropertyInfo.java | 6 +-
.../src/main/resources/key_properties.json | 7 +
.../src/main/resources/properties.json | 11 +-
.../src/main/resources/stacks/stack_advisor.py | 10 +-
.../StackConfigurationDefinitionTest.java | 63 ++++++++
...ckConfigurationDependencyDefinitionTest.java | 51 +++++++
.../internal/AbstractResourceProviderTest.java | 51 ++++++-
...igurationDependencyResourceProviderTest.java | 96 +++++++++++++
.../StackConfigurationResourceProviderTest.java | 5 +
.../configs/stack_config_properties_mapper.js | 10 ++
ambari-web/app/utils/ajax/ajax.js | 2 +-
28 files changed, 733 insertions(+), 49 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
index 24232ba..776f1f4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceFactoryImpl.java
@@ -162,6 +162,10 @@ public class ResourceInstanceFactoryImpl implements ResourceInstanceFactory {
resourceDefinition = new StackConfigurationResourceDefinition();
break;
+ case StackConfigurationDependency:
+ resourceDefinition = new StackConfigurationDependencyResourceDefinition();
+ break;
+
case OperatingSystem:
resourceDefinition = new OperatingSystemResourceDefinition();
break;
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackConfigurationDependencyResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackConfigurationDependencyResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackConfigurationDependencyResourceDefinition.java
new file mode 100644
index 0000000..c66441e
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackConfigurationDependencyResourceDefinition.java
@@ -0,0 +1,44 @@
+/**
+ * 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.api.resources;
+
+import org.apache.ambari.server.controller.spi.Resource.Type;
+
+public class StackConfigurationDependencyResourceDefinition extends BaseResourceDefinition {
+
+ public StackConfigurationDependencyResourceDefinition(Type resourceType) {
+ super(resourceType);
+ }
+
+ public StackConfigurationDependencyResourceDefinition() {
+ super(Type.StackConfigurationDependency);
+ }
+
+ @Override
+ public String getPluralName() {
+ return "dependencies";
+ }
+
+ @Override
+ public String getSingularName() {
+ return "dependency";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackConfigurationResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackConfigurationResourceDefinition.java b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackConfigurationResourceDefinition.java
index 610f822..537f916 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackConfigurationResourceDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/StackConfigurationResourceDefinition.java
@@ -22,6 +22,9 @@ package org.apache.ambari.server.api.resources;
import org.apache.ambari.server.controller.spi.Resource;
import org.apache.ambari.server.controller.spi.Resource.Type;
+import java.util.HashSet;
+import java.util.Set;
+
public class StackConfigurationResourceDefinition extends BaseResourceDefinition {
public StackConfigurationResourceDefinition(Type resourceType) {
@@ -42,4 +45,11 @@ public class StackConfigurationResourceDefinition extends BaseResourceDefinition
return "configuration";
}
+ @Override
+ public Set<SubResourceDefinition> getSubResourceDefinitions() {
+ Set<SubResourceDefinition> subs = new HashSet<SubResourceDefinition>();
+ subs.add(new SubResourceDefinition(Resource.Type.StackConfigurationDependency));
+
+ return subs;
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-server/src/main/java/org/apache/ambari/server/api/services/StacksService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/StacksService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/StacksService.java
index c467f44..76397fb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/StacksService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/StacksService.java
@@ -231,6 +231,19 @@ public class StacksService extends BaseService {
}
@GET
+ @Path("{stackName}/versions/{stackVersion}/services/{serviceName}/configurations/{propertyName}/dependencies")
+ @Produces("text/plain")
+ public Response getStackConfigurationDependencies(String body, @Context HttpHeaders headers,
+ @Context UriInfo ui, @PathParam("stackName") String stackName,
+ @PathParam("stackVersion") String stackVersion,
+ @PathParam("serviceName") String serviceName,
+ @PathParam("propertyName") String propertyName) {
+
+ return handleRequest(headers, body, ui, Request.Type.GET,
+ createStackConfigurationDependencyResource(stackName, stackVersion, serviceName, propertyName));
+ }
+
+ @GET
@Path("{stackName}/versions/{stackVersion}/services/{serviceName}/components")
@Produces("text/plain")
public Response getServiceComponents(String body,
@@ -367,6 +380,18 @@ public class StacksService extends BaseService {
return createResource(Resource.Type.StackConfiguration, mapIds);
}
+ ResourceInstance createStackConfigurationDependencyResource(String stackName,
+ String stackVersion, String serviceName, String propertyName) {
+
+ Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
+ mapIds.put(Resource.Type.Stack, stackName);
+ mapIds.put(Resource.Type.StackVersion, stackVersion);
+ mapIds.put(Resource.Type.StackService, serviceName);
+ mapIds.put(Resource.Type.StackConfiguration, propertyName);
+
+ return createResource(Resource.Type.StackConfigurationDependency, mapIds);
+ }
+
ResourceInstance createStackServiceResource(String stackName,
String stackVersion, String serviceName) {
Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommand.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommand.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommand.java
index 7caca31..505ea17 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommand.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommand.java
@@ -75,7 +75,8 @@ public abstract class StackAdvisorCommand<T extends StackAdvisorResponse> extend
+ ",services/StackServices/service_name,services/StackServices/service_version"
+ ",services/components/StackServiceComponents,services/components/dependencies,services/components/auto_deploy"
+ ",services/configurations/StackConfigurations/property_depends_on"
- + ",services/configurations/StackConfigurations/property_depended_by"
+ + ",services/configurations/dependencies/StackConfigurationDependency/dependency_name"
+ + ",services/configurations/dependencies/StackConfigurationDependency/dependency_type"
+ ",services/configurations/StackConfigurations/type"
+ "&services/StackServices/service_name.in(%s)";
private static final String SERVICES_PROPERTY = "services";
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
index 828df47..17b6d4a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
@@ -775,5 +775,12 @@ public interface AmbariManagementController {
public ExecutionCommand getExecutionCommand(Cluster cluster,
ServiceComponentHost scHost,
RoleCommand roleCommand) throws AmbariException;
+
+ /**
+ * Get configuration dependencies which are specific for a specific service configuration property
+ * @param requests
+ * @return
+ */
+ Set<StackConfigurationDependencyResponse> getStackConfigurationDependencies(Set<StackConfigurationDependencyRequest> requests) throws AmbariException;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/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 a57a150..0743629 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
@@ -126,6 +126,7 @@ import org.apache.ambari.server.state.HostComponentAdminState;
import org.apache.ambari.server.state.HostState;
import org.apache.ambari.server.state.MaintenanceState;
import org.apache.ambari.server.state.OperatingSystemInfo;
+import org.apache.ambari.server.state.PropertyDependencyInfo;
import org.apache.ambari.server.state.PropertyInfo;
import org.apache.ambari.server.state.PropertyInfo.PropertyType;
import org.apache.ambari.server.state.RepositoryInfo;
@@ -2332,6 +2333,53 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
return ec;
}
+ @Override
+ public Set<StackConfigurationDependencyResponse> getStackConfigurationDependencies(
+ Set<StackConfigurationDependencyRequest> requests) throws AmbariException {
+ Set<StackConfigurationDependencyResponse> response =
+ new HashSet<StackConfigurationDependencyResponse>();
+ for (StackConfigurationDependencyRequest request : requests) {
+
+ String stackName = request.getStackName();
+ String stackVersion = request.getStackVersion();
+ String serviceName = request.getServiceName();
+ String propertyName = request.getPropertyName();
+
+ Set<StackConfigurationDependencyResponse> stackConfigurations =
+ getStackConfigurationDependencies(request);
+
+ for (StackConfigurationDependencyResponse dependencyResponse : stackConfigurations) {
+ dependencyResponse.setStackName(stackName);
+ dependencyResponse.setStackVersion(stackVersion);
+ dependencyResponse.setServiceName(serviceName);
+ dependencyResponse.setPropertyName(propertyName);
+ }
+ response.addAll(stackConfigurations);
+ }
+
+ return response; }
+
+ private Set<StackConfigurationDependencyResponse> getStackConfigurationDependencies(StackConfigurationDependencyRequest request) throws AmbariException {
+ Set<StackConfigurationDependencyResponse> response =
+ new HashSet<StackConfigurationDependencyResponse>();
+
+ String stackName = request.getStackName();
+ String stackVersion = request.getStackVersion();
+ String serviceName = request.getServiceName();
+ String propertyName = request.getPropertyName();
+ String dependencyName = request.getDependencyName();
+
+ Set<PropertyInfo> properties = ambariMetaInfo.getPropertiesByName(stackName, stackVersion, serviceName, propertyName);
+
+ for (PropertyInfo property: properties) {
+ for (PropertyDependencyInfo dependency: property.getDependedByProperties()) {
+ if (dependencyName == null || dependency.getName().equals(dependencyName)) {
+ response.add(dependency.convertToResponse());
+ }
+ }
+ }
+
+ return response; }
@Transactional
void updateServiceStates(
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-server/src/main/java/org/apache/ambari/server/controller/StackConfigurationDependencyRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackConfigurationDependencyRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackConfigurationDependencyRequest.java
new file mode 100644
index 0000000..1605e97
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackConfigurationDependencyRequest.java
@@ -0,0 +1,44 @@
+/**
+ * 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;
+
+
+public class StackConfigurationDependencyRequest extends StackConfigurationRequest {
+
+ private String dependencyName;
+
+ public StackConfigurationDependencyRequest(String stackName, String stackVersion,
+ String serviceName, String propertyName,
+ String dependencyName) {
+ super(stackName, stackVersion, serviceName, propertyName);
+
+ this.dependencyName = dependencyName;
+
+ }
+
+ public String getDependencyName() {
+ return dependencyName;
+ }
+
+ public void setDependencyName(String dependencyName) {
+ this.dependencyName = dependencyName;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-server/src/main/java/org/apache/ambari/server/controller/StackConfigurationDependencyResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackConfigurationDependencyResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackConfigurationDependencyResponse.java
new file mode 100644
index 0000000..14aab3b
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackConfigurationDependencyResponse.java
@@ -0,0 +1,90 @@
+/**
+ * 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;
+
+
+public class StackConfigurationDependencyResponse {
+
+ private String stackName;
+ private String stackVersion;
+ private String serviceName;
+ private String propertyName;
+ private String dependencyName;
+ private String dependencyType;
+
+
+
+ public StackConfigurationDependencyResponse(String dependencyName) {
+ this.dependencyName = dependencyName;
+ }
+
+ public StackConfigurationDependencyResponse(String dependencyName,
+ String dependencyType) {
+ this.dependencyName = dependencyName;
+ this.dependencyType = dependencyType;
+ }
+
+ public String getStackName() {
+ return stackName;
+ }
+
+ public void setStackName(String stackName) {
+ this.stackName = stackName;
+ }
+
+ public String getStackVersion() {
+ return stackVersion;
+ }
+
+ public void setStackVersion(String stackVersion) {
+ this.stackVersion = stackVersion;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+ public void setPropertyName(String propertyName) {
+ this.propertyName = propertyName;
+ }
+
+ public String getDependencyName() {
+ return dependencyName;
+ }
+
+ public void setDependencyName(String dependencyName) {
+ this.dependencyName = dependencyName;
+ }
+
+ public String getDependencyType() {
+ return dependencyType;
+ }
+
+ public void setDependencyType(String dependencyType) {
+ this.dependencyType = dependencyType;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-server/src/main/java/org/apache/ambari/server/controller/StackConfigurationResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackConfigurationResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackConfigurationResponse.java
index bc200ff..0338ed9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackConfigurationResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackConfigurationResponse.java
@@ -56,7 +56,6 @@ public class StackConfigurationResponse {
* @param propertyAttributes Attributes map
* @param propertyValueAttributes Value Attributes
* @param dependsOnProperties depends on properties set
- * @param dependedByProperties depended by properties set
*/
public StackConfigurationResponse(String propertyName, String propertyValue,
String propertyDescription, String propertyDisplayName, String type,
@@ -64,8 +63,7 @@ public class StackConfigurationResponse {
Set<PropertyType> propertyTypes,
Map<String, String> propertyAttributes,
ValueAttributesInfo propertyValueAttributes,
- Set<PropertyDependencyInfo> dependsOnProperties,
- Set<PropertyDependencyInfo> dependedByProperties) {
+ Set<PropertyDependencyInfo> dependsOnProperties) {
setPropertyName(propertyName);
setPropertyValue(propertyValue);
setPropertyDescription(propertyDescription);
@@ -76,7 +74,6 @@ public class StackConfigurationResponse {
setPropertyAttributes(propertyAttributes);
setPropertyValueAttributes(propertyValueAttributes);
setDependsOnProperties(dependsOnProperties);
- setDependedByProperties(dependedByProperties);
}
private String stackName;
@@ -90,7 +87,6 @@ public class StackConfigurationResponse {
private Map<String, String> propertyAttributes;
private ValueAttributesInfo propertyValueAttributes;
private Set<PropertyDependencyInfo> dependsOnProperties;
- private Set<PropertyDependencyInfo> dependedByProperties;
private Boolean isRequired;
private Set<PropertyType> propertyTypes;
@@ -217,24 +213,6 @@ public class StackConfigurationResponse {
}
/**
- * Provides depended by properties of this configuration.
- *
- * @return depended by properties set
- */
- public Set<PropertyDependencyInfo> getDependedByProperties() {
- return dependedByProperties;
- }
-
- /**
- * Sets depended by properties set for this configuration.
- *
- * @param dependedByProperties
- */
- public void setDependedByProperties(Set<PropertyDependencyInfo> dependedByProperties) {
- this.dependedByProperties = dependedByProperties;
- }
-
- /**
* Is property a isRequired property
* @return True/False
*/
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-server/src/main/java/org/apache/ambari/server/controller/StackLevelConfigurationResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackLevelConfigurationResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackLevelConfigurationResponse.java
index 42abf15..c0f45a4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/StackLevelConfigurationResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/StackLevelConfigurationResponse.java
@@ -33,11 +33,10 @@ public class StackLevelConfigurationResponse extends StackConfigurationResponse
Boolean isRequired, Set<PropertyType> propertyTypes,
Map<String, String> propertyAttributes,
ValueAttributesInfo propertyValueAttributes,
- Set<PropertyDependencyInfo> dependsOnProperties,
- Set<PropertyDependencyInfo> dependedByProperties) {
+ Set<PropertyDependencyInfo> dependsOnProperties) {
super(propertyName, propertyValue, propertyDescription, propertyDisplayName, type, isRequired,
propertyTypes, propertyAttributes, propertyValueAttributes,
- dependsOnProperties, dependedByProperties);
+ dependsOnProperties);
}
public StackLevelConfigurationResponse(String propertyName, String propertyValue, String propertyDescription,
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/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 0b34ada..210227e 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
@@ -129,6 +129,8 @@ public abstract class AbstractControllerResourceProvider extends AbstractResourc
return new StackServiceComponentResourceProvider(propertyIds, keyPropertyIds, managementController);
case StackConfiguration:
return new StackConfigurationResourceProvider(propertyIds, keyPropertyIds, managementController);
+ case StackConfigurationDependency:
+ return new StackConfigurationDependencyResourceProvider(propertyIds, keyPropertyIds, managementController);
case StackLevelConfiguration:
return new StackLevelConfigurationResourceProvider(propertyIds, keyPropertyIds, managementController);
case RootService:
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationDependencyResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationDependencyResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationDependencyResourceProvider.java
new file mode 100644
index 0000000..9a0ee81
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationDependencyResourceProvider.java
@@ -0,0 +1,143 @@
+/**
+ * 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 org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.StackConfigurationDependencyRequest;
+import org.apache.ambari.server.controller.StackConfigurationDependencyResponse;
+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.Resource;
+import org.apache.ambari.server.controller.spi.Resource.Type;
+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.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+public class StackConfigurationDependencyResourceProvider extends
+ ReadOnlyResourceProvider {
+
+ public static final String STACK_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackConfigurationDependency", "stack_name");
+
+ public static final String STACK_VERSION_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackConfigurationDependency", "stack_version");
+
+ public static final String SERVICE_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackConfigurationDependency", "service_name");
+
+ public static final String PROPERTY_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackConfigurationDependency", "property_name");
+
+ public static final String DEPENDENCY_NAME_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackConfigurationDependency", "dependency_name");
+
+ public static final String DEPENDENCY_TYPE_PROPERTY_ID = PropertyHelper
+ .getPropertyId("StackConfigurationDependency", "dependency_type");
+
+ private static Set<String> pkPropertyIds = new HashSet<String>(
+ Arrays.asList(new String[] { STACK_NAME_PROPERTY_ID,
+ STACK_VERSION_PROPERTY_ID, SERVICE_NAME_PROPERTY_ID,
+ PROPERTY_NAME_PROPERTY_ID, DEPENDENCY_NAME_PROPERTY_ID }));
+
+ protected StackConfigurationDependencyResourceProvider(Set<String> propertyIds,
+ Map<Type, String> keyPropertyIds,
+ AmbariManagementController managementController) {
+ super(propertyIds, keyPropertyIds, managementController);
+ }
+
+ @Override
+ public Set<Resource> getResources(final Request request, Predicate predicate)
+ throws SystemException, UnsupportedPropertyException,
+ NoSuchResourceException, NoSuchParentResourceException {
+
+ final Set<StackConfigurationDependencyRequest> requests =
+ new HashSet<StackConfigurationDependencyRequest>();
+
+ if (predicate == null) {
+ requests.add(getRequest(Collections.<String, Object>emptyMap()));
+ } else {
+ for (Map<String, Object> propertyMap : getPropertyMaps(predicate)) {
+ requests.add(getRequest(propertyMap));
+ }
+ }
+
+ Set<String> requestedIds = getRequestPropertyIds(request, predicate);
+
+ Set<StackConfigurationDependencyResponse> responses = getResources(new Command<Set<StackConfigurationDependencyResponse>>() {
+ @Override
+ public Set<StackConfigurationDependencyResponse> invoke() throws AmbariException {
+ return getManagementController().getStackConfigurationDependencies(requests);
+ }
+ });
+
+ Set<Resource> resources = new HashSet<Resource>();
+
+ for (StackConfigurationDependencyResponse response : responses) {
+ Resource resource = new ResourceImpl(Type.StackConfigurationDependency);
+
+ setResourceProperty(resource, STACK_NAME_PROPERTY_ID,
+ response.getStackName(), requestedIds);
+
+ setResourceProperty(resource, STACK_VERSION_PROPERTY_ID,
+ response.getStackVersion(), requestedIds);
+
+ setResourceProperty(resource, SERVICE_NAME_PROPERTY_ID,
+ response.getServiceName(), requestedIds);
+
+ setResourceProperty(resource, PROPERTY_NAME_PROPERTY_ID,
+ response.getPropertyName(), requestedIds);
+
+ setResourceProperty(resource, DEPENDENCY_NAME_PROPERTY_ID,
+ response.getDependencyName(), requestedIds);
+
+ setResourceProperty(resource, DEPENDENCY_TYPE_PROPERTY_ID,
+ response.getDependencyType(), requestedIds);
+
+
+ resources.add(resource);
+ }
+
+ return resources;
+ }
+
+ private StackConfigurationDependencyRequest getRequest(Map<String, Object> properties) {
+ return new StackConfigurationDependencyRequest(
+ (String) properties.get(STACK_NAME_PROPERTY_ID),
+ (String) properties.get(STACK_VERSION_PROPERTY_ID),
+ (String) properties.get(SERVICE_NAME_PROPERTY_ID),
+ (String) properties.get(PROPERTY_NAME_PROPERTY_ID),
+ (String) properties.get(DEPENDENCY_NAME_PROPERTY_ID));
+ }
+
+ @Override
+ protected Set<String> getPKPropertyIds() {
+ return pkPropertyIds;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java
index cc624b1..bb115f1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProvider.java
@@ -64,9 +64,6 @@ public class StackConfigurationResourceProvider extends
public static final String PROPERTY_DEPENDS_ON_PROPERTY_ID = PropertyHelper
.getPropertyId("StackConfigurations", "property_depends_on");
- public static final String PROPERTY_DEPENDED_BY_PROPERTY_ID = PropertyHelper
- .getPropertyId("StackConfigurations", "property_depended_by");
-
public static final String PROPERTY_DESCRIPTION_PROPERTY_ID = PropertyHelper
.getPropertyId("StackConfigurations", "property_description");
@@ -144,9 +141,6 @@ public class StackConfigurationResourceProvider extends
setResourceProperty(resource, PROPERTY_DEPENDS_ON_PROPERTY_ID,
response.getDependsOnProperties(), requestedIds);
- setResourceProperty(resource, PROPERTY_DEPENDED_BY_PROPERTY_ID,
- response.getDependedByProperties(), requestedIds);
-
setResourceProperty(resource, PROPERTY_DESCRIPTION_PROPERTY_ID,
response.getPropertyDescription(), requestedIds);
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackLevelConfigurationResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackLevelConfigurationResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackLevelConfigurationResourceProvider.java
index 1e5109c..0525488 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackLevelConfigurationResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackLevelConfigurationResourceProvider.java
@@ -60,9 +60,6 @@ public class StackLevelConfigurationResourceProvider extends
public static final String DEPENDS_ON_PROPERTY_ID = PropertyHelper
.getPropertyId("StackLevelConfigurations", "property_depends_on");
- public static final String DEPENDED_BY_PROPERTY_ID = PropertyHelper
- .getPropertyId("StackLevelConfigurations", "property_depended_by");
-
public static final String PROPERTY_DESCRIPTION_PROPERTY_ID = PropertyHelper
.getPropertyId("StackLevelConfigurations", "property_description");
@@ -134,9 +131,6 @@ public class StackLevelConfigurationResourceProvider extends
setResourceProperty(resource, DEPENDS_ON_PROPERTY_ID,
response.getDependsOnProperties(), requestedIds);
- setResourceProperty(resource, DEPENDED_BY_PROPERTY_ID,
- response.getDependedByProperties(), requestedIds);
-
setResourceProperty(resource, PROPERTY_DESCRIPTION_PROPERTY_ID,
response.getPropertyDescription(), requestedIds);
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
index e2fad62..30bac9e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
@@ -95,6 +95,7 @@ public interface Resource {
Repository,
StackService,
StackConfiguration,
+ StackConfigurationDependency,
StackServiceComponent,
StackServiceComponentDependency,
DRFeed,
@@ -198,6 +199,7 @@ public interface Resource {
public static final Type Repository = InternalType.Repository.getType();
public static final Type StackService = InternalType.StackService.getType();
public static final Type StackConfiguration = InternalType.StackConfiguration.getType();
+ public static final Type StackConfigurationDependency = InternalType.StackConfigurationDependency.getType();
public static final Type StackServiceComponent = InternalType.StackServiceComponent.getType();
public static final Type StackServiceComponentDependency = InternalType.StackServiceComponentDependency.getType();
public static final Type DRFeed = InternalType.DRFeed.getType();
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyDependencyInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyDependencyInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyDependencyInfo.java
index 9427dd5..a801311 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyDependencyInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyDependencyInfo.java
@@ -19,6 +19,8 @@
package org.apache.ambari.server.state;
+import org.apache.ambari.server.controller.StackConfigurationDependencyResponse;
+
public class PropertyDependencyInfo {
private String type;
@@ -79,5 +81,10 @@ public class PropertyDependencyInfo {
", name='" + name + '\'' +
'}';
}
+
+ public StackConfigurationDependencyResponse convertToResponse() {
+ return new StackConfigurationDependencyResponse(getName(), getType());
+ }
+
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java
index 3596487..a6ef1d0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/PropertyInfo.java
@@ -126,9 +126,9 @@ public class PropertyInfo {
public StackConfigurationResponse convertToResponse() {
return new StackConfigurationResponse(getName(), getValue(),
- getDescription(), getDisplayName() , getFilename(), isRequireInput(), getPropertyTypes(),
- getAttributesMap(), getPropertyValueAttributes(),
- getDependsOnProperties(), getDependedByProperties());
+ getDescription(), getDisplayName() , getFilename(), isRequireInput(),
+ getPropertyTypes(), getAttributesMap(), getPropertyValueAttributes(),
+ getDependsOnProperties());
}
public boolean isDeleted() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/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 cd9b617..ff20b8b 100644
--- a/ambari-server/src/main/resources/key_properties.json
+++ b/ambari-server/src/main/resources/key_properties.json
@@ -65,6 +65,13 @@
"StackService": "StackConfigurations/service_name",
"StackConfiguration": "StackConfigurations/property_name"
},
+ "StackConfigurationDependency": {
+ "Stack": "StackConfigurationDependency/stack_name",
+ "StackVersion": "StackConfigurationDependency/stack_version",
+ "StackService": "StackConfigurationDependency/service_name",
+ "StackConfiguration": "StackConfigurationDependency/property_name",
+ "StackConfigurationDependency": "StackConfigurationDependency/dependency_name"
+ },
"StackServiceComponent": {
"Stack": "StackServiceComponents/stack_name",
"StackVersion": "StackServiceComponents/stack_version",
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/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 9357be3..ee798dd 100644
--- a/ambari-server/src/main/resources/properties.json
+++ b/ambari-server/src/main/resources/properties.json
@@ -219,7 +219,6 @@
"StackConfigurations/property_value",
"StackConfigurations/property_value_attributes",
"StackConfigurations/property_depends_on",
- "StackConfigurations/property_depended_by",
"StackConfigurations/property_description",
"StackConfigurations/property_display_name",
"StackConfigurations/type",
@@ -441,11 +440,19 @@
"StackLevelConfigurations/property_value",
"StackLevelConfigurations/property_value_attributes",
"StackLevelConfigurations/property_depends_on",
- "StackLevelConfigurations/property_depended_by",
"StackLevelConfigurations/property_description",
"StackLevelConfigurations/type",
"StackLevelConfigurations/final",
"StackLevelConfigurations/property_type",
"_"
+ ],
+ "StackConfigurationDependency":[
+ "StackConfigurationDependency/stack_name",
+ "StackConfigurationDependency/stack_version",
+ "StackConfigurationDependency/service_name",
+ "StackConfigurationDependency/property_name",
+ "StackConfigurationDependency/dependency_type",
+ "StackConfigurationDependency/dependency_name",
+ "_"
]
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-server/src/main/resources/stacks/stack_advisor.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/stack_advisor.py b/ambari-server/src/main/resources/stacks/stack_advisor.py
index 6319a65..06389d5 100644
--- a/ambari-server/src/main/resources/stacks/stack_advisor.py
+++ b/ambari-server/src/main/resources/stacks/stack_advisor.py
@@ -747,8 +747,12 @@ class DefaultStackAdvisor(StackAdvisor):
"name": config['StackConfigurations']['property_name']
}
if property in dependencies or property in changedConfigs:
- for dependedConfig in config['StackConfigurations']['property_depended_by']:
- if dependedConfig not in dependencies:
- dependencies.append(dependedConfig)
+ for dependedConfig in config['dependencies']:
+ dependency = {
+ "name": dependedConfig["StackConfigurationDependency"]["dependency_name"],
+ "type": dependedConfig["StackConfigurationDependency"]["dependency_type"]
+ }
+ if dependency not in dependencies:
+ dependencies.append(dependency)
return dependencies
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-server/src/test/java/org/apache/ambari/server/api/resources/StackConfigurationDefinitionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/resources/StackConfigurationDefinitionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/StackConfigurationDefinitionTest.java
new file mode 100644
index 0000000..4f4b4d5
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/StackConfigurationDefinitionTest.java
@@ -0,0 +1,63 @@
+/**
+ * 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.api.resources;
+
+import org.apache.ambari.server.controller.spi.Resource;
+import org.junit.Test;
+
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * StackConfigurationResourceDefinition unit tests.
+ */
+public class StackConfigurationDefinitionTest {
+
+ @Test
+ public void testGetPluralName() {
+ assertEquals("configurations", new StackConfigurationResourceDefinition().getPluralName());
+ }
+
+ @Test
+ public void testGetSingularName() {
+ assertEquals("configuration", new StackConfigurationResourceDefinition().getSingularName());
+ }
+
+ @Test
+ public void testGetSubResourceDefinitions() {
+ ResourceDefinition resource = new StackConfigurationResourceDefinition();
+ Set<SubResourceDefinition> subResources = resource.getSubResourceDefinitions();
+
+ assertEquals(1, subResources.size());
+ assertTrue(includesType(subResources, Resource.Type.StackConfigurationDependency));
+
+ }
+
+ private boolean includesType(Set<SubResourceDefinition> resources, Resource.Type type) {
+ for (SubResourceDefinition subResource : resources) {
+ if (subResource.getType() == type) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-server/src/test/java/org/apache/ambari/server/api/resources/StackConfigurationDependencyDefinitionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/resources/StackConfigurationDependencyDefinitionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/StackConfigurationDependencyDefinitionTest.java
new file mode 100644
index 0000000..94b3a4a
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/resources/StackConfigurationDependencyDefinitionTest.java
@@ -0,0 +1,51 @@
+/**
+ * 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.api.resources;
+
+import org.junit.Test;
+
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * StackConfigurationResourceDefinition unit tests.
+ */
+public class StackConfigurationDependencyDefinitionTest {
+
+ @Test
+ public void testGetPluralName() {
+ assertEquals("dependencies", new StackConfigurationDependencyResourceDefinition().getPluralName());
+ }
+
+ @Test
+ public void testGetSingularName() {
+ assertEquals("dependency", new StackConfigurationDependencyResourceDefinition().getSingularName());
+ }
+
+ @Test
+ public void testGetSubResourceDefinitions() {
+ ResourceDefinition resource = new StackConfigurationDependencyResourceDefinition();
+ Set<SubResourceDefinition> subResources = resource.getSubResourceDefinitions();
+
+ assertTrue(subResources.isEmpty());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractResourceProviderTest.java
index c977067..45ab2df 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractResourceProviderTest.java
@@ -38,6 +38,7 @@ import org.apache.ambari.server.controller.MaintenanceStateHelper;
import org.apache.ambari.server.controller.MemberRequest;
import org.apache.ambari.server.controller.RequestStatusResponse;
import org.apache.ambari.server.controller.ServiceComponentHostRequest;
+import org.apache.ambari.server.controller.StackConfigurationDependencyRequest;
import org.apache.ambari.server.controller.StackConfigurationRequest;
import org.apache.ambari.server.controller.StackLevelConfigurationRequest;
import org.apache.ambari.server.controller.TaskStatusRequest;
@@ -365,6 +366,13 @@ public class AbstractResourceProviderTest {
return null;
}
+ public static Set<StackConfigurationDependencyRequest> getStackConfigurationDependencyRequestSet(String stackName, String stackVersion,
+ String serviceName, String propertyName, String dependencyName)
+ {
+ EasyMock.reportMatcher(new StackConfigurationDependencyRequestSetMatcher(stackName, stackVersion, serviceName, propertyName, dependencyName));
+ return null;
+ }
+
public static Set<StackLevelConfigurationRequest> getStackLevelConfigurationRequestSet(String stackName, String stackVersion,
String propertyName)
{
@@ -731,7 +739,48 @@ public class AbstractResourceProviderTest {
stringBuffer.append("StackConfigurationRequestSetMatcher(").append(stackConfigurationRequest).append(")");
}
}
-
+
+ /**
+ * Matcher for a StackConfigurationDependency set containing a single request.
+ */
+ public static class StackConfigurationDependencyRequestSetMatcher extends HashSet<StackConfigurationRequest> implements IArgumentMatcher {
+
+ private final StackConfigurationDependencyRequest stackConfigurationDependencyRequest;
+
+ public StackConfigurationDependencyRequestSetMatcher(String stackName, String stackVersion,
+ String serviceName, String propertyName, String dependencyName) {
+ this.stackConfigurationDependencyRequest = new StackConfigurationDependencyRequest(stackName, stackVersion, serviceName, propertyName, dependencyName);
+ add(this.stackConfigurationDependencyRequest);
+ }
+
+ @Override
+ public boolean matches(Object o) {
+
+ if (!(o instanceof Set)) {
+ return false;
+ }
+
+ Set set = (Set) o;
+
+ if (set.size() != 1) {
+ return false;
+ }
+
+ Object request = set.iterator().next();
+
+ return request instanceof StackConfigurationRequest &&
+ eq(((StackConfigurationRequest) request).getPropertyName(), stackConfigurationDependencyRequest.getPropertyName()) &&
+ eq(((StackConfigurationRequest) request).getServiceName(), stackConfigurationDependencyRequest.getServiceName()) &&
+ eq(((StackConfigurationRequest) request).getStackName(), stackConfigurationDependencyRequest.getStackName()) &&
+ eq(((StackConfigurationRequest) request).getStackVersion(), stackConfigurationDependencyRequest.getStackVersion());
+ }
+
+ @Override
+ public void appendTo(StringBuffer stringBuffer) {
+ stringBuffer.append("StackConfigurationRequestSetMatcher(").append(stackConfigurationDependencyRequest).append(")");
+ }
+ }
+
public static class StackLevelConfigurationRequestSetMatcher extends HashSet<StackLevelConfigurationRequest> implements IArgumentMatcher {
private final StackLevelConfigurationRequest stackLevelConfigurationRequest;
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackConfigurationDependencyResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackConfigurationDependencyResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackConfigurationDependencyResourceProviderTest.java
new file mode 100644
index 0000000..f0ee61e
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackConfigurationDependencyResourceProviderTest.java
@@ -0,0 +1,96 @@
+/**
+ * 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 org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.StackConfigurationDependencyResponse;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceProvider;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+public class StackConfigurationDependencyResourceProviderTest {
+
+ @Test
+ public void testGetResources() throws Exception{
+
+
+ Resource.Type type = Resource.Type.StackConfigurationDependency;
+
+ AmbariManagementController managementController = createMock(AmbariManagementController.class);
+
+ Set<StackConfigurationDependencyResponse> allResponse = new HashSet<StackConfigurationDependencyResponse>();
+
+ allResponse.add(new StackConfigurationDependencyResponse("depName", "depType"));
+
+ // set expectations
+ expect(managementController.getStackConfigurationDependencies(
+ AbstractResourceProviderTest.Matcher.getStackConfigurationDependencyRequestSet(null, null, null, null, null))).
+ andReturn(allResponse).times(1);
+ // replay
+ replay(managementController);
+
+ ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
+ type,
+ PropertyHelper.getPropertyIds(type),
+ PropertyHelper.getKeyPropertyIds(type),
+ managementController);
+
+ Set<String> propertyIds = new HashSet<String>();
+
+ propertyIds.add(StackConfigurationDependencyResourceProvider.STACK_NAME_PROPERTY_ID);
+ propertyIds.add(StackConfigurationDependencyResourceProvider.STACK_VERSION_PROPERTY_ID);
+ propertyIds.add(StackConfigurationDependencyResourceProvider.SERVICE_NAME_PROPERTY_ID);
+ propertyIds.add(StackConfigurationDependencyResourceProvider.PROPERTY_NAME_PROPERTY_ID);
+ propertyIds.add(StackConfigurationDependencyResourceProvider.DEPENDENCY_NAME_PROPERTY_ID);
+ propertyIds.add(StackConfigurationDependencyResourceProvider.DEPENDENCY_TYPE_PROPERTY_ID);
+
+
+ // create the request
+ Request request = PropertyHelper.getReadRequest(propertyIds);
+
+ // get all ... no predicate
+ Set<Resource> resources = provider.getResources(request, null);
+
+ Assert.assertEquals(allResponse.size(), resources.size());
+
+ for (Resource resource : resources) {
+ String dependencyName = (String) resource.getPropertyValue(StackConfigurationDependencyResourceProvider.DEPENDENCY_NAME_PROPERTY_ID);
+ String dependencyType = (String) resource.getPropertyValue(StackConfigurationDependencyResourceProvider.DEPENDENCY_TYPE_PROPERTY_ID);
+
+ Assert.assertEquals("depName", dependencyName);
+ Assert.assertEquals("depType", dependencyType);
+
+ }
+
+ // verify
+ verify(managementController);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProviderTest.java
index d673671..1f18797 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackConfigurationResourceProviderTest.java
@@ -81,6 +81,7 @@ public class StackConfigurationResourceProviderTest {
propertyIds.add(StackConfigurationResourceProvider.PROPERTY_DESCRIPTION_PROPERTY_ID);
propertyIds.add(StackConfigurationResourceProvider.PROPERTY_TYPE_PROPERTY_ID);
propertyIds.add(StackConfigurationResourceProvider.PROPERTY_FINAL_PROPERTY_ID);
+ propertyIds.add(StackConfigurationResourceProvider.PROPERTY_DEPENDS_ON_PROPERTY_ID);
// create the request
Request request = PropertyHelper.getReadRequest(propertyIds);
@@ -100,11 +101,15 @@ public class StackConfigurationResourceProviderTest {
String propertyIsFinal = (String)
resource.getPropertyValue(StackConfigurationResourceProvider.PROPERTY_FINAL_PROPERTY_ID);
+ String propertyDependencies = (String)
+ resource.getPropertyValue(StackConfigurationResourceProvider.PROPERTY_DEPENDS_ON_PROPERTY_ID);
+
Assert.assertEquals(PROPERTY_NAME, propertyName);
Assert.assertEquals(PROPERTY_VALUE, propertyValue);
Assert.assertEquals(PROPERTY_DESC, propertyDesc);
Assert.assertEquals(TYPE, propertyType);
Assert.assertEquals("true", propertyIsFinal);
+ Assert.assertNull(propertyDependencies);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/configs/stack_config_properties_mapper.js b/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
index c062bf7..16d0abb 100644
--- a/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
+++ b/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
@@ -54,6 +54,16 @@ App.stackConfigPropertiesMapper = App.QuickDataMapper.create({
config.id = config.StackConfigurations.property_name + '_' + configType;
config.default_is_final = config.StackConfigurations.final === "true";
config.supports_final = !!configTypeInfo[configType] && configTypeInfo[configType].supports.final === "true";
+ // Map from /dependencies to property_depended_by
+ config.StackConfigurations.property_depended_by = [];
+ if (config.dependencies && config.dependencies.length > 0) {
+ config.dependencies.forEach(function(dep) {
+ config.StackConfigurations.property_depended_by.push({
+ type : dep.StackConfigurationDependency.dependency_type,
+ name : dep.StackConfigurationDependency.dependency_name
+ })
+ });
+ }
/**
* merging stack info with that is stored on UI
* for now is not used; uncomment in will be needed
http://git-wip-us.apache.org/repos/asf/ambari/blob/4bd764ed/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index 18beeb1..cbb0021 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -635,7 +635,7 @@ var urls = {
},
'configs.stack_configs.load.services': {
- 'real': '{stackVersionUrl}/services?StackServices/service_name.in({serviceList})&fields=configurations/*,StackServices/config_types/*',
+ 'real': '{stackVersionUrl}/services?StackServices/service_name.in({serviceList})&fields=configurations/*,configurations/dependencies/*,StackServices/config_types/*',
'mock': '/data/stacks/HDP-2.2/configurations.json'
},