// CurrentShardRegionState private static Proto.Msg.CurrentShardRegionState CurrentShardRegionStateToProto(CurrentShardRegionState state) { var p = new Proto.Msg.CurrentShardRegionState(); foreach (var shard in state.Shards) { p.Shards.Add(ShardStateToProto(shard)); } return(p); }
public void Cluster_sharding_with_remember_entities_should_start_new_nodes_with_different_extractor_and_have_the_entities_running_on_the_right_shards() { Within(TimeSpan.FromSeconds(30), () => { // start it with a new shard id extractor, which will put the entities // on different shards RunOn(() => { Watch(Region(Sys)); Cluster.Get(Sys).Leave(Cluster.Get(Sys).SelfAddress); ExpectTerminated(Region(Sys)); AwaitAssert(() => { Cluster.Get(Sys).IsTerminated.Should().BeTrue(); }); }, _config.Second, _config.Third); EnterBarrier("first-cluster-terminated"); // no sharding nodes left of the original cluster, start a new nodes RunOn(() => { var sys2 = ActorSystem.Create(Sys.Name, Sys.Settings.Config); var probe2 = CreateTestProbe(sys2); if (!IsDDataMode) { // setup Persistence Persistence.Persistence.Instance.Apply(sys2); sys2.ActorSelection(Node(_config.First) / "system" / "akka.persistence.journal.MemoryJournal").Tell(new Identify(null), probe2.Ref); var sharedStore = probe2.ExpectMsg <ActorIdentity>(TimeSpan.FromSeconds(10)).Subject; sharedStore.Should().NotBeNull(); MemoryJournalShared.SetStore(sharedStore, sys2); } Cluster.Get(sys2).Join(Node(_config.First).Address); StartShardingWithExtractor2(sys2, probe2.Ref); probe2.ExpectMsg <Started>(TimeSpan.FromSeconds(20)); CurrentShardRegionState stats = null; Within(TimeSpan.FromSeconds(10), () => { AwaitAssert(() => { Region(sys2).Tell(GetShardRegionState.Instance); var reply = ExpectMsg <CurrentShardRegionState>(); reply.Shards.Should().NotBeEmpty(); stats = reply; }); }); foreach (var shardState in stats.Shards) { foreach (var entityId in shardState.EntityIds) { var calculatedShardId = extractShardId2(int.Parse(entityId)); calculatedShardId.ShouldAllBeEquivalentTo(shardState.ShardId); } } EnterBarrier("verified"); Shutdown(sys2); }, _config.Second, _config.Third); RunOn(() => { EnterBarrier("verified"); }, _config.First); EnterBarrier("done"); }); }