BIND 10 trac2781, updated. ad4c8681d9700216ccdcd347823c5131f2796d60 [2781] add two logging IDs to skip polling and collecting statistics
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Aug 16 02:58:56 UTC 2013
The branch, trac2781 has been updated
via ad4c8681d9700216ccdcd347823c5131f2796d60 (commit)
via c185e035984740f3914a28f6a93f9d47ae8e75b2 (commit)
from 08a44d8edc6c12dbbd54b9d8b68350732ed57668 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit ad4c8681d9700216ccdcd347823c5131f2796d60
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Thu Aug 15 13:24:16 2013 +0900
[2781] add two logging IDs to skip polling and collecting statistics
Then all IDs have been reordered by reorder_message_file.py.
commit c185e035984740f3914a28f6a93f9d47ae8e75b2
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Thu Aug 15 14:06:12 2013 +0900
[2781] implement skipping collecting and polling statistics to stats
The stats module logs STATS_SKIP_POLLING when it catches an InitSessionTimeout
exception while initially receiving modules information from the init
module. Also, the stats module logs STATS_SKIP_COLLECTING including the name of
the module unable to collect when it catches a SessionTimeout exception while
collecting statistics from that module.
-----------------------------------------------------------------------
Summary of changes:
src/bin/stats/stats.py.in | 23 +++++++++++++++++------
src/bin/stats/stats_messages.mes | 11 +++++++++++
src/bin/stats/tests/stats_test.py | 25 +++++++++++++++++++++++++
3 files changed, 53 insertions(+), 6 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/stats/stats.py.in b/src/bin/stats/stats.py.in
index 212d558..35a48b7 100755
--- a/src/bin/stats/stats.py.in
+++ b/src/bin/stats/stats.py.in
@@ -186,6 +186,11 @@ class StatsError(Exception):
"""Exception class for Stats class"""
pass
+class InitSessionTimeout(isc.cc.session.SessionTimeout):
+ """SessionTimeout Exception in the session between the stats module and the
+ init module"""
+ pass
+
class Stats:
"""
Main class of stats module
@@ -271,6 +276,8 @@ class Stats:
# TODO: Is it OK to just pass? As part of refactoring, preserving
# the original behaviour.
value = None
+ except isc.cc.session.SessionTimeout as e:
+ raise InitSessionTimeout(e)
modules = []
if type(value) is list:
# NOTE: For example, the "show_processes" command
@@ -338,6 +345,7 @@ class Stats:
_statistics_data = []
_sequences = sequences[:]
while len(_sequences) > 0:
+ (module_name, seq) = (None, None)
try:
(module_name, seq) = _sequences.pop(0)
answer, env = self.cc_session.group_recvmsg(False, seq)
@@ -348,7 +356,7 @@ class Stats:
(module_name, env['from'], args))
# skip this module if SessionTimeout raised
except isc.cc.session.SessionTimeout:
- pass
+ logger.warn(STATS_SKIP_COLLECTING, module_name)
return _statistics_data
def _refresh_statistics(self, statistics_data):
@@ -371,11 +379,14 @@ class Stats:
search multiple instances of same module. Second requests
each module to invoke 'getstats'. Finally updates internal
statistics data every time it gets from each instance."""
- modules = self._get_multi_module_list()
- sequences = self._query_statistics(modules)
- _statistics_data = self._collect_statistics(sequences)
- self._refresh_statistics(_statistics_data)
- # if successfully done, set the last time of polling
+ try:
+ modules = self._get_multi_module_list()
+ sequences = self._query_statistics(modules)
+ _statistics_data = self._collect_statistics(sequences)
+ self._refresh_statistics(_statistics_data)
+ except InitSessionTimeout:
+ logger.warn(STATS_SKIP_POLLING)
+ # if successfully done or skipped, set the last time of polling
self._lasttime_poll = get_timestamp()
def _check_command(self, nonblock=False):
diff --git a/src/bin/stats/stats_messages.mes b/src/bin/stats/stats_messages.mes
index b6f0b16..38dddcc 100644
--- a/src/bin/stats/stats_messages.mes
+++ b/src/bin/stats/stats_messages.mes
@@ -64,6 +64,17 @@ will respond with an error and the command will be ignored.
This debug message is printed when a request is sent to the module
to send its data to the stats module.
+% STATS_SKIP_COLLECTING skipped collecting statistics from %1
+The stats module temporarily encountered an internal messaging bus error while
+collecting statistics from the module, then it skipped collecting statistics
+from it and will try to collect from the next module. The lack of statistics
+will be recovered at the next polling round.
+
+% STATS_SKIP_POLLING skipped polling statistics to modules
+The stats module temporarily encountered an internal messaging bus error while
+collecting initial information to collect statistics from the init module, then
+it skipped polling statistics and will try to do next time.
+
% STATS_STARTING starting
The stats module will be now starting.
diff --git a/src/bin/stats/tests/stats_test.py b/src/bin/stats/tests/stats_test.py
index 205e519..9a7ab74 100644
--- a/src/bin/stats/tests/stats_test.py
+++ b/src/bin/stats/tests/stats_test.py
@@ -1383,6 +1383,16 @@ class TestStats(unittest.TestCase):
stat.mccs.rpc_call = lambda x,y: __raise(99, 'Error')
self.assertListEqual([], stat._get_multi_module_list())
+ def test_get_multi_module_list_initsessiontimeout(self):
+ """Test _get_multi_module_list() returns an empty list if rcp_call()
+ raise a InitSeeionTimeout exception"""
+ # InitSeeionTimeout case
+ stat = MyStats()
+ ex = stats.InitSessionTimeout
+ def __raise(*x): raise ex(*x)
+ stat.mccs.rpc_call = lambda x,y: __raise()
+ self.assertRaises(ex, stat._get_multi_module_list)
+
def test_query_statistics(self):
"""Test _query_statistics returns a list of pairs of module and
sequences from group_sendmsg()"""
@@ -1613,6 +1623,21 @@ class TestStats(unittest.TestCase):
self.assertEqual(self.const_timestamp, stat._lasttime_poll)
stats.get_timestamp = orig_get_timestamp
+ def test_polling_initsessiontimeout(self):
+ """Test _lasttime_poll is updated after do_polling() in case that it catches
+ InitSesionTimeout at _get_multi_module_list()
+ """
+ orig_get_timestamp = stats.get_timestamp
+ stats.get_timestamp = lambda : self.const_timestamp
+ ex = stats.InitSessionTimeout
+ def __raise(*x): raise ex(*x)
+ stat = MyStats()
+ self.assertEqual(0.0, stat._lasttime_poll)
+ stat._get_multi_module_list = lambda: __raise()
+ stat.do_polling()
+ self.assertEqual(self.const_timestamp, stat._lasttime_poll)
+ stats.get_timestamp = orig_get_timestamp
+
class Z_TestOSEnv(unittest.TestCase):
# Running this test would break logging setting. To prevent it from
# affecting other tests we use the same workaround as Z_TestOSEnv in
More information about the bind10-changes
mailing list