Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
0568e990
Commit
0568e990
authored
Dec 14, 2012
by
JINMEI Tatuya
Browse files
[2380] use incremental loading, and a bit more logging
parent
3b50bb10
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/bin/loadzone/loadzone.py.in
View file @
0568e990
...
...
@@ -62,6 +62,8 @@ class LoadZoneRunner:
'''
def __init__(self, command_args):
self.__command_args = command_args
self.__load_iteration_limit = 100000 # arbitrary choice for now
self.__loaded_rrs = 0
# These are essentially private, and defined as "protected" for the
# convenience of tests inspecting them
...
...
@@ -72,6 +74,12 @@ class LoadZoneRunner:
self._datasrc_type = None
def _parse_args(self):
'''Parse command line options and other arguments.
This is essentially private, but defined as "protected" for tests.
'''
usage_txt = 'usage: %prog [options] zonename zonefile'
parser = OptionParser(usage=usage_txt)
set_cmd_options(parser)
...
...
@@ -123,6 +131,11 @@ class LoadZoneRunner:
[self._zone_name.to_text()])
def _do_load(self):
'''Main part of the load logic.
This is essentially private, but defined as "protected" for tests.
'''
created = False
try:
datasrc_client = DataSourceClient(self._datasrc_type,
...
...
@@ -133,8 +146,10 @@ class LoadZoneRunner:
self._zone_class)
loader = ZoneLoader(datasrc_client, self._zone_name,
self._zone_file)
loader.load()
return
while not loader.load_incremental(self.__load_iteration_limit):
self.__loaded_rrs += self.__load_iteration_limit
logger.info(LOADZONE_LOADING, self.__loaded_rrs,
self._zone_name, self._zone_class)
except Exception as ex:
# release any remaining lock held in the client/loader
loader, datasrc_client = None, None
...
...
@@ -145,9 +160,12 @@ class LoadZoneRunner:
raise LoadFailure(str(ex))
def run(self):
'''Top-level method, simply calling other helpers'''
try:
self._parse_args()
self._do_load()
logger.info(LOADZONE_DONE, self._zone_name, self._zone_class)
return 0
except BadArgument as ex:
logger.error(LOADZONE_ARGUMENT_ERROR, ex)
...
...
src/bin/loadzone/loadzone_messages.mes
View file @
0568e990
...
...
@@ -25,3 +25,7 @@
% LOADZONE_CANCEL_CREATE_ZONE Creation of new zone %1/%2 was canceled
% LOADZONE_UNEXPECTED_FAILURE Unexpected exception: ex
% LOADZONE_LOADING Loaded %1 RRs into %2/%3, continued
% LOADZONE_DONE Load zone %1/%2 completed
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment