AMBARI-7248. No deprecation warning after creating blueprint with global configs (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/da78f178 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/da78f178 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/da78f178 Branch: refs/heads/branch-alerts-dev Commit: da78f17816e9fa30d8d7dc9decea642ebfe5e37a Parents: 71c9845 Author: Andrew Onishuk <aonis...@hortonworks.com> Authored: Thu Sep 11 14:28:44 2014 +0300 Committer: Andrew Onishuk <aonis...@hortonworks.com> Committed: Thu Sep 11 14:28:44 2014 +0300 ---------------------------------------------------------------------- .../server/controller/RequestStatusResponse.java | 12 ++++++++++++ .../internal/AbstractResourceProvider.java | 3 +++ .../internal/ClusterResourceProvider.java | 17 ++++++++++++++++- .../internal/ClusterResourceProviderTest.java | 13 +++++++------ .../internal/RequestResourceProviderTest.java | 16 +++++++++++----- 5 files changed, 49 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/da78f178/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestStatusResponse.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestStatusResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestStatusResponse.java index d6eabf4..26d866d 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestStatusResponse.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/RequestStatusResponse.java @@ -31,6 +31,11 @@ public class RequestStatusResponse { private String logs; /** + * Request message + */ + private String message; + + /** * Request context */ private String requestContext; @@ -78,4 +83,11 @@ public class RequestStatusResponse { this.requestContext = requestContext; } + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } } http://git-wip-us.apache.org/repos/asf/ambari/blob/da78f178/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java index d14cdf3..2c25623 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractResourceProvider.java @@ -206,6 +206,9 @@ public abstract class AbstractResourceProvider extends BaseProvider implements R protected RequestStatus getRequestStatus(RequestStatusResponse response, Set<Resource> associatedResources) { if (response != null){ Resource requestResource = new ResourceImpl(Resource.Type.Request); + if (response.getMessage() != null){ + requestResource.setProperty(PropertyHelper.getPropertyId("Requests", "message"), response.getMessage()); + } requestResource.setProperty(PropertyHelper.getPropertyId("Requests", "id"), response.getRequestId()); requestResource.setProperty(PropertyHelper.getPropertyId("Requests", "status"), "InProgress"); return new RequestStatusImpl(requestResource, associatedResources); http://git-wip-us.apache.org/repos/asf/ambari/blob/da78f178/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java index 3307b59..f40979c 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClusterResourceProvider.java @@ -43,6 +43,7 @@ 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 org.apache.ambari.server.orm.dao.BlueprintDAO; +import org.apache.ambari.server.orm.entities.BlueprintConfigEntity; import org.apache.ambari.server.orm.entities.BlueprintEntity; import org.apache.ambari.server.orm.entities.HostGroupEntity; import org.apache.ambari.server.state.Config; @@ -420,6 +421,15 @@ public class ClusterResourceProvider extends BaseBlueprintProcessor { Map<String, HostGroupImpl> blueprintHostGroups = parseBlueprintHostGroups(blueprint, stack); applyRequestInfoToHostGroups(properties, blueprintHostGroups); Collection<Map<String, String>> configOverrides = (Collection<Map<String, String>>)properties.get("configurations"); + + String message = null; + for (BlueprintConfigEntity blueprintConfig: blueprint.getConfigurations()){ + if(blueprintConfig.getType().equals("global")){ + message = "WARNING: Global configurations are deprecated, please use *-env"; + break; + } + } + processConfigurations(processBlueprintConfigurations(blueprint, configOverrides), processBlueprintAttributes(blueprint), stack, blueprintHostGroups); validatePasswordProperties(blueprint, blueprintHostGroups, (String) properties.get("default_password")); @@ -436,8 +446,13 @@ public class ClusterResourceProvider extends BaseBlueprintProcessor { registerConfigGroups(clusterName, blueprintHostGroups, stack); persistInstallStateForUI(); - return ((ServiceResourceProvider) getResourceProvider(Resource.Type.Service)). + + RequestStatusResponse request = ((ServiceResourceProvider) getResourceProvider(Resource.Type.Service)). installAndStart(clusterName); + + request.setMessage(message); + + return request; } /** http://git-wip-us.apache.org/repos/asf/ambari/blob/da78f178/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java index b7430c8..3adebf0 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java @@ -34,6 +34,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -327,7 +328,7 @@ public class ClusterResourceProviderTest { expect(blueprintDAO.findByName(blueprintName)).andReturn(blueprint); expect(blueprint.getStackName()).andReturn(stackName); expect(blueprint.getStackVersion()).andReturn(stackVersion); - expect(blueprint.getConfigurations()).andReturn(configurations); + expect(blueprint.getConfigurations()).andReturn(configurations).anyTimes(); expect(blueprint.validateConfigurations(metaInfo, true)).andReturn( Collections.<String, Map<String, Collection<String>>>emptyMap()); @@ -393,10 +394,10 @@ public class ClusterResourceProviderTest { expect(blueprintConfig4.getType()).andReturn("falcon-env").anyTimes(); expect(blueprintConfig4.getConfigData()).andReturn(new Gson().toJson(falconEnvConfigProperties)).anyTimes(); expect(blueprintConfig5.getBlueprintName()).andReturn("test-blueprint").anyTimes(); - expect(blueprintConfig5.getType()).andReturn("hbase-env").anyTimes(); + expect(blueprintConfig5.getType()).andReturn("global").anyTimes(); expect(blueprintConfig5.getConfigData()).andReturn(new Gson().toJson(hbaseEnvConfigProperties)).anyTimes(); - + expect(blueprint.getHostGroups()).andReturn(Collections.singleton(hostGroup)).anyTimes(); expect(hostGroup.getName()).andReturn("group1").anyTimes(); expect(hostGroup.getComponents()).andReturn(hostGroupComponents).anyTimes(); @@ -764,7 +765,7 @@ public class ClusterResourceProviderTest { expect(blueprintDAO.findByName(blueprintName)).andReturn(blueprint); expect(blueprint.getStackName()).andReturn(stackName); expect(blueprint.getStackVersion()).andReturn(stackVersion); - expect(blueprint.getConfigurations()).andReturn(Collections.<BlueprintConfigEntity>singletonList(blueprintConfig)); + expect(blueprint.getConfigurations()).andReturn(Collections.<BlueprintConfigEntity>singletonList(blueprintConfig)).anyTimes(); expect(blueprint.validateConfigurations(metaInfo, true)).andReturn(allMissingPasswords); expect(metaInfo.getComponentDependencies("test", "1.23", "service1", "component1")). @@ -1549,7 +1550,7 @@ public class ClusterResourceProviderTest { expect(blueprintDAO.findByName(blueprintName)).andReturn(blueprint); expect(blueprint.getStackName()).andReturn(stackName); expect(blueprint.getStackVersion()).andReturn(stackVersion); - expect(blueprint.getConfigurations()).andReturn(Collections.<BlueprintConfigEntity>singletonList(blueprintConfig)); + expect(blueprint.getConfigurations()).andReturn(Collections.<BlueprintConfigEntity>singletonList(blueprintConfig)).anyTimes(); expect(blueprint.validateConfigurations(metaInfo, true)).andReturn(allMissingPasswords); expect(metaInfo.getComponentDependencies("test", "1.23", "service1", "component1")). @@ -2226,7 +2227,7 @@ public class ClusterResourceProviderTest { expect(blueprintDAO.findByName(blueprintName)).andReturn(blueprint); expect(blueprint.getStackName()).andReturn(stackName); expect(blueprint.getStackVersion()).andReturn(stackVersion); - expect(blueprint.getConfigurations()).andReturn(configurations).times(2); + expect(blueprint.getConfigurations()).andReturn(configurations).times(3); expect(blueprint.validateConfigurations(metaInfo, true)).andReturn( Collections.<String, Map<String, Collection<String>>>emptyMap()); http://git-wip-us.apache.org/repos/asf/ambari/blob/da78f178/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java index f5d8227..66a04b9 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java @@ -897,9 +897,10 @@ public class RequestResourceProviderTest { expect(managementController.createAction(capture(actionRequest), capture(propertyMap))) .andReturn(response).anyTimes(); + expect(response.getMessage()).andReturn("Message").anyTimes(); // replay - replay(managementController); + replay(managementController, response); // add the property map to a set for the request. add more maps for multiple creates Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>(); @@ -920,6 +921,8 @@ public class RequestResourceProviderTest { Map<String, String> requestInfoProperties = new HashMap<String, String>(); requestInfoProperties.put(RequestResourceProvider.COMMAND_ID, "HDFS_SERVICE_CHECK"); + + // create the request Request request = PropertyHelper.getCreateRequest(propertySet, requestInfoProperties); ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider( @@ -927,6 +930,7 @@ public class RequestResourceProviderTest { PropertyHelper.getPropertyIds(type), PropertyHelper.getKeyPropertyIds(type), managementController); + provider.createResources(request); ExecuteActionRequest capturedRequest = actionRequest.getValue(); @@ -956,9 +960,9 @@ public class RequestResourceProviderTest { expect(managementController.createAction(capture(actionRequest), capture(propertyMap))) .andReturn(response).anyTimes(); - + expect(response.getMessage()).andReturn("Message").anyTimes(); // replay - replay(managementController); + replay(managementController, response); // add the property map to a set for the request. add more maps for multiple creates Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>(); @@ -1043,9 +1047,10 @@ public class RequestResourceProviderTest { expect(managementController.createAction(capture(actionRequest), capture(propertyMap))) .andReturn(response).anyTimes(); + expect(response.getMessage()).andReturn("Message").anyTimes(); // replay - replay(managementController); + replay(managementController, response); // add the property map to a set for the request. add more maps for multiple creates Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>(); @@ -1116,9 +1121,10 @@ public class RequestResourceProviderTest { expect(managementController.createAction(capture(actionRequest), capture(propertyMap))) .andReturn(response).anyTimes(); + expect(response.getMessage()).andReturn("Message").anyTimes(); // replay - replay(managementController); + replay(managementController, response); // add the property map to a set for the request. add more maps for multiple creates Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();