Mercurial > hg > Database > Christie
changeset 192:149d7fb0cfa6
refactor learner
author | akahori |
---|---|
date | Tue, 12 Feb 2019 16:11:16 +0900 |
parents | 3a4f77778d90 |
children | f4343de364da 60afc98ce6a4 |
files | src/main/java/christie/test/topology/paxos/learner/AggregateProposalCodeGear.java src/main/java/christie/test/topology/paxos/learner/LearnerCodeGear.java src/main/java/christie/test/topology/paxos/learner/RecieveAcceptProposalCodeGear.java |
diffstat | 3 files changed, 20 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/christie/test/topology/paxos/learner/AggregateProposalCodeGear.java Tue Feb 12 16:10:57 2019 +0900 +++ b/src/main/java/christie/test/topology/paxos/learner/AggregateProposalCodeGear.java Tue Feb 12 16:11:16 2019 +0900 @@ -15,9 +15,14 @@ @Peek TopologyNodeConfig topologyNodeConfig; - @Take + //@Take HashMap<String, Proposal> acceptedMap; + + public AggregateProposalCodeGear(HashMap<String, Proposal> acceptedMap){ + this.acceptedMap=acceptedMap; + } + @Override protected void run(CodeGearManager cgm) { HashMap<Integer, Integer> proposalValueMap = new HashMap<>(); @@ -36,7 +41,7 @@ proposalValueMap.put(value, 1); } } - put("acceptedMap", acceptedMap); - cgm.setup(new RecieveAcceptProposalCodeGear()); + //put("acceptedMap", acceptedMap); + cgm.setup(new RecieveAcceptProposalCodeGear(acceptedMap)); } }
--- a/src/main/java/christie/test/topology/paxos/learner/LearnerCodeGear.java Tue Feb 12 16:10:57 2019 +0900 +++ b/src/main/java/christie/test/topology/paxos/learner/LearnerCodeGear.java Tue Feb 12 16:11:16 2019 +0900 @@ -12,7 +12,6 @@ @Override protected void run(CodeGearManager cgm) { - cgm.setup(new RecieveAcceptProposalCodeGear()); - put("acceptedMap", new HashMap<String, Proposal>()); + cgm.setup(new RecieveAcceptProposalCodeGear(new HashMap<String, Proposal>())); } }
--- a/src/main/java/christie/test/topology/paxos/learner/RecieveAcceptProposalCodeGear.java Tue Feb 12 16:10:57 2019 +0900 +++ b/src/main/java/christie/test/topology/paxos/learner/RecieveAcceptProposalCodeGear.java Tue Feb 12 16:11:16 2019 +0900 @@ -13,17 +13,24 @@ @Take Proposal acceptedProposal; - @Take + //@Peek HashMap<String, Proposal> acceptedMap; + public RecieveAcceptProposalCodeGear(HashMap<String, Proposal> acceptedMap){ + this.acceptedMap=acceptedMap; + } + @Override protected void run(CodeGearManager cgm) { System.out.println("accepted : " + acceptedProposal); acceptedMap.put(acceptedProposal.getAcceptorName(), acceptedProposal); - put("acceptedMap", acceptedMap); - if(acceptedMap.size() > acceptedProposal.getAcceptorNum()/2) cgm.setup(new AggregateProposalCodeGear()); - else cgm.setup(new RecieveAcceptProposalCodeGear()); + //put("acceptedMap", acceptedMap); + + if(acceptedMap.size() > acceptedProposal.getAcceptorNum()/2) + cgm.setup(new AggregateProposalCodeGear(acceptedMap)); + else + cgm.setup(new RecieveAcceptProposalCodeGear(acceptedMap)); } }