def __init__(self, sock_map, zone_name, rrclass, datasrc_client,
shutdown_event, master_addr, tsig_key=None):
super().__init__(sock_map, zone_name, rrclass, MockDataSourceClient(),
- shutdown_event, master_addr, begin_soa_rrset)
+ shutdown_event, master_addr, begin_soa_rrset,
+ xfrin.Counters(xfrin.SPECFILE_LOCATION))
self.query_data = b''
self.reply_data = b''
self.force_time_out = False
xfrin.process_xfrin(self, XfrinRecorder(), Name("example.org."),
RRClass.IN, None, zone_soa, None,
TEST_MASTER_IPV4_ADDRINFO, True, None,
- request_ixfr, self.__get_connection)
+ request_ixfr,
+ xfrin.Counters(xfrin.SPECFILE_LOCATION),
+ self.__get_connection)
self.assertEqual([], self.__rets)
self.assertEqual(transfers, self.__transfers)
# Create a connection for each attempt
def __init__(self,
sock_map, zone_name, rrclass, datasrc_client,
- shutdown_event, master_addrinfo, zone_soa, tsig_key=None,
- idle_timeout=60):
+ shutdown_event, master_addrinfo, zone_soa, counters,
+ tsig_key=None, idle_timeout=60):
"""Constructor of the XfirnConnection class.
Parameters:
address and port of the master server.
zone_soa (RRset or None): SOA RRset of zone's current SOA or None
if it's not available.
+ counters (Counters): used for statistics counters
idle_timeout (int): max idle time for read data from socket.
"""
# keep a record of this specific transfer to log on success
# (time, rr/s, etc)
self._transfer_stats = XfrinTransferStats()
- self._counters = Counters(SPECFILE_LOCATION)
+ self._counters = counters
def init_socket(self):
'''Initialize the underlyig socket.
def __process_xfrin(server, zone_name, rrclass, datasrc_client, zone_soa,
shutdown_event, master_addrinfo, check_soa, tsig_key,
- request_ixfr, conn_class):
+ request_ixfr, counters, conn_class):
conn = None
exception = None
ret = XFRIN_FAIL
retry = False
conn = conn_class(sock_map, zone_name, rrclass, datasrc_client,
shutdown_event, master_addrinfo, zone_soa,
- tsig_key)
+ counters, tsig_key)
conn.init_socket()
ret = XFRIN_FAIL
if conn.connect_to_master():
def process_xfrin(server, xfrin_recorder, zone_name, rrclass, datasrc_client,
zone_soa, shutdown_event, master_addrinfo, check_soa,
- tsig_key, request_ixfr, conn_class=XfrinConnection):
+ tsig_key, request_ixfr, counters, conn_class=XfrinConnection):
# Even if it should be rare, the main process of xfrin session can
# raise an exception. In order to make sure the lock in xfrin_recorder
# is released in any cases, we delegate the main part to the helper
try:
__process_xfrin(server, zone_name, rrclass, datasrc_client, zone_soa,
shutdown_event, master_addrinfo, check_soa, tsig_key,
- request_ixfr, conn_class)
+ request_ixfr, counters, conn_class)
except Exception as ex:
# don't log it until we complete decrement().
exception = ex
datasrc_client, zone_soa,
self._shutdown_event,
master_addrinfo, check_soa,
- tsig_key, request_ixfr))
+ tsig_key, request_ixfr,
+ self._counters))
xfrin_thread.start()
return (0, 'zone xfrin is started')