# HG changeset patch # User Shinji KONO # Date 1514681484 -32400 # Node ID 74dbb8809c737ee20e19604d256fb535236d1b2f # Parent cbfdcecf7e3ca560ebcb56ad9071bb9b0a979f89 add local topology test diff -r cbfdcecf7e3c -r 74dbb8809c73 src/main/java/alice/test/topology/localTestTopology/LTRemoteIncrement.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/alice/test/topology/localTestTopology/LTRemoteIncrement.java Sun Dec 31 09:51:24 2017 +0900 @@ -0,0 +1,33 @@ +package alice.test.topology.localTestTopology; + +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; + +import java.util.List; + +public class LTRemoteIncrement extends CodeSegment { + + private final LocalTestTopologyConfig conf; + public Receiver num = ids.create(CommandType.TAKE); + public Receiver clist = ids.create(CommandType.TAKE); + + public LTRemoteIncrement(LocalTestTopologyConfig conf) { + this.conf = conf; + num.setKey(conf.key,"num"); + clist.setKey(conf.key,"_CLIST"); + } + + @Override + public void run() { + int num = this.num.asInteger(); + System.out.println("node: " + conf.key + " num = " + num); + num++; + @SuppressWarnings("unchecked") + List list = clist.asClass(List.class); + for( String node : list) { + ods.put(node, "num", num ++); + } + } + +} \ No newline at end of file diff -r cbfdcecf7e3c -r 74dbb8809c73 src/main/java/alice/test/topology/localTestTopology/LTopologyStartCodeSegment.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/alice/test/topology/localTestTopology/LTopologyStartCodeSegment.java Sun Dec 31 09:51:24 2017 +0900 @@ -0,0 +1,22 @@ +package alice.test.topology.localTestTopology; + +import alice.codesegment.CodeSegment; + +import java.util.LinkedList; + +public class LTopologyStartCodeSegment extends CodeSegment { + + private final LinkedList configs; + + public LTopologyStartCodeSegment(LinkedList configs) { + this.configs = configs; + } + + @Override + public void run() { + for(LocalTestTopologyConfig conf : configs) { + new LTRemoteIncrement(conf); + } + ods.put("remote1", "num", 0); + } +} \ No newline at end of file diff -r cbfdcecf7e3c -r 74dbb8809c73 src/main/java/alice/test/topology/localTestTopology/LocalTestTopology.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/alice/test/topology/localTestTopology/LocalTestTopology.java Sun Dec 31 09:51:24 2017 +0900 @@ -0,0 +1,30 @@ +package alice.test.topology.localTestTopology; + +import alice.daemon.AliceDaemon; +import alice.datasegment.DataSegment; +import alice.topology.manager.StartTopologyManager; +import alice.topology.manager.TopologyManagerConfig; + +import java.util.LinkedList; + +public class LocalTestTopology { + + public static void main(String[] args) { + LinkedList configs = new LinkedList(); + int port = 10000; + configs.add(new LocalTestTopologyConfig(args, port++, "remote1")); + configs.add(new LocalTestTopologyConfig(args, port++, "remote2")); + configs.add(new LocalTestTopologyConfig(args, port++, "remote3")); + + TopologyManagerConfig topologyManagerConfigconf = new TopologyManagerConfig(args); + new AliceDaemon(topologyManagerConfigconf).listen(); + new StartTopologyManager(topologyManagerConfigconf).execute(); + + for (LocalTestTopologyConfig conf: configs ) { + new AliceDaemon(conf).listen(); + DataSegment.connect(conf.key, "rev" + conf.key, conf.hostname, conf.connectPort); + } + new LTopologyStartCodeSegment(configs).execute(); + } + +} diff -r cbfdcecf7e3c -r 74dbb8809c73 src/main/java/alice/test/topology/localTestTopology/LocalTestTopologyConfig.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/alice/test/topology/localTestTopology/LocalTestTopologyConfig.java Sun Dec 31 09:51:24 2017 +0900 @@ -0,0 +1,18 @@ +package alice.test.topology.localTestTopology; + +import alice.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 port, String dsmName) { + super(args); + hostname = "127.0.0.1"; + connectPort = port; + key = dsmName; + } + +}