43
|
1 package christie.topology.manager;
|
|
2
|
|
3
|
|
4 import christie.annotation.Peek;
|
|
5 import christie.annotation.Take;
|
|
6 import christie.codegear.CodeGear;
|
|
7 import christie.codegear.CodeGearManager;
|
|
8 import christie.topology.HostMessage;
|
|
9 import org.msgpack.type.ValueFactory;
|
|
10
|
|
11 import java.util.HashMap;
|
|
12 import java.util.LinkedList;
|
|
13
|
|
14 public class SearchHostName extends CodeGear {
|
|
15
|
|
16 @Take // reconnect NodeInfo
|
|
17 HostMessage reconnectHost;
|
|
18
|
60
|
19 @Peek
|
43
|
20 HashMap<String, LinkedList<HostMessage>> topology;
|
|
21
|
|
22 @Peek
|
|
23 boolean running;
|
|
24
|
|
25
|
|
26 public SearchHostName(){
|
|
27
|
|
28 }
|
|
29
|
|
30 @Override
|
|
31 protected void run(CodeGearManager cgm) {
|
|
32
|
|
33
|
|
34 // Question: remove処理 どうしようか. いらない気もする.
|
|
35 // DataSegment.remove(hostInfo.absName);
|
|
36
|
50
|
37 cgm.createRemoteDGM(reconnectHost.absName, reconnectHost.hostName, reconnectHost.port);
|
43
|
38 getDGM(reconnectHost.absName).put("host", reconnectHost.absName);
|
|
39
|
|
40 // put Host dataSegment on reconnect node
|
|
41 if (topology.containsKey(reconnectHost.absName)) {
|
|
42
|
|
43 // Question: これはバグ...?
|
|
44 // ods.put(reconnectHost.absName, "dummy"); // this is bug
|
|
45
|
|
46 if (running){
|
|
47 getLocalDGM().put(reconnectHost.absName, ValueFactory.createNilValue());
|
|
48 }
|
|
49
|
|
50
|
|
51 LinkedList<HostMessage> hostList = topology.get(reconnectHost.absName);
|
|
52 for (HostMessage host : hostList){
|
|
53 getLocalDGM().put(reconnectHost.absName, host);
|
|
54 System.out.println("put data in "+ reconnectHost.absName);
|
|
55 }
|
|
56 }
|
|
57
|
|
58 // update topology information
|
|
59 for (LinkedList<HostMessage> list :topology.values()){
|
|
60 for (HostMessage host : list){
|
|
61
|
|
62 // find and update old info
|
|
63 if (!reconnectHost.absName.equals(host.absName)) continue;
|
|
64
|
50
|
65 if (!reconnectHost.hostName.equals(host.hostName) || reconnectHost.port != host.port){
|
|
66 host.hostName = reconnectHost.hostName;
|
43
|
67 host.port = reconnectHost.port;
|
|
68
|
|
69 getLocalDGM().put(host.remoteAbsName, host);
|
|
70
|
|
71 } else {
|
|
72 // nothing to do ?
|
|
73 }
|
|
74 }
|
|
75 }
|
|
76
|
|
77 for (LinkedList<HostMessage> list :topology.values()){
|
|
78 System.out.print(list.get(0).remoteAbsName+" : ");
|
|
79 for (HostMessage host : list){
|
50
|
80 System.out.print("[ "+host.absName+" "+host.hostName+" "+host.port+" "+host.connectionName+" "+host.reverseName+" "+host.remoteAbsName+" ]");
|
43
|
81 }
|
|
82 System.out.println();
|
|
83 }
|
|
84 }
|
|
85
|
|
86 }
|