From: Naoki Kambe Date: Wed, 7 Aug 2013 06:19:52 +0000 (+0900) Subject: [2883] add counters as a keyword argument into NotifyOut X-Git-Tag: bind10-1.2.0beta1-release~236^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=695d7c75d5b307bd0eebf042b78904396e3adfcf;p=thirdparty%2Fkea.git [2883] add counters as a keyword argument into NotifyOut --- diff --git a/src/bin/xfrout/xfrout.py.in b/src/bin/xfrout/xfrout.py.in index 79bd026a2a..7bf1605f2d 100755 --- a/src/bin/xfrout/xfrout.py.in +++ b/src/bin/xfrout/xfrout.py.in @@ -1047,7 +1047,7 @@ class XfroutServer: def _start_notifier(self): datasrc = self._unix_socket_server.get_db_file() - self._notifier = notify_out.NotifyOut(datasrc) + self._notifier = notify_out.NotifyOut(datasrc, counters=self._counters) if 'also_notify' in self._config_data: for slave in self._config_data['also_notify']: address = self._default_notify_address diff --git a/src/lib/python/isc/notify/notify_out.py b/src/lib/python/isc/notify/notify_out.py index 9003ff5973..f4de7b8d43 100644 --- a/src/lib/python/isc/notify/notify_out.py +++ b/src/lib/python/isc/notify/notify_out.py @@ -128,7 +128,7 @@ class NotifyOut: notify message to its slaves). notify service can be started by calling dispatcher(), and it can be stopped by calling shutdown() in another thread. ''' - def __init__(self, datasrc_file, verbose=True): + def __init__(self, datasrc_file, counters=None, verbose=True): self._notify_infos = {} # key is (zone_name, zone_class) self._waiting_zones = [] self._notifying_zones = [] @@ -143,7 +143,7 @@ class NotifyOut: # Use nonblock event to eliminate busy loop # If there are no notifying zones, clear the event bit and wait. self._nonblock_event = threading.Event() - self._counters = Counters() + self._counters = counters def _init_notify_out(self, datasrc_file): '''Get all the zones name and its notify target's address. @@ -508,16 +508,17 @@ class NotifyOut: sock = zone_notify_info.create_socket(addrinfo[0]) sock.sendto(render.get_data(), 0, addrinfo) # count notifying by IPv4 or IPv6 for statistics - if zone_notify_info.get_socket().family == socket.AF_INET: - self._counters.inc('zones', - zone_notify_info.zone_class, - zone_notify_info.zone_name, - 'notifyoutv4') - elif zone_notify_info.get_socket().family == socket.AF_INET6: - self._counters.inc('zones', - zone_notify_info.zone_class, - zone_notify_info.zone_name, - 'notifyoutv6') + if self._counters is not None: + if zone_notify_info.get_socket().family == socket.AF_INET: + self._counters.inc('zones', + zone_notify_info.zone_class, + zone_notify_info.zone_name, + 'notifyoutv4') + elif zone_notify_info.get_socket().family == socket.AF_INET6: + self._counters.inc('zones', + zone_notify_info.zone_class, + zone_notify_info.zone_name, + 'notifyoutv6') logger.info(NOTIFY_OUT_SENDING_NOTIFY, AddressFormatter(addrinfo)) except (socket.error, addr.InvalidAddress) as err: logger.error(NOTIFY_OUT_SOCKET_ERROR, AddressFormatter(addrinfo),