changeset 0:6f44308ee519

aquarium with javafx
author YU
date Thu, 24 Jan 2013 02:16:17 +0900
parents
children b997f2ce1a04
files src/alice/test/topology/aquarium/fx/Aquarium.java src/alice/test/topology/aquarium/fx/AquariumConfig.java src/alice/test/topology/aquarium/fx/CheckMyName.java src/alice/test/topology/aquarium/fx/OtherNode.java src/alice/test/topology/aquarium/fx/RegistRoutingTable.java src/alice/test/topology/aquarium/fx/RoutingData.java src/alice/test/topology/aquarium/fx/RoutingTable.java src/alice/test/topology/aquarium/fx/StartCodeSegment.java src/alice/test/topology/aquarium/fx/TopNode.java
diffstat 9 files changed, 161 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /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());
+	}
+
+}
--- /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);
+	}
+
+}
--- /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();
+			}
+		}
+		
+		
+	}
+}
--- /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");
+		
+		
+	}
+
+}
--- /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();
+		
+	}
+
+}
--- /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;
+	}
+}
--- /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<RoutingData> table = new ArrayList<RoutingData>();
+	
+	public RoutingTable(){}
+	
+	public RoutingTable(String str){
+		table.add(new RoutingData(str));
+	}
+	
+}
--- /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();
+	}
+
+}
--- /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();
+		
+	}
+
+}