You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sw...@apache.org on 2013/04/18 22:21:26 UTC
svn commit: r1469547 - in /incubator/ambari/trunk: ./
ambari-agent/src/main/python/ambari_agent/ ambari-agent/src/test/python/
ambari-server/src/main/java/org/apache/ambari/server/agent/
ambari-server/src/main/java/org/apache/ambari/server/agent/rest/
Author: swagle
Date: Thu Apr 18 20:21:25 2013
New Revision: 1469547
URL: http://svn.apache.org/r1469547
Log:
AMBARI-1979. Last HeartBeat time and heartbeat status for agent take around 2-3 minutes to update on a server restart. (swagle)
Modified:
incubator/ambari/trunk/CHANGES.txt
incubator/ambari/trunk/ambari-agent/src/main/python/ambari_agent/Controller.py
incubator/ambari/trunk/ambari-agent/src/test/python/TestController.py
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java
Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1469547&r1=1469546&r2=1469547&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Thu Apr 18 20:21:25 2013
@@ -762,6 +762,9 @@ Trunk (unreleased changes):
BUG FIXES
+ AMBARI-1979. Last HeartBeat time and heartbeat status for agent take around 2-3
+ minutes to update on a server restart. (swagle)
+
AMBARI-1978. Deploying HDP-1.3.0 results in several alerts - is it related to
hard-coded port. (swagle)
Modified: incubator/ambari/trunk/ambari-agent/src/main/python/ambari_agent/Controller.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-agent/src/main/python/ambari_agent/Controller.py?rev=1469547&r1=1469546&r2=1469547&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-agent/src/main/python/ambari_agent/Controller.py (original)
+++ incubator/ambari/trunk/ambari-agent/src/main/python/ambari_agent/Controller.py Thu Apr 18 20:21:25 2013
@@ -46,7 +46,7 @@ logger = logging.getLogger()
class Controller(threading.Thread):
- def __init__(self, config, range=120):
+ def __init__(self, config, range=30):
threading.Thread.__init__(self)
logger.debug('Initializing Controller RPC thread.')
self.lock = threading.Lock()
Modified: incubator/ambari/trunk/ambari-agent/src/test/python/TestController.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-agent/src/test/python/TestController.py?rev=1469547&r1=1469546&r2=1469547&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-agent/src/test/python/TestController.py (original)
+++ incubator/ambari/trunk/ambari-agent/src/test/python/TestController.py Thu Apr 18 20:21:25 2013
@@ -25,10 +25,12 @@ from ambari_agent import Controller
from ambari_agent import hostname
import sys
from mock.mock import patch, MagicMock, call
-
+import logging
class TestController(unittest.TestCase):
+ logger = logging.getLogger()
+
@patch("threading.Thread")
@patch("threading.Lock")
@patch.object(Controller, "NetUtil")
@@ -177,6 +179,26 @@ class TestController(unittest.TestCase):
@patch("time.sleep")
+ def test_registerAndHeartbeatWithException(self, sleepMock):
+
+ registerWithServer = MagicMock(name="registerWithServer")
+ registerWithServer.return_value = {"response":"resp"}
+ self.controller.registerWithServer = registerWithServer
+ heartbeatWithServer = MagicMock(name="heartbeatWithServer")
+ self.controller.heartbeatWithServer = heartbeatWithServer
+
+ Controller.Controller.__sendRequest__ = MagicMock(side_effect=Exception())
+
+ self.controller.registerAndHeartbeat()
+ registerWithServer.assert_called_once_with()
+ heartbeatWithServer.assert_called_once_with()
+
+ self.controller.registerWithServer =\
+ Controller.Controller.registerWithServer
+ self.controller.heartbeatWithServer =\
+ Controller.Controller.registerWithServer
+
+ @patch("time.sleep")
def test_registerAndHeartbeat(self, sleepMock):
registerWithServer = MagicMock(name="registerWithServer")
Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java?rev=1469547&r1=1469546&r2=1469547&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartbeatMonitor.java Thu Apr 18 20:21:25 2013
@@ -82,8 +82,10 @@ public class HeartbeatMonitor implements
public void run() {
while (shouldRun) {
try {
- Thread.sleep(threadWakeupInterval);
doWork();
+ LOG.trace("Putting monitor to sleep for " + threadWakeupInterval + " " +
+ "milliseconds");
+ Thread.sleep(threadWakeupInterval);
} catch (InterruptedException ex) {
LOG.warn("Scheduler thread is interrupted going to stop", ex);
shouldRun = false;
@@ -133,6 +135,8 @@ public class HeartbeatMonitor implements
// Get status of service components
List<StatusCommand> cmds = generateStatusCommands(hostname);
+ LOG.trace("Generated " + cmds.size() + " status commands for host: " +
+ hostname);
if (cmds.isEmpty()) {
// Nothing to do
} else {
Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java?rev=1469547&r1=1469546&r2=1469547&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/agent/rest/AgentResource.java Thu Apr 18 20:21:25 2013
@@ -79,7 +79,7 @@ public class AgentResource {
/* Call into the heartbeat handler */
RegistrationResponse response = hh.handleRegistration(message);
- LOG.debug("Sending registration responce " + hh);
+ LOG.debug("Sending registration response " + response);
return response;
}
@@ -106,7 +106,7 @@ public class AgentResource {
HeartBeatResponse heartBeatResponse;
try {
heartBeatResponse = hh.handleHeartBeat(message);
- LOG.debug("Sending heartbeat responce " + hh);
+ LOG.debug("Sending heartbeat response " + heartBeatResponse);
} catch (Exception e) {
LOG.info("Error in HeartBeat", e);
throw new WebApplicationException(500);