コード例 #1
0
        public ProgressChannel(int producerPlacementCount,
                               ProgressUpdateConsumer consumerVertex,
                               StageOutput <Update, Empty> stream,
                               StageInput <Update, Empty> recvPort,
                               InternalController controller,
                               int channelId)
        {
            this.sendBundle = stream;
            this.recvBundle = recvPort;
            this.channelID  = channelId;

            var computation = sendBundle.ForStage.InternalComputation;
            var recvFiber   = this.recvBundle.GetPin(computation.Controller.Configuration.ProcessID);

            this.mailbox = new Mailbox(recvFiber.Vertex.Scheduler.State(computation).PostOffice, consumerVertex, this.channelID, consumerVertex.VertexId, producerPlacementCount);

            // recvFiber.Vertex.Scheduler.State(graphManager).PostOffice.RegisterMailbox(this.mailbox);

            this.postboxes = new Dictionary <int, Fiber>();
            foreach (VertexLocation loc in sendBundle.ForStage.Placement)
            {
                if (loc.ProcessId == controller.Configuration.ProcessID)
                {
                    this.postboxes[loc.VertexId] = new Fiber(this.channelID, loc.VertexId, this.sendBundle.GetFiber(loc.VertexId), this.mailbox, controller);
                }
            }

            if (controller.NetworkChannel != null)
            {
                controller.NetworkChannel.RegisterMailbox(this.mailbox);
            }

            Logging.Info("Allocated progress channel [{0}]: {1} -> {2}", this.channelID, sendBundle, recvBundle);
        }
コード例 #2
0
        public async Task Reset()
        {
            var controller = new InternalController(Manager);

            //Reset development account password
            await controller.Reset("dev@localhost");

            Assert.AreEqual(1, Smtp.SentEmailCount);
            Assert.AreEqual("WikiLibs API Server", Smtp.LastSendEmail.Subject);
            Assert.AreEqual(Shared.Modules.Smtp.Models.UserReset.Template, Smtp.LastSendEmail.Template);
            Assert.AreEqual("dev@localhost", Smtp.LastSendEmail.Recipients.First().Email);
            var data = Smtp.LastSendEmail.Model as Shared.Modules.Smtp.Models.UserReset;

            Assert.AreEqual(Context.Users.Last().Pass, data.NewPassword);

            //Check we can login
            var res = await controller.Login(new Models.Input.Auth.Login()
            {
                Email    = "dev@localhost",
                Password = data.NewPassword
            }) as JsonResult;

            var token = res.Value as string;

            Assert.IsNotNull(token);
        }
コード例 #3
0
        public void Confirm_Error_Invalid()
        {
            var controller = new InternalController(Manager);

            Assert.ThrowsAsync <InvalidCredentials>(() => controller.Confirm("abcd"));
            Assert.ThrowsAsync <InvalidCredentials>(() => controller.Confirm("abcd.efgh"));
        }
コード例 #4
0
            internal BaseWorkerGroup(InternalController controller, int numWorkers)
            {
                this.numWorkers = numWorkers;
                this.schedulers = new Scheduler[numWorkers];

                if (controller.Configuration.UseBroadcastWakeup)
                {
                    this.useBroadcastWakeup = true;
                    this.wakeUpEvent        = new EventCount();
                }
                else
                {
                    this.useBroadcastWakeup = false;
                }

                for (int i = 0; i < numWorkers; ++i)
                {
                    switch (System.Environment.OSVersion.Platform)
                    {
                    case PlatformID.Win32NT:
                        this.schedulers[i] = new PinnedScheduler(string.Format("Naiad worker {0}", i), i, controller);
                        break;

                    default:
                        this.schedulers[i] = new Scheduler(string.Format("Naiad worker {0}", i), i, controller);
                        break;
                    }
                }
            }
コード例 #5
0
        public void Confirm_Error_NonExistant()
        {
            var controller = new InternalController(Manager);

            Assert.ThrowsAsync <Shared.Exceptions.ResourceNotFound>(() => controller.Confirm("abcd.efgh.123456789"));
            Assert.ThrowsAsync <InvalidCredentials>(() => controller.Confirm("abcd." + new Guid().ToString() + ".123456789"));
        }
