Exemplo n.º 1
0
def create_host():
    start_controller("pyactive_thread")
    tcpconf = ('tcp', ('127.0.0.1', 9899))
    global host
    host = init_host(tcpconf)
    global remote_host
    remote_host = host.lookup(settings.PYACTIVE_URL+'controller/Host/0')
Exemplo n.º 2
0
def test():
    lP = []
    lA = []
    lL = []
    start_controller('pyactive_thread')
    host = init_host()
#     log = host.spawn_id('log', 'main', 'LogUML', [])
#     host.set_tracer(log)
#     interval(1, save_log, log)
    for i in range(0, N_LEARNERS):
        l = host.spawn_id(str(i), 'paxos_protocol', 'Learner',[N_ACCEPTORS])
        lL.append(l)
    for i in range(0, N_ACCEPTORS):
        a = host.spawn_id(str(i+N_LEARNERS), 'paxos_protocol', 'Acceptor', [N_ACCEPTORS])
        a.set_multi(lL)
        lA.append(a)    
    for i in range(0,N_PROPOSERS):
        p = host.spawn_id(str(i+N_LEARNERS+N_ACCEPTORS+5), 'paxos_protocol', 'Proposer', [N_ACCEPTORS])
        
        num = int(random.random() * 100)
        print i, num
        p.set_proposal(num)
        lP.append(p)
    lP[0].set_multi([lA[0], lA[1],lA[2]])
    lP[1].set_multi([lA[2], lA[3],lA[4]])
    lP[2].set_multi([lA[0], lA[1],lA[2]])
    lP[3].set_multi([lA[2], lA[3],lA[4]])
#     p = AMulti(lP)
#     p.prepare()
    lP[3].prepare()
    lP[0].prepare()
    lP[1].prepare()
    lP[2].prepare()
Exemplo n.º 3
0
def main(argv):
    
    global NUM_NODES, NUM_MSGS
      
    NUM_NODES = int(argv[0])
    NUM_MSGS = int(argv[1])
    start_controller('pyactive_thread')
    launch(testN)
    print 'finish!'
Exemplo n.º 4
0
def create_local_host():
    tcpconf = ('tcp', (settings.PYACTIVE_IP, settings.PYACTIVE_PORT))
    global host
    try:
        start_controller("pyactive_thread")
        host = init_host(tcpconf)
        logger.info("Controller PyActive host created")
    except:
        pass

    return host
Exemplo n.º 5
0
def main():
    start_controller('tasklet')
    launch(test3)
Exemplo n.º 6
0
def main():
    start_controller('tasklet')
    serve_forever(start_node)
Exemplo n.º 7
0
def main():
    #test3(sys.argv[1])
    start_controller("pyactive_thread")
    serve_forever(test3)
Exemplo n.º 8
0
 def setUpClass(cls):
     super(Test, cls).setUpClass()
     start_controller('pyactive_thread')
     cls.host = init_host()
Exemplo n.º 9
0
def main():
    start_controller('pyactive_thread')
    launch(test_2pc)
    print 'now testing bad...'
    launch(test_2pc_bad)
Exemplo n.º 10
0
def test():
    start_controller("pyactive_thread")
    tcpconf = ('tcp',('127.0.0.1',1232))
    host = init_host(tcpconf)
Exemplo n.º 11
0
def main():
    start_controller('tasklet')
    launch(test3)
Exemplo n.º 12
0
def main():
    start_controller('pyactive_thread')
    launch(test_remote_spawn)
Exemplo n.º 13
0
def main():
    start_controller("tasklet")
    launch(test_remote_spawn)
Exemplo n.º 14
0
def main():
    start_controller('tasklet')
    launch(client_test)
Exemplo n.º 15
0
def main():
    start_controller('pyactive_thread')
    launch(testN)
    print 'finish!'
Exemplo n.º 16
0
 def setUpClass(cls):
     super(Test, cls).setUpClass()
     start_controller('pyactive_thread')
     cls.host = init_host()
Exemplo n.º 17
0
def main():
    start_controller('pyactive_thread')
    serve_forever(start_test)
    print 'hola'
Exemplo n.º 18
0
    _sync = {'get_name': '1', 'registry_obj':'2'}
    _async = ['hello_world']
    _ref = []
    _parallel = []

    def __init__(self):
        self.name = None

    def hello_world(self):
        print 'async done'

    def get_name(self):
        return self.name

    def registry_obj(self, obj):
        self.obj = obj
        return True

def test3():

#    tcpconf = ('tcp',('127.0.0.1',6664))
    host = init_host()

    test = host.spawn_id('1','launch','Test',[])
    test.hello_world()

