Mercurial > hg > Members > tatsuki > Alice
view src/alice/test/topology/share/CheckMyName.java @ 150:206c7dd9cb48 working
remove version alpha beta
author | sugi |
---|---|
date | Tue, 27 Nov 2012 19:41:52 +0900 |
parents | 3e8e16b33406 |
children | d7816b9b72e9 |
line wrap: on
line source
package alice.test.topology.share; 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.aquarium.AddRoutingTable; import alice.test.topology.aquarium.Routing; import alice.test.topology.aquarium.RoutingTable; public class CheckMyName extends CodeSegment { Receiver host = ids.create(CommandType.PEEK); Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$"); String key = "fish"; public CheckMyName(){ this.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)); RoutingTable routing = new RoutingTable(); 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 SendData(0); }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 SendData(0); }else{ new LookUpData("data",0); } ods.put("local", "list", routing); new AddRoutingTable(routing,0); } for (int i =0 ;i<1000000;i++){} ods.update("local", key, new DataInfo()); if (num == 0) new AutoIncrement(key,0); new CheckLocalIndex(key,1); } }