Merge "Added config options for rate limiting of large object downloads."

This commit is contained in:
Jenkins 2012-06-20 18:12:48 +00:00 committed by Gerrit Code Review
commit cc73f5cbe0
4 changed files with 159 additions and 142 deletions

View File

@ -470,6 +470,11 @@ container sync won't be able to sync posts. The default is True.
.IP \fBaccount_autocreate\fR
If set to 'true' authorized accounts that do not yet exist within the Swift cluster
will be automatically created. The default is set to false.
.IP \fBrate_limit_after_segment\fR
Rate limit the download of large object segments after this segment is
downloaded. The default is 10 segments.
.IP \fBrate_limit_segments_per_sec\fR
Rate limit large object downlods at this rate. The default is 1.
.RE
.PD

View File

@ -592,6 +592,11 @@ max_containers_whitelist This is a comma separated list
of account hashes that ignore
the max_containers_per_account
cap.
rate_limit_after_segment 10 Rate limit the download of
large object segments after
this segment is downloaded.
rate_limit_segments_per_sec 1 Rate limit large object
downloads at this rate.
============================ =============== =============================
[tempauth]

View File

@ -163,9 +163,10 @@ class SegmentedIterable(object):
if self.seek:
req.range = 'bytes=%s-' % self.seek
self.seek = 0
if self.segment > 10:
if self.segment > self.controller.app.rate_limit_after_segment:
sleep(max(self.next_get_time - time.time(), 0))
self.next_get_time = time.time() + 1
self.next_get_time = time.time() + \
1.0 / self.controller.app.rate_limit_segments_per_sec
shuffle(nodes)
resp = self.controller.GETorHEAD_base(req, _('Object'), partition,
self.controller.iter_nodes(partition, nodes,
@ -1917,6 +1918,10 @@ class BaseApplication(object):
if a.strip()]
self.deny_host_headers = [host.strip() for host in
conf.get('deny_host_headers', '').split(',') if host.strip()]
self.rate_limit_after_segment = \
int(conf.get('rate_limit_after_segment', 10))
self.rate_limit_segments_per_sec = \
int(conf.get('rate_limit_segments_per_sec', 1))
def get_controller(self, path):
"""

View File

@ -3888,6 +3888,8 @@ class FakeObjectController(object):
self.trans_id = 'tx1'
self.object_ring = FakeRing()
self.node_timeout = 1
self.rate_limit_after_segment = 10
self.rate_limit_segments_per_sec = 1
def exception(self, *args):
self.exception_args = args