Mercurial > hg > Members > tatsuki > Alice
view src/alice/test/topology/fish/CheckMyName.java @ 35:ac3b48c5f4da
share width each other with tree
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 20 Jan 2012 04:00:12 +0900 |
parents | |
children | 0b25b48116b6 |
line wrap: on
line source
package alice.test.topology.fish; 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 { Receiver host = ids.create(CommandType.PEEK); @Override public void run() { String name = host.asString(); Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$"); Matcher matcher = pattern.matcher(name); matcher.find(); String type = matcher.group(1); int num = new Integer(matcher.group(2)); if (type.equals("cli")) { System.out.println("I am client"); ods.update("local", "width", 400); } else if (type.equals("node")) { WidthReceiver cs = new WidthReceiver(); cs.widths.setKey("local", "widths"); cs.routing.setKey("local", "routing"); ods.put("local", "routing", new RoutingTable()); if (num == 0) { // First node check System.out.println("I am node0"); return; } System.out.println("I am node"); } SendWidth cs = new SendWidth(); cs.width.setKey("local", "width"); } }