view topology/manager/TopologyManager.cs @ 58:0d2c956060d8

add topology manager
author KaitoMaeshiro <aosskaito@cr.ie.u-ryukyu.ac.jp>
date Tue, 25 Jan 2022 22:35:25 +0900
parents
children c4f8630b7822
line wrap: on
line source

using System;
using System.Collections.Generic;
using Christie_net.daemon;
using Christie_net.annotation;
using Christie_net.codegear;
using Christie_net.topology;


namespace Christie_net.topology.manager.TopologyManager {

    public class TopologyManager : CodeGear {
        [Peek] public TopologyManagerConfig.TopologyManagerConfig topologyManagerConfig;
        
        public TopologyManager() {
        }

        public override void Run(CodeGearManager cgm) {
            cgm.Setup(new CheckComingHost.CheckComingHost());
            GetLocalDgm().Put("absCookieTable", new Dictionary<String, String>());
            
            if(topologyManagerConfig.dynamic) {
                GetLocalDgm().Put("running", true);
                GetLocalDgm().Put("_STARTMESSAGE", new Message());

                if (topologyManagerConfig.type == TopologyType.TopologyType.Tree) {
                    GetLocalDgm().Put("parentManager", new ParentManager.ParentManager(topologyManagerConfig.hasChild));
                    GetLocalDgm().Put("nameTable", new Dictionary<String, HostMessage.HostMessage>());
                    GetLocalDgm().Put("hostCount", 0);
                    cgm.Setup(new CreateTreeTopology.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 Dictionary<String, LinkedList<HostMessage.HostMessage>>());
                GetLocalDgm().Put("createdList", new LinkedList<String>());

            }
        }
    }
}