Преглед изворни кода

AMBARI-2905. SNAMENODE should not start at HA cluster. (swagle)

Siddharth Wagle пре 11 година
родитељ
комит
e65468a6c0

+ 2 - 1
ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java

@@ -133,7 +133,8 @@ public class HeartbeatMonitor implements Runnable {
                 !sch.getState().equals(State.INIT) &&
                 !sch.getState().equals(State.INSTALLING) &&
                 !sch.getState().equals(State.INSTALL_FAILED) &&
-                !sch.getState().equals(State.UNINSTALLED)) {
+                !sch.getState().equals(State.UNINSTALLED) &&
+                !sch.getState().equals(State.MAINTENANCE)) {
               LOG.warn("Setting component state to UNKNOWN for component " + sc.getName() + " on " + host);
               sch.setState(State.UNKNOWN);
             }

+ 16 - 3
ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java

@@ -49,6 +49,7 @@ import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.State;
 import org.apache.ambari.server.state.fsm.InvalidStateTransitionException;
 import org.apache.ambari.server.state.svccomphost.ServiceComponentHostInstallEvent;
+import org.apache.ambari.server.state.svccomphost.ServiceComponentHostMaintenanceEvent;
 import org.apache.ambari.server.state.svccomphost.ServiceComponentHostOpSucceededEvent;
 import org.apache.ambari.server.state.svccomphost.ServiceComponentHostStartedEvent;
 import org.junit.After;
@@ -426,6 +427,18 @@ public class TestHeartbeatMonitor {
         // installing
         sch.handleEvent(new ServiceComponentHostInstallEvent(
             sch.getServiceComponentName(), sch.getHostName(), System.currentTimeMillis(), "HDP-0.1"));
+      } else if (sch.getServiceComponentName().equals("SECONDARY_NAMENODE"))  {
+        // installing
+        sch.handleEvent(new ServiceComponentHostInstallEvent(
+          sch.getServiceComponentName(), sch.getHostName(), System.currentTimeMillis(), "HDP-0.1"));
+
+        // installed
+        sch.handleEvent(new ServiceComponentHostOpSucceededEvent(sch.getServiceComponentName(),
+          sch.getHostName(), System.currentTimeMillis()));
+
+        // maintenance
+        sch.handleEvent(new ServiceComponentHostMaintenanceEvent(sch.getServiceComponentName(),
+          sch.getHostName(), System.currentTimeMillis()));
       }
     }
     
@@ -455,9 +468,9 @@ public class TestHeartbeatMonitor {
         assertEquals(sch.getServiceComponentName(), State.INSTALLING, sch.getState());
       else if (sc.isClientComponent())
         assertEquals(sch.getServiceComponentName(), State.INIT, sch.getState());
+      else if (sch.getServiceComponentName().equals("SECONDARY_NAMENODE"))
+        assertEquals(sch.getServiceComponentName(), State.MAINTENANCE,
+          sch.getState());
     }
-
-    
-    
   }
 }