From: JINMEI Tatuya Date: Sat, 15 Dec 2012 21:31:42 +0000 (-0800) Subject: [2380] always use incremental load so we can handle emergency exit (eg signals) X-Git-Tag: bind10-1.0.0-beta-release~9^2~14^2~14 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9d1e869ba98529030a65359ecaeb2273cd2cb14f;p=thirdparty%2Fkea.git [2380] always use incremental load so we can handle emergency exit (eg signals) still support no report mode. --- diff --git a/src/bin/loadzone/loadzone.py.in b/src/bin/loadzone/loadzone.py.in index 12bdd8bf4c..0346bd84d1 100755 --- a/src/bin/loadzone/loadzone.py.in +++ b/src/bin/loadzone/loadzone.py.in @@ -33,6 +33,11 @@ from isc.config.ccsession import path_search isc.log.init("b10-loadzone") logger = isc.log.Logger("loadzone") +# The default value for the interval of progress report in terms of the +# number of RRs loaded in that interval. Arbitrary choice, but intended to +# be reasonably small to handle emergency exit. +LOAD_INTERVAL_DEFAULT = 10000 + class BadArgument(Exception): '''An exception indicating an error in command line argument. @@ -59,7 +64,7 @@ the zone in. Example: help="enable debug logs with the specified level") parser.add_option("-i", "--report-interval", dest="report_interval", type='int', action="store", - default=10000, # arbitrary choice + default=LOAD_INTERVAL_DEFAULT, help="""report logs progress per specified number of RRs (specify 0 to suppress report) [default: %default]""") parser.add_option("-t", "--datasrc-type", dest="datasrc_type", @@ -103,7 +108,7 @@ class LoadZoneRunner: self._datasrc_type = None self._log_severity = 'INFO' self._log_debuglevel = 0 - self._load_iteration_limit = None + self._load_iteration_limit = LOAD_INTERVAL_DEFAULT self._config_log() @@ -217,11 +222,13 @@ class LoadZoneRunner: self._zone_file) self.__start_time = time.time() if self._load_iteration_limit > 0: - while not loader.load_incremental(self._load_iteration_limit): - self.__loaded_rrs += self._load_iteration_limit - self._report_progress(self.__loaded_rrs) + limit = self._load_iteration_limit else: - loader.load() + limit = LOAD_INTERVAL_DEFAULT + while not loader.load_incremental(limit): + self.__loaded_rrs += self._load_iteration_limit + if self._load_iteration_limit > 0: + self._report_progress(self.__loaded_rrs) except Exception as ex: # release any remaining lock held in the client/loader loader, datasrc_client = None, None diff --git a/src/bin/loadzone/tests/loadzone_test.py b/src/bin/loadzone/tests/loadzone_test.py index 3067c983b8..ad7c64e8af 100755 --- a/src/bin/loadzone/tests/loadzone_test.py +++ b/src/bin/loadzone/tests/loadzone_test.py @@ -67,7 +67,7 @@ class TestLoadZoneRunner(unittest.TestCase): self.assertIsNone(self.__runner._zone_file) self.assertIsNone(self.__runner._datasrc_config) self.assertIsNone(self.__runner._datasrc_type) - self.assertIsNone(self.__runner._load_iteration_limit) + self.assertEqual(10000, self.__runner._load_iteration_limit) self.assertEqual('INFO', self.__runner._log_severity) self.assertEqual(0, self.__runner._log_debuglevel)