Mercurial > hg > Database > Christie
view src/main/java/christie/test/topology/paxos/learner/AggregateProposalCodeGear.java @ 159:a0391cfdcef6
update topologymanager
author | akahori |
---|---|
date | Mon, 21 Jan 2019 18:02:49 +0900 |
parents | src/main/java/christie/test/Paxos/learner/AggregateProposalCodeGear.java@7a2108775da7 |
children | 6ea1f8958d1a |
line wrap: on
line source
package christie.test.topology.paxos.learner; import christie.annotation.Peek; import christie.annotation.Take; import christie.codegear.CodeGear; import christie.codegear.CodeGearManager; import christie.test.topology.paxos.Proposal; import java.util.HashMap; public class AggregateProposalCodeGear extends CodeGear { @Take HashMap<String, Proposal> acceptedMap; @Override protected void run(CodeGearManager cgm) { HashMap<Integer, Integer> proposalValueMap = new HashMap<>(); for(Proposal proposal: acceptedMap.values()){ int value = proposal.getValue(); if(proposalValueMap.containsKey(value)){ int count = proposalValueMap.get(value).intValue(); count++; if(count > proposal.getAcceptorNum()/2) { System.out.println(value); break; } proposalValueMap.replace(value, count); }else{ proposalValueMap.put(value, 1); } } put("acceptedMap", acceptedMap); } }