Mercurial > hg > Database > Christie
changeset 191:3a4f77778d90
fix receivepromisecg
author | akahori |
---|---|
date | Tue, 12 Feb 2019 16:10:57 +0900 |
parents | 2d0d41b648fa |
children | 149d7fb0cfa6 |
files | src/main/java/christie/test/topology/paxos/proposer/ReceivePromiseCodeGear.java |
diffstat | 1 files changed, 10 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/christie/test/topology/paxos/proposer/ReceivePromiseCodeGear.java Tue Feb 12 16:10:15 2019 +0900 +++ b/src/main/java/christie/test/topology/paxos/proposer/ReceivePromiseCodeGear.java Tue Feb 12 16:10:57 2019 +0900 @@ -17,16 +17,19 @@ //@Take int promiseCount; + int maxRecvProposalNumber; + Logger logger = LogManager.getLogger(RecieveAcceptedCodeGear.class); public ReceivePromiseCodeGear(Proposal sendedProposal){ - this(0, sendedProposal); + this(0, sendedProposal, 0); } - public ReceivePromiseCodeGear(int promiseCount, Proposal sendedProposal){ + public ReceivePromiseCodeGear(int promiseCount, Proposal sendedProposal, int maxRecvProposalNumber){ this.promiseCount = promiseCount; this.sendedProposal = sendedProposal; + this.maxRecvProposalNumber = maxRecvProposalNumber; } @@ -35,27 +38,22 @@ promiseCount++; if(receivePromise.getNumber() > sendedProposal.getNumber()){ - //logger.debug("increment : ", sendedProposal); - //put("sendProposal", sendedProposal); - cgm.setup(new SendPrepareRequestCodeGear(sendedProposal)); - return; }else{ if(receivePromise.isAccepted()){ - if(!sendedProposal.isAccepted()){ + int recvProposalNumber = receivePromise.getNumber(); + if(maxRecvProposalNumber < recvProposalNumber) { + maxRecvProposalNumber = recvProposalNumber; sendedProposal.setValue(receivePromise.getValue()); } } } - //put("sendedProposal", sendedProposal); - //put("promiseCount", promiseCount); + if(promiseCount > sendedProposal.getAcceptorNum()/2){ - if(promiseCount > sendedProposal.getAcceptorNum()/2){ - //put("acceptProposal", sendedProposal); cgm.setup(new SendAcceptRequestCodeGear(sendedProposal)); }else { - cgm.setup(new ReceivePromiseCodeGear(promiseCount, sendedProposal)); + cgm.setup(new ReceivePromiseCodeGear(promiseCount, sendedProposal, maxRecvProposalNumber)); } } }