You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by vb...@apache.org on 2014/05/28 20:10:55 UTC

git commit: AMBARI-5544. Revert Changes.Deleted slave components stick around from the services perspective.(vbrodetskyi)

Repository: ambari
Updated Branches:
  refs/heads/trunk c3a41c1fa -> 8ec1837c3


AMBARI-5544. Revert Changes.Deleted slave components stick around from the services perspective.(vbrodetskyi)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/8ec1837c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8ec1837c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8ec1837c

Branch: refs/heads/trunk
Commit: 8ec1837c3de8defafdc3074e68d38cb2bce65f61
Parents: c3a41c1
Author: Vitaly Brodetskyi <vb...@hortonworks.com>
Authored: Wed May 28 21:09:38 2014 +0300
Committer: Vitaly Brodetskyi <vb...@hortonworks.com>
Committed: Wed May 28 21:10:13 2014 +0300

----------------------------------------------------------------------
 .../AmbariManagementControllerImpl.java         | 36 +-------
 .../AmbariManagementControllerTest.java         | 89 --------------------
 .../RootServiceResponseFactoryTest.java         |  4 +-
 3 files changed, 3 insertions(+), 126 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8ec1837c/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 9ca6bd0..a80327c 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
@@ -2249,17 +2249,8 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
 
     for (Entry<ServiceComponent, Set<ServiceComponentHost>> entry
             : safeToRemoveSCHs.entrySet()) {
-      ServiceComponent serviceComponent = entry.getKey();
       for (ServiceComponentHost componentHost : entry.getValue()) {
-        removeFromExcludeHosts(serviceComponent, componentHost.getHostName());
-        serviceComponent.deleteServiceComponentHosts(
-                componentHost.getHostName());
-      }
-      if (serviceComponent.getServiceComponentHosts().isEmpty()) {
-        LOG.info("Change service component " + serviceComponent.getName()
-                + " state from " + serviceComponent.getDesiredState().toString()
-                + " to state " + State.INIT.toString());
-        serviceComponent.setDesiredState(State.INIT);
+        entry.getKey().deleteServiceComponentHosts(componentHost.getHostName());
       }
     }
 
@@ -2269,31 +2260,6 @@ public class AmbariManagementControllerImpl implements AmbariManagementControlle
     }
     return null;
   }
-
-  public RequestStatusResponse removeFromExcludeHosts(
-          ServiceComponent serviceComponent, String hostname)
-          throws AmbariException {
-    String clusterName = serviceComponent.getClusterName();
-    String serviceName = serviceComponent.getServiceName();
-    String serviceComponentName = serviceComponent.getName();
-    RequestStatusResponse response = null;
-    HashMap<String, String> requestProperties = new HashMap<String, String>();
-    HashMap<String, String> params = new HashMap<String, String>();
-    if ("YARN".equals(serviceName)) {
-      if ("NODEMANAGER".equals(serviceComponentName)) {
-        params.put("included_hosts", hostname);
-        params.put("slave_type", serviceComponentName);
-
-        RequestResourceFilter resourceFilter
-              = new RequestResourceFilter(serviceName, "RESOURCEMANAGER", null);
-        ExecuteActionRequest actionRequest = new ExecuteActionRequest(
-              clusterName, "DECOMMISSION", null,
-              Collections.singletonList(resourceFilter), null, params);
-        response = createAction(actionRequest, requestProperties);
-      }
-    }
-    return response;
-  }
   
   @Override
   public void deleteUsers(Set<UserRequest> requests)

http://git-wip-us.apache.org/repos/asf/ambari/blob/8ec1837c/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index 20fafb9..8fbf207 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -8333,95 +8333,6 @@ public class AmbariManagementControllerTest {
     }
 
   }
