Mercurial > hg > Database > Alice
view src/main/java/alice/test/topology/share/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.share; 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 { Receiver host = ids.create(CommandType.PEEK); Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$"); String key = "fish"; public CheckMyName(){ this.host.setKey("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)); if (type.equals("cli")){ System.out.println("cli"+num); new SendData(0); }else if (type.equals("node")){ System.out.println("node"+num); if (num != 0){ new SendData(0); }else{ new LookUpData("data",0); } } for (int i =0 ;i<1000000;i++){} ods.update(key, new DataInfo()); if (num == 0) new AutoIncrement(key,0); new CheckLocalIndex(key,1); } }