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