345
|
1 package alice.test.topology.share;
|
|
2
|
|
3 import java.util.List;
|
|
4
|
|
5 import alice.codesegment.CodeSegment;
|
|
6 import alice.datasegment.CommandType;
|
|
7 import alice.datasegment.Receiver;
|
|
8
|
|
9 public class CheckLocalIndex extends CodeSegment {
|
|
10
|
419
|
11 private Receiver data = ids.create(CommandType.PEEK);
|
|
12 private Receiver list = ids.create(CommandType.PEEK);
|
|
13 private Receiver host = ids.create(CommandType.PEEK);
|
|
14
|
|
15
|
|
16 public CheckLocalIndex(String key, int index) {
|
|
17 this.host.setKey("host");
|
|
18 this.list.setKey("_CLIST");
|
|
19 this.data.setKey(key, index);
|
|
20 }
|
345
|
21
|
419
|
22 @Override
|
|
23 public void run() {
|
|
24 @SuppressWarnings("unchecked")
|
|
25 List<String> r = list.asClass(List.class);
|
|
26 int count = 0;
|
|
27 boolean flag = false;
|
|
28 for (String node : r) {
|
|
29 if (node.equals("parent")) {
|
|
30 flag = true;
|
|
31 }
|
|
32 if (!node.equals(this.data.from)) {
|
|
33 ods.update(node, data.key, data.getVal());
|
|
34 count++;
|
|
35 }
|
|
36 }
|
|
37 if (count == 0 && flag) {
|
|
38 ods.put("parent", "data", data.getVal());
|
|
39 }
|
|
40 new CheckLocalIndex(data.key, data.index);
|
|
41
|
|
42 }
|
345
|
43
|
|
44 }
|