コード例 #1
0
ファイル: SimProc.cs プロジェクト: stuarthillary/sim-cluster
 public SimProc(ServiceId id, SimMachine machine, int procId, TaskFactory scheduler)
 {
     _cts       = new CancellationTokenSource();
     Id         = id;
     Machine    = machine;
     _procId    = procId;
     _scheduler = scheduler;
 }
コード例 #2
0
        public SimService(SimMachine machine, ServiceId id, Func <IEnv, IEngine> launcher)
        {
            Id        = id;
            _launcher = launcher;
            _machine  = machine;

            _scheduler = new SimScheduler(machine.Runtime, id);
            _factory   = new TaskFactory(_scheduler);
        }
コード例 #3
0
        public SimCluster(ClusterDef cluster, SimRuntime runtime)
        {
            Runtime = runtime;
            Rand    = Runtime.Rand;

            // we register each link as a network service
            foreach (var(id, def) in cluster.Routes)
            {
                var service   = new ServiceId($"network:{id.Source}->{id.Destinaton}");
                var scheduler = new SimScheduler(Runtime, service);
                Routes.Add(id, new SimRoute(scheduler, this, id, def));
            }

            foreach (var machine in cluster.Services.GroupBy(i => i.Key.Machine))
            {
                var m = new SimMachine(machine.Key, runtime, this);

                foreach (var pair in machine)
                {
                    m.Install(pair.Key, pair.Value);
                }
                Machines.Add(machine.Key, m);
            }
        }
コード例 #4
0
 public bool ResolveHost(string name, out SimMachine m)
 {
     return(Machines.TryGetValue(name, out m));
 }