345
|
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 {
|
419
|
11
|
|
12 private Receiver host = ids.create(CommandType.PEEK);
|
|
13
|
|
14 public CheckMyName(){
|
|
15 host.setKey("host");
|
|
16 }
|
|
17
|
|
18 @Override
|
|
19 public void run() {
|
|
20 String name = host.asString();
|
|
21 Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
|
|
22 Matcher matcher = pattern.matcher(name);
|
|
23
|
|
24 matcher.find();
|
|
25 String type = matcher.group(1);
|
|
26 int num = new Integer(matcher.group(2));
|
|
27
|
|
28 if (type.equals("cli")) {
|
|
29 System.out.println("********************I am cli" + num);
|
|
30 ods.update("local", "width", 400);
|
345
|
31
|
419
|
32 GetStartX cs = new GetStartX();
|
|
33 cs.startX.setKey("local", "startX");
|
|
34
|
|
35 } else if (type.equals("node")) {
|
|
36 System.out.println("********************I am node" + num);
|
|
37 WidthReceiver cs = new WidthReceiver();
|
|
38 cs.widths.setKey("local", "widths");
|
|
39 cs.routing.setKey("local", "routing");
|
|
40
|
|
41 PeekStartX cs2 = new PeekStartX(0);
|
|
42 cs2.startX.setKey("local", "startX");
|
|
43
|
|
44 ods.put("local", "routing", new RoutingTable());
|
|
45 if (num == 0) { // First node ("node0") check
|
|
46 StartStartX cs3 = new StartStartX();
|
|
47 cs3.width.setKey("local", "width");
|
|
48 //ods.update("local", "startX", 0);
|
|
49 return;
|
|
50 }
|
|
51 }
|
|
52
|
|
53 SendWidth cs = new SendWidth();
|
|
54 cs.width.setKey("local", "width");
|
|
55
|
|
56 }
|
345
|
57
|
|
58 }
|