예제 #1
0
def start_node():
    nodes_h = {}
    num_nodes = 20
    cont = 21 
    retry = 0
    j=0
    tcpconf = ('tcp', ('127.0.0.1', 6377))
    host = init_host(tcpconf)
    
    for i in range(num_nodes):
        nodes_h[i] = host.spawn_id(str(cont), 'chord_remote', 'Node', [])
        cont += 1
    for i in range(num_nodes):    
        nodes_h[i].init_node()
        
    remote_aref = 'atom://127.0.0.1:1432/chord/Node/2'
    remote_node = host.lookup(remote_aref)

    while j < num_nodes:
        try:
            if(nodes_h[j].join(remote_node)):
                print "True"
            interval(30, stablilize, nodes_h[j])
            interval(30, fix_finger, nodes_h[j])
            j += 1
            retry = 0
        except(TimeoutError):
            retry += 1
            if retry > 3:
                break
    
    interval(100, show, nodes_h[0])
    interval(100, show, nodes_h[num_nodes/2])
    interval(100, show, nodes_h[num_nodes - 1])
예제 #2
0
def start_node():            
    nodes_h = {}
    num_nodes = 10
    cont = 1
    retry = 0
    index=0
    tcpconf = ('tcp', ('127.0.0.1', 1238))
    host = init_host(tcpconf)
#    momconf = ('mom',{'name':'s1','ip':'127.0.0.1','port':61613,'namespace':'/topic/test'})
#    host = init_host(momconf)

    for i in range(num_nodes):
        nodes_h[i] = host.spawn_id(str(cont), 'scribe', 'ScribeNode', [])
        cont += 1
    for i in range(num_nodes):    
        nodes_h[i].init_node()
    
    while index < num_nodes:
        try:
            if(nodes_h[index].join(nodes_h[0])):
                print "True"
            interval(5, update, nodes_h[index])
            index += 1
            retry = 0
#            sleep(0.2)
        except TimeoutError:
            retry += 1
            if retry > 3:
                index += 1
    num_nodes -= 1
    "Lookup test"
    menu(host, nodes_h, num_nodes)
예제 #3
0
def start_node():
    nodes_h = {}
    num_nodes = 20
    cont = 21 
    retry = 0
    j=0
    tcpconf = ('tcp', ('127.0.0.1', 6377))
    host = init_host(tcpconf)
    
    for i in range(num_nodes):
        nodes_h[i] = host.spawn_id(str(cont), 'chord_remote', 'Node', [])
        cont += 1
    for i in range(num_nodes):    
        nodes_h[i].init_node()
        
    remote_aref = 'atom://127.0.0.1:1432/chord/Node/2'
    remote_node = host.lookup(remote_aref)

    while j < num_nodes:
        try:
            if(nodes_h[j].join(remote_node)):
                print "True"
            interval(30, stablilize, nodes_h[j])
            interval(30, fix_finger, nodes_h[j])
            j += 1
            retry = 0
        except(TimeoutError):
            retry += 1
            if retry > 3:
                break
    
    interval(100, show, nodes_h[0])
    interval(100, show, nodes_h[num_nodes/2])
    interval(100, show, nodes_h[num_nodes - 1])
예제 #4
0
def start_remote_node():
    nodes_h = {}
    num_nodes = 10
    cont = 11
    retry = 0
    index=0
    tcpconf = ('tcp', ('127.0.0.1', 6377))
    host = init_host(tcpconf)
#    momconf = ('mom',{'name':'c1','ip':'127.0.0.1','port':61613,'namespace':'/topic/test'})
#    host = init_host(momconf)
    for i in range(num_nodes):
        nodes_h[i] = host.spawn_id(str(cont), 'scribe', 'ScribeNode', [])
        cont += 1
    for i in range(num_nodes):    
        nodes_h[i].init_node()
