Author: swagle
Date: Sat Apr 13 00:41:02 2013
New Revision: 1467530

URL: http://svn.apache.org/r1467530
Log:
AMBARI-1915. Client install tasks are shown twice in install progress popup. 
(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/ServiceResourceProvider.java
    incubator/ambari/trunk/ambari-server/src/main/resources/properties.json
    
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.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/JMXHostProviderTest.java
    
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestImplTest.java
    
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java

Modified: incubator/ambari/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1467530&r1=1467529&r2=1467530&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Sat Apr 13 00:41:02 2013
@@ -704,6 +704,9 @@ Trunk (unreleased changes):
 
  BUG FIXES
 
+ AMBARI-1915. Client install tasks are shown twice in install progress 
+ popup. (swagle)
+
  AMBARI-1916. Filter for showing only properties which need restart is 
  broken. (srimanth)
 

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=1467530&r1=1467529&r2=1467530&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
 Sat Apr 13 00:41:02 2013
@@ -248,16 +248,19 @@ public interface AmbariManagementControl
    * values carried by the given request object.
    *
    *
+   *
    * @param requests    the request object which defines which service to
    *                   update and the values to set
    *
    * @param requestProperties
+   * @param reconfigureClients
    * @return a track action response
    *
    * @throws AmbariException thrown if the resource cannot be updated
    */
   public RequestStatusResponse updateServices(Set<ServiceRequest> requests,
-      Map<String, String> requestProperties, boolean runSmokeTest) throws 
AmbariException;
+      Map<String, String> requestProperties, boolean runSmokeTest,
+      boolean reconfigureClients) throws AmbariException;
 
   /**
    * Update the component identified by the given request object with the

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=1467530&r1=1467529&r2=1467530&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
 Sat Apr 13 00:41:02 2013
@@ -1535,7 +1535,8 @@ public class AmbariManagementControllerI
 
       LOG.info("Creating stages for upgrade.");
       List<Stage> stages = doStageCreation(cluster, changedServices, 
changedComps, changedScHosts,
-          requestParameters, requestProperties.get(REQUEST_CONTEXT_PROPERTY), 
false);
+          requestParameters, requestProperties.get(REQUEST_CONTEXT_PROPERTY),
+          false, false);
 
       if (stages == null || stages.isEmpty()) {
         return null;
@@ -1909,8 +1910,9 @@ public class AmbariManagementControllerI
       Map<State, List<Service>> changedServices,
       Map<State, List<ServiceComponent>> changedComps,
       Map<String, Map<State, List<ServiceComponentHost>>> changedScHosts,
-      Map<String, String> requestParameters, String requestContext, boolean 
runSmokeTest)
-          throws AmbariException {
+      Map<String, String> requestParameters, String requestContext,
+      boolean runSmokeTest, boolean reconfigureClients)
+      throws AmbariException {
 
     // TODO handle different transitions?
     // Say HDFS to stopped and MR to started, what order should actions be done
@@ -1932,9 +1934,11 @@ public class AmbariManagementControllerI
     Set<String> smokeTestServices = getServicesForSmokeTests(cluster,
       changedServices, changedScHosts, runSmokeTest);
 
-    // Re-install client only hosts to reattach changed configs on service
-    // restart
-    addClientSchForReinstall(cluster, changedServices, changedScHosts);
+    if (reconfigureClients) {
+      // Re-install client only hosts to reattach changed configs on service
+      // restart
+      addClientSchForReinstall(cluster, changedServices, changedScHosts);
+    }
 
     if (!changedScHosts.isEmpty()
         || !smokeTestServices.isEmpty()) {
@@ -2337,8 +2341,8 @@ public class AmbariManagementControllerI
 
   @Override
   public synchronized RequestStatusResponse updateServices(
-      Set<ServiceRequest> requests, Map<String, String> requestProperties,
-      boolean runSmokeTest) throws AmbariException {
+    Set<ServiceRequest> requests, Map<String, String> requestProperties,
+    boolean runSmokeTest, boolean reconfigureClients) throws AmbariException {
 
     if (requests.isEmpty()) {
       LOG.warn("Received an empty requests set");
@@ -2615,7 +2619,7 @@ public class AmbariManagementControllerI
 
     List<Stage> stages = doStageCreation(cluster, changedServices, 
changedComps,
       changedScHosts, null, requestProperties.get(REQUEST_CONTEXT_PROPERTY),
-      runSmokeTest);
+      runSmokeTest, reconfigureClients);
     persistStages(stages);
     updateServiceStates(changedServices, changedComps, changedScHosts);
     if (stages == null || stages.isEmpty()) {
@@ -2894,7 +2898,8 @@ public class AmbariManagementControllerI
     Cluster cluster = clusters.getCluster(clusterNames.iterator().next());
 
     List<Stage> stages = doStageCreation(cluster, null,
-        changedComps, changedScHosts, null, 
requestProperties.get(REQUEST_CONTEXT_PROPERTY), runSmokeTest);
+        changedComps, changedScHosts, null, requestProperties.get
+        (REQUEST_CONTEXT_PROPERTY), runSmokeTest, false);
     persistStages(stages);
     updateServiceStates(null, changedComps, changedScHosts);
     if (stages == null || stages.isEmpty()) {
@@ -3268,7 +3273,7 @@ public class AmbariManagementControllerI
       requestParameters.put(Configuration.UPGRADE_FROM_STACK, 
gson.toJson(fromStackVersion));
     }
     List<Stage> stages = doStageCreation(cluster, null, null, changedScHosts, 
requestParameters,
-        requestProperties.get(REQUEST_CONTEXT_PROPERTY), runSmokeTest);
+        requestProperties.get(REQUEST_CONTEXT_PROPERTY), runSmokeTest, false);
     persistStages(stages);
     updateServiceStates(null, null, changedScHosts);
     if (stages == null || stages.isEmpty()) {

Modified: 
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java?rev=1467530&r1=1467529&r2=1467530&view=diff
==============================================================================
--- 
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
 (original)
+++ 
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
 Sat Apr 13 00:41:02 2013
@@ -47,7 +47,10 @@ class ServiceResourceProvider extends Ab
 
   //Parameters from the predicate
   private static final String QUERY_PARAMETERS_RUN_SMOKE_TEST_ID =
-      "params/run_smoke_test";
+    "params/run_smoke_test";
+
+  private static final String QUERY_PARAMETERS_RECONFIGURE_CLIENT =
+    "params/reconfigure_client";
 
   private static Set<String> pkPropertyIds =
       new HashSet<String>(Arrays.asList(new String[]{
@@ -143,12 +146,16 @@ class ServiceResourceProvider extends Ab
       }
 
       final boolean runSmokeTest = "true".equals(getQueryParameterValue(
-          QUERY_PARAMETERS_RUN_SMOKE_TEST_ID, predicate)) ? true : false;
+        QUERY_PARAMETERS_RUN_SMOKE_TEST_ID, predicate)) ? true : false;
+
+      final boolean reconfigureClients = "false".equals(getQueryParameterValue(
+        QUERY_PARAMETERS_RECONFIGURE_CLIENT, predicate)) ? false : true;
 
       response = modifyResources(new Command<RequestStatusResponse>() {
         @Override
         public RequestStatusResponse invoke() throws AmbariException {
-          return getManagementController().updateServices(requests, 
request.getRequestInfoProperties(), runSmokeTest);
+          return getManagementController().updateServices(requests,
+            request.getRequestInfoProperties(), runSmokeTest, 
reconfigureClients);
         }
       });
     }

Modified: 
incubator/ambari/trunk/ambari-server/src/main/resources/properties.json
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/resources/properties.json?rev=1467530&r1=1467529&r2=1467530&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/resources/properties.json 
(original)
+++ incubator/ambari/trunk/ambari-server/src/main/resources/properties.json Sat 
Apr 13 00:41:02 2013
@@ -17,6 +17,7 @@
         "Services/attributes",
         "ServiceInfo/desired_configs",
         "params/run_smoke_test",
+        "params/reconfigure_client",
         "_"
     ],
     "Host":[

Modified: 
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java?rev=1467530&r1=1467529&r2=1467530&view=diff
==============================================================================
--- 
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
 (original)
+++ 
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
 Sat Apr 13 00:41:02 2013
@@ -1548,7 +1548,7 @@ public class AmbariManagementControllerI
 //        gson.<Map<String, String>>fromJson("{\"nagios-global\": \"version2\" 
}", confType)
 //        , null));
 
-    amc.updateServices(serviceRequests, mapRequestProps, true);
+    amc.updateServices(serviceRequests, mapRequestProps, true, false);
 
 
     Set<ServiceComponentRequest> serviceComponentRequests = new 
HashSet<ServiceComponentRequest>();
@@ -1578,7 +1578,7 @@ public class AmbariManagementControllerI
 
     serviceRequests.clear();
     serviceRequests.add(new ServiceRequest("c1", "HDFS", null, "INSTALLED"));
-    amc.updateServices(serviceRequests, mapRequestProps, true);
+    amc.updateServices(serviceRequests, mapRequestProps, true, false);
 
     Cluster cluster = clusters.getCluster("c1");
     Map<String, ServiceComponentHost> namenodes = 
cluster.getService("HDFS").getServiceComponent("NAMENODE").getServiceComponentHosts();
@@ -1646,7 +1646,8 @@ public class AmbariManagementControllerI
     serviceRequests.clear();
     serviceRequests.add(new ServiceRequest("c1", "HDFS", null, "STARTED"));
 
-    RequestStatusResponse response = amc.updateServices(serviceRequests, 
mapRequestProps, true);
+    RequestStatusResponse response = amc.updateServices(serviceRequests,
+      mapRequestProps, true, false);
     for (ShortTaskStatus shortTaskStatus : response.getTasks()) {
       assertFalse("host1".equals(shortTaskStatus.getHostName()) && 
"NAMENODE".equals(shortTaskStatus.getRole()));
     }
@@ -1679,14 +1680,16 @@ public class AmbariManagementControllerI
     //Stopping HDFS service
     serviceRequests.clear();
     serviceRequests.add(new ServiceRequest("c1", "HDFS", null, "INSTALLED"));
-    response = amc.updateServices(serviceRequests, mapRequestProps, false);
+    response = amc.updateServices(serviceRequests, mapRequestProps, false,
+      false);
 
     //Starting HDFS service. No run_smoke_test flag is set, smoke
     // test(HDFS_SERVICE_CHECK) won't run
     boolean runSmokeTest = false;
     serviceRequests.clear();
     serviceRequests.add(new ServiceRequest("c1", "HDFS", null, "STARTED"));
-    response = amc.updateServices(serviceRequests, mapRequestProps, 
runSmokeTest);
+    response = amc.updateServices(serviceRequests, mapRequestProps,
+      runSmokeTest, false);
 
     List<ShortTaskStatus> taskStatuses = response.getTasks();
     boolean smokeTestRequired = false;
@@ -1700,14 +1703,16 @@ public class AmbariManagementControllerI
     //Stopping HDFS service
     serviceRequests.clear();
     serviceRequests.add(new ServiceRequest("c1", "HDFS", null, "INSTALLED"));
-    response = amc.updateServices(serviceRequests, mapRequestProps, false);
+    response = amc.updateServices(serviceRequests, mapRequestProps, false,
+      false);
 
     //Starting HDFS service again.
     //run_smoke_test flag is set, smoke test will be run
     runSmokeTest = true;
     serviceRequests.clear();
     serviceRequests.add(new ServiceRequest("c1", "HDFS", null, "STARTED"));
-    response = amc.updateServices(serviceRequests, mapRequestProps, 
runSmokeTest);
+    response = amc.updateServices(serviceRequests, mapRequestProps,
+      runSmokeTest, false);
 
     taskStatuses = response.getTasks();
     smokeTestRequired = false;

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=1467530&r1=1467529&r2=1467530&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
 Sat Apr 13 00:41:02 2013
@@ -189,7 +189,8 @@ public class AmbariManagementControllerT
     controller.createHostComponents(requests);
   }
 
-  private long stopService(String clusterName, String serviceName) throws
+  private long stopService(String clusterName, String serviceName,
+                           boolean reconfigureClients) throws
     AmbariException {
     ServiceRequest r = new ServiceRequest(clusterName, serviceName, null,
       State.INSTALLED.toString());
@@ -198,7 +199,7 @@ public class AmbariManagementControllerT
     Map<String, String> mapRequestProps = new HashMap<String, String>();
     mapRequestProps.put("context", "Called from a test");
     RequestStatusResponse resp = controller.updateServices(requests,
-      mapRequestProps, true);
+      mapRequestProps, true, reconfigureClients);
 
     Assert.assertEquals(State.INSTALLED,
       clusters.getCluster(clusterName).getService(serviceName)
@@ -216,7 +217,8 @@ public class AmbariManagementControllerT
     return resp.getRequestId();
   }
 
-  private long startService(String clusterName, String serviceName) throws
+  private long startService(String clusterName, String serviceName,
+                            boolean reconfigureClients) throws
     AmbariException {
     ServiceRequest r = new ServiceRequest(clusterName, serviceName, null,
       State.STARTED.toString());
@@ -225,7 +227,7 @@ public class AmbariManagementControllerT
     Map<String, String> mapRequestProps = new HashMap<String, String>();
     mapRequestProps.put("context", "Called from a test");
     RequestStatusResponse resp = controller.updateServices(requests,
-      mapRequestProps, true);
+      mapRequestProps, true, reconfigureClients);
 
     Assert.assertEquals(State.STARTED,
       clusters.getCluster(clusterName).getService(serviceName)
@@ -243,7 +245,8 @@ public class AmbariManagementControllerT
     return resp.getRequestId();
   }
 
-  private long installService(String clusterName, String serviceName) throws
+  private long installService(String clusterName, String serviceName,
+                              boolean reconfigureClients) throws
     AmbariException {
     ServiceRequest r = new ServiceRequest(clusterName, serviceName, null,
       State.INSTALLED.toString());
@@ -252,7 +255,7 @@ public class AmbariManagementControllerT
     Map<String, String> mapRequestProps = new HashMap<String, String>();
     mapRequestProps.put("context", "Called from a test");
     RequestStatusResponse resp = controller.updateServices(requests,
-      mapRequestProps, true);
+      mapRequestProps, true, reconfigureClients);
 
     Assert.assertEquals(State.INSTALLED,
       clusters.getCluster(clusterName).getService(serviceName)
@@ -1406,7 +1409,7 @@ public class AmbariManagementControllerT
     requests.add(r);
 
     RequestStatusResponse trackAction =
-        controller.updateServices(requests, mapRequestProps, true);
+        controller.updateServices(requests, mapRequestProps, true, false);
     Assert.assertEquals(State.INSTALLED,
         clusters.getCluster(clusterName).getService(serviceName)
         .getDesiredState());
@@ -1529,7 +1532,8 @@ public class AmbariManagementControllerT
         State.STARTED.toString());
     requests.clear();
     requests.add(r);
-    trackAction = controller.updateServices(requests, mapRequestProps, true);
+    trackAction = controller.updateServices(requests, mapRequestProps, true,
+      false);
 
     Assert.assertEquals(State.STARTED,
         clusters.getCluster(clusterName).getService(serviceName)
@@ -1593,7 +1597,8 @@ public class AmbariManagementControllerT
         State.INSTALLED.toString());
     requests.clear();
     requests.add(r);
-    trackAction = controller.updateServices(requests, mapRequestProps, true);
+    trackAction = controller.updateServices(requests, mapRequestProps, true,
+      false);
 
     Assert.assertEquals(State.INSTALLED,
         clusters.getCluster(clusterName).getService(serviceName)
@@ -2274,7 +2279,7 @@ public class AmbariManagementControllerT
           null, State.INSTALLING.toString());
       reqs.clear();
       reqs.add(r);
-      controller.updateServices(reqs, mapRequestProps, true);
+      controller.updateServices(reqs, mapRequestProps, true, false);
       fail("Expected fail for invalid state transition");
     } catch (Exception e) {
       // Expected
@@ -2285,7 +2290,7 @@ public class AmbariManagementControllerT
     reqs.clear();
     reqs.add(r);
     RequestStatusResponse trackAction = controller.updateServices(reqs,
-        mapRequestProps, true);
+        mapRequestProps, true, false);
     Assert.assertNull(trackAction);
   }
 
@@ -2331,7 +2336,7 @@ public class AmbariManagementControllerT
           State.INSTALLED.toString());
       reqs.add(req1);
       reqs.add(req2);
-      controller.updateServices(reqs, mapRequestProps, true);
+      controller.updateServices(reqs, mapRequestProps, true, false);
       fail("Expected failure for multi cluster update");
     } catch (Exception e) {
       // Expected
@@ -2345,7 +2350,7 @@ public class AmbariManagementControllerT
           State.INSTALLED.toString());
       reqs.add(req1);
       reqs.add(req2);
-      controller.updateServices(reqs, mapRequestProps, true);
+      controller.updateServices(reqs, mapRequestProps, true, false);
       fail("Expected failure for dups services");
     } catch (Exception e) {
       // Expected
@@ -2362,7 +2367,7 @@ public class AmbariManagementControllerT
           State.STARTED.toString());
       reqs.add(req1);
       reqs.add(req2);
-      controller.updateServices(reqs, mapRequestProps, true);
+      controller.updateServices(reqs, mapRequestProps, true, false);
       fail("Expected failure for different states");
     } catch (Exception e) {
       // Expected
@@ -2481,7 +2486,7 @@ public class AmbariManagementControllerT
       req1 = new ServiceRequest(clusterName, serviceName1, null,
           State.STARTED.toString());
       reqs.add(req1);
-      controller.updateServices(reqs, mapRequestProps, true);
+      controller.updateServices(reqs, mapRequestProps, true, false);
       fail("Expected failure for invalid state update");
     } catch (Exception e) {
       // Expected
@@ -2508,7 +2513,7 @@ public class AmbariManagementControllerT
       req1 = new ServiceRequest(clusterName, serviceName1, null,
           State.STARTED.toString());
       reqs.add(req1);
-      controller.updateServices(reqs, mapRequestProps, true);
+      controller.updateServices(reqs, mapRequestProps, true, false);
       fail("Expected failure for invalid state update");
     } catch (Exception e) {
       // Expected
@@ -2537,7 +2542,8 @@ public class AmbariManagementControllerT
         State.STARTED.toString());
     reqs.add(req1);
     reqs.add(req2);
-    RequestStatusResponse trackAction = controller.updateServices(reqs, 
mapRequestProps, true);
+    RequestStatusResponse trackAction = controller.updateServices(reqs,
+      mapRequestProps, true, false);
 
     Assert.assertEquals(State.STARTED, s1.getDesiredState());
     Assert.assertEquals(State.STARTED, s2.getDesiredState());
@@ -2607,7 +2613,8 @@ public class AmbariManagementControllerT
         State.STARTED.toString());
     reqs.add(req1);
     reqs.add(req2);
-    trackAction = controller.updateServices(reqs, mapRequestProps, true);
+    trackAction = controller.updateServices(reqs, mapRequestProps, true,
+      false);
     Assert.assertNull(trackAction);
 
   }
@@ -3637,7 +3644,8 @@ public class AmbariManagementControllerT
     sReqs.clear();
     sReqs.add(new ServiceRequest(clusterName, serviceName, configVersions,
         "INSTALLED"));
-    RequestStatusResponse trackAction = controller.updateServices(sReqs, 
mapRequestProps, true);
+    RequestStatusResponse trackAction = controller.updateServices(sReqs,
+      mapRequestProps, true, false);
     List<Stage> stages = actionDB.getAllStages(trackAction.getRequestId());
     for (ExecutionCommandWrapper cmd : stages.get(0)
         .getExecutionCommands(host1)) {
@@ -3729,7 +3737,7 @@ public class AmbariManagementControllerT
     Set<ServiceRequest> requests = new HashSet<ServiceRequest>();
     requests.add(r);
 
-    controller.updateServices(requests, mapRequestProps, true);
+    controller.updateServices(requests, mapRequestProps, true, false);
     Assert.assertEquals(State.INSTALLED,
             clusters.getCluster(clusterName).getService(serviceName)
                     .getDesiredState());
@@ -3748,7 +3756,7 @@ public class AmbariManagementControllerT
             State.STARTED.toString());
     requests.clear();
     requests.add(r);
-    controller.updateServices(requests, mapRequestProps, true);
+    controller.updateServices(requests, mapRequestProps, true, false);
 
     // manually change live state to started as no running action manager
     for (ServiceComponent sc :
@@ -3848,7 +3856,7 @@ public class AmbariManagementControllerT
     sReqs.clear();
     sReqs.add(new ServiceRequest(clusterName, serviceName, configVersions,
             null));
-    Assert.assertNull(controller.updateServices(sReqs, mapRequestProps, true));
+    Assert.assertNull(controller.updateServices(sReqs, mapRequestProps, true, 
false));
 
     Assert.assertEquals(3, s.getDesiredConfigs().size());
     Assert.assertEquals(3, sc1.getDesiredConfigs().size());
@@ -4083,7 +4091,7 @@ public class AmbariManagementControllerT
     sReqs.clear();
     sReqs.add(new ServiceRequest(clusterName, serviceName, configVersions,
         null));
-    Assert.assertNull(controller.updateServices(sReqs, mapRequestProps, true));
+    Assert.assertNull(controller.updateServices(sReqs, mapRequestProps, true, 
false));
 
     Assert.assertEquals(3, s.getDesiredConfigs().size());
     Assert.assertEquals(3, sc1.getDesiredConfigs().size());
@@ -4235,7 +4243,7 @@ public class AmbariManagementControllerT
     Set<ServiceRequest> requests = new HashSet<ServiceRequest>();
     requests.add(r);
 
-    controller.updateServices(requests, mapRequestProps, true);
+    controller.updateServices(requests, mapRequestProps, true, false);
     Assert.assertEquals(State.INSTALLED,
       clusters.getCluster(clusterName).getService(serviceName)
         .getDesiredState());
@@ -4346,7 +4354,7 @@ public class AmbariManagementControllerT
     sReqs.clear();
     sReqs.add(new ServiceRequest(clusterName, serviceName, configVersions,
       null));
-    Assert.assertNull(controller.updateServices(sReqs, mapRequestProps, true));
+    Assert.assertNull(controller.updateServices(sReqs, mapRequestProps, true, 
false));
     Assert.assertEquals(2, s.getDesiredConfigs().size());
 
     // Reconfigure S Level
@@ -4356,7 +4364,7 @@ public class AmbariManagementControllerT
     sReqs.clear();
     sReqs.add(new ServiceRequest(clusterName, serviceName, configVersions,
       null));
-    Assert.assertNull(controller.updateServices(sReqs, mapRequestProps, true));
+    Assert.assertNull(controller.updateServices(sReqs, mapRequestProps, true, 
false));
 
     entityManager.clear();
 
@@ -4450,18 +4458,18 @@ public class AmbariManagementControllerT
     controller.updateCluster(crReq, null);
 
     // Install
-    long requestId1 = installService(clusterName, serviceName1);
+    long requestId1 = installService(clusterName, serviceName1, false);
 
     List<Stage> stages = actionDB.getAllStages(requestId1);
     Assert.assertEquals(2, stages.get(0).getOrderedHostRoleCommands().get(0)
       .getExecutionCommandWrapper().getExecutionCommand()
       .getConfigurationTags().size());
 
-    installService(clusterName, serviceName2);
+    installService(clusterName, serviceName2, false);
 
     // Start
-    startService(clusterName, serviceName1);
-    startService(clusterName, serviceName2);
+    startService(clusterName, serviceName1, false);
+    startService(clusterName, serviceName2, false);
 
     // Reconfigure
     configs.clear();
@@ -4473,12 +4481,12 @@ public class AmbariManagementControllerT
     controller.updateCluster(crReq, null);
 
     // Stop HDFS & MAPREDUCE
-    stopService(clusterName, serviceName1);
-    stopService(clusterName, serviceName2);
+    stopService(clusterName, serviceName1, false);
+    stopService(clusterName, serviceName2, false);
 
     // Start
-    long requestId2 = startService(clusterName, serviceName1);
-    long requestId3 = startService(clusterName, serviceName2);
+    long requestId2 = startService(clusterName, serviceName1, true);
+    long requestId3 = startService(clusterName, serviceName2, true);
 
     stages = actionDB.getAllStages(requestId2);
     stages.addAll(actionDB.getAllStages(requestId3));
@@ -4546,7 +4554,7 @@ public class AmbariManagementControllerT
     requests.add(r);
 
     RequestStatusResponse trackAction =
-        controller.updateServices(requests, mapRequestProps, true);
+        controller.updateServices(requests, mapRequestProps, true, false);
     Assert.assertEquals(State.INSTALLED,
         clusters.getCluster(clusterName).getService(serviceName)
         .getDesiredState());
@@ -4580,7 +4588,7 @@ public class AmbariManagementControllerT
     requests.clear();
     requests.add(r);
 
-    trackAction = controller.updateServices(requests, mapRequestProps, true);
+    trackAction = controller.updateServices(requests, mapRequestProps, true, 
false);
     Assert.assertNotNull(trackAction);
     Assert.assertEquals(State.INSTALLED,
         clusters.getCluster(clusterName).getService(serviceName)
@@ -4646,7 +4654,7 @@ public class AmbariManagementControllerT
     requests.add(r);
 
     RequestStatusResponse trackAction =
-      controller.updateServices(requests, mapRequestProps, true);
+      controller.updateServices(requests, mapRequestProps, true, false);
     Assert.assertEquals(State.INSTALLED,
       clusters.getCluster(clusterName).getService(serviceName)
         .getDesiredState());
@@ -5391,7 +5399,7 @@ public class AmbariManagementControllerT
     requests.add(r);
 
     RequestStatusResponse trackAction =
-      controller.updateServices(requests, mapRequestProps, true);
+      controller.updateServices(requests, mapRequestProps, true, false);
     Assert.assertEquals(State.INSTALLED,
       clusters.getCluster(clusterName).getService(serviceName)
         .getDesiredState());
@@ -5410,7 +5418,7 @@ public class AmbariManagementControllerT
       State.STARTED.toString());
     requests.clear();
     requests.add(r);
-    trackAction = controller.updateServices(requests, mapRequestProps, true);
+    trackAction = controller.updateServices(requests, mapRequestProps, true, 
false);
 
     // manually change live state to started as no running action manager
     for (ServiceComponent sc :
@@ -5455,7 +5463,7 @@ public class AmbariManagementControllerT
       State.INSTALLED.toString());
     requests.clear();
     requests.add(r);
-    controller.updateServices(requests, mapRequestProps, true);
+    controller.updateServices(requests, mapRequestProps, true, false);
 
     for (ServiceComponent sc :
       clusters.getCluster(clusterName).getService(serviceName)

Modified: 
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java?rev=1467530&r1=1467529&r2=1467530&view=diff
==============================================================================
--- 
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
 (original)
+++ 
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
 Sat Apr 13 00:41:02 2013
@@ -154,7 +154,7 @@ public class JMXHostProviderTest {
     configVersions.put("hdfs-site", "version1");
     sReqs.add(new ServiceRequest(clusterName, serviceName, configVersions,
       null));
-    controller.updateServices(sReqs, mapRequestProps, true);
+    controller.updateServices(sReqs, mapRequestProps, true, false);
   }
 
 

Modified: 
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestImplTest.java
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestImplTest.java?rev=1467530&r1=1467529&r2=1467530&view=diff
==============================================================================
--- 
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestImplTest.java
 (original)
+++ 
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestImplTest.java
 Sat Apr 13 00:41:02 2013
@@ -94,6 +94,7 @@ public class RequestImplTest {
     Assert.assertTrue(validPropertyIds.contains("Services/attributes"));
     
Assert.assertTrue(validPropertyIds.contains("ServiceInfo/desired_configs"));
     Assert.assertTrue(validPropertyIds.contains("params/run_smoke_test"));
+    Assert.assertTrue(validPropertyIds.contains("params/reconfigure_client"));
 
     request = 
PropertyHelper.getReadRequest(PropertyHelper.getPropertyIds(Resource.Type.Host));
     validPropertyIds = request.getPropertyIds();

Modified: 
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java?rev=1467530&r1=1467529&r2=1467530&view=diff
==============================================================================
--- 
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
 (original)
+++ 
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
 Sat Apr 13 00:41:02 2013
@@ -18,6 +18,7 @@
 
 package org.apache.ambari.server.controller.internal;
 
+import org.apache.ambari.server.actionmanager.Stage;
 import org.apache.ambari.server.controller.AmbariManagementController;
 import org.apache.ambari.server.controller.RequestStatusResponse;
 import org.apache.ambari.server.controller.ServiceRequest;
@@ -37,6 +38,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -194,7 +196,7 @@ public class ServiceResourceProviderTest
 
     // set expectations
     expect(managementController.updateServices(capture(requestsCapture),
-        eq(mapRequestProps), eq(false))).andReturn(response).once();
+      eq(mapRequestProps), eq(false), eq(true))).andReturn(response).once();
 
     // replay
     replay(managementController, response);
@@ -231,6 +233,83 @@ public class ServiceResourceProviderTest
   }
 
   @Test
+  public void testReconfigureClientsFlag() throws Exception {
+    Resource.Type type = Resource.Type.Service;
+
+    AmbariManagementController managementController1 = 
createMock(AmbariManagementController.class);
+    AmbariManagementController managementController2 = createMock
+      (AmbariManagementController.class);
+
+    RequestStatusResponse response1 = 
createNiceMock(RequestStatusResponse.class);
+    RequestStatusResponse response2 = createNiceMock(RequestStatusResponse
+      .class);
+    Capture<Set<ServiceRequest>> requestsCapture = new 
Capture<Set<ServiceRequest>>();
+
+    Map<String, String> mapRequestProps = new HashMap<String, String>();
+    mapRequestProps.put("context", "Called from a test");
+
+    Set<ServiceResponse> nameResponse = new HashSet<ServiceResponse>();
+    nameResponse.add(new ServiceResponse(100L, "Cluster100", "Service102", 
null, "HDP-0.1", "DEPLOYED"));
+
+    // set expectations
+    
expect(managementController1.getServices(EasyMock.<Set<ServiceRequest>>anyObject())).andReturn(nameResponse).once();
+    
expect(managementController2.getServices(EasyMock.<Set<ServiceRequest>>anyObject())).andReturn(nameResponse).once();
+
+    // set expectations
+    expect(managementController1.updateServices(capture(requestsCapture),
+      eq(mapRequestProps), eq(false), eq(true))).andReturn(response1).once();
+
+    expect(managementController2.updateServices(capture(requestsCapture),
+      eq(mapRequestProps), eq(false), eq(false))).andReturn(response2).once();
+
+    // replay
+    replay(managementController1, response1);
+    replay(managementController2, response2);
+
+    ResourceProvider provider1 = 
AbstractControllerResourceProvider.getResourceProvider(
+      type,
+      PropertyHelper.getPropertyIds(type),
+      PropertyHelper.getKeyPropertyIds(type),
+      managementController1);
+
+    ResourceProvider provider2 = AbstractControllerResourceProvider
+      .getResourceProvider(
+      type,
+      PropertyHelper.getPropertyIds(type),
+      PropertyHelper.getKeyPropertyIds(type),
+      managementController2);
+
+    // add the property map to a set for the request.
+    Map<String, Object> properties = new LinkedHashMap<String, Object>();
+
+    properties.put(ServiceResourceProvider.SERVICE_SERVICE_STATE_PROPERTY_ID,
+      "STARTED");
+
+    // create the request
+    Request request = PropertyHelper.getUpdateRequest(properties, 
mapRequestProps);
+
+    // update the service named Service102
+    Predicate  predicate1 = new PredicateBuilder().property
+      
(ServiceResourceProvider.SERVICE_CLUSTER_NAME_PROPERTY_ID).equals("Cluster100").
+      and().property(ServiceResourceProvider.SERVICE_SERVICE_NAME_PROPERTY_ID).
+      equals("Service102").and().property("params/reconfigure_client").
+      equals("true").toPredicate();
+
+    Predicate  predicate2 = new PredicateBuilder().property
+      
(ServiceResourceProvider.SERVICE_CLUSTER_NAME_PROPERTY_ID).equals("Cluster100").
+      and().property(ServiceResourceProvider.SERVICE_SERVICE_NAME_PROPERTY_ID).
+      equals("Service102").and().property("params/reconfigure_client").equals
+      ("false").toPredicate();
+
+    provider1.updateResources(request, predicate1);
+    provider2.updateResources(request, predicate2);
+
+    // verify
+    verify(managementController1, response1);
+    verify(managementController2, response2);
+  }
+
+  @Test
   public void testDeleteResources() throws Exception{
     Resource.Type type = Resource.Type.Service;
 


Reply via email to