Exemplo n.º 1
0
def main(reactor, internalCred, externalCred, internalPort, externalPort,
         commPort, consolePort):
    log.startLogging(sys.stdout)

    # Realms
    rce = RoboEarthCloudEngine(externalCred, commPort)
    user = UserRealm(rce)

    internalCred.add_checker(rce.checkUIDValidity)

    # Portals
    rcePortal = Portal(rce, (internalCred,))
    consolePortal = Portal(user, (externalCred,))

    # Internal Communication
    reactor.listenTCP(internalPort, PBServerFactory(rcePortal))

    # Client Connections
    reactor.listenTCP(consolePort, PBServerFactory(consolePortal))
    reactor.listenTCP(externalPort, Site(RobotResource(rce)))

    reactor.addSystemEventTrigger('before', 'shutdown', rce.preShutdown)
    reactor.addSystemEventTrigger('after', 'shutdown', rce.postShutdown)

    reactor.run()
Exemplo n.º 2
0
    def __init__(self):
        PBServerFactory.__init__(self, TaskMasterProxy())

        # XXX: Some parameters move to config file
	self.bordomCounter      = 0
	self.bordomDelay 	= 20    # sec
	self.killDelay		= 10    # sec
	self.refuelingThreshold = 3
	self.scheduler          = None
	self.taskId             = 0     # unique ID for each task
	self.taskQueue          = deque()   # the global pile of work to do
	self.tickInterval 	= 1     # sec
	self.workerDB           = {}    # worker database is simply a dictionary of Employment records
	self.workerStatusRing   = WorkerStatusRing(self.killDelay)
Exemplo n.º 3
0
    def __init__(self):
        PBServerFactory.__init__(self, TaskMasterProxy())

        # XXX: Some parameters move to config file
        self.bordomCounter = 0
        self.bordomDelay = 20  # sec
        self.killDelay = 10  # sec
        self.refuelingThreshold = 3
        self.scheduler = None
        self.taskId = 0  # unique ID for each task
        self.taskQueue = deque()  # the global pile of work to do
        self.tickInterval = 1  # sec
        self.workerDB = {
        }  # worker database is simply a dictionary of Employment records
        self.workerStatusRing = WorkerStatusRing(self.killDelay)
Exemplo n.º 4
0
 def startService(self):
     Plugin.startService(self)
     if not self._inputs == []:
         portal = Portal(CollectorRealm(self))
         portal.registerChecker(AllowAnonymousAccess())
         factory = PBServerFactory(portal)
         self._listener = reactor.listenTCP(self._port,
                                            factory,
                                            interface=self._address)
         logger.info("[%s] listening for remote messages on %s:%i" %
                     (self.name, self._address, self._port))
     else:
         logger.info("[%s] no inputs configured" % self.name)
Exemplo n.º 5
0
def main(reactor, duration):
    concurrency = 15

    server = PBServerFactory(BenchRoot())
    port = reactor.listenTCP(0, server)
    client = Client(reactor, port.getHost().port)
    d = client.run(concurrency, duration)
    def cleanup(passthrough):
        d = port.stopListening()
        d.addCallback(lambda ignored: passthrough)
        return d
    d.addCallback(cleanup)
    return d
Exemplo n.º 6
0
def main():
    """
    Create a PB server using MyRealm and run it on port 8800.
    """
    startLogging(stdout)

    p = Portal(MyRealm())

    # Here the username/password checker is registered.
    c1 = InMemoryUsernamePasswordDatabaseDontUse(user1="pass1", user2="pass2")
    p.registerChecker(c1)

    # Here the anonymous checker is registered.
    c2 = AllowAnonymousAccess()
    p.registerChecker(c2)

    reactor.listenTCP(8800, PBServerFactory(p))
    reactor.run()
Exemplo n.º 7
0
 def start(self):
     """Start listening in the proper description."""
     self.factory = PBServerFactory(self)
     self.listener = yield server_listen(self.factory, self.name,
                                         self.cmdline, self.description)
Exemplo n.º 8
0
'''
Created on Dec 13, 2011

@author: Marcus McCurdy <*****@*****.**>
'''
from twisted.internet import reactor
from twisted.spread.pb import PBServerFactory
from dht.kademliaproto import PerspectiveKademliaFromService, Kademlia

if __name__ == '__main__':
    remote = PerspectiveKademliaFromService(Kademlia())
    reactor.listenTCP(8789, PBServerFactory(remote))
    reactor.run()