Mercurial > hg > Database > Alice
view src/alice/test/topology/fishmodel/beta/CheckMyName.java @ 115:9845b74063ec working
share max number
author | sugi |
---|---|
date | Sat, 21 Jul 2012 10:02:41 +0900 |
parents | 7dbaaa0de144 |
children | 248064474909 |
line wrap: on
line source
package alice.test.topology.fishmodel.beta; import java.util.regex.Matcher; import java.util.regex.Pattern; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; import alice.test.topology.fishmodel.alpha.AutoIncrement; import alice.test.topology.fishmodel.alpha.SetLocation; import alice.test.topology.fishmodel.alpha.FishPoint; import alice.test.topology.fishmodel.alpha.MakeFrame; import alice.test.topology.fishmodel.alpha.MakeObject; public class CheckMyName extends CodeSegment { Receiver host = ids.create(CommandType.PEEK); Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$"); String key = "fish"; @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", "max", num); new CheckLocalIndex(key,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); }else if (type.equals("node")){ System.out.println("node"+num); if (num != 0){ routing.table.add(new Routing("parent")); ods.put("parent", "member", name); } 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); } /* for (int i = 6;i < 10 ; i++){ key = "fish"+i; if (num == 0) new AutoIncrement(key,0); ods.update("local", key, new FishPoint(-0.2f*(i-5),0.2f*(i-5))); new SetLocation(new MakeObject(frame),key,0,num); new CheckLocalIndex(key,1); } */ } }