Mercurial > hg > Database > Alice
changeset 643:74dbb8809c73
add local topology test
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 31 Dec 2017 09:51:24 +0900 |
parents | cbfdcecf7e3c |
children | e0621f645e2e |
files | src/main/java/alice/test/topology/localTestTopology/LTRemoteIncrement.java src/main/java/alice/test/topology/localTestTopology/LTopologyStartCodeSegment.java src/main/java/alice/test/topology/localTestTopology/LocalTestTopology.java src/main/java/alice/test/topology/localTestTopology/LocalTestTopologyConfig.java |
diffstat | 4 files changed, 103 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /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<String> list = clist.asClass(List.class); + for( String node : list) { + ods.put(node, "num", num ++); + } + } + +} \ No newline at end of file
--- /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<LocalTestTopologyConfig> configs; + + public LTopologyStartCodeSegment(LinkedList<LocalTestTopologyConfig> 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
--- /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<LocalTestTopologyConfig> configs = new LinkedList<LocalTestTopologyConfig>(); + 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(); + } + +}
--- /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; + } + +}