set the same options on all Tubs

This commit is contained in:
Brian Warner 2016-05-03 11:38:20 -07:00
parent aea0abf54a
commit b9edccbeaa
3 changed files with 17 additions and 11 deletions

View File

@ -359,11 +359,12 @@ class Client(node.Node, pollmixin.PollMixin):
# (and everybody else who wants to use storage servers) # (and everybody else who wants to use storage servers)
ps = self.get_config("client", "peers.preferred", "").split(",") ps = self.get_config("client", "peers.preferred", "").split(",")
preferred_peers = tuple([p.strip() for p in ps if p != ""]) preferred_peers = tuple([p.strip() for p in ps if p != ""])
sb = storage_client.StorageFarmBroker(permute_peers=True, preferred_peers=preferred_peers) sb = storage_client.StorageFarmBroker(permute_peers=True,
preferred_peers=preferred_peers,
tub_options=self.tub_options)
self.storage_broker = sb self.storage_broker = sb
sb.setServiceParent(self) sb.setServiceParent(self)
connection_threshold = min(self.encoding_params["k"], connection_threshold = min(self.encoding_params["k"],
self.encoding_params["happy"] + 1) self.encoding_params["happy"] + 1)
helper = storage_client.ConnectedEnough(sb, connection_threshold) helper = storage_client.ConnectedEnough(sb, connection_threshold)

View File

@ -201,18 +201,22 @@ class Node(service.MultiService):
def create_tub(self): def create_tub(self):
certfile = os.path.join(self.basedir, "private", self.CERTFILE) certfile = os.path.join(self.basedir, "private", self.CERTFILE)
self.tub = Tub(certFile=certfile) self.tub = Tub(certFile=certfile)
self.tub.setOption("logLocalFailures", True) self.tub_options = {
self.tub.setOption("logRemoteFailures", True) "logLocalFailures": True,
self.tub.setOption("expose-remote-exception-types", False) "logRemoteFailures": True,
"expose-remote-exception-types": False,
}
# see #521 for a discussion of how to pick these timeout values. # see #521 for a discussion of how to pick these timeout values.
keepalive_timeout_s = self.get_config("node", "timeout.keepalive", "") keepalive_timeout_s = self.get_config("node", "timeout.keepalive", "")
if keepalive_timeout_s: if keepalive_timeout_s:
self.tub.setOption("keepaliveTimeout", int(keepalive_timeout_s)) self.tub_options["keepaliveTimeout"] = int(keepalive_timeout_s)
disconnect_timeout_s = self.get_config("node", "timeout.disconnect", "") disconnect_timeout_s = self.get_config("node", "timeout.disconnect", "")
if disconnect_timeout_s: if disconnect_timeout_s:
# N.B.: this is in seconds, so use "1800" to get 30min # N.B.: this is in seconds, so use "1800" to get 30min
self.tub.setOption("disconnectTimeout", int(disconnect_timeout_s)) self.tub_options["disconnectTimeout"] = int(disconnect_timeout_s)
for (name, value) in self.tub_options.items():
self.tub.setOption(name, value)
self.nodeid = b32decode(self.tub.tubID.upper()) # binary format self.nodeid = b32decode(self.tub.tubID.upper()) # binary format
self.write_config("my_nodeid", b32encode(self.nodeid).lower() + "\n") self.write_config("my_nodeid", b32encode(self.nodeid).lower() + "\n")

View File

@ -102,11 +102,12 @@ class StorageFarmBroker(service.MultiService):
I'm also responsible for subscribing to the IntroducerClient to find out I'm also responsible for subscribing to the IntroducerClient to find out
about new servers as they are announced by the Introducer. about new servers as they are announced by the Introducer.
""" """
def __init__(self, permute_peers, preferred_peers=()): def __init__(self, permute_peers, preferred_peers=(), tub_options={}):
service.MultiService.__init__(self) service.MultiService.__init__(self)
assert permute_peers # False not implemented yet assert permute_peers # False not implemented yet
self.permute_peers = permute_peers self.permute_peers = permute_peers
self.preferred_peers = preferred_peers self.preferred_peers = preferred_peers
self._tub_options = tub_options
self.tubs = {} # self.tubs maps serverid -> Tub self.tubs = {} # self.tubs maps serverid -> Tub
# self.servers maps serverid -> IServer, and keeps track of all the # self.servers maps serverid -> IServer, and keeps track of all the
@ -141,9 +142,9 @@ class StorageFarmBroker(service.MultiService):
def _ensure_tub_created(self, serverid): def _ensure_tub_created(self, serverid):
if serverid in self.tubs: if serverid in self.tubs:
return return
self.tubs[serverid] = Tub() self.tubs[serverid] = t = Tub()
for (name, value) in self._tub_options.items():
# XXX set options? t.setOption(name, value)
self.tubs[serverid].setServiceParent(self) self.tubs[serverid].setServiceParent(self)
def _got_connection(self): def _got_connection(self):