Mercurial > hg > Database > Christie
view src/main/java/christie/test/topology/paxos/Proposal.java @ 173:6ea1f8958d1a
fix proposal
author | akahori |
---|---|
date | Fri, 25 Jan 2019 17:14:51 +0900 |
parents | a0391cfdcef6 |
children | 9b0a7f8dde81 |
line wrap: on
line source
package christie.test.topology.paxos; import org.msgpack.annotation.Message; @Message public class Proposal { private String proposerName = ""; private String acceptorName = ""; private int acceptorNum = 0; private int nodeNum = 0; private int number = 0; private int value = 0; private int id = 0; private int round = 0; private boolean accepted = false; public Proposal(){ } public Proposal(String proposerName, int nodeNum, int value, int id, int acceptorNum){ this.proposerName = proposerName; this.nodeNum = nodeNum; this.value = value; this.id = id; this.acceptorNum = acceptorNum; incrementNumber(); } public void setValue(int value){ this.value = value; } public int getValue(){ return this.value; } public void setNumber(int number) { this.number = number; } public int getNumber(){ return this.number; } public int incrementRound(){ this.round += 1; return this.round; } public int incrementNumber() { this.number = incrementRound() * nodeNum + id; return this.number; } public int getAcceptorNum(){ return this.acceptorNum; } public String getProposerName() { return proposerName; } public boolean isAccepted() { return accepted; } public void setAccepted(boolean accepted) { this.accepted = accepted; } public String getAcceptorName() { return acceptorName; } public void setAcceptorName(String acceptorName) { this.acceptorName = acceptorName; } public boolean equalValue(Proposal proposal){ return this.equalValue(proposal.value); } public boolean equalValue(int value){ if(this.value == value) return true; return false; } public String toString() { return "Proposal : number = " + number + ", value = " + value; } }