Mercurial > hg > Members > tatsuki > Alice
comparison src/main/java/alice/test/topology/aquarium/fx/CheckMyName.java @ 384:56d4f93a3921 multicast
add RegisterList
author | sugi |
---|---|
date | Wed, 11 Jun 2014 15:49:59 +0900 |
parents | 878d397904da |
children | 1cbac5818dca |
comparison
equal
deleted
inserted
replaced
383:878d397904da | 384:56d4f93a3921 |
---|---|
1 package alice.test.topology.aquarium.fx; | 1 package alice.test.topology.aquarium.fx; |
2 | 2 |
3 import java.util.ArrayList; | |
3 import java.util.regex.Matcher; | 4 import java.util.regex.Matcher; |
4 import java.util.regex.Pattern; | 5 import java.util.regex.Pattern; |
5 | 6 |
6 import alice.codesegment.CodeSegment; | 7 import alice.codesegment.CodeSegment; |
7 import alice.datasegment.CommandType; | 8 import alice.datasegment.CommandType; |
8 import alice.datasegment.Receiver; | 9 import alice.datasegment.Receiver; |
9 | 10 |
10 public class CheckMyName extends CodeSegment { | 11 public class CheckMyName extends CodeSegment { |
11 private Receiver host = ids.create(CommandType.PEEK); | 12 private Receiver host = ids.create(CommandType.PEEK); |
12 private Pattern pattern = Pattern.compile("^(node|cli|local)([0-9]+)$"); | 13 private Pattern pattern = Pattern.compile("^(node|cli|local)([0-9]+)$"); |
13 | 14 |
14 public CheckMyName(){ | 15 public CheckMyName(){ |
15 host.setKey("host"); | 16 host.setKey("host"); |
16 } | 17 } |
17 | 18 |
18 @Override | 19 @Override |
19 public void run() { | 20 public void run() { |
20 String name = host.asString(); | 21 String name = host.asString(); |
21 Matcher matcher = pattern.matcher(name); | 22 Matcher matcher = pattern.matcher(name); |
22 matcher.find(); | 23 matcher.find(); |
23 | 24 |
24 // use view scope | 25 // use view scope |
25 //String type = matcher.group(1); | 26 //String type = matcher.group(1); |
26 //int num = new Integer(matcher.group(2)); | 27 int num = new Integer(matcher.group(2)); |
27 | 28 |
29 if (num == 0){ // root node | |
30 new RegisterList(); | |
31 ods.put("registeredList", new ArrayList<FishInfo>()); | |
32 } else { | |
33 new ReceiveRegisterList(); | |
34 } | |
35 | |
28 FishInfo fishInfo = new FishInfo(0,0,0); | 36 FishInfo fishInfo = new FishInfo(0,0,0); |
29 fishInfo.setName(name); | 37 fishInfo.setName(name); |
30 | 38 |
31 ods.put("fishData", fishInfo); | 39 ods.put("fishData", fishInfo); |
32 | 40 |
33 new CreateObject(); | 41 new CreateObject(); |
34 new AddObject(); | 42 new AddObject(); |
35 | 43 |
36 String[] args = {name}; | 44 String[] args = {name}; |
37 Aquarium.main(args); | 45 Aquarium.main(args); |
38 } | 46 } |
39 } | 47 } |