Make NativeStorageServer.rref private

This commit is contained in:
Jean-Paul Calderone 2019-05-31 11:09:20 -04:00
parent 4a149cdf06
commit 8f4c994bea

View File

@ -111,7 +111,7 @@ class StorageFarmBroker(service.MultiService):
# these two are used in unit tests # these two are used in unit tests
def test_add_rref(self, serverid, rref, ann): def test_add_rref(self, serverid, rref, ann):
s = NativeStorageServer(serverid, ann.copy(), self._tub_maker, {}) s = NativeStorageServer(serverid, ann.copy(), self._tub_maker, {})
s.rref = rref s._rref = rref
s._is_connected = True s._is_connected = True
self.servers[serverid] = s self.servers[serverid] = s
@ -315,7 +315,7 @@ class NativeStorageServer(service.MultiService):
self.last_connect_time = None self.last_connect_time = None
self.last_loss_time = None self.last_loss_time = None
self.remote_host = None self.remote_host = None
self.rref = None self._rref = None
self._is_connected = False self._is_connected = False
self._reconnector = None self._reconnector = None
self._trigger_cb = None self._trigger_cb = None
@ -344,8 +344,8 @@ class NativeStorageServer(service.MultiService):
def get_permutation_seed(self): def get_permutation_seed(self):
return self._permutation_seed return self._permutation_seed
def get_version(self): def get_version(self):
if self.rref: if self._rref:
return self.rref.version return self._rref.version
return None return None
def get_name(self): # keep methodname short def get_name(self): # keep methodname short
# TODO: decide who adds [] in the short description. It should # TODO: decide who adds [] in the short description. It should
@ -367,8 +367,8 @@ class NativeStorageServer(service.MultiService):
def get_connection_status(self): def get_connection_status(self):
last_received = None last_received = None
if self.rref: if self._rref:
last_received = self.rref.getDataLastReceivedAt() last_received = self._rref.getDataLastReceivedAt()
return connection_status.from_foolscap_reconnector(self._reconnector, return connection_status.from_foolscap_reconnector(self._reconnector,
last_received) last_received)
@ -414,18 +414,18 @@ class NativeStorageServer(service.MultiService):
self.last_connect_time = time.time() self.last_connect_time = time.time()
self.remote_host = rref.getLocationHints() self.remote_host = rref.getLocationHints()
self.rref = rref self._rref = rref
self._is_connected = True self._is_connected = True
rref.notifyOnDisconnect(self._lost) rref.notifyOnDisconnect(self._lost)
def get_rref(self): def get_rref(self):
return self.rref return self._rref
def _lost(self): def _lost(self):
log.msg(format="lost connection to %(name)s", name=self.get_name(), log.msg(format="lost connection to %(name)s", name=self.get_name(),
facility="tahoe.storage_broker", umid="zbRllw") facility="tahoe.storage_broker", umid="zbRllw")
self.last_loss_time = time.time() self.last_loss_time = time.time()
# self.rref is now stale: all callRemote()s will get a # self._rref is now stale: all callRemote()s will get a
# DeadReferenceError. We leave the stale reference in place so that # DeadReferenceError. We leave the stale reference in place so that
# uploader/downloader code (which received this IServer through # uploader/downloader code (which received this IServer through
# get_connected_servers() or get_servers_for_psi()) can continue to # get_connected_servers() or get_servers_for_psi()) can continue to