BIND 10 master, updated. 67d8e93028e014f644868fede3570abb28e5fb43 Merge branch 'master' into trac519
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Aug 23 12:11:41 UTC 2011
The branch, master has been updated
via 67d8e93028e014f644868fede3570abb28e5fb43 (commit)
via 5ece3fe5e40efbcf7d727650475c35850624cfaf (commit)
via 568a8cc472f3207b44b92428e7ac40338d9ede37 (commit)
via a53c7d7c450de09ceb04b47cb59450225827bd51 (commit)
from 73df015104eb5ac8934ff1176c24079e6e9b09c3 (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 67d8e93028e014f644868fede3570abb28e5fb43
Merge: 5ece3fe5e40efbcf7d727650475c35850624cfaf 73df015104eb5ac8934ff1176c24079e6e9b09c3
Author: zhanglikun <zhanglikun at cnnic.cn>
Date: Tue Aug 23 20:07:49 2011 +0800
Merge branch 'master' into trac519
commit 5ece3fe5e40efbcf7d727650475c35850624cfaf
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Thu Aug 18 10:42:24 2011 +0000
[519] update stats documents
commit 568a8cc472f3207b44b92428e7ac40338d9ede37
Author: zhanglikun <zhanglikun at cnnic.cn>
Date: Thu Aug 18 16:37:15 2011 +0800
[519] Add unit test for the change to boss process. Catch the timeout exception when boss receiving the answer from stats.
commit a53c7d7c450de09ceb04b47cb59450225827bd51
Author: zhanglikun <zhanglikun at cnnic.cn>
Date: Wed Aug 10 17:51:36 2011 +0800
[519] 1. Make stats module get boss's start time from the answer of command 'getstats'. 2. Make boss and stats receive msgq message(the call to group_recvmsg) in block mode.
-----------------------------------------------------------------------
Summary of changes:
src/bin/bind10/bind10_src.py.in | 17 +++++++++++++----
src/bin/bind10/tests/bind10_test.py.in | 6 ++++++
src/bin/stats/b10-stats.8 | 2 +-
src/bin/stats/b10-stats.xml | 2 +-
src/bin/stats/stats.py.in | 26 ++++++++++++++++++--------
src/bin/stats/tests/b10-stats_test.py | 3 ++-
src/bin/stats/tests/isc/cc/session.py | 10 +++++++++-
7 files changed, 50 insertions(+), 16 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/bind10/bind10_src.py.in b/src/bin/bind10/bind10_src.py.in
index b497f7c..81b24f1 100755
--- a/src/bin/bind10/bind10_src.py.in
+++ b/src/bin/bind10/bind10_src.py.in
@@ -307,6 +307,11 @@ class BoB:
process_list.append([pid, self.processes[pid].name])
return process_list
+ def _get_stats_data(self):
+ return { "stats_data": {
+ 'bind10.boot_time': time.strftime('%Y-%m-%dT%H:%M:%SZ', _BASETIME)
+ }}
+
def command_handler(self, command, args):
logger.debug(DBG_COMMANDS, BIND10_RECEIVED_COMMAND, command)
answer = isc.config.ccsession.create_answer(1, "command not implemented")
@@ -316,14 +321,18 @@ class BoB:
if command == "shutdown":
self.runnable = False
answer = isc.config.ccsession.create_answer(0)
+ elif command == "getstats":
+ answer = isc.config.ccsession.create_answer(0, self._get_stats_data())
elif command == "sendstats":
# send statistics data to the stats daemon immediately
cmd = isc.config.ccsession.create_command(
- 'set', { "stats_data": {
- 'bind10.boot_time': time.strftime('%Y-%m-%dT%H:%M:%SZ', _BASETIME)
- }})
+ 'set', self._get_stats_data())
seq = self.cc_session.group_sendmsg(cmd, 'Stats')
- self.cc_session.group_recvmsg(True, seq)
+ # Consume the answer, in case it becomes a orphan message.
+ try:
+ self.cc_session.group_recvmsg(False, seq)
+ except isc.cc.session.SessionTimeout:
+ pass
answer = isc.config.ccsession.create_answer(0)
elif command == "ping":
answer = isc.config.ccsession.create_answer(0, "pong")
diff --git a/src/bin/bind10/tests/bind10_test.py.in b/src/bin/bind10/tests/bind10_test.py.in
index 077190c..424a610 100644
--- a/src/bin/bind10/tests/bind10_test.py.in
+++ b/src/bin/bind10/tests/bind10_test.py.in
@@ -147,6 +147,12 @@ class TestBoB(unittest.TestCase):
self.assertEqual(bob.command_handler("shutdown", None),
isc.config.ccsession.create_answer(0))
self.assertFalse(bob.runnable)
+ # "getstats" command
+ self.assertEqual(bob.command_handler("getstats", None),
+ isc.config.ccsession.create_answer(0,
+ { "stats_data": {
+ 'bind10.boot_time': time.strftime('%Y-%m-%dT%H:%M:%SZ', _BASETIME)
+ }}))
# "sendstats" command
self.assertEqual(bob.command_handler("sendstats", None),
isc.config.ccsession.create_answer(0))
diff --git a/src/bin/stats/b10-stats.8 b/src/bin/stats/b10-stats.8
index b88af6c..98b109b 100644
--- a/src/bin/stats/b10-stats.8
+++ b/src/bin/stats/b10-stats.8
@@ -36,7 +36,7 @@ with other modules like
\fBb10\-auth\fR
and so on\&. It waits for coming data from other modules, then other modules send data to stats module periodically\&. Other modules send stats data to stats module independently from implementation of stats module, so the frequency of sending data may not be constant\&. Stats module collects data and aggregates it\&.
\fBb10\-stats\fR
-invokes "sendstats" command for
+invokes an internal command for
\fBbind10\fR
after its initial starting because it\'s sure to collect statistics data from
\fBbind10\fR\&.
diff --git a/src/bin/stats/b10-stats.xml b/src/bin/stats/b10-stats.xml
index 1164711..9709175 100644
--- a/src/bin/stats/b10-stats.xml
+++ b/src/bin/stats/b10-stats.xml
@@ -64,7 +64,7 @@
send stats data to stats module independently from
implementation of stats module, so the frequency of sending data
may not be constant. Stats module collects data and aggregates
- it. <command>b10-stats</command> invokes "sendstats" command
+ it. <command>b10-stats</command> invokes an internal command
for <command>bind10</command> after its initial starting because it's
sure to collect statistics data from <command>bind10</command>.
<!-- TODO: reword that last sentence? -->
diff --git a/src/bin/stats/stats.py.in b/src/bin/stats/stats.py.in
index ce3d9f4..51d712b 100644
--- a/src/bin/stats/stats.py.in
+++ b/src/bin/stats/stats.py.in
@@ -213,6 +213,14 @@ class CCSessionListener(Listener):
except AttributeError as ae:
logger.error(STATS_UNKNOWN_COMMAND_IN_SPEC, cmd["command_name"])
+ def _update_stats_data(self, args):
+ # 'args' must be dictionary type
+ if isinstance(args, dict) and isinstance(args.get('stats_data'), dict):
+ self.stats_data.update(args['stats_data'])
+
+ # overwrite "stats.LastUpdateTime"
+ self.stats_data['stats.last_update_time'] = get_datetime()
+
def start(self):
"""
start the cc chanel
@@ -225,9 +233,16 @@ class CCSessionListener(Listener):
self.cc_session.start()
# request Bob to send statistics data
logger.debug(DBG_STATS_MESSAGING, STATS_SEND_REQUEST_BOSS)
- cmd = isc.config.ccsession.create_command("sendstats", None)
+ cmd = isc.config.ccsession.create_command("getstats", None)
seq = self.session.group_sendmsg(cmd, 'Boss')
- self.session.group_recvmsg(True, seq)
+ try:
+ answer, env = self.session.group_recvmsg(False, seq)
+ if answer:
+ rcode, arg = isc.config.ccsession.parse_answer(answer)
+ if rcode == 0:
+ self._update_stats_data(arg)
+ except isc.cc.session.SessionTimeout:
+ pass
def stop(self):
"""
@@ -276,12 +291,7 @@ class CCSessionListener(Listener):
"""
handle set command
"""
- # 'args' must be dictionary type
- self.stats_data.update(args['stats_data'])
-
- # overwrite "stats.LastUpdateTime"
- self.stats_data['stats.last_update_time'] = get_datetime()
-
+ self._update_stats_data(args)
return create_answer(0)
def command_remove(self, args, stats_item_name=''):
diff --git a/src/bin/stats/tests/b10-stats_test.py b/src/bin/stats/tests/b10-stats_test.py
index a42c81d..2fb4ab5 100644
--- a/src/bin/stats/tests/b10-stats_test.py
+++ b/src/bin/stats/tests/b10-stats_test.py
@@ -59,6 +59,7 @@ class TestStats(unittest.TestCase):
# check starting
self.assertFalse(self.subject.running)
self.subject.start()
+ self.assertEqual(len(self.session.old_message_queue), 1)
self.assertTrue(self.subject.running)
self.assertEqual(len(self.session.message_queue), 0)
self.assertEqual(self.module_name, 'Stats')
@@ -509,7 +510,7 @@ class TestStats(unittest.TestCase):
def test_for_boss(self):
last_queue = self.session.old_message_queue.pop()
self.assertEqual(
- last_queue.msg, {'command': ['sendstats']})
+ last_queue.msg, {'command': ['getstats']})
self.assertEqual(
last_queue.env['group'], 'Boss')
diff --git a/src/bin/stats/tests/isc/cc/session.py b/src/bin/stats/tests/isc/cc/session.py
index e16d6a9..e18a695 100644
--- a/src/bin/stats/tests/isc/cc/session.py
+++ b/src/bin/stats/tests/isc/cc/session.py
@@ -115,8 +115,16 @@ class Session:
def group_recvmsg(self, nonblock=True, seq=0):
que = self.dequeue()
+ if que.msg != None:
+ cmd = que.msg.get("command")
+ if cmd and cmd[0] == 'getstats':
+ # Create answer for command 'getstats'
+ retdata = { "stats_data": {
+ 'bind10.boot_time' : "1970-01-01T00:00:00Z"
+ }}
+ return {'result': [0, retdata]}, que.env
return que.msg, que.env
-
+
def group_reply(self, routing, msg):
return self.enqueue(msg=msg, env={
"type": "send",
More information about the bind10-changes
mailing list