当前位置: 首页>>代码示例>>C#>>正文


C# Address.Should方法代码示例

本文整理汇总了C#中Akka.Actor.Address.Should方法的典型用法代码示例。如果您正苦于以下问题:C# Address.Should方法的具体用法?C# Address.Should怎么用?C# Address.Should使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Akka.Actor.Address的用法示例。


在下文中一共展示了Address.Should方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: JoinClusterWithOneOfflineSeedNode

        public void JoinClusterWithOneOfflineSeedNode()
        {
            Within(TimeSpan.FromSeconds(30), () =>
            {
                RunOn(() =>
                {
                    Sys.ActorOf(c => c.Receive<UniqueAddress>((address, ctx) =>
                    {
                        _seedUniqueAddress = address;
                        ctx.Sender.Tell("ok");
                    }), "address-receiver");
                    Sys.ActorOf(Props.Create(() => new DomainEventLogger()), "cluster-logger");


                }, _config.NonSeed);
                EnterBarrier("addr-receiver-ready");

                RunOn(() =>
                {
                    _seedUniqueAddress = Cluster.Get(_seedSystem.Value).SelfUniqueAddress;
                    _seedSystem.Value.ActorOf(Props.Create(() => new DomainEventLogger()), "clusterLogger");
                    var probe = CreateTestProbe(_seedSystem.Value);
                    _seedSystem.Value.ActorSelection(new RootActorPath(GetAddress(_config.NonSeed)) / "user" / "address-receiver").Tell(_seedUniqueAddress, probe.Ref);
                    probe.ExpectMsg("ok", TimeSpan.FromSeconds(5));
                }, _config.Seed);
                EnterBarrier("addr-transferred");

                RunOn(() =>
                {
                    Cluster.Get(_seedSystem.Value).JoinSeedNodes(SeedNodes);
                    AwaitCondition(() => Cluster.Get(_seedSystem.Value).ReadView.IsSingletonCluster);
                    _seedSystem.Value.ActorOf(Props.Create(() => new LeaderSynchronizer()), "leader-sync");
                }, _config.Seed);
                EnterBarrier("seed-self-joined");

                RunOn(() =>
                {
                    var unreachableNodeAddress = Cluster.Get(_unavailableSeedSystem.Value).SelfAddress;
                    // terminate the unreachableSeedNode
                    Shutdown(_unavailableSeedSystem.Value, RemainingOrDefault);

                    Cluster.JoinSeedNodes(SeedNodes.Add(unreachableNodeAddress)); // append the unreachable node address
                    AwaitMembersUp(2);
                    Sys.ActorOf(Props.Create(() => new LeaderSynchronizer()), "leader-sync");
                }, _config.NonSeed);
                EnterBarrier("formed-cluster");

               
                /*
                 * Verify that both nodes agree on who the leader is
                 */

                RunOn(() =>
                {
                    var addr2 = GetAddress(_config.NonSeed);
                    var probe2 = CreateTestProbe(_seedSystem.Value);
                    AwaitAssert(() =>
                    {
                        _seedSystem.Value.ActorSelection(new RootActorPath(addr2) / "user" / "leader-sync")
                            .Tell("leader", probe2.Ref);
                        _verifiedLeader = probe2.ExpectMsg<Address>();
                        _verifiedLeader.Should().Be(Cluster.Get(_seedSystem.Value).State.Leader);
                    });


                }, _config.Seed);

                RunOn(() =>
                {
                    AwaitAssert(() =>
                    {
                        _verifiedLeader =
                            Sys.ActorSelection(new RootActorPath(SeedUniqueAddress.Address) / "user" / "leader-sync")
                                .Ask<Address>("leader")
                                .Result;
                        _verifiedLeader.Should().Be(Cluster.State.Leader);
                    });
                }, _config.NonSeed);
                EnterBarrier("verified-leader");
            });
        }
开发者ID:Micha-kun,项目名称:akka.net,代码行数:81,代码来源:JoinWithOfflineSeedNodeSpec.cs


注:本文中的Akka.Actor.Address.Should方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。