269
|
1 package alice.topology.manager.reconnection;
|
|
2
|
|
3 import java.util.ArrayList;
|
|
4 import java.util.HashMap;
|
|
5 import java.util.List;
|
|
6
|
270
|
7 import org.msgpack.type.ValueFactory;
|
|
8
|
269
|
9 import alice.codesegment.CodeSegment;
|
|
10 import alice.datasegment.CommandType;
|
|
11 import alice.datasegment.Receiver;
|
|
12 import alice.topology.HostMessage;
|
|
13
|
|
14 public class CheckConnectionList extends CodeSegment {
|
|
15
|
|
16 private Receiver name = ids.create(CommandType.TAKE);
|
|
17 private Receiver connection = ids.create(CommandType.TAKE);
|
|
18 private Receiver abs = ids.create(CommandType.PEEK);
|
|
19 private Receiver clone = ids.create(CommandType.TAKE);
|
|
20
|
|
21 public CheckConnectionList(){
|
|
22 name.setKey("_RECABSNAME");
|
|
23 connection.setKey("connection");
|
|
24 abs.setKey("_ABSIPTABLE");
|
270
|
25 clone.setKey("_HMCLONE");
|
269
|
26 }
|
|
27
|
|
28 @Override
|
|
29 public void run() {
|
|
30 @SuppressWarnings("unchecked")
|
|
31 HashMap<String, ArrayList<HostMessage>> connectionList = connection.asClass(HashMap.class);
|
|
32 @SuppressWarnings("unchecked")
|
|
33 List<HostMessage> ABSIPList = abs.asClass(List.class);
|
|
34 String absName = name.asClass(String.class);
|
|
35 HostMessage oldInfo = clone.asClass(HostMessage.class);
|
|
36 HostMessage newInfo = null;
|
|
37 for (HostMessage mes : ABSIPList){
|
|
38 if (mes.absName.equals(absName)){
|
|
39 newInfo = mes;
|
|
40 break;
|
|
41 }
|
|
42 }
|
|
43
|
|
44 List<HostMessage> clist = connectionList.get(absName);
|
|
45 for (HostMessage mes : clist){
|
|
46 ods.put(absName, mes);
|
|
47 for (HostMessage mes2 : ABSIPList){
|
|
48 if (mes.name.equals(mes2.name)&&mes.port == mes2.port){
|
|
49 String absName2 = mes2.getABSName();
|
|
50 List<HostMessage> clist2 = connectionList.get(absName2);
|
|
51 for (HostMessage mes3 : clist2){
|
|
52 if (mes3.name.equals(oldInfo.name)&&mes3.port == oldInfo.port){
|
|
53 mes3.name = newInfo.name;
|
|
54 mes3.port = newInfo.port;
|
274
|
55 mes3.setFlag();
|
270
|
56 ods.put(absName2, "_RECODATA", mes3);
|
269
|
57 break;
|
|
58 }
|
|
59 }
|
|
60 break;
|
|
61 }
|
|
62 }
|
|
63 }
|
274
|
64 System.out.println("SendHost Data");
|
270
|
65 ods.put(absName, ValueFactory.createNilValue());
|
269
|
66 ods.update("connection", connectionList);
|
|
67 new ReceiveError();
|
|
68 }
|
274
|
69 } |