You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2013/06/21 15:52:45 UTC

svn commit: r1495444 - in /incubator/ambari/trunk/ambari-server/src: main/java/org/apache/ambari/server/controller/ main/java/org/apache/ambari/server/state/svccomphost/ test/java/org/apache/ambari/server/controller/

Author: ncole
Date: Fri Jun 21 13:52:45 2013
New Revision: 1495444

URL: http://svn.apache.org/r1495444
Log:
AMBARI-2458. Add ability to change UNKOWN to MAINTENANCE for host_components (ncole)

Modified:
    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/state/svccomphost/ServiceComponentHostImpl.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java

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=1495444&r1=1495443&r2=1495444&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 Fri Jun 21 13:52:45 2013
@@ -2041,6 +2041,7 @@ public class AmbariManagementControllerI
                     || oldSchState == State.UNINSTALLED
                     || oldSchState == State.INSTALLED
                     || oldSchState == State.INSTALLING
+                    || oldSchState == State.UNKNOWN
                     || oldSchState == State.INSTALL_FAILED) {
                   roleCommand = RoleCommand.INSTALL;
                   event = new ServiceComponentHostInstallEvent(
@@ -2283,6 +2284,7 @@ public class AmbariManagementControllerI
             || oldState == State.INSTALL_FAILED
             || oldState == State.UPGRADING
             || oldState == State.STOPPING
+            || oldState == State.UNKNOWN
             || oldState == State.MAINTENANCE) {
           return true;
         }
@@ -2307,7 +2309,8 @@ public class AmbariManagementControllerI
           return true;
         }
       case MAINTENANCE:
-        if (oldState == State.INSTALLED) {
+        if (oldState == State.INSTALLED
+            || oldState == State.UNKNOWN) {
           return true;
         }
     }
@@ -3138,7 +3141,7 @@ public class AmbariManagementControllerI
       // If upgrade request comes without state information then its an error
       boolean upgradeRequest = checkIfUpgradeRequestAndValidate(request, cluster, s, sc, sch);
 
-      if (newState == null || oldState.equals(State.UNKNOWN)) {
+      if (newState == null) {
         if (LOG.isDebugEnabled()) {
           LOG.debug("Nothing to do for new updateServiceComponentHost request"
               + ", clusterName=" + request.getClusterName()
@@ -3373,10 +3376,13 @@ public class AmbariManagementControllerI
         }
         break;
       case MAINTENANCE:
-        if (oldState == State.INSTALLED) {
+        if (oldState == State.INSTALLED ||
+          oldState == State.UNKNOWN) {
           return true;
         }
         break;
+      default:
+        break;
     }
     return false;
   }

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java?rev=1495444&r1=1495443&r2=1495444&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java Fri Jun 21 13:52:45 2013
@@ -332,6 +332,11 @@ public class ServiceComponentHostImpl im
           State.INSTALLED,
           ServiceComponentHostEventType.HOST_SVCCOMP_RESTORE,
           new ServiceComponentHostOpCompletedTransition())
+      
+      .addTransition(State.UNKNOWN,
+          State.MAINTENANCE,
+          ServiceComponentHostEventType.HOST_SVCCOMP_MAINTENANCE,
+          new ServiceComponentHostOpCompletedTransition())
 
      .installTopology();
 

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=1495444&r1=1495443&r2=1495444&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 Fri Jun 21 13:52:45 2013
@@ -1669,6 +1669,37 @@ public class AmbariManagementControllerI
     amc.createHostComponents(componentHostRequests);
     namenodes = cluster.getService("HDFS").getServiceComponent("NAMENODE").getServiceComponentHosts();
     assertEquals(2, namenodes.size());
+    
+    
+    // make unknown
+    ServiceComponentHost sch = null;
+    for (ServiceComponentHost tmp : cluster.getServiceComponentHosts("host2")) {
+      if (tmp.getServiceComponentName().equals("DATANODE")) {
+        tmp.setState(State.UNKNOWN);
+        sch = tmp;
+      }
+    }
+    assertNotNull(sch);
+
+    // make maintenance
+    componentHostRequests.clear();
+    componentHostRequests.add(new ServiceComponentHostRequest("c1", null, "DATANODE", "host2", null, "MAINTENANCE"));
+    amc.updateHostComponents(componentHostRequests, mapRequestProps, false);
+    assertEquals(State.MAINTENANCE, sch.getState ());
+    
+    // confirm delete
+    componentHostRequests.clear();
+    componentHostRequests.add(new ServiceComponentHostRequest("c1", null, "DATANODE", "host2", null, null));
+    amc.deleteHostComponents(componentHostRequests);
+    
+    sch = null;
+    for (ServiceComponentHost tmp : cluster.getServiceComponentHosts("host2")) {
+      if (tmp.getServiceComponentName().equals("DATANODE")) {
+        sch = tmp;
+      }
+    }
+    assertNull(sch);
+    
   }
 
   private void testRunSmokeTestFlag(Map<String, String> mapRequestProps,