-
-  @Test
-  public void testDeleteNodeManagers() throws Exception {
-    String clusterName = "foo1";
-    createCluster(clusterName);
-    Cluster cluster = clusters.getCluster(clusterName);
-    cluster.setDesiredStackVersion(new StackId("HDP-2.0.7"));
-    String serviceName = Service.Type.HDFS.toString();
-    createService(clusterName, serviceName, null);
-    String componentName1 = Role.NAMENODE.toString();
-    String componentName2 = Role.DATANODE.toString();
-    createServiceComponent(clusterName, serviceName, componentName1, State.INIT);
-    createServiceComponent(clusterName, serviceName, componentName2, State.INIT);
-    String host1 = "h1";
-    String host2 = "h2";
-    addHost(host2, clusterName);
-    addHost(host1, clusterName);
-    createServiceComponentHost(clusterName, null, componentName1, host1, null);
-    createServiceComponentHost(clusterName, serviceName, componentName2, host1, null);
-    String yarnService = Service.Type.YARN.toString();
-    createService(clusterName, yarnService, null);
-    String resourceManagerComponent = Role.RESOURCEMANAGER.toString();
-    String nodeManagerComponent = Role.NODEMANAGER.toString();
-    createServiceComponent(clusterName, yarnService, nodeManagerComponent, State.INIT);
-    createServiceComponentHost(clusterName, yarnService, nodeManagerComponent, host1, null);
-    createServiceComponentHost(clusterName, yarnService, nodeManagerComponent, host2, null);
-
-    // Install
-    installService(clusterName, serviceName, false, false);
-    installService(clusterName, yarnService, false, false);
-
-    // make them believe they are up
-    Map<String, ServiceComponentHost> hostComponents = cluster.getService(serviceName).getServiceComponent(componentName1).getServiceComponentHosts();
-    for (Map.Entry<String, ServiceComponentHost> entry : hostComponents.entrySet()) {
-      ServiceComponentHost cHost = entry.getValue();
-      cHost.handleEvent(new ServiceComponentHostInstallEvent(cHost.getServiceComponentName(), cHost.getHostName(), System.currentTimeMillis(), cluster.getDesiredStackVersion().getStackId()));
-      cHost.handleEvent(new ServiceComponentHostOpSucceededEvent(cHost.getServiceComponentName(), cHost.getHostName(), System.currentTimeMillis()));
-    }
-    hostComponents = cluster.getService(serviceName).getServiceComponent(componentName2).getServiceComponentHosts();
-    for (Map.Entry<String, ServiceComponentHost> entry : hostComponents.entrySet()) {
-      ServiceComponentHost cHost = entry.getValue();
-      cHost.handleEvent(new ServiceComponentHostInstallEvent(cHost.getServiceComponentName(), cHost.getHostName(), System.currentTimeMillis(), cluster.getDesiredStackVersion().getStackId()));
-      cHost.handleEvent(new ServiceComponentHostOpSucceededEvent(cHost.getServiceComponentName(), cHost.getHostName(), System.currentTimeMillis()));
-    }
-    hostComponents = cluster.getService(yarnService).getServiceComponent(nodeManagerComponent).getServiceComponentHosts();
-    for (Map.Entry<String, ServiceComponentHost> entry : hostComponents.entrySet()) {
-      ServiceComponentHost cHost = entry.getValue();
-      cHost.handleEvent(new ServiceComponentHostInstallEvent(cHost.getServiceComponentName(), cHost.getHostName(), System.currentTimeMillis(), cluster.getDesiredStackVersion().getStackId()));
-      cHost.handleEvent(new ServiceComponentHostOpSucceededEvent(cHost.getServiceComponentName(), cHost.getHostName(), System.currentTimeMillis()));
-    }
-
-    ServiceComponent serviceComponent = cluster.getService(yarnService).getServiceComponent(nodeManagerComponent);
-    Assert.assertEquals(State.INSTALLED, serviceComponent.getDesiredState());
-
-    Set<ServiceComponentHostRequest> schRequests = new HashSet<ServiceComponentHostRequest>();
-
-    // delete NodeManagers from all hosts if RESOURCEMANAGER not installed
-    schRequests.clear();
-    schRequests.add(new ServiceComponentHostRequest(clusterName, yarnService, nodeManagerComponent, host1, null));
-    schRequests.add(new ServiceComponentHostRequest(clusterName, yarnService, nodeManagerComponent, host2, null));
-
-    // verify if removeFromExcludeHosts was called while deletion
-    // it need RESOURCEMANAGER component
-    try {
-      controller.deleteHostComponents(schRequests);
-      Assert.fail("Expected a AmbariException.");
-    } catch (AmbariException e) {
-      // expected
-    }
-
-    createServiceComponent(clusterName, yarnService, resourceManagerComponent, State.INIT);
-    createServiceComponentHost(clusterName, yarnService, resourceManagerComponent, host1, null);
-    hostComponents = cluster.getService(yarnService).getServiceComponent(resourceManagerComponent).getServiceComponentHosts();
-    for (Map.Entry<String, ServiceComponentHost> entry : hostComponents.entrySet()) {
-      ServiceComponentHost cHost = entry.getValue();
-      cHost.handleEvent(new ServiceComponentHostInstallEvent(cHost.getServiceComponentName(), cHost.getHostName(), System.currentTimeMillis(), cluster.getDesiredStackVersion().getStackId()));
-      cHost.handleEvent(new ServiceComponentHostOpSucceededEvent(cHost.getServiceComponentName(), cHost.getHostName(), System.currentTimeMillis()));
-    }
-
-    // delete NodeManagers from all hosts
-    schRequests.clear();
-    schRequests.add(new ServiceComponentHostRequest(clusterName, yarnService, nodeManagerComponent, host1, null));
-    schRequests.add(new ServiceComponentHostRequest(clusterName, yarnService, nodeManagerComponent, host2, null));
-    controller.deleteHostComponents(schRequests);
-
-    Assert.assertEquals(3, cluster.getServiceComponentHosts(host1).size());
-    Assert.assertEquals(0, cluster.getServiceComponentHosts(host2).size());
-    Assert.assertEquals(State.INIT, serviceComponent.getDesiredState());
-  }
   
   @Test
   public void testGetRootServices() throws Exception {

http://git-wip-us.apache.org/repos/asf/ambari/blob/8ec1837c/ambari-server/src/test/java/org/apache/ambari/server/controller/RootServiceResponseFactoryTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/RootServiceResponseFactoryTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/RootServiceResponseFactoryTest.java
index 1365543..3ece6ac 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/RootServiceResponseFactoryTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/RootServiceResponseFactoryTest.java
@@ -134,7 +134,7 @@ public class RootServiceResponseFactoryTest {
              assertEquals(response.getComponentVersion(), "1.3.0");
              assertEquals(response.getProperties().size(), 1);
              assertTrue(response.getProperties().containsKey("jdk_location"));
-             assertEquals(response.getProperties().get("jdk_location"), "http://localhost:8080/resources/");
+             //assertEquals(response.getProperties().get("jdk_location"), "http://localhost:8080/resources/");
            }
          }
       } else {
@@ -158,7 +158,7 @@ public class RootServiceResponseFactoryTest {
         assertEquals(response.getComponentVersion(), "1.3.0");
         assertEquals(response.getProperties().size(), 1);
         assertTrue(response.getProperties().containsKey("jdk_location"));
-        assertEquals(response.getProperties().get("jdk_location"), "http://localhost:8080/resources/");
+        //assertEquals(response.getProperties().get("jdk_location"), "http://localhost:8080/resources/");
       }
     }