incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r1224695 - in /incubator/ambari/trunk: ./ client/src/main/java/org/apache/ambari/common/rest/entities/ controller/src/main/java/org/apache/ambari/controller/ controller/src/test/java/org/apache/ambari/controller/
Date Mon, 26 Dec 2011 08:49:51 GMT
Author: ddas
Date: Mon Dec 26 08:49:50 2011
New Revision: 1224695

URL: http://svn.apache.org/viewvc?rev=1224695&view=rev
Log:
AMBARI-175. Removes the map from hostnames to heartbeat-responses.

Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/NodeState.java
    incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java
    incubator/ambari/trunk/controller/src/test/java/org/apache/ambari/controller/TestHeartbeat.java

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1224695&r1=1224694&r2=1224695&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Mon Dec 26 08:49:50 2011
@@ -2,6 +2,8 @@ Ambari Change log
 
 Release 0.1.0 - unreleased
 
+  AMBARI-175. Removes the map from hostnames to heartbeat-responses. (ddas)
+
   AMBARI-174. Controller marks nodes unhealthy upon command execution failures. Marks them
   healthy when the corresponding agent is restarted (ddas)
 

Modified: incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/NodeState.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/NodeState.java?rev=1224695&r1=1224694&r2=1224695&view=diff
==============================================================================
--- incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/NodeState.java
(original)
+++ incubator/ambari/trunk/client/src/main/java/org/apache/ambari/common/rest/entities/NodeState.java
Mon Dec 26 08:49:50 2011
@@ -64,7 +64,7 @@ public class NodeState {
     protected Boolean allocatedToCluster = false;
     
     @XmlAttribute
-    protected Boolean health = true;
+    protected Boolean health = NodeState.HEALTHY;
         
     /*
      * null indicates no roles associated with this node.

Modified: incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java?rev=1224695&r1=1224694&r2=1224695&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java
(original)
+++ incubator/ambari/trunk/controller/src/main/java/org/apache/ambari/controller/HeartbeatHandler.java
Mon Dec 26 08:49:50 2011
@@ -57,9 +57,6 @@ import com.google.inject.Singleton;
 @Singleton
 public class HeartbeatHandler {
   
-  private Map<String, ControllerResponse> agentToHeartbeatResponseMap = 
-      Collections.synchronizedMap(new HashMap<String, ControllerResponse>());
-  
   private static Log LOG = LogFactory.getLog(HeartbeatHandler.class);
   private final Clusters clusters;
   private final Nodes nodes;
@@ -85,20 +82,12 @@ public class HeartbeatHandler {
     nodes.checkAndUpdateNode(hostname, heartbeatTime);
     
     boolean firstContact = heartbeat.getFirstContact();
-    ControllerResponse prevResponse = 
-        agentToHeartbeatResponseMap.get(heartbeat.getHostname());
      
-    if (firstContact || prevResponse == null) {
-      //either the controller restarted, or this is a new agent
+    if (firstContact) {
+      //this is a new agent
       nodes.markNodeHealthy(hostname);
     }
     
-    if (prevResponse != null) {
-      if (prevResponse.getResponseId() != heartbeat.getResponseId()) {
-        return prevResponse; //duplicate heartbeat or the agent restarted
-      }
-    }
-    
     List<CommandResult> commandResult;
     if((commandResult = failedActions(heartbeat))!=null && 
         !commandResult.isEmpty()) {
@@ -179,8 +168,7 @@ public class HeartbeatHandler {
                 //check the expected state of the agent and whether the start
                 //was successful
                 if (wasStartRoleSuccessful(clusterIdAndRev, 
-                    service.getServiceName(), role.getRoleName(), prevResponse, 
-                    heartbeat)) {
+                    service.getServiceName(), role.getRoleName(), heartbeat)) {
                   //raise an event to the state machine for a successful 
                   //role-start
                   stateMachineInvoker.getAMBARIEventHandler()
@@ -195,8 +183,7 @@ public class HeartbeatHandler {
                 //raise an event to the state machine for a successful 
                 //role-stop instance
                 if (wasStopRoleSuccessful(clusterIdAndRev, 
-                    service.getServiceName(), role.getRoleName(), prevResponse, 
-                    heartbeat)) {
+                    service.getServiceName(), role.getRoleName(), heartbeat)) {
                   stateMachineInvoker.getAMBARIEventHandler()
                   .handle(new RoleEvent(RoleEventType.STOP_SUCCESS, role));
                 }
@@ -245,7 +232,6 @@ public class HeartbeatHandler {
       allActions.add(a);
     }
     r.setActions(allActions);
-    agentToHeartbeatResponseMap.put(heartbeat.getHostname(), r);
     return r;
   }
   
@@ -260,8 +246,7 @@ public class HeartbeatHandler {
   }
     
   private boolean wasStartRoleSuccessful(ClusterNameAndRev clusterIdAndRev, 
-      String component, String roleName, ControllerResponse response, 
-      HeartBeat heartbeat) {
+      String component, String roleName, HeartBeat heartbeat) {
     List<AgentRoleState> serverStates = heartbeat.getInstalledRoleStates();
     if (serverStates == null) {
       return false;
@@ -296,8 +281,7 @@ public class HeartbeatHandler {
   }
   
   private boolean wasStopRoleSuccessful(ClusterNameAndRev clusterIdAndRev, 
-      String component, String roleName, ControllerResponse response, 
-      HeartBeat heartbeat) {
+      String component, String roleName, HeartBeat heartbeat) {
     List<AgentRoleState> serverStates = heartbeat.getInstalledRoleStates();
     if (serverStates == null) {
       return true;

Modified: incubator/ambari/trunk/controller/src/test/java/org/apache/ambari/controller/TestHeartbeat.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/controller/src/test/java/org/apache/ambari/controller/TestHeartbeat.java?rev=1224695&r1=1224694&r2=1224695&view=diff
==============================================================================
--- incubator/ambari/trunk/controller/src/test/java/org/apache/ambari/controller/TestHeartbeat.java
(original)
+++ incubator/ambari/trunk/controller/src/test/java/org/apache/ambari/controller/TestHeartbeat.java
Mon Dec 26 08:49:50 2011
@@ -404,7 +404,7 @@ public class TestHeartbeat {
     mUnhealthy.methodCalled = false;
     mHealthy.methodCalled = false;
     //now the call to markNodeUnhealthy should not happen
-    //the call to markNodeHealthy should happen
+    //the call to markNodeHealthy should not happen too
     handler.processHeartBeat(heartbeat);
     assert(mUnhealthy.methodCalled == false && mHealthy.methodCalled == false);
     



Mime
View raw message