#    remote_aref = 'mom://s1/scribe/ScribeNode/1'   
    remote_aref = 'atom://127.0.0.1:1238/scribe/ScribeNode/2'
    remote_node = host.lookup(remote_aref)

    while index < num_nodes:
        try:
            if(nodes_h[index].join(remote_node)):
                print "True"
            interval(5, update, nodes_h[index])
            index += 1
            retry = 0
        except(TimeoutError):
            retry += 1
            print 'Timeout Error: Attempts '+retry
            if retry > 3:
                index += 1
    menu(host, nodes_h, num_nodes)
예제 #5
0
파일: chord.py 프로젝트: sfcelma/pyactive
def start_node():            
    #Canviar per fer el lookup
    nodes_h = {}
    num_nodes = 3
    cont = 1
    retry = 0
    index=0
#    tcpconf = ('tcp', ('127.0.0.1', 1238))
    host = init_host()
    log = host.spawn_id('log','chord_log','LogUML',[])
    host.set_tracer(log)

    for i in range(num_nodes):
        nodes_h[i] = host.spawn_id(str(cont), 'chord', 'Node', [])
        cont += 1
    for i in range(num_nodes):    
        nodes_h[i].init_node()
    
    while index < num_nodes:
        try:
            if(nodes_h[index].join(nodes_h[0])):
                print "True"
            interval(1, update, nodes_h[index])
            index += 1
            retry = 0
        except TimeoutError:
            retry += 1
            if retry > 3:
                break
    interval(30, show, nodes_h[0])
    interval(30, show, nodes_h[num_nodes/2])
    interval(30, show, nodes_h[num_nodes - 1])

    interval(15, save_log, log)
예제 #6
0
    def __init__(self, time, retries, owner, actors = []):
        self.owner = owner
        self.s_actor = new_supervisor(self.owner.aref)
        self.actors = {}
        self.retries = {}
        self.max_retries = retries

        self.multiActors = SMulti( self.s_actor, actors)
        self.add_actors(actors)
        interval(time, self.ask_actors)
예제 #7
0
파일: chord.py 프로젝트: sergitoda/pyactive
def start_node():
    #Canviar per fer el lookup
    nodes_h = {}
    num_nodes = 20
    cont = 1
    retry = 0
    index = 0
    tcpconf = ('tcp', ('127.0.0.1', 1238))
    host = init_host(tcpconf)
    #    log = host.spawn_id('log','chord_log','LogUML',[])
    #    host.set_tracer(log)

    for i in range(num_nodes):
        nodes_h[i] = host.spawn_id(str(cont), 'chord', 'Node', [])
        cont += 1
    for i in range(num_nodes):
        nodes_h[i].init_node()

    while index < num_nodes:
        try:
            if (nodes_h[index].join(nodes_h[0])):
                print "True"
            interval(15, update, nodes_h[index])
            index += 1
            retry = 0
        except TimeoutError:
            retry += 1
            if retry > 3:
                break
    interval(100, show, nodes_h[0])
    interval(100, show, nodes_h[num_nodes / 2])
    interval(100, show, nodes_h[num_nodes - 1])
예제 #8
0
def start_remote_node():            
    nodes_h = {}
    num_nodes = 100
    cont = 21 + 50
    retry = 0
    index = 0
#    tcpconf = ('tcp', ('127.0.0.1', 6375))
#    host = init_host(tcpconf)
    momconf = ('mom',{'name':'c1','ip':'127.0.0.1','port':61613,'namespace':'/topic/test'})
    host = init_host(momconf)
    
    for i in range(num_nodes):
        nodes_h[i] = host.spawn_id(str(cont), 'chord_protocol', 'Node', [])
        cont += 1
    for i in range(num_nodes):    
        nodes_h[i].init_node()
    remote_aref = 'mom://s1/chord_protocol/Node/1'
#    remote_aref = 'atom://127.0.0.1:1238/chord/Node/1'
    remote_node = host.lookup(remote_aref)
    while index < num_nodes:
        try:
            if(nodes_h[index].join(remote_node)):
                print "True"
            interval(5, update, nodes_h[index])
            index += 1
            retry = 0
        except TimeoutError:
            retry += 1
            if retry > 3:
                break
        
    interval(200, show, nodes_h[0])
    interval(200, show, nodes_h[num_nodes/2])
    interval(200, show, nodes_h[num_nodes - 1])
