Mercurial > hg > Database > Christie
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/christie/topology/node/IncomingConnectionInfo.java Thu Aug 23 09:29:05 2018 +0900 @@ -0,0 +1,53 @@ +package christie.topology.node; + + +import christie.annotation.Take; +import christie.codegear.CodeGear; +import christie.codegear.CodeGearManager; +import christie.topology.HostMessage; +import org.apache.log4j.Logger; + +public class IncomingConnectionInfo extends CodeGear { + + @Take + HostMessage hostInfo; + + private String absName; + private int count; + private Logger log = Logger.getLogger(IncomingConnectionInfo.class); + private String managerKey; + + public IncomingConnectionInfo(String absName, int count, String managerKey) { + this.absName = absName; + this.count = count; + this.managerKey = managerKey; + // hostInfo.setKey(managerKey,absName); + + } + + + + @Override + protected void run(CodeGearManager cgm) { + log.info(hostInfo.toString()); + if ( hostInfo.hostName.equals("")) { // end case + log.info(" topology node finished " + absName); + getLocalDGM().put("configNodeNum", count); + return ; + } + log.info("topology node " + absName + " will connect to " + hostInfo.hostName ); + if (cgm.getDgmList().contains(hostInfo.connectionName)) { + // need to wait remove by DeleteConnection + getDGM("manager").put(absName, hostInfo); + } else { + cgm.createRemoteDGM(hostInfo.connectionName, hostInfo.hostName, hostInfo.port); + getDGM(hostInfo.connectionName).put("reverseKey", hostInfo.reverseName); + count++; + + getLocalDGM().put("cMember", hostInfo.connectionName); + cgm.setup(new CreateConnectionList()); + } + cgm.setup(new IncomingConnectionInfo(absName, count, managerKey)); + } + +}