492
|
1 package alice.topology.node;
|
|
2
|
|
3 import java.util.List;
|
|
4
|
|
5 import alice.codesegment.CodeSegment;
|
|
6 import alice.datasegment.CommandType;
|
|
7 import alice.datasegment.DataSegment;
|
|
8 import alice.datasegment.DataSegmentManager;
|
|
9 import alice.datasegment.Receiver;
|
|
10
|
|
11 public class PrepareToClose extends CodeSegment {
|
|
12
|
|
13 private Receiver info = ids.create(CommandType.PEEK);
|
|
14 private Receiver info1 = ids.create(CommandType.TAKE);
|
|
15
|
|
16 public PrepareToClose() {
|
|
17 info.setKey("_CLOSEMESSEAGE");
|
|
18 info1.setKey("_CLIST");
|
|
19 }
|
|
20
|
|
21 @SuppressWarnings("unchecked")
|
|
22 @Override
|
|
23 public void run() {
|
|
24 String managerKey = info.asString();
|
|
25 List<String> list = info1.asClass(List.class);
|
|
26 if (list.contains(managerKey)) {
|
|
27 list.remove(managerKey);
|
|
28 DataSegmentManager manager = DataSegment.get(managerKey);
|
|
29 manager.setSendError(false);
|
|
30
|
|
31 ods.put(managerKey, "_CLOSEREADY", managerKey);
|
|
32 ods.put("_CLOSEREADY", managerKey);
|
|
33 ods.put(info1.key, list);
|
|
34
|
|
35 new CloseRemoteDataSegment();
|
|
36 } else {
|
|
37 // lost node is this node's parent
|
|
38 }
|
|
39
|
|
40 }
|
|
41
|
|
42 }
|