Merge "Add an __str__ method to brokers"

This commit is contained in:
Jenkins 2013-10-23 19:50:28 +00:00 committed by Gerrit Code Review
commit 7ccde73974
5 changed files with 19 additions and 11 deletions

View File

@ -118,10 +118,10 @@ class AccountAuditor(Daemon):
broker.get_info()
self.logger.increment('passes')
self.account_passes += 1
self.logger.debug(_('Audit passed for %s') % broker.db_file)
self.logger.debug(_('Audit passed for %s') % broker)
except (Exception, Timeout):
self.logger.increment('failures')
self.account_failures += 1
self.logger.exception(_('ERROR Could not get account info %s'),
(broker.db_file))
path)
self.logger.timing_since('timing', start_time)

View File

@ -187,6 +187,14 @@ class DatabaseBroker(object):
self.container = container
self._db_version = -1
def __str__(self):
"""
Returns a string indentifying the entity under broker to a human.
The baseline implementation returns a full pathname to a database.
This is vital for useful diagnostics.
"""
return self.db_file
def initialize(self, put_timestamp=None):
"""
Create the DB

View File

@ -296,8 +296,8 @@ class Replicator(Daemon):
if objects:
self.logger.debug(_(
'Synchronization for %s has fallen more than '
'%s rows behind; moving on and will try again next pass.') %
(broker.db_file, self.max_diffs * self.per_diff))
'%s rows behind; moving on and will try again next pass.'),
broker, self.max_diffs * self.per_diff)
self.stats['diff_capped'] += 1
self.logger.increment('diff_caps')
else:
@ -606,7 +606,7 @@ class ReplicatorRpc(object):
info = broker.get_replication_info()
except (Exception, Timeout) as e:
if 'no such table' in str(e):
self.logger.error(_("Quarantining DB %s") % broker.db_file)
self.logger.error(_("Quarantining DB %s"), broker)
quarantine_db(broker.db_file, broker.db_type)
return HTTPNotFound()
raise

View File

@ -118,10 +118,10 @@ class ContainerAuditor(Daemon):
broker.get_info()
self.logger.increment('passes')
self.container_passes += 1
self.logger.debug(_('Audit passed for %s'), broker.db_file)
self.logger.debug(_('Audit passed for %s'), broker)
except (Exception, Timeout):
self.logger.increment('failures')
self.container_failures += 1
self.logger.exception(_('ERROR Could not get container info %s'),
broker.db_file)
path)
self.logger.timing_since('timing', start_time)

View File

@ -245,7 +245,7 @@ class ContainerSync(Daemon):
if err:
self.logger.info(
_('ERROR %(db_file)s: %(validate_sync_to_err)s'),
{'db_file': broker.db_file,
{'db_file': str(broker),
'validate_sync_to_err': err})
self.container_failures += 1
self.logger.increment('failures')
@ -299,7 +299,7 @@ class ContainerSync(Daemon):
self.container_failures += 1
self.logger.increment('failures')
self.logger.exception(_('ERROR Syncing %s'),
broker.db_file if broker else path)
broker if broker else path)
def container_sync_row(self, row, sync_to, sync_key, broker, info):
"""
@ -397,14 +397,14 @@ class ContainerSync(Daemon):
else:
self.logger.exception(
_('ERROR Syncing %(db_file)s %(row)s'),
{'db_file': broker.db_file, 'row': row})
{'db_file': str(broker), 'row': row})
self.container_failures += 1
self.logger.increment('failures')
return False
except (Exception, Timeout) as err:
self.logger.exception(
_('ERROR Syncing %(db_file)s %(row)s'),
{'db_file': broker.db_file, 'row': row})
{'db_file': str(broker), 'row': row})
self.container_failures += 1
self.logger.increment('failures')
return False