view src/main/java/christie/topology/manager/TopologyManager.java @ 158:e295cb59e514

update refactor topology manager
author akahori
date Wed, 16 Jan 2019 18:57:04 +0900 (2019-01-16)
parents daf37151dd97
children 6eb548c188e5
line wrap: on
line source
package christie.topology.manager;

import christie.annotation.Peek;
import christie.codegear.CodeGear;
import christie.codegear.CodeGearManager;

import java.util.HashMap;
import java.util.LinkedList;

import christie.topology.HostMessage;

public class TopologyManager extends CodeGear {

    @Peek
    TopologyManagerConfig topologyManagerConfig;

    public TopologyManager() {
    }

    @Override
    protected void run(CodeGearManager cgm) {
        cgm.setup(new CheckComingHost());
        getLocalDGM().put("absCookieTable", new HashMap<String, String>());

        if(topologyManagerConfig.dynamic) {
            getLocalDGM().put("running", true);
            getLocalDGM().put("start", "start");

            if (topologyManagerConfig.type == TopologyType.Tree) {
                getLocalDGM().put("parentManager", new ParentManager(topologyManagerConfig.hasChild));
                getLocalDGM().put("nameTable", new HashMap<String, HostMessage>());
                getLocalDGM().put("hostCount", 0);
                cgm.setup(new CreateTreeTopology());
                //cgm.setup(new ReceiveDisconnectMessage());
            }

        }else{
            getLocalDGM().put("running", false);
            cgm.setup(new FileParser());
            cgm.setup(new IncomingHosts());
            cgm.setup(new ConfigWaiter());

        }

        cgm.setup(new CreateHash());
        cgm.setup(new TopologyFinish());

        getLocalDGM().put("topology", new HashMap<String, LinkedList<HostMessage>>());
        getLocalDGM().put("createdList", new LinkedList<String>());
    }


}