# HG changeset patch # User akahori # Date 1534984335 -32400 # Node ID 5973151028758e5983141648da0cc6d747123f0c # Parent 8dfd93810041b937e8a22c1e7042ddc5034a8a55 add localTestTopology diff -r 8dfd93810041 -r 597315102875 src/main/java/christie/test/topology/localTestTopology/LTRemoteIncrement.java --- /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 _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 diff -r 8dfd93810041 -r 597315102875 src/main/java/christie/test/topology/localTestTopology/LocalTestTopology.java --- /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 configs = new LinkedList(); + 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); + } +} diff -r 8dfd93810041 -r 597315102875 src/main/java/christie/test/topology/localTestTopology/LocalTestTopologyConfig.java --- /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; + } + +}