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