Explorar o código

AMBARI-7248. No deprecation warning after creating blueprint with global configs (aonishuk)

Andrew Onishuk %!s(int64=11) %!d(string=hai) anos
pai
achega
da78f17816

+ 12 - 0
ambari-server/src/main/java/org/apache/ambari/server/controller/RequestStatusResponse.java

@@ -30,6 +30,11 @@ public class RequestStatusResponse {
   // TODO how are logs to be sent back?
   private String logs;
 
+  /**
+   * Request message
+   */
+  private String message;
+
   /**
    * Request context
    */
@@ -78,4 +83,11 @@ public class RequestStatusResponse {
     this.requestContext = requestContext;
   }
 
+  public String getMessage() {
+    return message;
+  }
+
+  public void setMessage(String message) {
+    this.message = message;
+  }
 }

+ 3 - 0
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);

+ 16 - 1
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;
   }
 
   /**

+ 7 - 6
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());
 

+ 11 - 5
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>>();