annotate src/main/java/christie/topology/node/TopologyNode.java @ 77:c73f4ff18cfc

refactor TopologyNode
author akahori
date Wed, 05 Sep 2018 10:26:10 +0900
parents 36c5c050394d
children 33afa0fa8bc5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
fd944876257b add node and keepalive
akahori
parents:
diff changeset
1 package christie.topology.node;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
2
61
20d4c0cce914 refactor Topology Node
akahori
parents: 58
diff changeset
3 import christie.annotation.Peek;
49
fd944876257b add node and keepalive
akahori
parents:
diff changeset
4 import christie.codegear.CodeGear;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
5 import christie.codegear.CodeGearManager;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
6 import christie.topology.HostMessage;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
7 import christie.topology.manager.IncomingHosts;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
8
fd944876257b add node and keepalive
akahori
parents:
diff changeset
9 import java.net.InetAddress;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
10 import java.net.UnknownHostException;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
11 import java.util.ArrayList;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
12
fd944876257b add node and keepalive
akahori
parents:
diff changeset
13 public class TopologyNode extends CodeGear{
fd944876257b add node and keepalive
akahori
parents:
diff changeset
14
61
20d4c0cce914 refactor Topology Node
akahori
parents: 58
diff changeset
15 @Peek
20d4c0cce914 refactor Topology Node
akahori
parents: 58
diff changeset
16 TopologyNodeConfig topologyNodeConfig;
49
fd944876257b add node and keepalive
akahori
parents:
diff changeset
17
61
20d4c0cce914 refactor Topology Node
akahori
parents: 58
diff changeset
18 public TopologyNode() {
49
fd944876257b add node and keepalive
akahori
parents:
diff changeset
19 }
fd944876257b add node and keepalive
akahori
parents:
diff changeset
20
fd944876257b add node and keepalive
akahori
parents:
diff changeset
21 @Override
fd944876257b add node and keepalive
akahori
parents:
diff changeset
22 protected void run(CodeGearManager cgm) {
61
20d4c0cce914 refactor Topology Node
akahori
parents: 58
diff changeset
23
20d4c0cce914 refactor Topology Node
akahori
parents: 58
diff changeset
24 cgm.createRemoteDGM(topologyNodeConfig.getManagerKey(),
58
9922e6decbe8 fix conf
akahori
parents: 49
diff changeset
25 topologyNodeConfig.getManagerHostName(),
9922e6decbe8 fix conf
akahori
parents: 49
diff changeset
26 topologyNodeConfig.getManagerPort());
61
20d4c0cce914 refactor Topology Node
akahori
parents: 58
diff changeset
27
20d4c0cce914 refactor Topology Node
akahori
parents: 58
diff changeset
28
49
fd944876257b add node and keepalive
akahori
parents:
diff changeset
29 String localHostName = null;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
30 try {
fd944876257b add node and keepalive
akahori
parents:
diff changeset
31 localHostName = InetAddress.getLocalHost().getHostAddress();
fd944876257b add node and keepalive
akahori
parents:
diff changeset
32 } catch (UnknownHostException e) {
fd944876257b add node and keepalive
akahori
parents:
diff changeset
33 e.printStackTrace();
fd944876257b add node and keepalive
akahori
parents:
diff changeset
34 }
61
20d4c0cce914 refactor Topology Node
akahori
parents: 58
diff changeset
35
49
fd944876257b add node and keepalive
akahori
parents:
diff changeset
36 HostMessage host = new HostMessage(localHostName, cgm.localPort);
58
9922e6decbe8 fix conf
akahori
parents: 49
diff changeset
37 host.cookie = topologyNodeConfig.cookie;
49
fd944876257b add node and keepalive
akahori
parents:
diff changeset
38
61
20d4c0cce914 refactor Topology Node
akahori
parents: 58
diff changeset
39 getDGM(topologyNodeConfig.getManagerKey()).put("hostMessage", host);
77
c73f4ff18cfc refactor TopologyNode
akahori
parents: 71
diff changeset
40
49
fd944876257b add node and keepalive
akahori
parents:
diff changeset
41 getLocalDGM().put("_CLIST", new ArrayList<String>());
fd944876257b add node and keepalive
akahori
parents:
diff changeset
42 getLocalDGM().put("reverseCount", 0);
fd944876257b add node and keepalive
akahori
parents:
diff changeset
43
61
20d4c0cce914 refactor Topology Node
akahori
parents: 58
diff changeset
44 cgm.setup(new SaveCookie());
66
4e2453333508 del IncomingAbstractHostName
akahori
parents: 61
diff changeset
45 cgm.setup(new IncomingConnectionInfo());
61
20d4c0cce914 refactor Topology Node
akahori
parents: 58
diff changeset
46 cgm.setup(new IncomingReverseKey());
71
36c5c050394d update put startCG
akahori
parents: 68
diff changeset
47 cgm.setup(new ConfigurationFinish());
49
fd944876257b add node and keepalive
akahori
parents:
diff changeset
48
fd944876257b add node and keepalive
akahori
parents:
diff changeset
49 }
fd944876257b add node and keepalive
akahori
parents:
diff changeset
50 }