Merge "Make stale_reads_ok an argument of __init__"
This commit is contained in:
commit
541c189533
@ -60,11 +60,13 @@ class AccountController(object):
|
||||
swift.common.db.DB_PREALLOCATION = \
|
||||
config_true_value(conf.get('db_preallocation', 'f'))
|
||||
|
||||
def _get_account_broker(self, drive, part, account):
|
||||
def _get_account_broker(self, drive, part, account, **kwargs):
|
||||
hsh = hash_path(account)
|
||||
db_dir = storage_directory(DATADIR, part, hsh)
|
||||
db_path = os.path.join(self.root, drive, db_dir, hsh + '.db')
|
||||
return AccountBroker(db_path, account=account, logger=self.logger)
|
||||
kwargs.setdefault('account', account)
|
||||
kwargs.setdefault('logger', self.logger)
|
||||
return AccountBroker(db_path, **kwargs)
|
||||
|
||||
def _deleted_response(self, broker, req, resp, body=''):
|
||||
# We are here since either the account does not exist or
|
||||
@ -188,9 +190,9 @@ class AccountController(object):
|
||||
return HTTPNotAcceptable(request=req)
|
||||
if self.mount_check and not check_mount(self.root, drive):
|
||||
return HTTPInsufficientStorage(drive=drive, request=req)
|
||||
broker = self._get_account_broker(drive, part, account)
|
||||
broker = self._get_account_broker(drive, part, account,
|
||||
stale_reads_ok=True)
|
||||
broker.pending_timeout = 0.1
|
||||
broker.stale_reads_ok = True
|
||||
if broker.is_deleted():
|
||||
return self._deleted_response(broker, req, HTTPNotFound)
|
||||
info = broker.get_info()
|
||||
@ -241,9 +243,9 @@ class AccountController(object):
|
||||
|
||||
if self.mount_check and not check_mount(self.root, drive):
|
||||
return HTTPInsufficientStorage(drive=drive, request=req)
|
||||
broker = self._get_account_broker(drive, part, account)
|
||||
broker = self._get_account_broker(drive, part, account,
|
||||
stale_reads_ok=True)
|
||||
broker.pending_timeout = 0.1
|
||||
broker.stale_reads_ok = True
|
||||
if broker.is_deleted():
|
||||
return self._deleted_response(broker, req, HTTPNotFound)
|
||||
return account_listing_response(account, req, out_content_type, broker,
|
||||
|
@ -74,7 +74,7 @@ class ContainerController(object):
|
||||
swift.common.db.DB_PREALLOCATION = \
|
||||
config_true_value(conf.get('db_preallocation', 'f'))
|
||||
|
||||
def _get_container_broker(self, drive, part, account, container):
|
||||
def _get_container_broker(self, drive, part, account, container, **kwargs):
|
||||
"""
|
||||
Get a DB broker for the container.
|
||||
|
||||
@ -87,8 +87,10 @@ class ContainerController(object):
|
||||
hsh = hash_path(account, container)
|
||||
db_dir = storage_directory(DATADIR, part, hsh)
|
||||
db_path = os.path.join(self.root, drive, db_dir, hsh + '.db')
|
||||
return ContainerBroker(db_path, account=account, container=container,
|
||||
logger=self.logger)
|
||||
kwargs.setdefault('account', account)
|
||||
kwargs.setdefault('container', container)
|
||||
kwargs.setdefault('logger', self.logger)
|
||||
return ContainerBroker(db_path, **kwargs)
|
||||
|
||||
def account_update(self, req, account, container, broker):
|
||||
"""
|
||||
@ -310,9 +312,9 @@ class ContainerController(object):
|
||||
return HTTPNotAcceptable(request=req)
|
||||
if self.mount_check and not check_mount(self.root, drive):
|
||||
return HTTPInsufficientStorage(drive=drive, request=req)
|
||||
broker = self._get_container_broker(drive, part, account, container)
|
||||
broker = self._get_container_broker(drive, part, account, container,
|
||||
stale_reads_ok=True)
|
||||
broker.pending_timeout = 0.1
|
||||
broker.stale_reads_ok = True
|
||||
if broker.is_deleted():
|
||||
return HTTPNotFound(request=req)
|
||||
info = broker.get_info()
|
||||
@ -390,9 +392,9 @@ class ContainerController(object):
|
||||
return HTTPNotAcceptable(request=req)
|
||||
if self.mount_check and not check_mount(self.root, drive):
|
||||
return HTTPInsufficientStorage(drive=drive, request=req)
|
||||
broker = self._get_container_broker(drive, part, account, container)
|
||||
broker = self._get_container_broker(drive, part, account, container,
|
||||
stale_reads_ok=True)
|
||||
broker.pending_timeout = 0.1
|
||||
broker.stale_reads_ok = True
|
||||
if broker.is_deleted():
|
||||
return HTTPNotFound(request=req)
|
||||
info = broker.get_info()
|
||||
|
Loading…
x
Reference in New Issue
Block a user