예제 #9
0
def start_node():            
    nodes_h = {}
    num_nodes = 30
    cont = 21
    retry = 0
    index = 0
    tcpconf = ('tcp', ('127.0.0.1', 6375))
    host = init_host(tcpconf)
    
    for i in range(num_nodes):
        nodes_h[i] = host.spawn_id(str(cont), 'chord_remote', 'Node', [])
        cont += 1
    for i in range(num_nodes):    
        nodes_h[i].init_node()
        
    remote_aref = 'atom://127.0.0.1:1238/chord/Node/1'
    remote_node = host.lookup(remote_aref)
    while index < num_nodes:
        try:
            if(nodes_h[index].join(remote_node)):
                print "True"
            interval(15, update, nodes_h[index])
            index += 1
            retry = 0
        except TimeoutError:
            retry += 1
            if retry > 3:
                break
    interval(100, show, nodes_h[0])
    interval(100, show, nodes_h[num_nodes/2])
    interval(100, show, nodes_h[num_nodes - 1])
예제 #10
0
def start_remote_node():
    nodes_h = {}
    num_nodes = 50
    #     cont = 21 + 50
    retry = 0
    j = 0
    sample = uniform(num_nodes, I, MAX)
    #    tcpconf = ('tcp', ('127.0.0.1', 6377))
    #    host = init_host(tcpconf)
    momconf = ("mom", {"name": "c2", "ip": "127.0.0.1", "port": 61613, "namespace": "/topic/test"})
    host = init_host(momconf)
    for i in range(num_nodes):
        nodes_h[i] = host.spawn_id(str(sample[i]), "chord_with_succlist", "SuccNode", [])
    #         cont += 1
    for i in range(num_nodes):
        nodes_h[i].init_node()
    remote_aref = "mom://s1/chord_with_succlist/SuccNode/7"
    #    remote_aref = 'atom://127.0.0.1:1432/chord/Node/2'
    remote_node = host.lookup(remote_aref)

    while j < num_nodes:
        try:
            if nodes_h[j].join(remote_node):
                print "True"
            interval(5, update, nodes_h[j])
            j += 1
            retry = 0
        except (TimeoutError):
            retry += 1
            if retry > 3:
                break

    interval(200, show, nodes_h[0])
    interval(200, show, nodes_h[num_nodes / 2])
    interval(200, show, nodes_h[num_nodes - 1])
예제 #11
0
def start_node():
    nodes_h = {}
    num_nodes = 50
    #    cont = 1
    retry = 0
    j = 0
    #    tcpconf = ('tcp', ('127.0.0.1', 1432))
    #    host = init_host(tcpconf)
    sample = uniform(num_nodes, I, MAX)
    print sorted(sample)
    momconf = ("mom", {"name": "s1", "ip": "127.0.0.1", "port": 61613, "namespace": "/topic/test"})
    host = init_host(momconf)
    #    log = host.spawn_id('log','chord_log','LogUML',[])
    #    host.set_tracer(log)
    for i in range(num_nodes):
        nodes_h[i] = host.spawn_id(str(sample[i]), "chord_with_succlist", "SuccNode", [])
    #        cont += 1
    for i in range(num_nodes):
        nodes_h[i].init_node()

    while j < num_nodes:
        try:
            if nodes_h[j].join(nodes_h[0]):
                print "True"

            interval(5, update, nodes_h[j])
        except TimeoutError:
            retry += 1
            if retry > 3:
                break
        else:
            j += 1
    interval(200, show, nodes_h[0])
    interval(200, show, nodes_h[num_nodes / 2])
    interval(200, show, nodes_h[num_nodes - 1])
