Mercurial > hg > Database > Christie
view src/main/java/christie/test/topology/paxos/CheckMyName.java @ 272:b592fe1d4a4e default tip
create example Attendance
author | matac42 <matac@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 01 Jul 2021 20:41:07 +0900 |
parents | dd3c0ba6a0a6 |
children |
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 org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; public class CheckMyName extends CodeGear { @Peek TopologyDataGear topoDG; Logger logger = LogManager.getLogger(CheckMyName.class); 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")) { //logger.debug("proposer : " + nodeName); cgm.setup(new ProposerCodeGear()); } else if(type.equals("acceptor")) { //logger.debug("acceptor : " + nodeName); cgm.setup(new AcceptorCodeGear()); } else if(type.equals("learner")) { //logger.debug("learner : " + nodeName); cgm.setup(new LearnerCodeGear()); } } }