mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-06-18 23:38:18 +00:00
Teach StorageFarmBroker to fire a deferred when a connection threshold is reached. refs #1449
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
@ -131,6 +131,7 @@ class Client(node.Node, pollmixin.PollMixin):
|
||||
|
||||
def __init__(self, basedir="."):
|
||||
node.Node.__init__(self, basedir)
|
||||
self.upload_ready_d = defer.Deferred()
|
||||
self.started_timestamp = time.time()
|
||||
self.logSource="Client"
|
||||
self.encoding_params = self.DEFAULT_ENCODING_PARAMETERS.copy()
|
||||
@ -372,7 +373,12 @@ class Client(node.Node, pollmixin.PollMixin):
|
||||
# (and everybody else who wants to use storage servers)
|
||||
ps = self.get_config("client", "peers.preferred", "").split(",")
|
||||
preferred_peers = tuple([p.strip() for p in ps if p != ""])
|
||||
sb = storage_client.StorageFarmBroker(self.tub, permute_peers=True, preferred_peers=preferred_peers)
|
||||
|
||||
connection_threshold = min(self.encoding_params["k"],
|
||||
self.encoding_params["happy"] + 1)
|
||||
|
||||
sb = storage_client.StorageFarmBroker(self.tub, True, connection_threshold,
|
||||
self.upload_ready_d, preferred_peers=preferred_peers)
|
||||
self.storage_broker = sb
|
||||
|
||||
# load static server specifications from tahoe.cfg, if any.
|
||||
@ -528,6 +534,9 @@ class Client(node.Node, pollmixin.PollMixin):
|
||||
s = drop_upload.DropUploader(self, upload_dircap, local_dir_utf8)
|
||||
s.setServiceParent(self)
|
||||
s.startService()
|
||||
|
||||
# start processing the upload queue when we've connected to enough servers
|
||||
self.upload_ready_d.addCallback(s.upload_ready)
|
||||
except Exception, e:
|
||||
self.log("couldn't start drop-uploader: %r", args=(e,))
|
||||
|
||||
|
Reference in New Issue
Block a user