Mercurial > hg > Database > Christie
comparison src/main/java/christie/topology/node/TopologyNode.java @ 49:fd944876257b
add node and keepalive
author | akahori |
---|---|
date | Thu, 23 Aug 2018 09:29:05 +0900 |
parents | |
children | 9922e6decbe8 |
comparison
equal
deleted
inserted
replaced
48:174a2f37ec28 | 49:fd944876257b |
---|---|
1 package christie.topology.node; | |
2 | |
3 import christie.codegear.CodeGear; | |
4 import christie.codegear.CodeGearManager; | |
5 import christie.topology.HostMessage; | |
6 import christie.topology.manager.IncomingHosts; | |
7 | |
8 import java.net.InetAddress; | |
9 import java.net.UnknownHostException; | |
10 import java.util.ArrayList; | |
11 | |
12 public class TopologyNode extends CodeGear{ | |
13 | |
14 private final String manager; | |
15 private final String local; | |
16 private TopologyNodeConfig conf; | |
17 private CodeGear startCS; | |
18 | |
19 public TopologyNode(TopologyNodeConfig conf, CodeGear startCS) { | |
20 this.conf = conf; | |
21 this.startCS = startCS; | |
22 this.manager = conf.getManagerKey(); | |
23 this.local = conf.getLocalKey(); | |
24 } | |
25 | |
26 @Override | |
27 protected void run(CodeGearManager cgm) { | |
28 cgm.createRemoteDGM(manager, conf.getManagerHostName(), conf.getManagerPort()); | |
29 String localHostName = null; | |
30 try { | |
31 localHostName = InetAddress.getLocalHost().getHostAddress(); | |
32 } catch (UnknownHostException e) { | |
33 e.printStackTrace(); | |
34 } | |
35 cgm.setup(new SaveCookie()); | |
36 if (cgm.localPort == 0) { | |
37 // local test mode | |
38 localHostName = conf.getLocalKey(); | |
39 } | |
40 getLocalDGM().put("config" , conf ); | |
41 | |
42 HostMessage host = new HostMessage(localHostName, cgm.localPort); | |
43 host.cookie = conf.cookie; | |
44 getDGM(manager).put("hostMessage", host); | |
45 | |
46 getLocalDGM().put("_CLIST", new ArrayList<String>()); | |
47 //getDGM(local).put("_CLIST", new ArrayList<String>()); | |
48 | |
49 cgm.setup(new IncomingAbstractHostName(conf)); | |
50 | |
51 cgm.setup(new IncomingReverseKey()); | |
52 | |
53 getLocalDGM().put("reverseCount", 0); | |
54 | |
55 cgm.setup(new ConfigurationFinish(startCS)); | |
56 | |
57 } | |
58 } |