コード例 #6
0
        /// <summary>
        /// Constructor
        /// </summary>

        public CentralizedProgressChannel(Stage <Runtime.Progress.ProgressUpdateCentralizer, Pointstamp> consumer,
                                          StageOutput <Int64, Pointstamp> stream, StageInput <Int64, Pointstamp> recvPort,
                                          InternalController controller,
                                          int channelId)
        {
            this.consumer = consumer;

            this.sendBundle = stream;   // producer.Output;
            this.recvBundle = recvPort; // consumer.Input;

            this.postboxes = new Dictionary <int, Fiber>();

            this.channelID = channelId;

            // Get the shard id and process id of the single consumer
            var consumerShardId   = consumer.Placement.Single().VertexId;
            var consumerProcessId = consumer.Placement.Single().ProcessId;

            var graphManager = sendBundle.ForStage.InternalGraphManager;

            if (debug)
            {
                Console.Error.WriteLine("  IncastChannel create ProcessId = {0}", graphManager.Controller.Configuration.ProcessID);
            }

            var myProcessId = graphManager.Controller.Configuration.ProcessID;

            if (myProcessId == consumerProcessId)
            {
                if (debug)
                {
                    Console.Error.WriteLine("  IncastChannel creating receive mailbox");
                }
                VertexInput <Int64, Pointstamp> recvFiber = this.recvBundle.GetPin(consumerProcessId);

                this.mailbox = new Mailbox(recvFiber.Vertex.Scheduler.State(graphManager).PostOffice,
                                           consumer.GetShard(consumerShardId), this.channelID, consumerShardId);
                recvFiber.Vertex.Scheduler.State(graphManager).PostOffice.RegisterMailbox(this.mailbox);
                if (controller.NetworkChannel != null)
                {
                    controller.NetworkChannel.RegisterMailbox(this.mailbox);
                }
            }

            foreach (VertexLocation loc in sendBundle.ForStage.Placement)
            {
                if (loc.ProcessId == sendBundle.ForStage.InternalGraphManager.Controller.Configuration.ProcessID)
                {
                    if (debug)
                    {
                        Console.Error.WriteLine("  IncastChannel loc = {0}/{1}/{2}", loc.ProcessId, loc.VertexId, loc.ThreadId);
                    }
                    var postbox = new Fiber(this.channelID, loc.VertexId, this.sendBundle.GetFiber(loc.VertexId),
                                            this.mailbox, controller, consumerShardId, consumerProcessId);
                    this.postboxes[loc.VertexId] = postbox;
                }
            }
            Logging.Info("Allocated incast channel [{0}]: {1} -> {2}", this.channelID, sendBundle, recvBundle);
        }
コード例 #7
0
        public void Reset_Error_NonExistant()
        {
            var controller = new InternalController(Manager);

            Assert.ThrowsAsync <Shared.Exceptions.ResourceNotFound>(() => controller.Reset("*****@*****.**"));
            Context.Users.First().IsBot = true;
            Assert.ThrowsAsync <Shared.Exceptions.ResourceNotFound>(() => controller.Reset("dev@localhost"));
        }
コード例 #8
0
        public static void Start(this MonoBehaviour behaviour, IEnumerator routine, out IRoutine controller)
        {
            InternalController c = new InternalController();

            c.Start(routine);
            controller = c;
            behaviour.StartCoroutine(c.Run());
        }
コード例 #9
0
        public async Task Register_Error_Dupe()
        {
            var controller = new InternalController(Manager);

            await PostTestUser(controller);

            Assert.ThrowsAsync <Shared.Exceptions.ResourceAlreadyExists>(() => PostTestUser(controller));
        }
コード例 #10
0
        /// <summary>
        /// Constructs a controller for a new computation.
        /// </summary>
        /// <param name="config">Controller configuration</param>
        public Controller(Configuration config)
        {
            switch (config.Mode)
            {
            case Mode.Legacy:
                this.impl = new LegacyController(config);
                break;

            default:
                throw new NotImplementedException(string.Format("Cannot instantiate a controller in mode {0}", config.Mode));
            }
        }
