Mercurial > hg > Database > Alice
view src/main/java/alice/test/topology/fish/CheckMyName.java @ 547:e91a574b69de dispose
remove index
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 18 Aug 2015 16:15:17 +0900 |
parents | 15eeb439830c |
children |
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 { private Receiver host = ids.create(CommandType.PEEK); public CheckMyName(){ host.setKey("host", this); } @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 cli" + num); ods.update("local", "width", 400); GetStartX cs = new GetStartX(); cs.startX.setKey("local", "startX", this); } else if (type.equals("node")) { System.out.println("********************I am node" + num); WidthReceiver cs = new WidthReceiver(); cs.widths.setKey("local", "widths", this); cs.routing.setKey("local", "routing", this); PeekStartX cs2 = new PeekStartX(); cs2.startX.setKey("local", "startX", this); ods.put("local", "routing", new RoutingTable()); if (num == 0) { // First node ("node0") check StartStartX cs3 = new StartStartX(); cs3.width.setKey("local", "width", this); //ods.update("local", "startX", 0); return; } } SendWidth cs = new SendWidth(); cs.width.setKey("local", "width", this); } }