mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-02 03:06:41 +00:00
add remaining get_* methods to storage_client.Server, NoNetworkServer, and
MockIServer stubs
This commit is contained in:
parent
36fabb4f4a
commit
9672b34880
@ -179,6 +179,7 @@ class NativeStorageServer:
|
||||
|
||||
def __init__(self, serverid, ann_d, min_shares=1):
|
||||
self.serverid = serverid
|
||||
self._tubid = serverid
|
||||
self.announcement = ann_d
|
||||
self.min_shares = min_shares
|
||||
|
||||
@ -191,10 +192,24 @@ class NativeStorageServer:
|
||||
self._reconnector = None
|
||||
self._trigger_cb = None
|
||||
|
||||
def __repr__(self):
|
||||
return "<NativeStorageServer for %s>" % self.name()
|
||||
def get_serverid(self):
|
||||
return self.serverid
|
||||
return self._tubid
|
||||
def get_permutation_seed(self):
|
||||
return self.serverid
|
||||
return self._tubid
|
||||
def get_version(self):
|
||||
if self.rref:
|
||||
return self.rref.version
|
||||
return None
|
||||
def name(self): # keep methodname short
|
||||
return self.serverid_s
|
||||
def longname(self):
|
||||
return idlib.nodeid_b2a(self._tubid)
|
||||
def get_lease_seed(self):
|
||||
return self._tubid
|
||||
def get_foolscap_write_enabler_seed(self):
|
||||
return self._tubid
|
||||
|
||||
def get_nickname(self):
|
||||
return self.announcement["nickname"].decode("utf-8")
|
||||
@ -215,8 +230,8 @@ class NativeStorageServer:
|
||||
self._reconnector = tub.connectTo(furl, self._got_connection)
|
||||
|
||||
def _got_connection(self, rref):
|
||||
lp = log.msg(format="got connection to %(serverid)s, getting versions",
|
||||
serverid=self.serverid_s,
|
||||
lp = log.msg(format="got connection to %(name)s, getting versions",
|
||||
name=self.name(),
|
||||
facility="tahoe.storage_broker", umid="coUECQ")
|
||||
if self._trigger_cb:
|
||||
eventually(self._trigger_cb)
|
||||
@ -224,11 +239,11 @@ class NativeStorageServer:
|
||||
d = add_version_to_remote_reference(rref, default)
|
||||
d.addCallback(self._got_versioned_service, lp)
|
||||
d.addErrback(log.err, format="storageclient._got_connection",
|
||||
serverid=self.serverid_s, umid="Sdq3pg")
|
||||
name=self.name(), umid="Sdq3pg")
|
||||
|
||||
def _got_versioned_service(self, rref, lp):
|
||||
log.msg(format="%(serverid)s provided version info %(version)s",
|
||||
serverid=self.serverid_s, version=rref.version,
|
||||
log.msg(format="%(name)s provided version info %(version)s",
|
||||
name=self.name(), version=rref.version,
|
||||
facility="tahoe.storage_broker", umid="SWmJYg",
|
||||
level=log.NOISY, parent=lp)
|
||||
|
||||
@ -241,8 +256,7 @@ class NativeStorageServer:
|
||||
return self.rref
|
||||
|
||||
def _lost(self):
|
||||
log.msg(format="lost connection to %(serverid)s",
|
||||
serverid=self.serverid_s,
|
||||
log.msg(format="lost connection to %(name)s", name=self.name(),
|
||||
facility="tahoe.storage_broker", umid="zbRllw")
|
||||
self.last_loss_time = time.time()
|
||||
self.rref = None
|
||||
|
@ -121,12 +121,24 @@ class NoNetworkServer:
|
||||
def __init__(self, serverid, rref):
|
||||
self.serverid = serverid
|
||||
self.rref = rref
|
||||
def __repr__(self):
|
||||
return "<NoNetworkServer for %s>" % self.name()
|
||||
def get_serverid(self):
|
||||
return self.serverid
|
||||
def get_permutation_seed(self):
|
||||
return self.serverid
|
||||
def get_lease_seed(self):
|
||||
return self.serverid
|
||||
def name(self):
|
||||
return idlib.shortnodeid_b2a(self.serverid)
|
||||
def longname(self):
|
||||
return idlib.nodeid_b2a(self.serverid)
|
||||
def get_nickname(self):
|
||||
return "nickname"
|
||||
def get_rref(self):
|
||||
return self.rref
|
||||
def get_version(self):
|
||||
return self.rref.version
|
||||
|
||||
class NoNetworkStorageBroker:
|
||||
implements(IStorageBroker)
|
||||
|
@ -103,6 +103,10 @@ class TestShareFinder(unittest.TestCase):
|
||||
return self.serverid
|
||||
def get_rref(self):
|
||||
return self.rref
|
||||
def name(self):
|
||||
return "name-%s" % self.serverid
|
||||
def get_version(self):
|
||||
return self.rref.version
|
||||
|
||||
mockserver1 = MockServer({1: mock.Mock(), 2: mock.Mock()})
|
||||
mockserver2 = MockServer({})
|
||||
|
Loading…
Reference in New Issue
Block a user