예제 #12
0
def start_node():
    nodes_h = {}
    num_nodes = 30
    cont = 21
    retry = 0
    index = 0
    tcpconf = ('tcp', ('127.0.0.1', 6375))
    host = init_host(tcpconf)

    for i in range(num_nodes):
        nodes_h[i] = host.spawn_id(str(cont), 'chord_remote', 'Node', [])
        cont += 1
    for i in range(num_nodes):
        nodes_h[i].init_node()

    remote_aref = 'atom://127.0.0.1:1238/chord/Node/1'
    remote_node = host.lookup(remote_aref)
    while index < num_nodes:
        try:
            if (nodes_h[index].join(remote_node)):
                print "True"
            interval(15, update, nodes_h[index])
            index += 1
            retry = 0
        except TimeoutError:
            retry += 1
            if retry > 3:
                break
    interval(100, show, nodes_h[0])
    interval(100, show, nodes_h[num_nodes / 2])
    interval(100, show, nodes_h[num_nodes - 1])
예제 #13
0
def test():
    lP = []
    lA = []
    lL = []
    host = init_host()
    log = host.spawn_id('log', 'mpaxos_main', 'LogUML', [])
    host.set_tracer(log)
    interval(1, save_log, log)
    for i in range(0, N_SERVERS):
        l = host.spawn_id(str(i), 'multi_paxos', 'Server',[N_SERVERS])
        lL.append(l)
    for i in range(0, N_SERVERS):
        if i == 0:
            lL[i].set_multi(lL[1:])
        else:
            lL[i].set_multi(lL[:i] + lL[i+1:])
        
        interval(2, update, lL[i])       

    lL[N_SERVERS - 1].set_leader()         
    for i in range(0,N_SERVERS):        
        num = int(random.random() * 100)
        print i, num
        lL[i].set_proposal(num)
    
    print lL[N_SERVERS - 1].set_proposal(int(random.random() * 100))
    print lL[N_SERVERS - 1].set_proposal(int(random.random() * 100))
    print lL[N_SERVERS - 1].set_proposal(int(random.random() * 100))
    print lL[N_SERVERS - 1].set_proposal(int(random.random() * 100))    
#    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()
    
    print lL[0].prepare()
    print lL[1].prepare()
    print lL[2].prepare()
    print lL[N_SERVERS - 1].prepare()
    sleep(5)
    lL[N_SERVERS - 1].set_proposal(num) 
    print lL[N_SERVERS - 1].prepare()
예제 #14
0
def start_node():            
    nodes_h = {}
    num_nodes = 5
    cont = 1
    retry = 0
    index=0
#    tcpconf = ('tcp', ('127.0.0.1', 1234))
#    host = init_host(tcpconf)
    momconf = ('mom',{'name':'s1','ip':'127.0.0.1','port':61613,'namespace':'/topic/test'})
    host = init_host(momconf)

    log = host.spawn_id('log','chord_log','LogUML',[])
    host.set_tracer(log)
#    print log
    for i in range(num_nodes):
        nodes_h[i] = host.spawn_id(str(cont), 'chord_protocol', 'Node', [])
        cont += 1
    for i in range(num_nodes):    
        nodes_h[i].init_node()
    
    while index < num_nodes:
        try:
            if(nodes_h[index].join(nodes_h[0])):
                print "True"
            interval(5, update, nodes_h[index])
            index += 1
            retry = 0
            sleep(0.2)
        except TimeoutError:
            retry += 1
            if retry > 3:
                index += 1
    interval(200, show, nodes_h[0])
    interval(200, show, nodes_h[num_nodes/2])
    interval(200, show, nodes_h[num_nodes - 1])
    interval(15, save_log, log)
예제 #15
0
 def run(self):
     print self.id, ' running...'
     self.run_state = True
     self.stop_event = interval(2, self.run_cycle, )
