Mercurial > hg > Database > Alice
comparison src/alice/test/topology/fish/CheckMyName.java @ 35:ac3b48c5f4da
share width each other with tree
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 20 Jan 2012 04:00:12 +0900 |
parents | |
children | 0b25b48116b6 |
comparison
equal
deleted
inserted
replaced
34:ca079a730d0b | 35:ac3b48c5f4da |
---|---|
1 package alice.test.topology.fish; | |
2 | |
3 import java.util.regex.Matcher; | |
4 import java.util.regex.Pattern; | |
5 | |
6 import alice.codesegment.CodeSegment; | |
7 import alice.datasegment.CommandType; | |
8 import alice.datasegment.Receiver; | |
9 | |
10 public class CheckMyName extends CodeSegment { | |
11 | |
12 Receiver host = ids.create(CommandType.PEEK); | |
13 | |
14 @Override | |
15 public void run() { | |
16 String name = host.asString(); | |
17 Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$"); | |
18 Matcher matcher = pattern.matcher(name); | |
19 | |
20 matcher.find(); | |
21 String type = matcher.group(1); | |
22 int num = new Integer(matcher.group(2)); | |
23 | |
24 if (type.equals("cli")) { | |
25 System.out.println("I am client"); | |
26 ods.update("local", "width", 400); | |
27 } else if (type.equals("node")) { | |
28 WidthReceiver cs = new WidthReceiver(); | |
29 cs.widths.setKey("local", "widths"); | |
30 cs.routing.setKey("local", "routing"); | |
31 | |
32 ods.put("local", "routing", new RoutingTable()); | |
33 if (num == 0) { // First node check | |
34 System.out.println("I am node0"); | |
35 return; | |
36 } | |
37 System.out.println("I am node"); | |
38 } | |
39 | |
40 SendWidth cs = new SendWidth(); | |
41 cs.width.setKey("local", "width"); | |
42 | |
43 } | |
44 | |
45 } |