41
|
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 IncomingHosts extends CodeGear {
|
|
14
|
60
|
15 @Peek // Topology from parse file
|
94
|
16 HashMap<String, LinkedList<HostMessage>> resultParse;
|
60
|
17 @Peek // nodeName list
|
|
18 LinkedList<String> nodeNames;
|
|
19 @Peek
|
|
20 HashMap<String, String> absCookieTable;
|
41
|
21
|
|
22 @Take // new coming host info
|
44
|
23 HostMessage newHost;
|
|
24 @Take
|
|
25 String MD5;
|
41
|
26
|
|
27 public IncomingHosts() {
|
|
28
|
|
29 }
|
|
30
|
|
31 @Override
|
57
|
32 protected void run(CodeGearManager cgm) {
|
41
|
33 // not have or match cookie
|
|
34 String nodeName = nodeNames.poll();
|
44
|
35
|
94
|
36 String newHostName = newHost.getHostName();
|
|
37 int newHostPort = newHost.getPort();
|
|
38
|
41
|
39 // Manager connect to Node
|
94
|
40 cgm.createRemoteDGM(nodeName, newHostName, newHostPort);
|
41
|
41
|
44
|
42 absCookieTable.put(MD5, nodeName);
|
41
|
43
|
64
|
44 getDGM(nodeName).put( "nodeName", nodeName);
|
44
|
45 getDGM(nodeName).put("cookie", MD5);
|
41
|
46
|
94
|
47 LinkedList<HostMessage> nodeInfoList = resultParse.get(nodeName);
|
68
|
48 getDGM(nodeName).put("connectNodeNum", nodeInfoList.size());
|
94
|
49 for (HostMessage nodeInfo : nodeInfoList) {
|
|
50 nodeInfo.setHostAndPort(newHostName, newHostPort);
|
41
|
51
|
94
|
52 getLocalDGM().put("nodeInfo", nodeInfo);
|
64
|
53
|
44
|
54 cgm.setup(new RecordTopology());
|
41
|
55 }
|
|
56 cgm.setup(new IncomingHosts());
|
|
57 }
|
|
58 }
|