view src/main/java/christie/topology/node/IncomingConnectionInfo.java @ 59:76b6da075ce0

fix run code
author akahori
date Tue, 28 Aug 2018 09:45:53 +0900
parents fd944876257b
children 20d4c0cce914
line wrap: on
line source

package christie.topology.node;


import christie.annotation.Take;
import christie.annotation.TakeFrom;
import christie.codegear.CodeGear;
import christie.codegear.CodeGearManager;
import christie.topology.HostMessage;
import org.apache.log4j.Logger;

public class IncomingConnectionInfo extends CodeGear {

    @TakeFrom("manager")
    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));
    }

}