You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sw...@apache.org on 2013/04/04 22:00:11 UTC

svn commit: r1464715 - in /incubator/ambari/trunk: ./ ambari-server/src/main/java/org/apache/ambari/server/controller/ ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ ambari-server/src/test/java/org/apache/ambari/server/contro...

Author: swagle
Date: Thu Apr  4 20:00:11 2013
New Revision: 1464715

URL: http://svn.apache.org/r1464715
Log:
AMBARI-1791. Can not specify request context for smoke test request. (swagle)

Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ActionResourceProvider.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ActionResourceProviderTest.java

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1464715&r1=1464714&r2=1464715&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Thu Apr  4 20:00:11 2013
@@ -552,6 +552,8 @@ Trunk (unreleased changes):
 
  BUG FIXES
 
+ AMBARI-1791. Can not specify request context for smoke test request. (swagle)
+
  AMBARI-1788. JMX getSpec error filling up server logs. (swagle)
 
  AMBARI-1787. Nagios script causes Datanode error. (swagle)

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java?rev=1464715&r1=1464714&r2=1464715&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java Thu Apr  4 20:00:11 2013
@@ -390,10 +390,11 @@ public interface AmbariManagementControl
    * Create the action defined by the attributes in the given request object.
    *
    * @param request the request object which defines the action to be created
+   * @param requestProperties the request properties
    *
    * @throws AmbariException thrown if the action cannot be created
    */
-  public RequestStatusResponse createActions(Set<ActionRequest> request)
+  public RequestStatusResponse createActions(Set<ActionRequest> request, Map<String, String> requestProperties)
       throws AmbariException;
   
   /**

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java?rev=1464715&r1=1464714&r2=1464715&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java Thu Apr  4 20:00:11 2013
@@ -4066,10 +4066,16 @@ public class AmbariManagementControllerI
   }
 
   @Override
-  public RequestStatusResponse createActions(Set<ActionRequest> request)
+  public RequestStatusResponse createActions(Set<ActionRequest> request, Map<String, String> requestProperties)
       throws AmbariException {
     String clusterName = null;
 
+    String requestContext = "";
+    
+    if (requestProperties != null)
+      requestContext = requestProperties.get(REQUEST_CONTEXT_PROPERTY);
+      
+    
     String logDir = ""; //TODO empty for now
 
     for (ActionRequest actionRequest : request) {
@@ -4089,9 +4095,10 @@ public class AmbariManagementControllerI
         throw new AmbariException("Requests for different clusters found");
       }
     }
-
+    
     Stage stage = stageFactory.createNew(actionManager.getNextRequestId(),
-        logDir, clusterName, "");
+        logDir, clusterName, requestContext);
+    
     stage.setStageId(0);
     for (ActionRequest actionRequest : request) {
       if (actionRequest.getActionName().contains("SERVICE_CHECK")) {

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ActionResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ActionResourceProvider.java?rev=1464715&r1=1464714&r2=1464715&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ActionResourceProvider.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ActionResourceProvider.java Thu Apr  4 20:00:11 2013
@@ -64,13 +64,16 @@ class ActionResourceProvider extends Abs
              NoSuchParentResourceException {
 
     final Set<ActionRequest> requests = new HashSet<ActionRequest>();
+    
+    final Map<String, String> requestInfoProperties = request.getRequestInfoProperties();
+    
     for (Map<String, Object> propertyMap : request.getProperties()) {
       requests.add(getRequest(propertyMap));
     }
     return getRequestStatus(createResources(new Command<RequestStatusResponse>() {
       @Override
       public RequestStatusResponse invoke() throws AmbariException {
-        return getManagementController().createActions(requests);
+        return getManagementController().createActions(requests, requestInfoProperties);
       }
     }));
   }

Modified: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java?rev=1464715&r1=1464714&r2=1464715&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java (original)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java Thu Apr  4 20:00:11 2013
@@ -103,6 +103,8 @@ public class AmbariManagementControllerT
   private static final String NON_EXT_VALUE = "XXX";
 
   private static final String COMPONENT_NAME = "NAMENODE";
+  
+  private static final String REQUEST_CONTEXT_PROPERTY = "context";
 
   private AmbariManagementController controller;
   private Clusters clusters;
@@ -3472,13 +3474,18 @@ public class AmbariManagementControllerT
     }};
     ActionRequest actionRequest = new ActionRequest("c1", "HDFS", Role.HDFS_SERVICE_CHECK.name(), params);
     actionRequests.add(actionRequest);
+    
+    Map<String, String> requestProperties = new HashMap<String, String>();
+    requestProperties.put(REQUEST_CONTEXT_PROPERTY, "Called from a test");
 
-    RequestStatusResponse response = controller.createActions(actionRequests);
+    RequestStatusResponse response = controller.createActions(actionRequests, requestProperties);
     
     assertEquals(1, response.getTasks().size());
     ShortTaskStatus task = response.getTasks().get(0);
 
     List<HostRoleCommand> storedTasks = actionDB.getRequestTasks(response.getRequestId());
+    Stage stage = actionDB.getAllStages(response.getRequestId()).get(0);
+
     assertEquals(1, storedTasks.size());
     HostRoleCommand hostRoleCommand = storedTasks.get(0);
 
@@ -3490,10 +3497,12 @@ public class AmbariManagementControllerT
     assertEquals(actionRequest.getParameters(), hostRoleCommand.getExecutionCommandWrapper().getExecutionCommand().getRoleParams());
     assertNotNull(hostRoleCommand.getExecutionCommandWrapper().getExecutionCommand().getConfigurations());
     assertEquals(2, hostRoleCommand.getExecutionCommandWrapper().getExecutionCommand().getConfigurations().size());
-    
+    assertEquals(requestProperties.get(REQUEST_CONTEXT_PROPERTY), stage.getRequestContext());
     actionRequests.add(new ActionRequest("c1", "MAPREDUCE", Role.MAPREDUCE_SERVICE_CHECK.name(), null));
 
-    response = controller.createActions(actionRequests);
+
+
+    response = controller.createActions(actionRequests, requestProperties);
 
     assertEquals(2, response.getTasks().size());
 

Modified: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ActionResourceProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ActionResourceProviderTest.java?rev=1464715&r1=1464714&r2=1464715&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ActionResourceProviderTest.java (original)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ActionResourceProviderTest.java Thu Apr  4 20:00:11 2013
@@ -42,6 +42,7 @@ import static org.easymock.EasyMock.crea
 import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.verify;
+import static org.easymock.EasyMock.eq;
 
 /**
  * ActionResourceProvider tests.
@@ -53,9 +54,12 @@ public class ActionResourceProviderTest 
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
     RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);
+    
+    Map<String, String> requestProperties = new HashMap<String, String>();
+    requestProperties.put("context", "Called from a test");
 
     expect(managementController.createActions(AbstractResourceProviderTest.Matcher.getActionRequestSet(
-        "Cluster100", "Service100", "Action100"))).andReturn(response);
+        "Cluster100", "Service100", "Action100"), eq(requestProperties))).andReturn(response);
 
     // replay
     replay(managementController, response);
@@ -80,7 +84,7 @@ public class ActionResourceProviderTest 
     propertySet.add(properties);
 
     // create the request
-    Request request = PropertyHelper.getCreateRequest(propertySet, null);
+    Request request = PropertyHelper.getCreateRequest(propertySet, requestProperties);
 
     provider.createResources(request);