Mercurial > hg > Database > Christie
view src/main/java/christie/test/topology/paxos/CheckMyName.java @ 166:f2218b5590d3
add CheckMyName
author | akahori |
---|---|
date | Tue, 22 Jan 2019 15:07:12 +0900 |
parents | |
children | dd3c0ba6a0a6 |
line wrap: on
line source
package christie.test.topology.paxos; import christie.annotation.Peek; import christie.codegear.CodeGear; import christie.codegear.CodeGearManager; import christie.test.topology.paxos.acceptor.AcceptorCodeGear; import christie.test.topology.paxos.learner.LearnerCodeGear; import christie.test.topology.paxos.proposer.ProposerCodeGear; import christie.topology.TopologyDataGear; import java.util.regex.Matcher; import java.util.regex.Pattern; public class CheckMyName extends CodeGear { @Peek TopologyDataGear topoDG; Pattern pattern = Pattern.compile("^(proposer|acceptor|learner)([0-9]+)$"); @Override protected void run(CodeGearManager cgm) { String nodeName = topoDG.getNodeName(); Matcher matcher = pattern.matcher(nodeName); matcher.find(); String type = matcher.group(1); if(type.equals("proposer")) cgm.setup(new ProposerCodeGear()); else if(type.equals("acceptor")) cgm.setup(new AcceptorCodeGear()); else if(type.equals("learner")) cgm.setup(new LearnerCodeGear()); } }