ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpapirkovs...@apache.org
Subject ambari git commit: AMBARI-15202. Status commands temporary break host component state machine. (mpapirkovskyy)
Date Thu, 03 Mar 2016 14:46:10 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 486981463 -> 0e583d354


AMBARI-15202. Status commands temporary break host component state machine. (mpapirkovskyy)


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

Branch: refs/heads/branch-2.2
Commit: 0e583d354f7e40e4cd11f0d7a8bc5d611ddfbb60
Parents: 4869814
Author: Myroslav Papirkovskyi <mpapyrkovskyy@hortonworks.com>
Authored: Fri Feb 26 16:59:58 2016 +0200
Committer: Myroslav Papirkovskyi <mpapyrkovskyy@hortonworks.com>
Committed: Thu Mar 3 16:43:45 2016 +0200

----------------------------------------------------------------------
 .../ambari/server/agent/HeartbeatProcessor.java | 11 +--
 .../server/agent/HeartbeatProcessorTest.java    | 79 +++++++++++++++++++-
 2 files changed, 84 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0e583d35/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatProcessor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatProcessor.java
b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatProcessor.java
index cc986c4..b5e61d1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatProcessor.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatProcessor.java
@@ -208,8 +208,9 @@ public class HeartbeatProcessor extends AbstractService{
 
     processAlerts(heartbeat);
 
-    processCommandReports(heartbeat, now);
+    //process status reports before command reports to prevent status override immediately
after task finish
     processStatusReports(heartbeat);
+    processCommandReports(heartbeat, now);
     //host status calculation are based on task and status reports, should be performed last
     processHostStatus(heartbeat);
   }
@@ -595,18 +596,18 @@ public class HeartbeatProcessor extends AbstractService{
               org.apache.ambari.server.state.State liveState =
                   org.apache.ambari.server.state.State.valueOf(org.apache.ambari.server.state.State.class,
                       status.getStatus());
+              //ignore reports from status commands if component is in INIT or any "in progress"
state
               if (prevState.equals(org.apache.ambari.server.state.State.INSTALLED)
                   || prevState.equals(org.apache.ambari.server.state.State.STARTED)
-                  || prevState.equals(org.apache.ambari.server.state.State.STARTING)
-                  || prevState.equals(org.apache.ambari.server.state.State.STOPPING)
                   || prevState.equals(org.apache.ambari.server.state.State.UNKNOWN)) {
-                scHost.setState(liveState); //TODO direct status set breaks state machine
sometimes !!!
+                scHost.setState(liveState);
                 if (!prevState.equals(liveState)) {
                   LOG.info("State of service component " + componentName
                       + " of service " + status.getServiceName()
                       + " of cluster " + status.getClusterName()
                       + " has changed from " + prevState + " to " + liveState
-                      + " at host " + hostname);
+                      + " at host " + hostname
+                      + " according to STATUS_COMMAND report");
                 }
               }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/0e583d35/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java
index eb99142..7f3d763 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java
@@ -520,7 +520,8 @@ public class HeartbeatProcessorTest {
     assertEquals(SecurityState.SECURED_KERBEROS, serviceComponentHost1.getSecurityState());
     assertEquals(State.INSTALLED, componentState2);
     assertEquals(SecurityState.SECURING, serviceComponentHost2.getSecurityState());
-    assertEquals(State.STARTED, componentState3);
+    //starting state will not be overridden by status command
+    assertEquals(State.STARTING, componentState3);
     assertEquals(SecurityState.UNSECURED, serviceComponentHost3.getSecurityState());
   }
 
@@ -1286,5 +1287,81 @@ public class HeartbeatProcessorTest {
     Assert.assertNotNull(entity);
   }
 
+  @Test
+  @SuppressWarnings("unchecked")
+  public void testComponentInProgressStatusSafeAfterStatusReport() throws Exception {
+    Cluster cluster = heartbeatTestHelper.getDummyCluster();
+    Service hdfs = cluster.addService(HDFS);
+    hdfs.persist();
+    hdfs.addServiceComponent(DATANODE).persist();
+    hdfs.getServiceComponent(DATANODE).
+        addServiceComponentHost(DummyHostname1).persist();
+    hdfs.addServiceComponent(NAMENODE).persist();
+    hdfs.getServiceComponent(NAMENODE).
+        addServiceComponentHost(DummyHostname1).persist();
+
+    ActionQueue aq = new ActionQueue();
+
+    ServiceComponentHost serviceComponentHost1 = clusters.
+        getCluster(DummyCluster).getService(HDFS).
+        getServiceComponent(DATANODE).
+        getServiceComponentHost(DummyHostname1);
+    ServiceComponentHost serviceComponentHost2 = clusters.
+        getCluster(DummyCluster).getService(HDFS).
+        getServiceComponent(NAMENODE).
+        getServiceComponentHost(DummyHostname1);
+    serviceComponentHost1.setState(State.STARTING);
+    serviceComponentHost2.setState(State.STOPPING);
+
+    HeartBeat hb = new HeartBeat();
+    hb.setTimestamp(System.currentTimeMillis());
+    hb.setResponseId(0);
+    hb.setHostname(DummyHostname1);
+    hb.setNodeStatus(new HostStatus(HostStatus.Status.HEALTHY, DummyHostStatus));
+    hb.setReports(new ArrayList<CommandReport>());
+    ArrayList<ComponentStatus> componentStatuses = new ArrayList<ComponentStatus>();
+
+    ComponentStatus componentStatus1 = new ComponentStatus();
+    componentStatus1.setClusterName(DummyCluster);
+    componentStatus1.setServiceName(HDFS);
+    componentStatus1.setMessage(DummyHostStatus);
+    componentStatus1.setStatus(State.INSTALLED.name());
+    componentStatus1.setSecurityState(SecurityState.UNSECURED.name());
+    componentStatus1.setComponentName(DATANODE);
+    componentStatuses.add(componentStatus1);
+
+    ComponentStatus componentStatus2 = new ComponentStatus();
+    componentStatus2.setClusterName(DummyCluster);
+    componentStatus2.setServiceName(HDFS);
+    componentStatus2.setMessage(DummyHostStatus);
+    componentStatus2.setStatus(State.INSTALLED.name());
+    componentStatus2.setSecurityState(SecurityState.UNSECURED.name());
+    componentStatus2.setComponentName(NAMENODE);
+    componentStatuses.add(componentStatus2);
+
+    hb.setComponentStatus(componentStatuses);
+
+    final HostRoleCommand command = hostRoleCommandFactory.create(DummyHostname1,
+        Role.DATANODE, null, null);
+
+    ActionManager am = heartbeatTestHelper.getMockActionManager();
+    expect(am.getTasks(anyObject(List.class))).andReturn(
+        new ArrayList<HostRoleCommand>() {{
+          add(command);
+          add(command);
+        }});
+    replay(am);
+
+    HeartBeatHandler handler = heartbeatTestHelper.getHeartBeatHandler(am, aq);
+    HeartbeatProcessor heartbeatProcessor = handler.getHeartbeatProcessor();
+    heartbeatProcessor.processHeartbeat(hb);
+
+    State componentState1 = serviceComponentHost1.getState();
+    State componentState2 = serviceComponentHost2.getState();
+    assertEquals(State.STARTING, componentState1);
+    assertEquals(State.STOPPING, componentState2);
+  }
+
+
 
 }
\ No newline at end of file


Mime
View raw message