Mercurial > hg > Database > Alice
view src/main/java/alice/test/topology/fish/CheckMyName.java @ 345:8f71c3e6f11d
Change directory structure Maven standard
author | sugi |
---|---|
date | Wed, 16 Apr 2014 18:26:07 +0900 |
parents | |
children | aefbe41fcf12 |
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"); } @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"); } else if (type.equals("node")) { System.out.println("********************I am node" + num); WidthReceiver cs = new WidthReceiver(); cs.widths.setKey("local", "widths"); cs.routing.setKey("local", "routing"); PeekStartX cs2 = new PeekStartX(0); cs2.startX.setKey("local", "startX"); ods.put("local", "routing", new RoutingTable()); if (num == 0) { // First node ("node0") check StartStartX cs3 = new StartStartX(); cs3.width.setKey("local", "width"); //ods.update("local", "startX", 0); return; } } SendWidth cs = new SendWidth(); cs.width.setKey("local", "width"); } }