コード例 #11
0
 public async Task PostTestUser(InternalController controller)
 {
     await controller.Register(new Models.Input.Users.UserCreate()
     {
         Email      = "*****@*****.**",
         Password   = "******",
         FirstName  = "Test",
         LastName   = "Test",
         Private    = false,
         Pseudo     = "pseudo",
         ProfileMsg = "This is a testing account"
     });
 }
コード例 #12
0
        // For each operator, compute the minimal antichain of times that are reachable from the given list of versions, and
        // update their state accordingly.
        public void UpdateReachability(InternalController controller, Pointstamp[] versions, List <Dataflow.Vertex> vertices)
        {
            //Console.Error.WriteLine("Updating reachability with versions");
            //foreach (var version in versions)
            //    Console.Error.WriteLine(version);

            var result = DetermineReachabilityList(versions);

            foreach (var vertex in vertices)
            {
                vertex.UpdateReachability(result[vertex.Stage.StageId]);
            }
        }
コード例 #13
0
        public async Task Auth()
        {
            var controller = new InternalController(Manager);

            var res = await controller.Login(new Models.Input.Auth.Login()
            {
                Email    = "dev@localhost",
                Password = "******"
            }) as JsonResult;

            var token = res.Value as string;

            Assert.IsNotNull(token);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        public CentralizedProgressChannel(Stage <ProgressUpdateCentralizer, Empty> consumer,
                                          StageOutput <Update, Empty> stream, StageInput <Update, Empty> recvPort,
                                          InternalController controller,
                                          int channelId)
        {
            this.consumer = consumer;

            this.sendBundle = stream;   // producer.Output;
            this.recvBundle = recvPort; // consumer.Input;

            this.postboxes = new Dictionary <int, Fiber>();

            this.channelID = channelId;

            // Get the vertex id and process id of the single consumer
            var consumerVertexId  = consumer.Placement.Single().VertexId;
            var consumerProcessId = consumer.Placement.Single().ProcessId;

            var computation = sendBundle.ForStage.InternalComputation;

            var myProcessId = computation.Controller.Configuration.ProcessID;

            if (myProcessId == consumerProcessId)
            {
                VertexInput <Update, Empty> recvFiber = this.recvBundle.GetPin(consumerProcessId);

                this.mailbox = new Mailbox(recvFiber.Vertex.Scheduler.State(computation).PostOffice,
                                           consumer.GetVertex(consumerVertexId), this.channelID, consumerVertexId);

                //recvFiber.Vertex.Scheduler.State(computation).PostOffice.RegisterMailbox(this.mailbox);

                if (controller.NetworkChannel != null)
                {
                    controller.NetworkChannel.RegisterMailbox(this.mailbox);
                }
            }

            foreach (VertexLocation loc in sendBundle.ForStage.Placement)
            {
                if (loc.ProcessId == sendBundle.ForStage.InternalComputation.Controller.Configuration.ProcessID)
                {
                    var postbox = new Fiber(this.channelID, loc.VertexId, this.sendBundle.GetFiber(loc.VertexId),
                                            this.mailbox, controller, consumerVertexId, consumerProcessId);
                    this.postboxes[loc.VertexId] = postbox;
                }
            }
            Logging.Info("Allocated CentralizedProgressChannel [{0}]: {1} -> {2}", this.channelID, sendBundle, recvBundle);
            NaiadTracing.Trace.ChannelInfo(ChannelId, SourceStage.StageId, DestinationStage.StageId, true, true);
        }
コード例 #15
0
        public void Auth_Error_Invalid()
        {
            var controller = new InternalController(Manager);

            Assert.ThrowsAsync <InvalidCredentials>(() => controller.Login(new Models.Input.Auth.Login()
            {
                Email    = "dev@localhost123456789",
                Password = "******"
            }));

            //Check that bot login is not allowed using standard user systems
            Context.Users.Last().IsBot = true;
            Assert.ThrowsAsync <InvalidCredentials>(() => controller.Login(new Models.Input.Auth.Login()
            {
                Email    = "dev@localhost",
                Password = "******"
            }));
        }
コード例 #16
0
ファイル: SubgraphManager.cs プロジェクト: sherryshare/Naiad
        public BaseGraphManager(InternalController controller, int index)
        {
            this.controller       = controller;
            this.defaultPlacement = this.controller.DefaultPlacement;
            this.index            = index;

            this.contextManager = new Naiad.Dataflow.TimeContextManager(this);

            if (this.controller.Configuration.DistributedProgressTracker)
            {
                this.progressTracker = new DistributedProgressTracker(this);
            }
            else
            {
                this.progressTracker = new CentralizedProgressTracker(this);
            }

            this.InitializeReporting(this.controller.Configuration.DomainReporting, this.controller.Configuration.InlineReporting, this.controller.Configuration.AggregateReporting);
        }
コード例 #17
0
        public async Task Register()
        {
            var controller = new InternalController(Manager);

            //Creation
            await PostTestUser(controller);

            Assert.AreEqual(1, Smtp.SentEmailCount);
            Assert.AreEqual("WikiLibs API Server", Smtp.LastSendEmail.Subject);
            Assert.AreEqual(Shared.Modules.Smtp.Models.UserRegistration.Template, Smtp.LastSendEmail.Template);
            Assert.AreEqual("*****@*****.**", Smtp.LastSendEmail.Recipients.First().Email);
            Assert.AreEqual(Context.Users.Last().FirstName + " " + Context.Users.Last().LastName, Smtp.LastSendEmail.Recipients.First().Name);
            var data = Smtp.LastSendEmail.Model as Shared.Modules.Smtp.Models.UserRegistration;

            Assert.AreEqual(Context.Users.Last().FirstName + " " + Context.Users.Last().LastName, data.UserName);
            Assert.AreEqual(Context.Users.Last().Confirmation, data.ConfirmCode);
            Assert.AreEqual(2, Context.Users.Count());
            Assert.IsNotNull(Context.Users.Last().Confirmation);

            //Check we can't login
            Assert.ThrowsAsync <InvalidCredentials>(() => controller.Login(new Models.Input.Auth.Login()
            {
                Email    = "*****@*****.**",
                Password = "******"
            }));

            //Confirmation
            await controller.Confirm(data.ConfirmCode);

            Assert.AreEqual(2, Context.Users.Count());
            Assert.IsNull(Context.Users.Last().Confirmation);

            //Check we can login
            var res = await controller.Login(new Models.Input.Auth.Login()
            {
                Email    = "*****@*****.**",
                Password = "******"
            }) as JsonResult;

            var token = res.Value as string;

            Assert.IsNotNull(token);
        }
コード例 #18
0
        /// <summary>
        /// Creates a new thread scheduler
        /// </summary>
        /// <param name="n">The friendly name of this scheduler</param>
        /// <param name="i">The id of the core this thread is affinitized to</param>
        /// <param name="c">The internal controller reference</param>
        internal Scheduler(string n, int i, InternalController c)
        {
            Name       = n;
            Index      = i;
            Controller = c;

            //this.postOffice = new PostOffice(this);

            this.thread      = new Thread(this.InternalStart);
            this.thread.Name = string.Format("Naiad Worker {0}", i);
            Logging.Info("Scheduler {0} created", i);

            this.deadlockTimeout = c.Configuration.DeadlockTimeout;

            this.statistics = new long[(int)RuntimeStatistic.NUM_STATISTICS];

            this.sendPool = c.Configuration.SendBufferPolicy == Configuration.SendBufferMode.PerWorker
                ? new BoundedBufferPool2 <byte>(c.Configuration.SendPageSize, c.Configuration.SendPageCount)
                : null;
        }
コード例 #19
0
        public BaseComputation(InternalController controller, int index)
        {
            this.controller       = controller;
            this.defaultPlacement = this.controller.DefaultPlacement;
            this.index            = index;

            this.ShutdownCounter = new CountdownEvent(controller.Workers.Count);

            this.contextManager = new Microsoft.Research.Naiad.Dataflow.TimeContextManager(this);

            if (this.controller.Configuration.DistributedProgressTracker)
            {
                this.progressTracker = new DistributedProgressTracker(this);
            }
            else
            {
                this.progressTracker = new CentralizedProgressTracker(this);
            }

            this.InitializeReporting(this.controller.Configuration.DomainReporting, this.controller.Configuration.InlineReporting, this.controller.Configuration.AggregateReporting);
        }
コード例 #20
0
        /// <summary>
        /// 設定を保存
        /// </summary>
        private void SaveSettings()
        {
            // 再起動メッセージフラグ
            bool rebootMessage = false;

            if (textBox1.Text == "" || textBox2.Text == "")
            {
                InternalController.ErrorMessageShow("ディレクトリが選択されていません。");
                return;
            }

            // HoI4本体ディレクトリが本当に合っているか(commonディレクトリとgfxディレクトリとhoi4.exeの存在確認)
            if (Directory.Exists(textBox1.Text + @"\common") == true && Directory.Exists(textBox1.Text + @"\gfx") == true && File.Exists(textBox1.Text + @"\hoi4.exe") == true)
            {
                Properties.Settings.Default.hoi4dir         = textBox1.Text;
                Properties.Settings.Default.moddir          = textBox2.Text;
                Properties.Settings.Default.afterOpenFolder = checkBox1.Checked;
                Properties.Settings.Default.Save();
            }
            else
            {
                InternalController.ErrorMessageShow("HoI4本体のディレクトリが間違っています。正しいディレクトリを選択してください。");
                return;
            }

            if (checkBox2.Checked == true && checkBox3.Checked == true && checkBox4.Checked == true && checkBox5.Checked == true)
            {
                if (checkBox6.Checked == false)
                {
                    InternalController.ErrorMessageShow("デフォルトイデオロギーをすべて無効化するには、一つ以上カスタムイデオロギーを追加してください。");
                    return;
                }
                else
                {
                    Properties.Settings.Default.neutralityDisabled = checkBox2.Checked;
                    Properties.Settings.Default.democraticDisabled = checkBox3.Checked;
                    Properties.Settings.Default.fascismDisabled    = checkBox4.Checked;
                    Properties.Settings.Default.communismDisabled  = checkBox5.Checked;
                    Properties.Settings.Default.Save();

                    rebootMessage = true;
                }
            }
            else
            {
                Properties.Settings.Default.neutralityDisabled = checkBox2.Checked;
                Properties.Settings.Default.democraticDisabled = checkBox3.Checked;
                Properties.Settings.Default.fascismDisabled    = checkBox4.Checked;
                Properties.Settings.Default.communismDisabled  = checkBox5.Checked;
                Properties.Settings.Default.Save();
                rebootMessage = true;
            }

            if (checkBox6.Checked == false)
            {
                Properties.Settings.Default.customIdeologiesEnabled = false;
                Properties.Settings.Default.customIdeologiesInternalName.Clear();
                Properties.Settings.Default.customIdeologiesInternalName.Add("temp");
                Properties.Settings.Default.customIdeologiesName.Clear();
                Properties.Settings.Default.customIdeologiesName.Add("temp");
                Properties.Settings.Default.Save();

                rebootMessage = true;
            }
            else
            {
                Properties.Settings.Default.customIdeologiesEnabled = true;

                if (listBox1.Items.Count != 0)
                {
                    // 一度設定を初期化する
                    Properties.Settings.Default.customIdeologiesInternalName.Clear();
                    Properties.Settings.Default.customIdeologiesName.Clear();

                    string[] list          = listBox1.Items.Cast <string>().ToArray();
                    string[] names         = new string[listBox1.Items.Count + 1];
                    string[] internalNames = new string[listBox1.Items.Count + 1];

                    for (int cnt = 0; cnt < listBox1.Items.Count; cnt++)
                    {
                        names[cnt]         = list[cnt].Substring(0, list[cnt].IndexOf(" ("));
                        internalNames[cnt] = list[cnt].Substring(list[cnt].IndexOf(" (") + 2).TrimEnd(')');
                    }

                    Properties.Settings.Default.customIdeologiesInternalName.AddRange(internalNames);
                    Properties.Settings.Default.customIdeologiesName.AddRange(names);
                    Properties.Settings.Default.Save();

                    rebootMessage = true;
                }
                else
                {
                    InternalController.ErrorMessageShow("カスタムイデオロギーの追加が有効化されている場合、カスタムイデオロギーリストを空にすることはできません。");
                    return;
                }
            }

            // 再起動メッセージ
            if (rebootMessage == true)
            {
                InternalController.InfoMessageShow("反映に再起動が必要な設定が変更されました。\n再起動は[ファイル] - [再起動]で行えます。");
            }


            this.Close();
        }
コード例 #21
0
 public void Setup()
 {
     _internalController = new InternalController();
 }
コード例 #22
0
            public Fiber(int channelID, int vertexID, VertexOutput <Update, Empty> sender, CentralizedProgressChannel.Mailbox localMailbox, InternalController controller, int receiverVertexId, int receiverProcessId)
            {
                this.channelID      = channelID;
                this.vertexID       = vertexID;
                this.sender         = sender;
                this.localMailbox   = localMailbox;
                this.networkChannel = controller.NetworkChannel;
                this.numProcesses   = controller.Configuration.Processes;
                int processID = controller.Configuration.ProcessID;

                this.receiverVertexId  = receiverVertexId;
                this.receiverProcessId = receiverProcessId;

                if (this.networkChannel != null)
                {
                    this.encoder = new AutoSerializedMessageEncoder <Update, Empty>(0, this.sender.Vertex.Stage.InternalComputation.Index << 16 | this.channelID, this.networkChannel.GetBufferPool(0, -1), this.networkChannel.SendPageSize, controller.SerializationFormat, SerializedMessageType.Data, () => this.networkChannel.GetSequenceNumber(-1));
                    this.encoder.CompletedMessage += (o, a) => { this.SendPageContents(a.Hdr, a.Segment); };
                }
            }
コード例 #23
0
            public Fiber(int channelID, int vertexID, VertexOutput <Update, Empty> sender, ProgressChannel.Mailbox localMailbox, InternalController controller)
            {
                this.processId      = controller.Configuration.ProcessID;
                this.channelID      = channelID;
                this.vertexID       = vertexID;
                this.sender         = sender;
                this.localMailbox   = localMailbox;
                this.networkChannel = controller.NetworkChannel;
                this.numProcesses   = controller.Configuration.Processes;
                int processID = controller.Configuration.ProcessID;

                if (this.networkChannel != null)
                {
                    this.encoder = new AutoSerializedMessageEncoder <Update, Empty>(-1, this.sender.Vertex.Stage.InternalComputation.Index << 16 | this.channelID, this.networkChannel.GetBufferPool(-1, -1), this.networkChannel.SendPageSize, controller.SerializationFormat, SerializedMessageType.Data, () => this.GetNextSequenceNumber());
                    this.encoder.CompletedMessage += (o, a) => { this.BroadcastPageContents(a.Hdr, a.Segment); /* Console.WriteLine("Sending progress message"); */ };
                }
            }
コード例 #24
0
ファイル: MessageDelivery.cs プロジェクト: omidm/naiad
 public PostOffice(Scheduling.Scheduler scheduler)
 {
     this.scheduler  = scheduler;
     this.Controller = scheduler.Controller;
     this.mailboxes  = new List <UntypedLocalMailbox>();
 }
コード例 #25
0
 public PinnedScheduler(string n, int i, InternalController c)
     : base(n, i, c)
 {
 }
コード例 #26
0
        public void Confirm_Error_Null()
        {
            var controller = new InternalController(Manager);

            Assert.ThrowsAsync <InvalidCredentials>(() => controller.Confirm(null));
        }
コード例 #27
0
            public Fiber(int channelID, int shardID, VertexOutput <Int64, Pointstamp> sender, CentralizedProgressChannel.Mailbox localMailbox, InternalController controller, int receiverShardId, int receiverProcessId)
            {
                this.channelID      = channelID;
                this.shardID        = shardID;
                this.sender         = sender;
                this.localMailbox   = localMailbox;
                this.networkChannel = controller.NetworkChannel;
                this.numProcesses   = controller.Configuration.Processes;
                int processID = controller.Configuration.ProcessID;

                this.receiverShardId   = receiverShardId;
                this.receiverProcessId = receiverProcessId;

                if (this.networkChannel != null)
                {
                    this.encoder = new AutoSerializedMessageEncoder <Int64, Pointstamp>(0,
                                                                                        this.sender.Vertex.Stage.InternalGraphManager.Index << 16 | this.channelID, this.networkChannel.GetBufferPool(0, -1), this.networkChannel.SendPageSize, AutoSerializationMode.Basic, SerializedMessageType.Data,
                                                                                        () => this.networkChannel.GetSequenceNumber(-1));
                    this.encoder.CompletedMessage += (o, a) => { this.SendPageContents(a.Hdr, a.Segment); };
                }
            }
コード例 #28
0
ファイル: Networking.cs プロジェクト: omidm/naiad
        //TOCHECK: config is passed in but inside the method we use this.Controller.Configuration a lot
        internal TcpNetworkChannel(int id, InternalController controller, Configuration config)
        {
            this.id = id;
            this.Controller = controller;

            this.localProcessID = this.Controller.Configuration.ProcessID;

            this.graphmailboxes = new List<List<List<UntypedMailbox>>>();

            this.connections = new List<ConnectionState>();

            this.sendConnectionCountdown = new CountdownEvent(1);
            this.recvConnectionCountdown = new CountdownEvent(1);

            this.shutdownRecvCountdown = new CountdownEvent(1);
            this.shutdownSendCountdown = new CountdownEvent(1);

            this.startupRecvCountdown = new CountdownEvent(1);

            this.startCommunicatingEvent = new ManualResetEvent(false);

            if (controller.Configuration.UseNetworkBroadcastWakeup)
            {
                this.useBroadcastWakeup = true;
                this.wakeUpEvent = new EventCount();
            }
            else
            {
                this.useBroadcastWakeup = false;
                this.wakeUpEvent = null;
            }

            this.broadcastSequenceNumber = 1;

            // UDP broadcast setup.
            if (this.Controller.Configuration.Broadcast == Configuration.BroadcastProtocol.UdpOnly
            || this.Controller.Configuration.Broadcast == Configuration.BroadcastProtocol.TcpUdp)
            {

                this.udpClient = new UdpClient(new IPEndPoint(this.Controller.Configuration.Endpoints[this.Controller.Configuration.ProcessID].Address, this.Controller.Configuration.BroadcastAddress.Port));
                
                IPEndPoint multicastGroupEndpoint = this.Controller.Configuration.BroadcastAddress;
                byte[] addrbytes = multicastGroupEndpoint.Address.GetAddressBytes();

                Logging.Progress("Configuring UDP broadcast channel using address {0}", multicastGroupEndpoint);

                if (this.Controller.Configuration.ProcessID != 0)
                {
                    if ((addrbytes[0] & 0xF0) == 224)
                    {
                        //Console.WriteLine("Multicast!");
                        this.udpClient.JoinMulticastGroup(multicastGroupEndpoint.Address);
                    }
                    else
                    {
                        //Console.WriteLine("Broadcast?");
                    }
                    Thread udpclientThread = new Thread(() => this.UdpReceiveThread(multicastGroupEndpoint));
                    udpclientThread.IsBackground = true;
                    udpclientThread.Start();
                }
                else
                {
                    if ((addrbytes[0] & 0xF0) == 224)
                    {
                        //Console.WriteLine("Multicast!");
                        this.udpClient.Connect(multicastGroupEndpoint);
                    }
                    else
                    {
                        //Console.WriteLine("Broadcast?");
                        this.udpClient.Connect(multicastGroupEndpoint);
                        this.udpClient.EnableBroadcast = true;
                    }
                }
            }
 
            this.sendPageSize = this.Controller.Configuration.SendPageSize;

            for (int i = 0; i < this.Controller.Configuration.Endpoints.Length; ++i)
                if (i != this.Controller.Configuration.ProcessID)
                    this.AddEndPointOutgoing(i, this.Controller.Configuration.Endpoints[i]);

            this.MAX_SEND_SIZE = 32 * this.sendPageSize;

            this.globalPool = new BoundedBufferPool2<byte>(this.sendPageSize, this.Controller.Configuration.SendPageCount);
        }