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
|
|
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();
|
129
|
35 getLocalDGM().put("nodeNames", nodeNames);
|
44
|
36
|
94
|
37 String newHostName = newHost.getHostName();
|
|
38 int newHostPort = newHost.getPort();
|
|
39
|
41
|
40 // Manager connect to Node
|
94
|
41 cgm.createRemoteDGM(nodeName, newHostName, newHostPort);
|
41
|
42
|
44
|
43 absCookieTable.put(MD5, nodeName);
|
129
|
44 getLocalDGM().put("absCookieTable", absCookieTable);
|
41
|
45
|
64
|
46 getDGM(nodeName).put( "nodeName", nodeName);
|
44
|
47 getDGM(nodeName).put("cookie", MD5);
|
41
|
48
|
94
|
49 LinkedList<HostMessage> nodeInfoList = resultParse.get(nodeName);
|
68
|
50 getDGM(nodeName).put("connectNodeNum", nodeInfoList.size());
|
94
|
51 for (HostMessage nodeInfo : nodeInfoList) {
|
|
52 nodeInfo.setHostAndPort(newHostName, newHostPort);
|
41
|
53
|
94
|
54 getLocalDGM().put("nodeInfo", nodeInfo);
|
64
|
55
|
44
|
56 cgm.setup(new RecordTopology());
|
41
|
57 }
|
129
|
58 getLocalDGM().put("resultParse", resultParse);
|
|
59
|
41
|
60 cgm.setup(new IncomingHosts());
|
|
61 }
|
|
62 }
|