Mercurial > hg > Database > Alice
view src/alice/test/topology/aquarium/CheckMyName.java @ 139:f995396f2af7 working
remove bug
author | sugi |
---|---|
date | Tue, 18 Sep 2012 16:19:50 +0900 |
parents | 87f1a30a8c82 |
children | b51d3bf971e7 |
line wrap: on
line source
package alice.test.topology.aquarium; 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]+)$"); private String key = "fish"; 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)); MakeFrame frame = new MakeFrame(name); RoutingTable routing = new RoutingTable(); ods.put("local", "num", 1); if (type.equals("cli")){ System.out.println("cli"+num); routing.table.add(new Routing("parent")); ods.put("local", "list", routing); new AddRoutingTable(routing,0); ods.put("parent", "member", name); new TakeMynum(); }else if (type.equals("node")){ System.out.println("node"+num); if (num != 0){ routing.table.add(new Routing("parent")); ods.put("parent", "member", name); new TakeMynum(); } ods.put("local", "list", routing); new AddRoutingTable(routing,0); } ods.update("local", key, new FishPoint(-0.1f,-0.1f)); new SetLocation(new MakeObject(frame),key,0,num); new CheckLocalIndex(key,1); for (int i = 0;i < 3 ; i++){ key = "fish"+i; if (num == 0) new AutoIncrement(key,0); ods.update("local", key, new FishPoint(0.2f*i,0.2f*i)); new SetLocation(new MakeObject(frame),key,0,num); new CheckLocalIndex(key,1); } } }