Mercurial > hg > Database > Alice
view src/alice/test/topology/share/CheckMyName.java @ 103:37f3483a869b working
remove bug from "CheckParentIndex" and "CheckLocalIndex"
author | sugi |
---|---|
date | Mon, 02 Jul 2012 11:16:01 +0900 |
parents | df786bf8f036 |
children | a8f77957a477 |
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.movement.FishPoint; public class CheckMyName extends CodeSegment { Receiver host = ids.create(CommandType.PEEK); Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$"); String key = "fish"; public CheckMyName(){ host.setKey("local","host"); } @Override public synchronized void run(){ String name = host.asString(); Matcher matcher = pattern.matcher(name); matcher.find(); String type = matcher.group(1); int cliNum = new Integer(matcher.group(2)); if (type.equals("cli")){ System.out.println("cli"+cliNum); ods.update("local", this.key, new FishPoint(0.0f,0.0f)); new CheckLocalIndex(this.key,0); new CheckParentIndex(this.key,0); }else if(type.equals("node")){ System.out.println("node"+cliNum); if (cliNum == 0){ try { for (float i = 0.0f; i < 2.0f; i +=0.1f) { System.out.println("i = " + i); ods.update("local", "fish", new FishPoint(i,i)); wait(500); } }catch (InterruptedException e) { e.printStackTrace(); } }else{ ods.update("local", this.key, new FishPoint(0.0f,0.0f)); new CheckLocalIndex(this.key,0); new CheckParentIndex(this.key,0); } } } }