-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sharding update #3524
Merged
Merged
Sharding update #3524
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e2053b1
Provide access to known shard types
zbynek001 2310d5a
Separate sharding regions and proxies
zbynek001 e59f7c9
Fix race in ClusterShardingFailureSpec
zbynek001 f9c46a4
Better warning message on cluster sharding registration
zbynek001 dd61262
entityId => Behavior in ClusterSharding API
zbynek001 1bdd840
sharding tests updated
zbynek001 8cf08d0
headers fixed, docs updated
zbynek001 b2192e5
ClusterSharding: automatically choose start or startProxy by a node role
zbynek001 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/contrib/cluster/Akka.Cluster.Sharding.Tests/GetShardTypeNamesSpec.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
//----------------------------------------------------------------------- | ||
// <copyright file="ClusterShardingConfigSpec.cs" company="Akka.NET Project"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copyright headers have the wrong file names |
||
// Copyright (C) 2009-2018 Lightbend Inc. <http://www.lightbend.com> | ||
// Copyright (C) 2013-2018 .NET Foundation <https://github.com/akkadotnet/akka.net> | ||
// </copyright> | ||
//----------------------------------------------------------------------- | ||
|
||
using System; | ||
using Akka.Cluster.Tools.Singleton; | ||
using Akka.Configuration; | ||
using Akka.TestKit.TestActors; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Akka.Cluster.Sharding.Tests | ||
{ | ||
public class GetShardTypeNamesSpec : Akka.TestKit.Xunit2.TestKit | ||
{ | ||
public GetShardTypeNamesSpec() : base(GetConfig()) | ||
{ | ||
} | ||
|
||
public static Config GetConfig() | ||
{ | ||
return ConfigurationFactory.ParseString("akka.actor.provider = \"Akka.Cluster.ClusterActorRefProvider, Akka.Cluster\"") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
|
||
.WithFallback(Sharding.ClusterSharding.DefaultConfig()) | ||
.WithFallback(DistributedData.DistributedData.DefaultConfig()) | ||
.WithFallback(ClusterSingletonManager.DefaultConfig()); | ||
} | ||
|
||
[Fact] | ||
public void GetShardTypeNames_must_contain_empty_when_join_cluster_without_shards() | ||
{ | ||
ClusterSharding.Get(Sys).ShardTypeNames.Should().BeEmpty(); | ||
} | ||
|
||
[Fact] | ||
public void GetShardTypeNames_must_contain_started_shards_when_started_2_shards() | ||
{ | ||
Cluster.Get(Sys).Join(Cluster.Get(Sys).SelfAddress); | ||
var settings = ClusterShardingSettings.Create(Sys); | ||
ClusterSharding.Get(Sys).Start("type1", EchoActor.Props(this), settings, ExtractEntityId, ExtractShardId); | ||
ClusterSharding.Get(Sys).Start("type2", EchoActor.Props(this), settings, ExtractEntityId, ExtractShardId); | ||
|
||
ClusterSharding.Get(Sys).ShardTypeNames.ShouldBeEquivalentTo(new string[] { "type1", "type2" }); | ||
} | ||
|
||
private Tuple<string, object> ExtractEntityId(object message) | ||
{ | ||
switch (message) | ||
{ | ||
case int i: | ||
return new Tuple<string, object>(i.ToString(), message); | ||
} | ||
throw new NotSupportedException(); | ||
} | ||
|
||
private string ExtractShardId(object message) | ||
{ | ||
switch (message) | ||
{ | ||
case int i: | ||
return (i % 10).ToString(); | ||
} | ||
throw new NotSupportedException(); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be
nameof(CounterSupervisor)
.