81
|
1 package alice.test.topology.movement;
|
|
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 Receiver host = ids.create(CommandType.PEEK);
|
87
|
12 Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
|
|
13
|
81
|
14 @Override
|
|
15 public void run(){
|
|
16
|
|
17 String name = host.asString();
|
|
18 Matcher matcher = pattern.matcher(name);
|
|
19
|
|
20 matcher.find();
|
|
21 String type = matcher.group(1);
|
|
22 int cliNum = new Integer(matcher.group(2));
|
|
23
|
|
24 if (type.equals("cli")){
|
|
25 System.out.println("cli"+cliNum);
|
88
|
26 MakeFrame frame = new MakeFrame();
|
89
|
27 MakeObject obj = new MakeObject(frame);
|
|
28 frame.register(obj);
|
|
29 checkLocation cs = new checkLocation(obj,"fish1X");
|
83
|
30 cs.host.setKey("local","host");
|
88
|
31 cs.nowX.setKey("parent","fish1X");
|
|
32
|
89
|
33 MakeObject obj2 = new MakeObject(frame);
|
|
34 frame.register(obj2);
|
|
35 checkLocation cs2 = new checkLocation(obj2,"fish2X");
|
|
36 cs2.host.setKey("local","host");
|
|
37 cs2.nowX.setKey("parent","fish2X");
|
|
38
|
81
|
39
|
|
40 }else if(type.equals("node")){
|
|
41 System.out.println("node0");
|
88
|
42 ods.update("local", "fish1X", -1000);
|
89
|
43 ods.update("local", "fish2X", -1000);
|
81
|
44
|
|
45 }
|
|
46 }
|
|
47 }
|