Ticket #1636: dead-rref.diff

File dead-rref.diff, 3.0 KB (added by warner, at 2012-06-12T22:36:10Z)

retain rref even after disconnect

  • src/allmydata/interfaces.py

    diff --git a/src/allmydata/interfaces.py b/src/allmydata/interfaces.py
    index 14e52be..14ddc85 100644
    a b class IServer(IDisplayableServer): 
    433433    def start_connecting(tub, trigger_cb):
    434434        pass
    435435    def get_rref():
    436         pass
     436        """Once a server is connected, I return a RemoteReference.
     437        Before a server is connected for the first time, I return None.
     438
     439        Note that the rref I return will start producing DeadReferenceErrors
     440        once the connection is lost.
     441        """
    437442
    438443
    439444class IMutableSlotWriter(Interface):
  • src/allmydata/storage_client.py

    diff --git a/src/allmydata/storage_client.py b/src/allmydata/storage_client.py
    index 68823f0..b536c67 100644
    a b class StorageFarmBroker: 
    7777    def test_add_rref(self, serverid, rref, ann):
    7878        s = NativeStorageServer(serverid, ann.copy())
    7979        s.rref = rref
     80        s._is_connected = True
    8081        self.servers[serverid] = s
    8182
    8283    def test_add_server(self, serverid, s):
    class StorageFarmBroker: 
    129130        return frozenset(self.servers.keys())
    130131
    131132    def get_connected_servers(self):
    132         return frozenset([s for s in self.servers.values() if s.get_rref()])
     133        return frozenset([s for s in self.servers.values() if s.is_connected()])
    133134
    134135    def get_known_servers(self):
    135136        return frozenset(self.servers.values())
    class NativeStorageServer: 
    215216        self.last_loss_time = None
    216217        self.remote_host = None
    217218        self.rref = None
     219        self._is_connected = False
    218220        self._reconnector = None
    219221        self._trigger_cb = None
    220222
    class NativeStorageServer: 
    254256        return self.announcement
    255257    def get_remote_host(self):
    256258        return self.remote_host
     259    def is_connected(self):
     260        return self._is_connected
    257261    def get_last_connect_time(self):
    258262        return self.last_connect_time
    259263    def get_last_loss_time(self):
    class NativeStorageServer: 
    287291        self.last_connect_time = time.time()
    288292        self.remote_host = rref.getPeer()
    289293        self.rref = rref
     294        self._is_connected = True
    290295        rref.notifyOnDisconnect(self._lost)
    291296
    292297    def get_rref(self):
    class NativeStorageServer: 
    296301        log.msg(format="lost connection to %(name)s", name=self.get_name(),
    297302                facility="tahoe.storage_broker", umid="zbRllw")
    298303        self.last_loss_time = time.time()
    299         self.rref = None
     304        # self.rref is now stale: all callRemote()s will get a
     305        # DeadReferenceError. We leave the stale reference in place so that
     306        # uploader/downloader code (which received this IServer through
     307        # get_connected_servers() or get_servers_for_psi()) can continue to
     308        # use s.get_rref().callRemote() and not worry about it being None.
     309        self._is_connected = False
    300310        self.remote_host = None
    301311
    302312    def stop_connecting(self):