Mercurial > hg > Database > Christie
changeset 51:597315102875
add localTestTopology
author | akahori |
---|---|
date | Thu, 23 Aug 2018 09:32:15 +0900 |
parents | 8dfd93810041 |
children | bacc42fb65a1 |
files | src/main/java/christie/test/topology/localTestTopology/LTRemoteIncrement.java src/main/java/christie/test/topology/localTestTopology/LocalTestTopology.java src/main/java/christie/test/topology/localTestTopology/LocalTestTopologyConfig.java |
diffstat | 3 files changed, 93 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/christie/test/topology/localTestTopology/LTRemoteIncrement.java Thu Aug 23 09:32:15 2018 +0900 @@ -0,0 +1,32 @@ +package christie.test.topology.localTestTopology; + +import christie.annotation.Take; +import christie.codegear.CodeGear; +import christie.codegear.CodeGearManager; + +import java.util.List; + +public class LTRemoteIncrement extends CodeGear { + + private final LocalTestTopologyConfig conf; + + @Take + int num; + @Take + List<String> _CLIST; + + public LTRemoteIncrement(LocalTestTopologyConfig conf) { + this.conf = conf; + + } + + @Override + protected void run(CodeGearManager cgm) { + System.out.println("node: " + conf.key + " num = " + num); + num++; + for( String node : _CLIST) { + getDGM(node).put("num", num ++); + } + } + +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/christie/test/topology/localTestTopology/LocalTestTopology.java Thu Aug 23 09:32:15 2018 +0900 @@ -0,0 +1,44 @@ +package christie.test.topology.localTestTopology; + + +import christie.codegear.CodeGearManager; +import christie.codegear.StartCodeGear; +import christie.topology.manager.StartTopologyManager; +import christie.topology.manager.TopologyManagerConfig; +import christie.topology.node.StartTopologyNode; +import christie.topology.node.TopologyNodeConfig; + +import java.util.LinkedList; + +public class LocalTestTopology extends StartCodeGear{ + + + public LocalTestTopology(CodeGearManager cgm) { + super(cgm); + } + + public static void main(String[] args) { + LinkedList<LocalTestTopologyConfig> configs = new LinkedList<LocalTestTopologyConfig>(); + configs.add(new LocalTestTopologyConfig(args, 10001, "node0")); + configs.add(new LocalTestTopologyConfig(args, 10002, "node1")); + configs.add(new LocalTestTopologyConfig(args, 10003, "node2")); + + TopologyManagerConfig topologyManagerConfig = new TopologyManagerConfig(new String[]{"--confFile", "ring.dot", "--showTime"}); + + new StartTopologyManager(createCGM(10000), topologyManagerConfig); + + for (LocalTestTopologyConfig conf: configs ) { + CodeGearManager nodeCGM = createCGM(conf.connectPort); + String[] csarg = {"--host","localhost","--localKey",conf.key }; + TopologyNodeConfig cs = new TopologyNodeConfig(csarg); + + new StartTopologyNode(nodeCGM, cs, new LTRemoteIncrement(conf)); + } + + } + + @Override + protected void run(CodeGearManager cgm) { + cgm.getDGM("node1").put("num", 0); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/christie/test/topology/localTestTopology/LocalTestTopologyConfig.java Thu Aug 23 09:32:15 2018 +0900 @@ -0,0 +1,17 @@ +package christie.test.topology.localTestTopology; + +import christie.daemon.Config; + +public class LocalTestTopologyConfig extends Config { + + public String hostname = "127.0.0.1"; + public int connectPort = 10000; + public String key = "remote"; + + public LocalTestTopologyConfig(String[] args,int connectPort, String dsmName) { + super(args); + this.connectPort = connectPort; + key = dsmName; + } + +}