annotate src/alice/topology/manager/reconnection/CheckConnectionList.java @ 274:f866178f3018

success to reconnect
author sugi
date Sun, 29 Sep 2013 17:17:10 +0900
parents 3667ab045530
children 99026285c5dc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
269
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
1 package alice.topology.manager.reconnection;
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
2
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
3 import java.util.ArrayList;
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
4 import java.util.HashMap;
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
5 import java.util.List;
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
6
270
23e53aaa8720 reconnect manager worked.
sugi
parents: 269
diff changeset
7 import org.msgpack.type.ValueFactory;
23e53aaa8720 reconnect manager worked.
sugi
parents: 269
diff changeset
8
269
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
9 import alice.codesegment.CodeSegment;
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
10 import alice.datasegment.CommandType;
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
11 import alice.datasegment.Receiver;
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
12 import alice.topology.HostMessage;
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
13
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
14 public class CheckConnectionList extends CodeSegment {
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
15
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
16 private Receiver name = ids.create(CommandType.TAKE);
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
17 private Receiver connection = ids.create(CommandType.TAKE);
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
18 private Receiver abs = ids.create(CommandType.PEEK);
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
19 private Receiver clone = ids.create(CommandType.TAKE);
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
20
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
21 public CheckConnectionList(){
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
22 name.setKey("_RECABSNAME");
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
23 connection.setKey("connection");
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
24 abs.setKey("_ABSIPTABLE");
270
23e53aaa8720 reconnect manager worked.
sugi
parents: 269
diff changeset
25 clone.setKey("_HMCLONE");
269
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
26 }
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
27
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
28 @Override
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
29 public void run() {
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
30 @SuppressWarnings("unchecked")
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
31 HashMap<String, ArrayList<HostMessage>> connectionList = connection.asClass(HashMap.class);
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
32 @SuppressWarnings("unchecked")
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
33 List<HostMessage> ABSIPList = abs.asClass(List.class);
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
34 String absName = name.asClass(String.class);
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
35 HostMessage oldInfo = clone.asClass(HostMessage.class);
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
36 HostMessage newInfo = null;
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
37 for (HostMessage mes : ABSIPList){
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
38 if (mes.absName.equals(absName)){
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
39 newInfo = mes;
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
40 break;
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
41 }
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
42 }
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
43
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
44 List<HostMessage> clist = connectionList.get(absName);
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
45 for (HostMessage mes : clist){
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
46 ods.put(absName, mes);
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
47 for (HostMessage mes2 : ABSIPList){
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
48 if (mes.name.equals(mes2.name)&&mes.port == mes2.port){
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
49 String absName2 = mes2.getABSName();
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
50 List<HostMessage> clist2 = connectionList.get(absName2);
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
51 for (HostMessage mes3 : clist2){
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
52 if (mes3.name.equals(oldInfo.name)&&mes3.port == oldInfo.port){
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
53 mes3.name = newInfo.name;
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
54 mes3.port = newInfo.port;
274
f866178f3018 success to reconnect
sugi
parents: 271
diff changeset
55 mes3.setFlag();
270
23e53aaa8720 reconnect manager worked.
sugi
parents: 269
diff changeset
56 ods.put(absName2, "_RECODATA", mes3);
269
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
57 break;
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
58 }
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
59 }
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
60 break;
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
61 }
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
62 }
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
63 }
274
f866178f3018 success to reconnect
sugi
parents: 271
diff changeset
64 System.out.println("SendHost Data");
270
23e53aaa8720 reconnect manager worked.
sugi
parents: 269
diff changeset
65 ods.put(absName, ValueFactory.createNilValue());
269
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
66 ods.update("connection", connectionList);
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
67 new ReceiveError();
9982e1c4f099 debugging reconnectManager
sugi
parents:
diff changeset
68 }
274
f866178f3018 success to reconnect
sugi
parents: 271
diff changeset
69 }