/// <summary>
        /// Creates partition actors on cluster.
        /// </summary>
        protected void InitPartitionActorsDist()
        {
            this.ActorMap = CreatePartitionMap();

            for (int i = 0; i < this.ActorMap.Count; i++)
            {
                //string actorName = $"{nameof(DictNodeActor)}-{Guid.NewGuid()}-{this.ActorMap[i].NodeIndx}-{this.ActorMap[i].PartitionIndx}";

                ActorReference actorRef1 = m_ActorSystem.CreateActor <HtmActor>(1);

                try
                {
                    this.ActorMap[i].ActorRef = m_ActorSystem.CreateActor <HtmActor>(new ActorId(this.ActorMap[i].PartitionIndx));

                    var result = ((ActorReference)this.ActorMap[i].ActorRef).Ask <int>(new CreateDictNodeMsg()
                    {
                        HtmAkkaConfig = this.HtmConfig,
                    }, this.Config.ConnectionTimeout, this.m_ActorMap[i].NodePath).Result;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
示例#2
0
        public void TellTest()
        {
            Debug.WriteLine($"Start of {nameof(TellTest)}");

            var         cfg       = GetLocaSysConfig();
            ActorSystem sysLocal  = new AkkaSb.Net.ActorSystem($"{nameof(TellTest)}/local", cfg);
            ActorSystem sysRemote = new ActorSystem($"{nameof(TellTest)}/remote", GetRemoteSysConfig());

            CancellationTokenSource src = new CancellationTokenSource();

            var task = Task.Run(() =>
            {
                sysRemote.Start(src.Token);
            });

            ActorReference actorRef1 = sysLocal.CreateActor <MyActor>(1);

            actorRef1.Tell("message 1").Wait();

            actorRef1.Tell(new TestClass()).Wait();

            ActorReference actorRef2 = sysLocal.CreateActor <MyActor>(2);

            actorRef2.Tell("message 2").Wait();

            while (true)
            {
                if (receivedMessages.Count == 3)
                {
                    Assert.IsTrue(receivedMessages.Values.Contains("message 1"));
                    Assert.IsTrue(receivedMessages.Values.Contains("message 2"));
                    Assert.IsTrue(receivedMessages.Values.Contains("UnitTestsProject.SbAkkaTest+TestClass"));
                    src.Cancel();
                    break;
                }
                Thread.Sleep(250);
            }

            task.Wait();

            Debug.WriteLine($"End of {nameof(TellTest)}");
        }