# HG changeset patch # User YU # Date 1358961377 -32400 # Node ID 6f44308ee519cd89b2e7faaca7590d63317777fd aquarium with javafx diff -r 000000000000 -r 6f44308ee519 src/alice/test/topology/aquarium/fx/Aquarium.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/topology/aquarium/fx/Aquarium.java Thu Jan 24 02:16:17 2013 +0900 @@ -0,0 +1,11 @@ +package alice.test.topology.aquarium.fx; + +import alice.topology.node.TopologyNode; + +public class Aquarium { + public static void main(String[] args){ + AquariumConfig conf = new AquariumConfig(args); + new TopologyNode(conf, new StartCodeSegment()); + } + +} diff -r 000000000000 -r 6f44308ee519 src/alice/test/topology/aquarium/fx/AquariumConfig.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/topology/aquarium/fx/AquariumConfig.java Thu Jan 24 02:16:17 2013 +0900 @@ -0,0 +1,11 @@ +package alice.test.topology.aquarium.fx; + +import alice.topology.node.TopologyNodeConfig; + +public class AquariumConfig extends TopologyNodeConfig { + + public AquariumConfig(String[] args) { + super(args); + } + +} diff -r 000000000000 -r 6f44308ee519 src/alice/test/topology/aquarium/fx/CheckMyName.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/topology/aquarium/fx/CheckMyName.java Thu Jan 24 02:16:17 2013 +0900 @@ -0,0 +1,38 @@ +package alice.test.topology.aquarium.fx; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; + +public class CheckMyName extends CodeSegment{ + private Receiver host = ids.create(CommandType.PEEK); + private Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$"); + + public CheckMyName(){ + host.setKey("local","host"); + } + + @Override + public void run() { + String name = host.asString(); + Matcher matcher = pattern.matcher(name); + + matcher.find(); + String type = matcher.group(1); + int num = new Integer(matcher.group(2)); + if (type.equals("cli")){ + new OtherNode(); + } else if (type.equals("node")){ + if (num==0) { + new TopNode(); + } else { + new OtherNode(); + } + } + + + } +} diff -r 000000000000 -r 6f44308ee519 src/alice/test/topology/aquarium/fx/OtherNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/topology/aquarium/fx/OtherNode.java Thu Jan 24 02:16:17 2013 +0900 @@ -0,0 +1,16 @@ +package alice.test.topology.aquarium.fx; + +import alice.codesegment.CodeSegment; + +public class OtherNode extends CodeSegment{ + + @Override + public void run() { + ods.put("local", "list", new RoutingTable("parent")); + new RegistRoutingTable(); + ods.put("parent", "member", "ADD_MEM"); + + + } + +} diff -r 000000000000 -r 6f44308ee519 src/alice/test/topology/aquarium/fx/RegistRoutingTable.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/topology/aquarium/fx/RegistRoutingTable.java Thu Jan 24 02:16:17 2013 +0900 @@ -0,0 +1,27 @@ +package alice.test.topology.aquarium.fx; + +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; + +public class RegistRoutingTable extends CodeSegment{ + + private Receiver rdata = ids.create(CommandType.PEEK); + private Receiver data = ids.create(CommandType.TAKE); + + public RegistRoutingTable(){ + rdata.setKey("list"); + data.setKey("member"); + } + + @Override + public void run() { + RoutingTable routing = rdata.asClass(RoutingTable.class); + routing.table.add(new RoutingData(data.from)); + System.out.println(routing.toString()); + ods.update("local", "list", routing); + new RegistRoutingTable(); + + } + +} diff -r 000000000000 -r 6f44308ee519 src/alice/test/topology/aquarium/fx/RoutingData.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/topology/aquarium/fx/RoutingData.java Thu Jan 24 02:16:17 2013 +0900 @@ -0,0 +1,14 @@ +package alice.test.topology.aquarium.fx; + +import org.msgpack.annotation.Message; + +@Message +public class RoutingData { + + public String name; + + public RoutingData(){} + public RoutingData(String name){ + this.name = name; + } +} diff -r 000000000000 -r 6f44308ee519 src/alice/test/topology/aquarium/fx/RoutingTable.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/topology/aquarium/fx/RoutingTable.java Thu Jan 24 02:16:17 2013 +0900 @@ -0,0 +1,18 @@ +package alice.test.topology.aquarium.fx; + +import java.util.ArrayList; +import java.util.List; + +import org.msgpack.annotation.Message; + +@Message +public class RoutingTable { + public List table = new ArrayList(); + + public RoutingTable(){} + + public RoutingTable(String str){ + table.add(new RoutingData(str)); + } + +} diff -r 000000000000 -r 6f44308ee519 src/alice/test/topology/aquarium/fx/StartCodeSegment.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/topology/aquarium/fx/StartCodeSegment.java Thu Jan 24 02:16:17 2013 +0900 @@ -0,0 +1,12 @@ +package alice.test.topology.aquarium.fx; + +import alice.codesegment.CodeSegment; + +public class StartCodeSegment extends CodeSegment{ + + @Override + public void run() { + new CheckMyName(); + } + +} diff -r 000000000000 -r 6f44308ee519 src/alice/test/topology/aquarium/fx/TopNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/test/topology/aquarium/fx/TopNode.java Thu Jan 24 02:16:17 2013 +0900 @@ -0,0 +1,14 @@ +package alice.test.topology.aquarium.fx; + +import alice.codesegment.CodeSegment; + +public class TopNode extends CodeSegment{ + + @Override + public void run() { + ods.put("local", "list", new RoutingTable()); + new RegistRoutingTable(); + + } + +}