2. acceptor check whether the key of this value has already reach consensus if it is already decided, the acceptor will send back the decided value with a consensus flag
3. if not ,the acceptor check whether the ID of this Key is the biggest one he saw in this Epoch, If the ID is the biggest one on this key, the acceptor will send promise message
2a If the acceptor has already accept a value on this key, it will promise this message with the accepted value, on other case the acceptor will promise with an empty value
4. When the proposer got majority of promise, he will check if the value of promise if it already has a value, the proposer will propose the value with the biggest acceptor_id, otherwise, the proposer will propose his own value
5. When the acceptor got the proposal, he will compare the ID of the proposal with he previously promised ID if it is equal, the acceptor will broadcast accept message
6. When each node got majarity of accept message on same value and key in this Epoc the consensus of this key reached, update the const table
2.Once an acceptor receive this message he will test heart beat on the leader, if the leader is dead he will send broadcast the accept message
Once a member could not detect one's heart beat it will prepare a kick off message and send to leader
Once a member need to synchronize a record, it will first create a prepare message with key to the leader,
Once an acceptor receive a prepare of data sync message he first check if it is from leader if not,ignore it.if it is it will check on his own db and send the version of that record and his node_id in the promise
Once the leader receive all promise from the member, he will than propose the node_id with the highest version on that record
Once receive all the accept message the node will compare his record version with the highest version, if his version is lower, the node will ask for owner of the latest record
3. Once the cluster member is bigger than 3 the nodes will first start Election for leader using paxos algorithm
5. Once leader Confirmed the members will open worker Service and Data transfer service and start to synchronize the undone maintask list
1. Once a Node Receive a request, first check if he is leader if he is leader, divide the main task into small pieces of subtasks and arrange to peers, create the main task, sub task and undone main task, save to level db and prepare synchronize the record to the cluster
2. Once a member receive the update undone main task, subtask or undone main task, start a cycle pick up his own subtask and start run
3. Once a member finish the subtask, create subtask result and start synchronize consensus on taskStatus and task result
4. Once the leader synchronized all the result of the subtask start merge and save the final result to local db and send the final result back to client and synchronize the undone task list
The task data was synchronized among nodes so every one almost have the latest version of data except in some cases, so everyone could be the leader
Then the new leader will start synchronize undone main tasks among nodes, if the old leader cannot synchronize his newest version of undone task, the task will be lost however the consensus will be continued because when the old leader came back online, he will either publish his version (if it is higher ) or use the cluster's version of undone task
When the member Dead, leader will first detect and kick him off. Than the leader will check undone tasks to see whether this node has any undone subtasks, if it has, the leader will create a new subtask on the maintask and synchronize the record.Since leader will not update the old subtask.When the old node come back. it will receive the new arranged undone main task,the consensus will continue and the old subtask will not rerun and no version conflict
Configuration File
{
"Addr": "localhost:7001", // Paxos Consensus Channel
"HeartBeatAddr" : "localhost:7002", // Hello Message and Heart beat
"StarterPeerAddr" : null, // the starter's hello channel of this peer
"DataTransferAddr" : "localhost:7003", // Data synchronize channel
"HttpServiceAddr": "localhost:8002", // http service channel, each nodes has an http service and they could provide service
"NodeId": "0", // Unique Node Id (Number)
"DataSetPath" : "/Users/liwei/Desktop/goProject/distributeWordSplit/dataSet1" // directory path for leveldb
}
./go_build_main_go [configuration.json]