Seções:
|
Fase 3 - two phase commitNessa fase do trabalho foi implementado o two phase commit com uma pequena extensão. O protocolo funciona da seguinte maneira:
Nessa fase do trabalho foi melhorado o sistema de log do servidor, e o servidor foi instrumentado para simular falhas em diferentes fases da transação. Os códigos se encontram logo abaixo: ServidorClientearquivo de configuracaoExemplos de execuçãoUma execução sem falhas: macalan: ./client.py -f config.ini -i macalan -m try -n 15
{'resultado': 'commit', 'id': 'macalan', 'tipo': 'result'}
macalan: ./server.py -f config.ini -i macalan
recebi: {'tipo': 'try', 'valor': '15'}
iniciando o twophasecommit
Sending oktocommit to: ['talisker']
Acionando o timer
mensagem recebida de talisker tipo readytocommit
verifica se todo mundo respondeu
['talisker'] = ['talisker']
ok, todo mundo respondeu
phase2 commit
Novo Valor: 15
Enviando {'trans': 'macalan-1163864113.47', 'type': 'commit', 'id': 'macalan'} para ['talisker']
sending client: {'resultado': 'commit', 'id': 'macalan', 'tipo': 'result'}
client conection closed
talisker: ./server.py -f config.ini -i talisker
enviando {'trans': 'macalan-1163864113.47', 'type': 'readytocommit', 'id': 'talisker'} para macalan endereco ('macalan', 45005)
iniciando o timer
Recebi de macalan um commit
operacao confirmada pelo controlador
iniciando 2 fase com: commit
Novo Valor: 15
Execução com falha na fase 2, seguida de recuperação: macalan: ./client.py -f config.ini -i macalan -m try -n 10
{'resultado': 'commit', 'id': 'macalan', 'tipo': 'result'}
macalan: ./server.py -f config.ini -i macalan
recebi: {'tipo': 'try', 'valor': '10'}
iniciando o twophasecommit
Sending oktocommit to: ['talisker']
Acionando o timer
mensagem recebida de talisker tipo readytocommit
verifica se todo mundo respondeu
['talisker'] = ['talisker']
ok, todo mundo respondeu
phase2 commit
Novo Valor: 10
Enviando {'trans': 'macalan-1163864540.57', 'type': 'commit', 'id': 'macalan'} para ['talisker']
sending client: {'resultado': 'commit', 'id': 'macalan', 'tipo': 'result'}
client conection closed
re-enviando mensagem da fase 2: {'trans': 'macalan-1163864540.57', 'type': 'commit', 'id': 'macalan'} para talisker
talisker: ./server.py -f config.ini -i talisker
enviando {'trans': 'macalan-1163864540.57', 'type': 'readytocommit', 'id': 'talisker'} para macalan endereco ('macalan', 45005)
iniciando o timer
timer expirou!
Perdemos a mensagem da fase 2, iniciando recuperacao
enviando {'trans': 'macalan-1163864540.57', 'type': 'sendagain', 'id': 'talisker'} para macalan endereco ('macalan', 45005)
iniciando o timer
Recebi de macalan um commit
operacao confirmada pelo controlador
iniciando 2 fase com: commit
Novo Valor: 10
Exemplo de execução com erro na fase2 e na recuperação: macalan: ./client.py -f config.ini -i macalan -m try -n 50
{'resultado': 'commit', 'id': 'macalan', 'tipo': 'result'}
macalan: ./server.py -f config.ini -i macalan
recebi: {'tipo': 'try', 'valor': '50'}
iniciando o twophasecommit
Sending oktocommit to: ['talisker']
Acionando o timer
mensagem recebida de talisker tipo readytocommit
verifica se todo mundo respondeu
['talisker'] = ['talisker']
ok, todo mundo respondeu
phase2 commit
Novo Valor: 50
Enviando {'trans': 'macalan-1163864707.65', 'type': 'commit', 'id': 'macalan'} para ['talisker']
sending client: {'resultado': 'commit', 'id': 'macalan', 'tipo': 'result'}
client conection closed
re-enviando mensagem da fase 2: {'trans': 'macalan-1163864707.65', 'type': 'commit', 'id': 'macalan'} para talisker
talisker: ./server.py -f config.ini -i talisker
enviando {'trans': 'macalan-1163864707.65', 'type': 'readytocommit', 'id': 'talisker'} para macalan endereco ('macalan', 45005)
iniciando o timer
timer expirou!
Perdemos a mensagem da fase 2, iniciando recuperacao
enviando {'trans': 'macalan-1163864707.65', 'type': 'sendagain', 'id': 'talisker'} para macalan endereco ('macalan', 45005)
iniciando o timer
timer expirou!
iniciando 2 fase com: block
nodo bloqueado!
|