예제 #16
0
def start_node():
    nodes_h = {}
    num_nodes = 20
    cont = 1
    retry = 0
    j = 0
    tcpconf = ('tcp', ('127.0.0.1', 1432))
    host = init_host(tcpconf)
    log = host.spawn_id('log', 'chord_log', 'LogUML', [])
    host.set_tracer(log)
    for i in range(num_nodes):
        nodes_h[i] = host.spawn_id(str(cont), 'chord', 'Node', [])
        cont += 1
    for i in range(num_nodes):
        nodes_h[i].init_node()
    while j < num_nodes:
        try:
            if (nodes_h[j].join(nodes_h[0])):
                print "True"
            interval(30, stablilize, nodes_h[j])
            interval(30, fix_finger, nodes_h[j])
            j += 1
            retry = 0
        except TimeoutError:
            retry += 1
            if retry > 3:
                break
    interval(100, show, nodes_h[0])
    interval(100, show, nodes_h[num_nodes / 2])
    interval(100, show, nodes_h[num_nodes - 1])
    interval(15, save_log, log)
예제 #17
0
파일: chord.py 프로젝트: sfcelma/pyactive
def start_node():            
    nodes_h = {}
    num_nodes = 20
    cont = 1
    retry = 0
    j = 0
    tcpconf = ('tcp', ('127.0.0.1', 1432))
    host = init_host(tcpconf)
    log = host.spawn_id('log','chord_log','LogUML',[])
    host.set_tracer(log)
    for i in range(num_nodes):
        nodes_h[i] = host.spawn_id(str(cont), 'chord', 'Node', [])
        cont += 1
    for i in range(num_nodes):    
        nodes_h[i].init_node()
    while j < num_nodes:
        try:
            if(nodes_h[j].join(nodes_h[0])):
                print "True"
            interval(30, stablilize, nodes_h[j])
            interval(30, fix_finger, nodes_h[j])
            j += 1
            retry = 0
        except TimeoutError:
            retry += 1
            if retry > 3:
                break
    interval(100, show, nodes_h[0])
    interval(100, show, nodes_h[num_nodes /2])
    interval(100, show, nodes_h[num_nodes -1])
    interval(15, save_log, log)
예제 #18
0
def test():
    # We get the list with the N node identifiers, uniformly distributed in theidentifier space dictionary.
    nodes_h = {}
    num_nodes = 40
    retry = 0
    index=0
    sample = uniform(num_nodes, I, MAX)
        # Decorator that controls the number of hoops. Enabled.
    HopCounter.enable(True)
    # Counter at 0.
    
    "Lookup test"
#    tcpconf = ('tcp', ('127.0.0.1', 1238))
#    host = init_host(tcpconf)
    momconf = ('mom',{'name':'s1','ip':'127.0.0.1','port':61613,'namespace':'/topic/test'})
    host = init_host(momconf)

    for i in range(num_nodes):
        nodes_h[i] = host.spawn_id(str(sample[i]), 'scribe', 'ScribeNode', [])
    for i in range(num_nodes):    
        nodes_h[i].init_node()
    
    while index < num_nodes:
        try:
            if(nodes_h[index].join(nodes_h[0])):
                print "True"
            interval(20, update, nodes_h[index])
            index += 1
            retry = 0
#            sleep(0.2)
        except TimeoutError:
            retry += 1
            if retry > 3:
                index += 1

    "select the set of failed peers"
    # We randomly set some nodes as fallen using the flag failed = True.
#    Standard code initially given:
#    for node_id in sample:
#        if random.random() < f:
#            dht[node_id].failed = True
    print 'Id List', sample
#    f = raw_input("Number of failed nodes:")
#    failed_nodes(nodes_h, float(f), num_nodes)

    f = raw_input("Number of failed nodes:")

    HopCounter.resetCounter()
    num = 0
    NUM_QUERIES = 5000
    for i in range(NUM_QUERIES):
        "Return a random element from the non-empty sequence seq. If seq is empty, raises IndexError."
        # We randomly get a node identifier, in the sample list, which we found before.
        src = random.choice(nodes_h)
        # We randomly get a number btween 0 and MAX.
        key = int(random.uniform(0, MAX - 1))
        dst = src.lookup_subscribe(ScribeMessage(id=key))
        num += ((dst != None) and 1) or 0
    
    "disable"
    print HopCounter.getHopCounter()
    print ("<L> = %f Pr[success] = %f" % (HopCounter.getMeanHops(NUM_QUERIES), num / float(NUM_QUERIES)))
    print 'finish!!'