Exemple #1
0
    def __init__(self, svc, addr, ui, callLater=None):
        """
        Create a Sigma Nexus

        @param svc: a Q2QService

        @param addr: a Q2QAddress

        @param ui: an ISigmaNexusUI implementor.

        @param callLater: a callable with the signature and semantics of
        IReactorTime.callLater
        """

        # callLater is for testing purposes.
        self.scores = {}  # map q2qaddress to score
        self.transloads = {}  # map filename to active transloads
        self.svc = svc
        self.addr = addr
        self.conns = conncache.ConnectionCache()
        if callLater is None:
            from twisted.internet import reactor
            callLater = reactor.callLater
        self.callLater = callLater
        self.ui = ui

        self.serverFactory = SigmaServerFactory(self)
        self.clientFactory = SigmaClientFactory(self)

        svc.listenQ2Q(addr, {PROTOCOL_NAME: self.serverFactory},
                      'Nexus device description')
 def setUp(self):
     """
     Create a L{conncache.ConnectionCache}, endpoint and protocol to test
     against.
     """
     self.cache = conncache.ConnectionCache()
     self.endpoint = FakeEndpoint()
     self.protocol = Protocol()
Exemple #3
0
    def test_connectionLost_unregistersFromConnectionCache(self):
        """
        L{sigma.SigmaProtocol.connectionLost} notifies the connection
        cache that the connection is lost.
        """
        cache = conncache.ConnectionCache()

        class FakeNexus(object):
            conns = cache
            addr = object()
            svc = object()

        protocol = sigma.SigmaProtocol(FakeNexus())
        transport = DisconnectingTransport()
        q2qPeer = object()
        transport.getQ2QPeer = lambda: q2qPeer

        protocol.makeConnection(transport)
        d = cache.shutdown()
        transport.loseConnectionDeferred.callback(None)
        self.assertNoResult(d)
        protocol.connectionLost(Failure(ConnectionDone))
        self.successResultOf(d)