if __name__ == "__main__":
    start_controller('pyactive_thread')
    launch(test3)
Exemplo n.º 19
0
def main():
    start_controller('pyactive_thread')
    launch(client_test)
Exemplo n.º 20
0
def main():
    start_controller('tasklet')
    launch(test_2pc)
    print 'now testing bad...'
Exemplo n.º 21
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     start_controller('tasklet')
     self.host = init_host()
Exemplo n.º 22
0
def main():
    start_controller('tasklet')
    serve_forever(test)
Exemplo n.º 23
0
    #  create bds
    for i in range(bds):
        index = sl_division * i
        bd.append(host.spawn_id(str(i), 'P2', 'Bd', [sl_division, index, streetLights]))

    # create streetLights
    for i in range(streetLights):
        st.append(host.spawn_id(str(i), 'P2', 'StreetLight', [i % bds]))

    # create server
    for i in range(servers):
        serv.append(host.spawn_id(str(i), 'P2', 'Server', [st, log, i, bd]))

    # create queue
    queue = host.spawn_id('1', 'P2', 'Queue', [serv, servers])

    # Sensor.start('signal.txt')
    s = host.spawn_id('1', 'P2', 'Sensor', [st, log])

    for i in range(streetLights):
        st[i].set_queue(queue, i)

    s.start(wd + '/input.txt')

    print '=====[SERVER START]====='


if __name__ == '__main__':
    start_controller('pyactive_thread')
    serve_forever(send)
Exemplo n.º 24
0
 def setUpClass(self):
     tcpconf = ('tcp',('127.0.0.1',6664))
     start_controller('pyactive_thread')
     self.host = init_host(tcpconf)
Exemplo n.º 25
0
def main():
    start_controller('tasklet')
    serve_forever(test3)
Exemplo n.º 26
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     start_controller('tasklet')
     self.host = init_host()
Exemplo n.º 27
0
def main():
    start_controller('pyactive_thread')
    launch(test_log)
Exemplo n.º 28
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     start_controller('pyactive_thread')
     self.host = init_host()
Exemplo n.º 29
0
def main():
    start_controller('pyactive_thread')
    serve_forever(test_registry)
Exemplo n.º 30
0
def main():
    start_controller('pyactive_thread')
    serve_forever(example1)
Exemplo n.º 31
0
'''
Created on 14/07/2014

@author: edgar
'''
from pyactive.controller import init_host, launch, serve_forever,  start_controller, sleep, interval
from pyactive.exception import TimeoutError

start_controller("pyactive_thread")

momconf = ('mom',{'name':'c1','ip':'127.0.0.1','port':61613,'namespace':'/topic/test_edgar'})
host = init_host(momconf)
#host = init_host(('127.0.0.1',4329),True)
#host = Host(host)
#oref = 'env2:simple:s1:Server'
aref = 'mom://s1/server/Server/0'
ref = host.lookup(aref)

ref.stop_clients()
#ref.run_clients()
Exemplo n.º 32
0
def main():
    start_controller('pyactive_thread')
    launch(test3)
Exemplo n.º 33
0
def main():
    start_controller('tasklet')
    launch(client_test)
Exemplo n.º 34
0
 def setUpClass(cls):
     super(Test, cls).setUpClass()
     tcpconf = ('tcp',('127.0.0.1',6842))
     start_controller('pyactive_thread')
     cls.host = init_host(tcpconf)
Exemplo n.º 35
0
from pyactive.controller import init_host, launch, start_controller

class Test():
    def __init__(self):
        self.name = None
    
       
    #@async
    def hello_world(self):
        print 'async done'
    
    #@sync(1)     
    def get_name(self):
        return self.name
    #@sync(2)
    def registry_obj(self, obj):
        self.obj = obj
        return True
    
def test3():
    
#    tcpconf = ('tcp',('127.0.0.1',6664))
    host = init_host()
 
    test = host.spawn_id('1','launch','Test',[])
    test.hello_world()
    host.shutdown()

if __name__ == "__main__":
    start_controller('tasklet')
    launch(test3)
Exemplo n.º 36
0
def main():
    start_controller('pyactive_thread')
    serve_forever(start_node)
Exemplo n.º 37
0
def main():
    start_controller("pyactive_thread")
    serve_forever(test3)
Exemplo n.º 38
0
def main():
    start_controller("tasklet")
    serve_forever(test3)
Exemplo n.º 39
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     start_controller('pyactive_thread')
     self.host = init_host()
Exemplo n.º 40
0
def main():
    start_controller('pyactive_thread')
    serve_forever(test3)
Exemplo n.º 41
0
def main():
    start_controller('tasklet')
    launch(test_remote_spawn)