annotate src/main/java/christie/topology/node/IncomingConnectionInfo.java @ 49:fd944876257b

add node and keepalive
author akahori
date Thu, 23 Aug 2018 09:29:05 +0900
parents
children 76b6da075ce0
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
fd944876257b add node and keepalive
akahori
parents:
diff changeset
3
fd944876257b add node and keepalive
akahori
parents:
diff changeset
4 import christie.annotation.Take;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
5 import christie.codegear.CodeGear;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
6 import christie.codegear.CodeGearManager;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
7 import christie.topology.HostMessage;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
8 import org.apache.log4j.Logger;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
9
fd944876257b add node and keepalive
akahori
parents:
diff changeset
10 public class IncomingConnectionInfo extends CodeGear {
fd944876257b add node and keepalive
akahori
parents:
diff changeset
11
fd944876257b add node and keepalive
akahori
parents:
diff changeset
12 @Take
fd944876257b add node and keepalive
akahori
parents:
diff changeset
13 HostMessage hostInfo;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
14
fd944876257b add node and keepalive
akahori
parents:
diff changeset
15 private String absName;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
16 private int count;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
17 private Logger log = Logger.getLogger(IncomingConnectionInfo.class);
fd944876257b add node and keepalive
akahori
parents:
diff changeset
18 private String managerKey;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
19
fd944876257b add node and keepalive
akahori
parents:
diff changeset
20 public IncomingConnectionInfo(String absName, int count, String managerKey) {
fd944876257b add node and keepalive
akahori
parents:
diff changeset
21 this.absName = absName;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
22 this.count = count;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
23 this.managerKey = managerKey;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
24 // hostInfo.setKey(managerKey,absName);
fd944876257b add node and keepalive
akahori
parents:
diff changeset
25
fd944876257b add node and keepalive
akahori
parents:
diff changeset
26 }
fd944876257b add node and keepalive
akahori
parents:
diff changeset
27
fd944876257b add node and keepalive
akahori
parents:
diff changeset
28
fd944876257b add node and keepalive
akahori
parents:
diff changeset
29
fd944876257b add node and keepalive
akahori
parents:
diff changeset
30 @Override
fd944876257b add node and keepalive
akahori
parents:
diff changeset
31 protected void run(CodeGearManager cgm) {
fd944876257b add node and keepalive
akahori
parents:
diff changeset
32 log.info(hostInfo.toString());
fd944876257b add node and keepalive
akahori
parents:
diff changeset
33 if ( hostInfo.hostName.equals("")) { // end case
fd944876257b add node and keepalive
akahori
parents:
diff changeset
34 log.info(" topology node finished " + absName);
fd944876257b add node and keepalive
akahori
parents:
diff changeset
35 getLocalDGM().put("configNodeNum", count);
fd944876257b add node and keepalive
akahori
parents:
diff changeset
36 return ;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
37 }
fd944876257b add node and keepalive
akahori
parents:
diff changeset
38 log.info("topology node " + absName + " will connect to " + hostInfo.hostName );
fd944876257b add node and keepalive
akahori
parents:
diff changeset
39 if (cgm.getDgmList().contains(hostInfo.connectionName)) {
fd944876257b add node and keepalive
akahori
parents:
diff changeset
40 // need to wait remove by DeleteConnection
fd944876257b add node and keepalive
akahori
parents:
diff changeset
41 getDGM("manager").put(absName, hostInfo);
fd944876257b add node and keepalive
akahori
parents:
diff changeset
42 } else {
fd944876257b add node and keepalive
akahori
parents:
diff changeset
43 cgm.createRemoteDGM(hostInfo.connectionName, hostInfo.hostName, hostInfo.port);
fd944876257b add node and keepalive
akahori
parents:
diff changeset
44 getDGM(hostInfo.connectionName).put("reverseKey", hostInfo.reverseName);
fd944876257b add node and keepalive
akahori
parents:
diff changeset
45 count++;
fd944876257b add node and keepalive
akahori
parents:
diff changeset
46
fd944876257b add node and keepalive
akahori
parents:
diff changeset
47 getLocalDGM().put("cMember", hostInfo.connectionName);
fd944876257b add node and keepalive
akahori
parents:
diff changeset
48 cgm.setup(new CreateConnectionList());
fd944876257b add node and keepalive
akahori
parents:
diff changeset
49 }
fd944876257b add node and keepalive
akahori
parents:
diff changeset
50 cgm.setup(new IncomingConnectionInfo(absName, count, managerKey));
fd944876257b add node and keepalive
akahori
parents:
diff changeset
51 }
fd944876257b add node and keepalive
akahori
parents:
diff changeset
52
fd944876257b add node and keepalive
akahori
parents:
diff changeset
53 }