BIND 10 trac2858, updated. fe0477b2919e96eb742dbcd0c211189010273d22 [2858] Propagate the reader sets updates
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Aug 20 12:59:27 UTC 2013
The branch, trac2858 has been updated
via fe0477b2919e96eb742dbcd0c211189010273d22 (commit)
via 98e78fd6f2394b344741252e745cc30013858adf (commit)
from ffff944e95d88cac1272dd8b4c2954b7d67454fd (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 fe0477b2919e96eb742dbcd0c211189010273d22
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Tue Aug 20 14:58:41 2013 +0200
[2858] Propagate the reader sets updates
commit 98e78fd6f2394b344741252e745cc30013858adf
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Tue Aug 20 14:38:29 2013 +0200
[2858] Filter the group updates
Filter the incoming updates about subscriptions to groups and act on the
relevant ones.
-----------------------------------------------------------------------
Summary of changes:
src/bin/memmgr/memmgr.py.in | 27 +++++++++++++++-
src/bin/memmgr/tests/memmgr_test.py | 59 +++++++++++++++++++++++++++++++++++
2 files changed, 85 insertions(+), 1 deletion(-)
-----------------------------------------------------------------------
diff --git a/src/bin/memmgr/memmgr.py.in b/src/bin/memmgr/memmgr.py.in
index 24a956b..7a4cc85 100755
--- a/src/bin/memmgr/memmgr.py.in
+++ b/src/bin/memmgr/memmgr.py.in
@@ -198,8 +198,33 @@ class Memmgr(BIND10Server):
self._master_sock.close()
self._builder_sock.close()
+ def _subscribe_reader(self, reader):
+ for dsrc_info in self._datasrc_info_list:
+ for sgmt_info in dsrc_info.segment_info_map.values():
+ sgmt_info.add_reader(reader)
+
+ def _unsubscribe_reader(self, reader):
+ for dsrc_info in self._datasrc_info_list:
+ for sgmt_info in dsrc_info.segment_info_map.values():
+ sgmt_info.remove_reader(reader)
+
def _group_notification(self, event, params):
- pass
+ """
+ Watch group subscriptions and unsubscriptions and update the
+ SegmentInfo objects.
+ """
+ if params is None:
+ return # No group if no params.
+ group = params.get('group')
+ if group != 'SegmentReader':
+ return # Some other group, not interested
+ client = params.get('client')
+ if client is None:
+ return
+ if event == 'subscribed':
+ self._subscribe_reader(client)
+ elif event == 'unsubscribed':
+ self._unsubscribe_reader(client)
def _setup_module(self):
"""Module specific initialization for BIND10Server."""
diff --git a/src/bin/memmgr/tests/memmgr_test.py b/src/bin/memmgr/tests/memmgr_test.py
index db9818d..f8bceda 100755
--- a/src/bin/memmgr/tests/memmgr_test.py
+++ b/src/bin/memmgr/tests/memmgr_test.py
@@ -302,6 +302,65 @@ class TestMemmgr(unittest.TestCase):
self.assertEqual([command], self.__mgr._builder_command_queue)
del self.__mgr._builder_command_queue[:]
+ def test_group_notification(self):
+ """
+ Test the callback which watches over changes to group membership.
+ """
+ # Mock up the actual functions that do work.
+ self.__events = []
+ def event(what, reader):
+ self.__events.append((what, reader))
+ self.__mgr._subscribe_reader = \
+ lambda reader: event('subscribe', reader)
+ self.__mgr._unsubscribe_reader = \
+ lambda reader: event('unsubscribe', reader)
+
+ # Few things that should be ignored. Different groups and unknown
+ # events.
+
+ # No params -> no group
+ self.__mgr._group_notification('subscribed', None)
+ self.__mgr._group_notification('subscribed', {'group': 'Other',
+ 'client': 'c123'})
+ self.__mgr._group_notification('unsubscribed', {'group': # No client
+ 'SegmentReader'})
+ # Unknown event
+ self.__mgr._group_notification('event', {'group': 'SegmentReader',
+ 'client': 'c123'})
+
+ self.assertEqual(self.__events, [])
+ # We subscribe and unsubscribe
+ self.__mgr._group_notification('subscribed', {'group': 'SegmentReader',
+ 'client': 'c123'})
+ self.__mgr._group_notification('unsubscribed',
+ {'group': 'SegmentReader',
+ 'client': 'c123'})
+ self.assertEqual(self.__events, [('subscribe', 'c123'),
+ ('unsubscribe', 'c123')])
+
+ def test_reader_updates(self):
+ """
+ Check the updating of reader sets work sane.
+ """
+ class SgmtInfo:
+ def __init__(self):
+ self.actions = []
+ def remove_reader(self, reader):
+ self.actions.append(('remove', reader))
+ def add_reader(self, reader):
+ self.actions.append(('add', reader))
+ sgmt_info = SgmtInfo()
+ class DataSrcInfo:
+ def __init__(self):
+ self.segment_info_map = \
+ {(isc.dns.RRClass.IN, "name"): sgmt_info}
+ dsrc_info = DataSrcInfo()
+ self.__mgr._datasrc_info_list.append(dsrc_info)
+ self.__mgr._subscribe_reader('reader1')
+ self.__mgr._unsubscribe_reader('reader2')
+ self.assertEqual(sgmt_info.actions, [('add', 'reader1'),
+ ('remove', 'reader2')])
+
def test_notify_from_builder(self):
"""
Check the notify from builder thing eats the notifications and
More information about the bind10-changes
mailing list