Пример #1
0
    def remote_registerEngine(self,
                              engineReference,
                              id=None,
                              pid=None,
                              pproperties=None):
        # First adapt the engineReference to a basic non-queued engine
        engine = IEngineBase(engineReference)
        if pproperties:
            engine.properties = pickle.loads(pproperties)
        # Make it an IQueuedEngine before registration
        remoteEngine = IEngineQueued(engine)
        # Get the ip/port of the remote side
        peerAddress = engineReference.broker.transport.getPeer()
        ip = peerAddress.host
        port = peerAddress.port
        regDict = self.service.registerEngine(remoteEngine, id, ip, port, pid)

        # Now setup callback for disconnect and unregistering the engine
        def notify(*args):
            return self.service.unregisterEngine(regDict['id'])

        engineReference.broker.notifyOnDisconnect(notify)

        engine.notifier = notify
        engine.stopNotifying = engineReference.broker.dontNotifyOnDisconnect

        return regDict
Пример #2
0
    def __init__(self, service):

        assert IEngineBase.providedBy(service), \
            "IEngineBase is not provided by " + repr(service)
        pb.PBClientFactory.__init__(self)
        self.service = service
        self.engineReference = IPBEngine(service)
        self.deferred = self.getRootObject()
        self.deferred.addCallbacks(self._gotRoot, self._getRootFailure)
Пример #3
0
 def __init__(self, service):
     # service is an IEngineBase implementer, like EngineService
     assert IEngineBase.providedBy(service), \
         "IEngineBase is not provided by" + repr(service)
     self.service = service
     self.collectors = {}