Beispiel #1
0
def paxos_learn_base(acceptorUuid,host,port):
    
    while True:
        getQueuItem(wsgiObj,wsgiObj.SIGNAL_LEARN_SEND.get(acceptorUuid))
        param = wsgiObj.CACHE_LEARN_SEND.get(acceptorUuid)
        item = param.get('item')
        item_learn_transmit(acceptorUuid,host,port,item)
Beispiel #2
0
def paxos_learn_base(acceptorUuid, host, port):

    while True:
        getQueuItem(wsgiObj, wsgiObj.SIGNAL_LEARN_SEND.get(acceptorUuid))
        param = wsgiObj.CACHE_LEARN_SEND.get(acceptorUuid)
        item = param.get('item')
        item_learn_transmit(acceptorUuid, host, port, item)
Beispiel #3
0
def paxos_acceptor_broadcast(acceptorUuid,host,port):
    
    while True:
        
        getQueuItem(wsgiObj,wsgiObj.SIGNAL_BROAD_SEND.get(acceptorUuid))
        param = wsgiObj.CACHE_BROAD_SEND.get(acceptorUuid)
        broadUuid = param.get('broadUuid')
        item = param.get('item')
        val = param.get('val')
        paxos_broad(host, port, item, val, broadUuid)
Beispiel #4
0
def paxos_decision():
    
    while True:
        acceptorUuid = getQueuItem(wsgiObj,wsgiObj.SIGNAL_LEARN_RECV)
        param = wsgiObj.CACHE_LEARN_RECV.get(acceptorUuid)
        item_decision(acceptorUuid,param)
        
Beispiel #5
0
def paxos_item_store():

    started = False
    while True:
        for keyitem in get_item():
            if not started:
                started = True
                do_start_mst().start()
            logUuid,logentry = getQueuItem(wsgiObj, wsgiObj.store_param)
            item_proposer_broad(keyitem, logentry, get_broad_uuids())
            wsgiObj.store_resut.put((logUuid,0))
Beispiel #6
0
def paxos_item_store():

    started = False
    while True:
        for keyitem in get_item():
            if not started:
                started = True
                do_start_mst().start()
            logUuid, logentry = getQueuItem(wsgiObj, wsgiObj.store_param)
            item_proposer_broad(keyitem, logentry, get_broad_uuids())
            wsgiObj.store_resut.put((logUuid, 0))
Beispiel #7
0
def get_resp(logUuid):

    resp = None    
    while True:
        uuid,data = getQueuItem(wsgiObj, wsgiObj.store_resut)
        if logUuid == uuid:
            resp = data
            break
        else:
            wsgiObj.signalLearn.put((uuid,data))
            signal_sleep(wsgiObj, 0.1)
    return resp
Beispiel #8
0
def get_resp(logUuid):

    resp = None
    while True:
        uuid, data = getQueuItem(wsgiObj, wsgiObj.store_resut)
        if logUuid == uuid:
            resp = data
            break
        else:
            wsgiObj.signalLearn.put((uuid, data))
            signal_sleep(wsgiObj, 0.1)
    return resp
Beispiel #9
0
def paxos_acceptor_main():
    
    wsgiObj.PAXOS_IDENTITY = identiry_acceptor
    
    while True:
        
        key,val = getQueuItem(wsgiObj,wsgiObj.PAXOS_QUEUE)
        if str_equal(key ,key_paxos_leader):
            leaderUuid,leaderTime,broadUuid = val
            wsgiObj.broadUuid = broadUuid
            start_time = leaderTime
            wsgiObj.PAXOS_VALUE.put(key_paxos_leader,val)
            threading.Timer(wsgiObj.PAXOS_LEADER_TERM,paxos_timer_acceptor,[start_time]).start()
        else:
            pass
Beispiel #10
0
def item_proposer_learn(item):

    for hostUuid, _, _ in wsgiObj.PAXOS_ACCEPTORS:
        if hostUuid == wsgiObj.hostUuid:
            continue
        wsgiObj.CACHE_LEARN_SEND.put(hostUuid, {'item': item, 'val': None})
        wsgiObj.SIGNAL_LEARN_SEND.get(hostUuid).put(0)

    while True:
        qitem = getQueuItem(wsgiObj, wsgiObj.signalLearn)
        if qitem == item:
            break
        else:
            wsgiObj.signalLearn.put(qitem)
            signal_sleep(wsgiObj, 0.1)
    val = wsgiObj.cacheLearn.get(qitem)
    return val
Beispiel #11
0
def item_proposer_learn(item):
    
    for hostUuid,_,_ in wsgiObj.PAXOS_ACCEPTORS:
        if hostUuid == wsgiObj.hostUuid:
            continue
        wsgiObj.CACHE_LEARN_SEND.put(hostUuid,{'item':item,
                                         'val':None})
        wsgiObj.SIGNAL_LEARN_SEND.get(hostUuid).put(0)
        
    while True:
        qitem = getQueuItem(wsgiObj, wsgiObj.signalLearn)
        if qitem == item:
            break
        else:
            wsgiObj.signalLearn.put(qitem)
            signal_sleep(wsgiObj, 0.1)
    val = wsgiObj.cacheLearn.get(qitem)
    return val
Beispiel #12
0
def paxos_decision():

    while True:
        acceptorUuid = getQueuItem(wsgiObj, wsgiObj.SIGNAL_LEARN_RECV)
        param = wsgiObj.CACHE_LEARN_RECV.get(acceptorUuid)
        item_decision(acceptorUuid, param)
Beispiel #13
0
def paxos_broad_base(acceptorUuid,host,port):
    
    while True:
        getQueuItem(wsgiObj,wsgiObj.SIGNAL_BROAD_SEND.get(acceptorUuid))
        param = wsgiObj.CACHE_BROAD_SEND.get(acceptorUuid)
        item_broad_transmit(acceptorUuid, host, port, param)
Beispiel #14
0
def paxos_broad_base(acceptorUuid, host, port):

    while True:
        getQueuItem(wsgiObj, wsgiObj.SIGNAL_BROAD_SEND.get(acceptorUuid))
        param = wsgiObj.CACHE_BROAD_SEND.get(acceptorUuid)
        item_broad_transmit(acceptorUuid, host, port, param)