Akka.Cluster.Sharding.Tests.ClusterShardingSpec.Persistent_cluster_shards_should_recover_entities_upon_restart C# (CSharp) Метод

Persistent_cluster_shards_should_recover_entities_upon_restart() приватный Метод

private Persistent_cluster_shards_should_recover_entities_upon_restart ( ) : void
Результат void
        public void Persistent_cluster_shards_should_recover_entities_upon_restart()
        {
            Within(TimeSpan.FromSeconds(50), () =>
            {
                RunOn(() =>
                {
                    var x = _persistentEntitiesRegion.Value;
                    var y = _anotherPersistentRegion.Value;
                }, _third, _fourth, _fifth);
                EnterBarrier("persistent-start");

                RunOn(() =>
                {
                    //Create an increment counter 1
                    _persistentEntitiesRegion.Value.Tell(new Counter.EntityEnvelope(1, Counter.Increment.Instance));
                    _persistentEntitiesRegion.Value.Tell(new Counter.EntityEnvelope(1, new Counter.Get(1)));
                    ExpectMsg(1);

                    //Shut down the shard and confirm it's dead
                    var shard = Sys.ActorSelection(LastSender.Path.Parent);
                    var region = Sys.ActorSelection(LastSender.Path.Parent.Parent);

                    // stop shard
                    region.Tell(new PersistentShardCoordinator.HandOff("1"));
                    ExpectMsg<PersistentShardCoordinator.ShardStopped>(s => s.Shard == "1", TimeSpan.FromSeconds(10));

                    var probe = CreateTestProbe();
                    AwaitAssert(() =>
                    {
                        shard.Tell(new Identify(1), probe.Ref);
                        probe.ExpectMsg<ActorIdentity>(i => i.MessageId.Equals(1) && i.Subject == null, TimeSpan.FromSeconds(1));
                    }, TimeSpan.FromSeconds(5), TimeSpan.FromMilliseconds(500));

                    //Get the path to where the shard now resides
                    _persistentEntitiesRegion.Value.Tell(new Counter.Get(13));
                    ExpectMsg(0);

                    //Check that counter 1 is now alive again, even though we have
                    // not sent a message to it via the ShardRegion
                    var counter1 = Sys.ActorSelection(LastSender.Path.Parent / "1");
                    counter1.Tell(new Identify(2));
                    Assert.NotNull(ExpectMsg<ActorIdentity>(TimeSpan.FromSeconds(3)).Subject);

                    counter1.Tell(new Counter.Get(1));
                    ExpectMsg(1);
                }, _third);
                EnterBarrier("after-shard-restart");

                RunOn(() =>
                {
                    //Check a second region does not share the same persistent shards

                    //Create a separate 13 counter
                    _anotherPersistentRegion.Value.Tell(new Counter.EntityEnvelope(13, Counter.Increment.Instance));
                    _anotherPersistentRegion.Value.Tell(new Counter.Get(13));
                    ExpectMsg(1);

                    //Check that no counter "1" exists in this shard
                    var secondCounter1 = Sys.ActorSelection(LastSender.Path.Parent / "1");
                    secondCounter1.Tell(new Identify(3));
                    ExpectMsg<ActorIdentity>(i => i.MessageId.Equals(3) && i.Subject == null, TimeSpan.FromSeconds(3));
                }, _fourth);
                EnterBarrier("after-12");
            });
        }