diff --git a/src/.nuget/NuGet.exe b/src/.nuget/NuGet.exe
index 9f8781de0db..324daa842c5 100644
Binary files a/src/.nuget/NuGet.exe and b/src/.nuget/NuGet.exe differ
diff --git a/src/Akka.sln b/src/Akka.sln
index 80cdfe49a89..7da27222e6c 100644
--- a/src/Akka.sln
+++ b/src/Akka.sln
@@ -232,27 +232,6 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.Serialization.TestKit", "contrib\serializers\Akka.Serialization.TestKit\Akka.Serialization.TestKit.csproj", "{CAA97041-CFC0-4081-9BD2-8B139E62A611}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.Serialization.WireTests", "contrib\serializers\Akka.Serialization.WireTests\Akka.Serialization.WireTests.csproj", "{402FA351-D6C6-40FD-8868-F07156035919}"
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Cluster", "Cluster", "{76F58DC4-19F1-43EF-A6E2-EC1CC8395AC5}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.Cluster.Sharding", "contrib\cluster\Akka.Cluster.Sharding\Akka.Cluster.Sharding.csproj", "{A05C31E8-0246-46A1-B3BC-4D6FE7A9AA49}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.Cluster.Tools", "contrib\cluster\Akka.Cluster.Tools\Akka.Cluster.Tools.csproj", "{5CF8A8BE-B634-473F-BB01-EBA878746BD4}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.Cluster.Tools.Tests", "contrib\cluster\Akka.Cluster.Tools.Tests\Akka.Cluster.Tools.Tests.csproj", "{9D8D62C7-7B4B-4CDF-8FE8-675DB71F6B21}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.Cluster.Sharding.Tests", "contrib\cluster\Akka.Cluster.Sharding.Tests\Akka.Cluster.Sharding.Tests.csproj", "{B369F314-4D37-4AC1-B4FB-64FF671AF0BC}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ClusterTools", "ClusterTools", "{B1DDEC01-8525-4C38-B820-7C44F5A2930B}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ClusterSharding", "ClusterSharding", "{21E02199-F0E0-4818-A7D6-CBF28F79920D}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClusterSharding.Node", "examples\Cluster\ClusterSharding\ClusterSharding.Node\ClusterSharding.Node.csproj", "{30A0B17D-B913-49AB-8CBB-8DF383AB7A52}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClusterToolsExample.Shared", "examples\Cluster\ClusterTools\ClusterToolsExample.Shared\ClusterToolsExample.Shared.csproj", "{88D7D845-2F50-4D37-9026-B0A8353D0E8D}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClusterToolsExample.Seed", "examples\Cluster\ClusterTools\ClusterToolsExample.Seed\ClusterToolsExample.Seed.csproj", "{ED00E6F4-2B5C-4F16-ADE4-45E4A73C17B8}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClusterToolsExample.Node", "examples\Cluster\ClusterTools\ClusterToolsExample.Node\ClusterToolsExample.Node.csproj", "{337A85B5-4A7C-4883-8634-46E7E52A765F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -875,70 +854,6 @@ Global
{402FA351-D6C6-40FD-8868-F07156035919}.Release Mono|Any CPU.Build.0 = Release|Any CPU
{402FA351-D6C6-40FD-8868-F07156035919}.Release|Any CPU.ActiveCfg = Release|Any CPU
{402FA351-D6C6-40FD-8868-F07156035919}.Release|Any CPU.Build.0 = Release|Any CPU
- {A05C31E8-0246-46A1-B3BC-4D6FE7A9AA49}.Debug Mono|Any CPU.ActiveCfg = Debug|Any CPU
- {A05C31E8-0246-46A1-B3BC-4D6FE7A9AA49}.Debug Mono|Any CPU.Build.0 = Debug|Any CPU
- {A05C31E8-0246-46A1-B3BC-4D6FE7A9AA49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A05C31E8-0246-46A1-B3BC-4D6FE7A9AA49}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A05C31E8-0246-46A1-B3BC-4D6FE7A9AA49}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
- {A05C31E8-0246-46A1-B3BC-4D6FE7A9AA49}.Release Mono|Any CPU.Build.0 = Release|Any CPU
- {A05C31E8-0246-46A1-B3BC-4D6FE7A9AA49}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A05C31E8-0246-46A1-B3BC-4D6FE7A9AA49}.Release|Any CPU.Build.0 = Release|Any CPU
- {5CF8A8BE-B634-473F-BB01-EBA878746BD4}.Debug Mono|Any CPU.ActiveCfg = Debug|Any CPU
- {5CF8A8BE-B634-473F-BB01-EBA878746BD4}.Debug Mono|Any CPU.Build.0 = Debug|Any CPU
- {5CF8A8BE-B634-473F-BB01-EBA878746BD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {5CF8A8BE-B634-473F-BB01-EBA878746BD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {5CF8A8BE-B634-473F-BB01-EBA878746BD4}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
- {5CF8A8BE-B634-473F-BB01-EBA878746BD4}.Release Mono|Any CPU.Build.0 = Release|Any CPU
- {5CF8A8BE-B634-473F-BB01-EBA878746BD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {5CF8A8BE-B634-473F-BB01-EBA878746BD4}.Release|Any CPU.Build.0 = Release|Any CPU
- {9D8D62C7-7B4B-4CDF-8FE8-675DB71F6B21}.Debug Mono|Any CPU.ActiveCfg = Debug|Any CPU
- {9D8D62C7-7B4B-4CDF-8FE8-675DB71F6B21}.Debug Mono|Any CPU.Build.0 = Debug|Any CPU
- {9D8D62C7-7B4B-4CDF-8FE8-675DB71F6B21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {9D8D62C7-7B4B-4CDF-8FE8-675DB71F6B21}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {9D8D62C7-7B4B-4CDF-8FE8-675DB71F6B21}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
- {9D8D62C7-7B4B-4CDF-8FE8-675DB71F6B21}.Release Mono|Any CPU.Build.0 = Release|Any CPU
- {9D8D62C7-7B4B-4CDF-8FE8-675DB71F6B21}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {9D8D62C7-7B4B-4CDF-8FE8-675DB71F6B21}.Release|Any CPU.Build.0 = Release|Any CPU
- {B369F314-4D37-4AC1-B4FB-64FF671AF0BC}.Debug Mono|Any CPU.ActiveCfg = Debug|Any CPU
- {B369F314-4D37-4AC1-B4FB-64FF671AF0BC}.Debug Mono|Any CPU.Build.0 = Debug|Any CPU
- {B369F314-4D37-4AC1-B4FB-64FF671AF0BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {B369F314-4D37-4AC1-B4FB-64FF671AF0BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {B369F314-4D37-4AC1-B4FB-64FF671AF0BC}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
- {B369F314-4D37-4AC1-B4FB-64FF671AF0BC}.Release Mono|Any CPU.Build.0 = Release|Any CPU
- {B369F314-4D37-4AC1-B4FB-64FF671AF0BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {B369F314-4D37-4AC1-B4FB-64FF671AF0BC}.Release|Any CPU.Build.0 = Release|Any CPU
- {30A0B17D-B913-49AB-8CBB-8DF383AB7A52}.Debug Mono|Any CPU.ActiveCfg = Debug|Any CPU
- {30A0B17D-B913-49AB-8CBB-8DF383AB7A52}.Debug Mono|Any CPU.Build.0 = Debug|Any CPU
- {30A0B17D-B913-49AB-8CBB-8DF383AB7A52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {30A0B17D-B913-49AB-8CBB-8DF383AB7A52}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {30A0B17D-B913-49AB-8CBB-8DF383AB7A52}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
- {30A0B17D-B913-49AB-8CBB-8DF383AB7A52}.Release Mono|Any CPU.Build.0 = Release|Any CPU
- {30A0B17D-B913-49AB-8CBB-8DF383AB7A52}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {30A0B17D-B913-49AB-8CBB-8DF383AB7A52}.Release|Any CPU.Build.0 = Release|Any CPU
- {88D7D845-2F50-4D37-9026-B0A8353D0E8D}.Debug Mono|Any CPU.ActiveCfg = Debug|Any CPU
- {88D7D845-2F50-4D37-9026-B0A8353D0E8D}.Debug Mono|Any CPU.Build.0 = Debug|Any CPU
- {88D7D845-2F50-4D37-9026-B0A8353D0E8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {88D7D845-2F50-4D37-9026-B0A8353D0E8D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {88D7D845-2F50-4D37-9026-B0A8353D0E8D}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
- {88D7D845-2F50-4D37-9026-B0A8353D0E8D}.Release Mono|Any CPU.Build.0 = Release|Any CPU
- {88D7D845-2F50-4D37-9026-B0A8353D0E8D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {88D7D845-2F50-4D37-9026-B0A8353D0E8D}.Release|Any CPU.Build.0 = Release|Any CPU
- {ED00E6F4-2B5C-4F16-ADE4-45E4A73C17B8}.Debug Mono|Any CPU.ActiveCfg = Debug|Any CPU
- {ED00E6F4-2B5C-4F16-ADE4-45E4A73C17B8}.Debug Mono|Any CPU.Build.0 = Debug|Any CPU
- {ED00E6F4-2B5C-4F16-ADE4-45E4A73C17B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {ED00E6F4-2B5C-4F16-ADE4-45E4A73C17B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {ED00E6F4-2B5C-4F16-ADE4-45E4A73C17B8}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
- {ED00E6F4-2B5C-4F16-ADE4-45E4A73C17B8}.Release Mono|Any CPU.Build.0 = Release|Any CPU
- {ED00E6F4-2B5C-4F16-ADE4-45E4A73C17B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {ED00E6F4-2B5C-4F16-ADE4-45E4A73C17B8}.Release|Any CPU.Build.0 = Release|Any CPU
- {337A85B5-4A7C-4883-8634-46E7E52A765F}.Debug Mono|Any CPU.ActiveCfg = Debug|Any CPU
- {337A85B5-4A7C-4883-8634-46E7E52A765F}.Debug Mono|Any CPU.Build.0 = Debug|Any CPU
- {337A85B5-4A7C-4883-8634-46E7E52A765F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {337A85B5-4A7C-4883-8634-46E7E52A765F}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {337A85B5-4A7C-4883-8634-46E7E52A765F}.Release Mono|Any CPU.ActiveCfg = Release|Any CPU
- {337A85B5-4A7C-4883-8634-46E7E52A765F}.Release Mono|Any CPU.Build.0 = Release|Any CPU
- {337A85B5-4A7C-4883-8634-46E7E52A765F}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {337A85B5-4A7C-4883-8634-46E7E52A765F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -1042,16 +957,5 @@ Global
{B47CA568-40CF-48DE-B87E-31BD400EBB08} = {0E55F1F8-E212-43D7-A0C0-ACEA9794B0D7}
{CAA97041-CFC0-4081-9BD2-8B139E62A611} = {0E55F1F8-E212-43D7-A0C0-ACEA9794B0D7}
{402FA351-D6C6-40FD-8868-F07156035919} = {0E55F1F8-E212-43D7-A0C0-ACEA9794B0D7}
- {76F58DC4-19F1-43EF-A6E2-EC1CC8395AC5} = {588C1513-FAB6-42C3-B6FC-3485F13620CF}
- {A05C31E8-0246-46A1-B3BC-4D6FE7A9AA49} = {76F58DC4-19F1-43EF-A6E2-EC1CC8395AC5}
- {5CF8A8BE-B634-473F-BB01-EBA878746BD4} = {76F58DC4-19F1-43EF-A6E2-EC1CC8395AC5}
- {9D8D62C7-7B4B-4CDF-8FE8-675DB71F6B21} = {76F58DC4-19F1-43EF-A6E2-EC1CC8395AC5}
- {B369F314-4D37-4AC1-B4FB-64FF671AF0BC} = {76F58DC4-19F1-43EF-A6E2-EC1CC8395AC5}
- {B1DDEC01-8525-4C38-B820-7C44F5A2930B} = {DCE4B11E-6A5F-4AC8-A089-037F0B14BFAB}
- {21E02199-F0E0-4818-A7D6-CBF28F79920D} = {DCE4B11E-6A5F-4AC8-A089-037F0B14BFAB}
- {30A0B17D-B913-49AB-8CBB-8DF383AB7A52} = {21E02199-F0E0-4818-A7D6-CBF28F79920D}
- {88D7D845-2F50-4D37-9026-B0A8353D0E8D} = {B1DDEC01-8525-4C38-B820-7C44F5A2930B}
- {ED00E6F4-2B5C-4F16-ADE4-45E4A73C17B8} = {B1DDEC01-8525-4C38-B820-7C44F5A2930B}
- {337A85B5-4A7C-4883-8634-46E7E52A765F} = {B1DDEC01-8525-4C38-B820-7C44F5A2930B}
EndGlobalSection
EndGlobal
diff --git a/src/SharedAssemblyInfo.cs b/src/SharedAssemblyInfo.cs
index 41fdd7e5345..fcb5f369368 100644
--- a/src/SharedAssemblyInfo.cs
+++ b/src/SharedAssemblyInfo.cs
@@ -4,5 +4,5 @@
[assembly: AssemblyCompanyAttribute("Akka.NET Team")]
[assembly: AssemblyCopyrightAttribute("Copyright © 2013-2015 Akka.NET Team")]
[assembly: AssemblyTrademarkAttribute("")]
-[assembly: AssemblyVersionAttribute("1.0.6.0")]
-[assembly: AssemblyFileVersionAttribute("1.0.6.0")]
+[assembly: AssemblyVersionAttribute("1.0.5.0")]
+[assembly: AssemblyFileVersionAttribute("1.0.5.0")]
diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/Akka.Cluster.Sharding.Tests.csproj b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/Akka.Cluster.Sharding.Tests.csproj
deleted file mode 100644
index 22441ab6469..00000000000
--- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/Akka.Cluster.Sharding.Tests.csproj
+++ /dev/null
@@ -1,135 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {B369F314-4D37-4AC1-B4FB-64FF671AF0BC}
- Library
- Properties
- Akka.Cluster.Sharding.Tests
- Akka.Cluster.Sharding.Tests
- v4.5
- 512
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
- ..\..\..\packages\System.Collections.Immutable.1.1.37\lib\dotnet\System.Collections.Immutable.dll
- True
-
-
-
-
-
-
-
-
-
- ..\..\..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll
- True
-
-
- ..\..\..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll
- True
-
-
- ..\..\..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll
- True
-
-
- ..\..\..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll
- True
-
-
-
-
-
-
-
-
-
-
-
-
- {a05c31e8-0246-46a1-b3bc-4d6fe7a9aa49}
- Akka.Cluster.Sharding
-
-
- {5CF8A8BE-B634-473F-BB01-EBA878746BD4}
- Akka.Cluster.Tools
-
-
- {3b9e6211-9488-4db5-b714-24248693b38f}
- Akka.Persistence.Sql.Common
-
-
- {453efd22-7c53-4887-9dbf-fcfc9172e909}
- Akka.Persistence.Sqlite
-
-
- {7dbd5c17-5e9d-40c4-9201-d092751532a7}
- Akka.TestKit.Xunit2
-
-
- {f0781bea-5ba0-4af0-bb15-e3f209b681f5}
- Akka.Cluster.Tests.MultiNode
-
-
- {6ab00f61-269a-4501-b06a-026707f000a7}
- Akka.Cluster
-
-
- {fca84dea-c118-424b-9eb8-34375dfef18a}
- Akka.Persistence
-
-
- {e5957c3e-2b1e-469f-a680-7953b4dea31b}
- Akka.Remote.TestKit
-
-
- {c9105c76-b084-4da1-9348-1c74a8f22f6b}
- Akka.Remote.Tests.MultiNode
-
-
- {ea4ff8fd-7c53-49c8-b9aa-02e458b3e6a7}
- Akka.Remote
-
-
- {0d3cbad0-bbdb-43e5-afc4-ed1d3ecdc224}
- Akka.TestKit
-
-
- {5deddf90-37f0-48d3-a0b0-a5cbd8a7e377}
- Akka
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ClusterShardingFailureSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ClusterShardingFailureSpec.cs
deleted file mode 100644
index 7971a2373d1..00000000000
--- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ClusterShardingFailureSpec.cs
+++ /dev/null
@@ -1,316 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright (C) 2009-2015 Typesafe Inc.
-// Copyright (C) 2013-2015 Akka.NET project
-//
-//-----------------------------------------------------------------------
-
-using System;
-using System.IO;
-using System.Linq;
-using Akka.Actor;
-using Akka.Cluster.Tests.MultiNode;
-using Akka.Configuration;
-using Akka.Persistence.Journal;
-using Akka.Remote.TestKit;
-using Akka.Remote.Transport;
-using Xunit;
-
-namespace Akka.Cluster.Sharding.Tests
-{
- public class ClusterShardingFailureSpecConfig : MultiNodeConfig
- {
- public ClusterShardingFailureSpecConfig()
- {
- var controller = Role("controller");
- var first = Role("first");
- var second = Role("second");
-
- CommonConfig = ConfigurationFactory.ParseString(@"
- akka.loglevel = INFO
- akka.actor.provider = ""Akka.Cluster.ClusterActorRefProvider""
- akka.remote.log-remote-lifecycle-events = off
- akka.cluster.auto-down-unreachable-after = 0s
- akka.cluster.down-removal-margin = 5s
- akka.cluster.roles = [""backend""]
- akka.persistence.journal.plugin = ""akka.persistence.journal.in-mem""
- akka.persistence.journal.in-mem {
- timeout = 5s
- store {
- native = off
- dir = ""target/journal-ClusterShardingFailureSpec""
- }
- }
- akka.persistence.snapshot-store.plugin = ""akka.persistence.snapshot-store.local""
- akka.persistence.snapshot-store.local.dir = ""target/snapshots-ClusterShardingFailureSpec""
- akka.cluster.sharding.coordinator-failure-backoff = 3s
- akka.cluster.sharding.shard-failure-backoff = 3s
- ");
-
- TestTransport = true;
- }
- }
-
- public class ClusterShardingFailureNode1 : ClusterShardingFailureSpec { }
- public class ClusterShardingFailureNode2 : ClusterShardingFailureSpec { }
- public class ClusterShardingFailureNode3 : ClusterShardingFailureSpec { }
-
- public abstract class ClusterShardingFailureSpec : MultiNodeClusterSpec
- {
- #region setup
-
- [Serializable]
- internal sealed class Get
- {
- public readonly string Id;
- public Get(string id)
- {
- Id = id;
- }
- }
-
- [Serializable]
- internal sealed class Add
- {
- public readonly string Id;
- public readonly int I;
- public Add(string id, int i)
- {
- Id = id;
- I = i;
- }
- }
-
- [Serializable]
- internal sealed class Value
- {
- public readonly string Id;
- public readonly int N;
- public Value(string id, int n)
- {
- Id = id;
- N = n;
- }
- }
-
- internal class Entity : ReceiveActor
- {
- private int _n = 0;
-
- public Entity()
- {
- Receive(get => Sender.Tell(new Value(get.Id, _n)));
- Receive(add => _n += add.I);
- }
- }
-
- internal IdExtractor extractEntityId = message =>
- {
- if (message is Get) return Tuple.Create((message as Get).Id, message);
- if (message is Add) return Tuple.Create((message as Add).Id, message);
- return null;
- };
-
- internal ShardResolver extractShardId = message =>
- {
- if (message is Get) return (message as Get).Id[0].ToString();
- if (message is Add) return (message as Add).Id[0].ToString();
- return null;
- };
-
- private DirectoryInfo[] _storageLocations;
- private Lazy _region;
- private RoleName _first;
- private RoleName _second;
- private RoleName _controller;
-
- protected ClusterShardingFailureSpec() : base(new ClusterShardingFailureSpecConfig())
- {
- _storageLocations = new[]
- {
- "akka.persistence.journal.leveldb.dir",
- "akka.persistence.journal.leveldb-shared.store.dir",
- "akka.persistence.snapshot-store.local.dir"
- }.Select(s => new DirectoryInfo(Sys.Settings.Config.GetString(s))).ToArray();
-
- _region = new Lazy(() => ClusterSharding.Get(Sys).ShardRegion("Entity"));
-
- _controller = new RoleName("controller");
- _first = new RoleName("first");
- _second = new RoleName("second");
- }
-
-
- protected override void AtStartup()
- {
- base.AtStartup();
- RunOn(() =>
- {
- foreach (var location in _storageLocations) if (location.Exists) location.Delete();
- }, _first);
- }
-
- protected override void AfterTermination()
- {
- base.AfterTermination();
- RunOn(() =>
- {
- foreach (var location in _storageLocations) if (location.Exists) location.Delete();
- }, _first);
- }
-
- #endregion
-
- private void Join(RoleName from, RoleName to)
- {
- RunOn(() =>
- {
- Cluster.Join(Node(to).Address);
- StartSharding();
- }, from);
- EnterBarrier(from.Name + "-joined");
- }
-
- private void StartSharding()
- {
- ClusterSharding.Get(Sys).Start(
- typeName: "Entity",
- entityProps: Props.Create(),
- settings: ClusterShardingSettings.Create(Sys),
- idExtractor: extractEntityId,
- shardResolver: extractShardId);
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void ClusterSharding_with_flaky_journal_should_setup_shared_journal()
- {
- // start the Persistence extension
- Persistence.Persistence.Instance.Apply(Sys);
- RunOn(() =>
- {
- Sys.ActorOf(Props.Create(), "store");
- }, _controller);
- EnterBarrier("persistence-started");
-
- RunOn(() =>
- {
- Sys.ActorSelection(Node(_first) / "user" / "store").Tell(new Identify(null));
- var sharedStore = ExpectMsg().Subject;
- //TODO: SharedLeveldbJournal.setStore(sharedStore, system)
- }, _first, _second);
- EnterBarrier("after-1");
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void ClusterSharding_with_flaky_journal_should_join_cluster()
- {
- ClusterSharding_with_flaky_journal_should_setup_shared_journal();
-
- Within(TimeSpan.FromSeconds(20), () =>
- {
- Join(_first, _first);
- Join(_second, _first);
-
- RunOn(() =>
- {
- var region = _region.Value;
- region.Tell(new Add("10", 1));
- region.Tell(new Add("20", 2));
- region.Tell(new Add("21", 3));
- region.Tell(new Get("10"));
- ExpectMsg(v => v.Id == "10" && v.N == 1);
- region.Tell(new Get("20"));
- ExpectMsg(v => v.Id == "20" && v.N == 2);
- region.Tell(new Get("21"));
- ExpectMsg(v => v.Id == "21" && v.N == 3);
- }, _first);
- EnterBarrier("after-2");
- });
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void ClusterSharding_with_flaky_journal_should_recover_after_journal_failure()
- {
- ClusterSharding_with_flaky_journal_should_join_cluster();
-
- Within(TimeSpan.FromSeconds(20), () =>
- {
- RunOn(() =>
- {
- TestConductor.Blackhole(_controller, _first, ThrottleTransportAdapter.Direction.Both).Wait();
- TestConductor.Blackhole(_controller, _second, ThrottleTransportAdapter.Direction.Both).Wait();
- }, _controller);
- EnterBarrier("journal-backholded");
-
- RunOn(() =>
- {
- // try with a new shard, will not reply until journal is available again
- var region = _region.Value;
- region.Tell(new Add("40", 4));
- var probe = CreateTestProbe();
- region.Tell(new Get("40"), probe.Ref);
- probe.ExpectNoMsg(TimeSpan.FromSeconds(1));
- }, _first);
- EnterBarrier("first-delayed");
-
- RunOn(() =>
- {
- TestConductor.PassThrough(_controller, _first, ThrottleTransportAdapter.Direction.Both).Wait();
- TestConductor.PassThrough(_controller, _second, ThrottleTransportAdapter.Direction.Both).Wait();
- }, _controller);
- EnterBarrier("journal-ok");
-
- RunOn(() =>
- {
- var region = _region.Value;
- region.Tell(new Get("21"));
- ExpectMsg(v => v.Id == "21" && v.N == 3);
- var entity21 = LastSender;
- var shard2 = Sys.ActorSelection(entity21.Path.Parent);
-
-
- //Test the PersistentShardCoordinator allocating shards during a journal failure
- region.Tell(new Add("30", 3));
-
- //Test the Shard starting entities and persisting during a journal failure
- region.Tell(new Add("11", 1));
-
- //Test the Shard passivate works during a journal failure
- shard2.Tell(new ShardRegion.Passivate(PoisonPill.Instance), entity21);
- region.Tell(new Add("21", 1));
-
- region.Tell(new Get("21"));
- ExpectMsg(v => v.Id == "21" && v.N == 1);
-
- region.Tell(new Get("30"));
- ExpectMsg(v => v.Id == "30" && v.N == 3);
-
- region.Tell(new Get("11"));
- ExpectMsg(v => v.Id == "11" && v.N == 1);
-
- region.Tell(new Get("40"));
- ExpectMsg(v => v.Id == "40" && v.N == 4);
- }, _first);
- EnterBarrier("verified-first");
-
- RunOn(() =>
- {
- var region = _region.Value;
- region.Tell(new Add("10", 1));
- region.Tell(new Add("20", 2));
- region.Tell(new Add("30", 3));
- region.Tell(new Add("11", 4));
- region.Tell(new Get("10"));
- ExpectMsg(v => v.Id == "10" && v.N == 2);
- region.Tell(new Get("11"));
- ExpectMsg(v => v.Id == "11" && v.N == 5);
- region.Tell(new Get("20"));
- ExpectMsg(v => v.Id == "20" && v.N == 4);
- region.Tell(new Get("30"));
- ExpectMsg(v => v.Id == "30" && v.N == 6);
- }, _second);
- EnterBarrier("after-3");
- });
- }
- }
-}
\ No newline at end of file
diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ClusterShardingGracefulShutdownSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ClusterShardingGracefulShutdownSpec.cs
deleted file mode 100644
index 6434035881e..00000000000
--- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ClusterShardingGracefulShutdownSpec.cs
+++ /dev/null
@@ -1,241 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright (C) 2009-2015 Typesafe Inc.
-// Copyright (C) 2013-2015 Akka.NET project
-//
-//-----------------------------------------------------------------------
-
-using System;
-using System.IO;
-using System.Linq;
-using Akka.Actor;
-using Akka.Cluster.Tests.MultiNode;
-using Akka.Configuration;
-using Akka.Persistence.Journal;
-using Akka.Remote.TestKit;
-using Xunit;
-
-namespace Akka.Cluster.Sharding.Tests
-{
- public class ClusterShardingGracefulShutdownSpecConfig : MultiNodeConfig
- {
- public ClusterShardingGracefulShutdownSpecConfig()
- {
- var first = Role("first");
- var second = Role("second");
-
- CommonConfig = ConfigurationFactory.ParseString(@"
- akka.loglevel = INFO
- akka.actor.provider = ""Akka.Cluster.ClusterActorRefProvider""
- akka.remote.log-remote-lifecycle-events = off
- akka.persistence.journal.plugin = ""Akka.Persistence.Journal.in-mem""
- akka.persistence.journal.in-mem {
- timeout = 5s
- store {
- native = off
- dir = ""target/journal-ClusterShardingGracefulShutdownSpec""
- }
- }
- akka.persistence.snapshot-store.plugin = ""akka.persistence.snapshot-store.local""
- akka.persistence.snapshot-store.local.dir = ""target/snapshots-ClusterShardingGracefulShutdownSpec""
- ");
- }
- }
-
- public class ClusterShardingGracefulShutdownNode1 : ClusterShardingGracefulShutdownSpec { }
- public class ClusterShardingGracefulShutdownNode2 : ClusterShardingGracefulShutdownSpec { }
-
- public abstract class ClusterShardingGracefulShutdownSpec : MultiNodeClusterSpec
- {
- #region setup
-
- [Serializable]
- internal sealed class StopEntity
- {
- public static readonly StopEntity Instance = new StopEntity();
-
- private StopEntity()
- {
- }
- }
-
- internal class Entity : ReceiveActor
- {
- public Entity()
- {
- Receive(id => Sender.Tell(id));
- Receive(_ => Context.Stop(Self));
- }
- }
-
- internal class IllustrateGracefulShutdown : UntypedActor
- {
- private readonly Cluster _cluster;
- private readonly IActorRef _region;
- public IllustrateGracefulShutdown()
- {
- _cluster = Cluster.Get(Context.System);
- _region = ClusterSharding.Get(Context.System).ShardRegion("Entity");
- }
-
- protected override void OnReceive(object message)
- {
- Terminated terminated;
- if (message.Equals("leave"))
- {
- Context.Watch(_region);
- _region.Tell(ShardRegion.GracefulShutdown.Instance);
- }
- else if ((terminated = message as Terminated) != null && terminated.ActorRef.Equals(_region))
- {
- //_cluster.RegisterOnMemberRemoved(() => Context.System.Shutdown());
- _cluster.Leave(_cluster.SelfAddress);
- }
- }
- }
-
- internal IdExtractor extractEntityId = message => message is int ? Tuple.Create(message.ToString(), message) : null;
-
- internal ShardResolver extractShardId = message => message is int ? message.ToString() : null;
-
- private readonly Lazy _region;
-
- private readonly DirectoryInfo[] _storageLocations;
- private readonly RoleName _first;
- private readonly RoleName _second;
-
- protected ClusterShardingGracefulShutdownSpec() : base(new ClusterShardingGracefulShutdownSpecConfig())
- {
- _storageLocations = new[]
- {
- "akka.persistence.journal.leveldb.dir",
- "akka.persistence.journal.leveldb-shared.store.dir",
- "akka.persistence.snapshot-store.local.dir"
- }.Select(s => new DirectoryInfo(Sys.Settings.Config.GetString(s))).ToArray();
-
- _region = new Lazy(() => ClusterSharding.Get(Sys).ShardRegion("Entity"));
-
- _first = new RoleName("first");
- _second = new RoleName("second");
- }
-
- protected override void AtStartup()
- {
- base.AtStartup();
- RunOn(() =>
- {
- foreach (var location in _storageLocations) if (location.Exists) location.Delete();
- }, _first);
- }
-
- protected override void AfterTermination()
- {
- base.AfterTermination();
- RunOn(() =>
- {
- foreach (var location in _storageLocations) if (location.Exists) location.Delete();
- }, _first);
- }
-
- #endregion
-
- private void Join(RoleName from, RoleName to)
- {
- RunOn(() =>
- {
- Cluster.Join(Node(to).Address);
- StartSharding();
- }, from);
- EnterBarrier(from.Name + "-joined");
- }
-
- private void StartSharding()
- {
- var allocationStrategy = new LeastShardAllocationStrategy(2, 1);
- ClusterSharding.Get(Sys).Start(
- typeName: "Entity",
- entityProps: Props.Create(),
- settings: ClusterShardingSettings.Create(Sys),
- idExtractor: extractEntityId,
- shardResolver: extractShardId,
- allocationStrategy: allocationStrategy,
- handOffStopMessage: StopEntity.Instance);
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void ClusterSharding_should_setup_shared_journal()
- {
- // start the Persistence extension
- Persistence.Persistence.Instance.Apply(Sys);
- RunOn(() =>
- {
- Sys.ActorOf(Props.Create(), "store");
- }, _first);
- EnterBarrier("persistence-started");
-
- RunOn(() =>
- {
- Sys.ActorSelection(Node(_first) / "user" / "store").Tell(new Identify(null));
- var sharedStore = ExpectMsg().Subject;
- //TODO: SharedLeveldbJournal.setStore(sharedStore, system)
- }, _first, _second);
- EnterBarrier("after-1");
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void ClusterSharding_should_start_some_shards_in_both_regions()
- {
- ClusterSharding_should_setup_shared_journal();
-
- Join(_first, _first);
- Join(_second, _first);
-
- AwaitAssert(() =>
- {
- var probe = CreateTestProbe();
- var regionAddresses = Enumerable.Range(1, 100)
- .Select(n =>
- {
- _region.Value.Tell(n, probe.Ref);
- probe.ExpectMsg(n, TimeSpan.FromSeconds(1));
- return probe.LastSender.Path.Address;
- })
- .ToArray();
-
- Assert.Equal(2, regionAddresses.Length);
- });
- EnterBarrier("after-2");
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void ClusterSharding_should_gracefully_shutdown_a_region()
- {
- ClusterSharding_should_start_some_shards_in_both_regions();
-
- RunOn(() =>
- {
- _region.Value.Tell(ShardRegion.GracefulShutdown.Instance);
- }, _second);
-
- RunOn(() =>
- {
- var probe = CreateTestProbe();
- for (int i = 1; i <= 200; i++)
- {
- _region.Value.Tell(i, probe.Ref);
- probe.ExpectMsg(i, TimeSpan.FromSeconds(1));
- Assert.Equal(_region.Value.Path / i.ToString() / i.ToString(), probe.LastSender.Path);
- }
- }, _first);
- EnterBarrier("handoff-completed");
-
- RunOn(() =>
- {
- var region = _region.Value;
- Watch(region);
- ExpectTerminated(region);
- }, _second);
- EnterBarrier("after-3");
- }
- }
-}
\ No newline at end of file
diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ClusterShardingLeavingSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ClusterShardingLeavingSpec.cs
deleted file mode 100644
index 95aba86cd39..00000000000
--- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ClusterShardingLeavingSpec.cs
+++ /dev/null
@@ -1,288 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright (C) 2009-2015 Typesafe Inc.
-// Copyright (C) 2013-2015 Akka.NET project
-//
-//-----------------------------------------------------------------------
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using Akka.Actor;
-using Akka.Cluster.Tests.MultiNode;
-using Akka.Configuration;
-using Akka.Persistence.Journal;
-using Akka.Remote.TestKit;
-using Xunit;
-
-namespace Akka.Cluster.Sharding.Tests
-{
- public class ClusterShardingLeavingSpecConfig : MultiNodeConfig
- {
- public ClusterShardingLeavingSpecConfig()
- {
- var first = Role("first");
- var second = Role("second");
- var third = Role("third");
- var fourth = Role("fourth");
-
- CommonConfig = ConfigurationFactory.ParseString(@"
- akka.loglevel = INFO
- akka.actor.provider = ""Akka.Cluster.ClusterActorRefProvider""
- akka.remote.log-remote-lifecycle-events = off
- akka.cluster.auto-down-unreachable-after = 0s
- akka.cluster.down-removal-margin = 5s
- akka.persistence.journal.plugin = ""Akka.Persistence.Journal.in-mem""
- akka.persistence.journal.in-mem {
- timeout = 5s
- store {
- native = off
- dir = ""target/journal-ClusterShardingLeavingSpec""
- }
- }
- akka.persistence.snapshot-store.plugin = ""akka.persistence.snapshot-store.local""
- akka.persistence.snapshot-store.local.dir = ""target/snapshots-ClusterShardingLeavingSpec""
- ");
- }
- }
-
- public class ClusterShardingLeavingNode1 : ClusterShardinLeavingSpec { }
- public class ClusterShardingLeavingNode2 : ClusterShardinLeavingSpec { }
- public class ClusterShardingLeavingNode3 : ClusterShardinLeavingSpec { }
- public class ClusterShardingLeavingNode4 : ClusterShardinLeavingSpec { }
-
- public abstract class ClusterShardinLeavingSpec : MultiNodeClusterSpec
- {
- #region setup
-
- [Serializable]
- internal sealed class Ping
- {
- public readonly string Id;
-
- public Ping(string id)
- {
- Id = id;
- }
- }
-
- [Serializable]
- internal sealed class GetLocations
- {
- public static readonly GetLocations Instance = new GetLocations();
-
- private GetLocations()
- {
- }
- }
-
- [Serializable]
- internal sealed class Locations
- {
- public readonly IDictionary LocationMap;
- public Locations(IDictionary locationMap)
- {
- LocationMap = locationMap;
- }
- }
-
- internal class Entity : ReceiveActor
- {
- public Entity()
- {
- Receive(_ => Sender.Tell(Self));
- }
- }
-
- internal class ShardLocations : ReceiveActor
- {
- private Locations _locations = null;
-
- public ShardLocations()
- {
- Receive(_ => Sender.Tell(_locations));
- Receive(l => _locations = l);
- }
- }
-
- internal IdExtractor extractEntityId = message => message is Ping ? Tuple.Create((message as Ping).Id, message) : null;
- internal ShardResolver extractShardId = message => message is Ping ? (message as Ping).Id[0].ToString() : null;
-
- private readonly DirectoryInfo[] _storageLocations;
- private readonly Lazy _region;
-
- private readonly RoleName _first;
- private readonly RoleName _second;
- private readonly RoleName _third;
- private readonly RoleName _fourth;
-
- protected ClusterShardinLeavingSpec() : base(new ClusterShardingLeavingSpecConfig())
- {
- _storageLocations = new[]
- {
- "akka.persistence.journal.leveldb.dir",
- "akka.persistence.journal.leveldb-shared.store.dir",
- "akka.persistence.snapshot-store.local.dir"
- }.Select(s => new DirectoryInfo(Sys.Settings.Config.GetString(s))).ToArray();
-
- _first = new RoleName("first");
- _second = new RoleName("second");
- _third = new RoleName("third");
- _fourth = new RoleName("fourth");
-
- _region = new Lazy(() => ClusterSharding.Get(Sys).ShardRegion("Entity"));
- }
-
- protected override int InitialParticipantsValueFactory { get { return Roles.Count; } }
-
- protected override void AtStartup()
- {
- base.AtStartup();
- RunOn(() =>
- {
- foreach (var location in _storageLocations) if (location.Exists) location.Delete();
- }, _first);
- }
-
- protected override void AfterTermination()
- {
- base.AfterTermination();
- RunOn(() =>
- {
- foreach (var location in _storageLocations) if (location.Exists) location.Delete();
- }, _first);
- }
-
- #endregion
-
- private void Join(RoleName from, RoleName to)
- {
- RunOn(() =>
- {
- Cluster.Join(Node(to).Address);
- StartSharding();
- Within(TimeSpan.FromSeconds(5), () =>
- {
- AwaitAssert(() => Assert.True(Cluster.ReadView.State.Members.Any(m => m.UniqueAddress == Cluster.SelfUniqueAddress && m.Status == MemberStatus.Up)));
- });
- }, from);
- EnterBarrier(from.Name + "-joined");
- }
-
- private void StartSharding()
- {
- ClusterSharding.Get(Sys).Start(
- typeName: "Entity",
- entityProps: Props.Create(),
- settings: ClusterShardingSettings.Create(Sys),
- idExtractor: extractEntityId,
- shardResolver: extractShardId);
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void ClusterSharding_with_leaving_member_should_setup_shared_journal()
- {
- // start the Persistence extension
- Persistence.Persistence.Instance.Apply(Sys);
- RunOn(() =>
- {
- Sys.ActorOf(Props.Create(), "store");
- }, _first);
- EnterBarrier("persistence-started");
-
- Sys.ActorSelection(Node(_first) / "user" / "store").Tell(new Identify(null));
- var sharedStore = ExpectMsg().Subject;
-
- //SharedLeveldbJournal.setStore(sharedStore, system)
- EnterBarrier("after-1");
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void ClusterSharding_with_leaving_member_should_join_cluster()
- {
- ClusterSharding_with_leaving_member_should_setup_shared_journal();
-
- Within(TimeSpan.FromSeconds(20), () =>
- {
- Join(_first, _first);
- Join(_second, _first);
- Join(_third, _first);
- Join(_fourth, _first);
-
- EnterBarrier("after-2");
- });
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void ClusterSharding_with_leaving_member_should_initialize_shards()
- {
- ClusterSharding_with_leaving_member_should_join_cluster();
-
- RunOn(() =>
- {
- var shardLocations = Sys.ActorOf(Props.Create(), "shardLocations");
- var locations = Enumerable.Range(1, 10)
- .Select(n =>
- {
- var id = n.ToString();
- _region.Value.Tell(new Ping(id));
- return new KeyValuePair(id, ExpectMsg());
- })
- .ToDictionary(kv => kv.Key, kv => kv.Value);
-
- shardLocations.Tell(new Locations(locations));
- }, _first);
- EnterBarrier("after-3");
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void ClusterSharding_with_leaving_member_should_recover_after_leaving_coordinator_node()
- {
- ClusterSharding_with_leaving_member_should_initialize_shards();
-
- Within(TimeSpan.FromSeconds(30), () =>
- {
- RunOn(() =>
- {
- Cluster.Leave(Node(_first).Address);
- }, _third);
-
- RunOn(() =>
- {
- var region = _region.Value;
- Watch(region);
- ExpectTerminated(region, TimeSpan.FromSeconds(15));
- }, _first);
- EnterBarrier("stopped");
-
- RunOn(() =>
- {
- Sys.ActorSelection(Node(_first) / "user" / "sharedLocations").Tell(GetLocations.Instance);
- var locations = ExpectMsg();
- var firstAddress = Node(_first).Address;
- AwaitAssert(() =>
- {
- var region = _region.Value;
- var probe = CreateTestProbe();
- foreach (var kv in locations.LocationMap)
- {
- var id = kv.Key;
- var r = kv.Value;
- region.Tell(new Ping(id), probe.Ref);
- if (r.Path.Address.Equals(firstAddress))
- {
- Assert.NotEqual(r, probe.ExpectMsg(TimeSpan.FromSeconds(1)));
- }
- else
- {
- probe.ExpectMsg(r, TimeSpan.FromSeconds(1)); // should not move
- }
- }
- });
- }, _second, _third, _fourth);
- EnterBarrier("after-4");
- });
- }
- }
-}
\ No newline at end of file
diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ClusterShardingSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ClusterShardingSpec.cs
deleted file mode 100644
index f727619722d..00000000000
--- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/ClusterShardingSpec.cs
+++ /dev/null
@@ -1,1090 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright (C) 2009-2015 Typesafe Inc.
-// Copyright (C) 2013-2015 Akka.NET project
-//
-//-----------------------------------------------------------------------
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Threading;
-using Akka.Cluster.Sharding;
-using Akka.Configuration;
-using Akka.Persistence;
-using Akka.Remote.TestKit;
-using Akka.Actor;
-using Akka.Cluster.Tests.MultiNode;
-using Akka.Cluster.Tools.Singleton;
-using Akka.Pattern;
-using Akka.Persistence.Journal;
-using Akka.TestKit;
-using Akka.TestKit.Internal.StringMatcher;
-using Akka.TestKit.TestEvent;
-using Xunit;
-
-namespace Akka.Cluster.Sharding.Tests
-{
- public class ClusterShardingSpecConfig : MultiNodeConfig
- {
- public ClusterShardingSpecConfig()
- {
- var controller = Role("controller");
- var first = Role("first");
- var second = Role("second");
- var third = Role("third");
- var fourth = Role("fourth");
- var fifth = Role("fifth");
- var sixth = Role("sixth");
-
- CommonConfig = ConfigurationFactory.ParseString(@"
- akka.loglevel = INFO
- akka.actor.provider = ""Akka.Cluster.ClusterActorRefProvider""
- akka.remote.log-remote-lifecycle-events = off
- akka.cluster.auto-down-unreachable-after = 0s
- akka.cluster.down-removal-margin = 5s
- akka.cluster.roles = [""backend""]
- akka.persistence.journal.plugin = ""akka.persistence.journal.leveldb-shared""
- akka.persistence.journal.leveldb-shared.store {
- native = off
- dir = ""target/journal-ClusterShardingSpec""
- }
- akka.persistence.snapshot-store.plugin = ""akka.persistence.snapshot-store.local""
- akka.persistence.snapshot-store.local.dir = ""target/snapshots-ClusterShardingSpec""
- akka.cluster.sharding {
- retry-interval = 1 s
- handoff-timeout = 10 s
- shard-start-timeout = 5s
- entity-restart-backoff = 1s
- rebalance-interval = 2 s
- least-shard-allocation-strategy {
- rebalance-threshold = 2
- max-simultaneous-rebalance = 1
- }
- }");
-
- NodeConfig(new[] { sixth }, new[] { ConfigurationFactory.ParseString(@"akka.cluster.roles = [""frontend""]") });
- }
- }
-
- internal class Counter : PersistentActor
- {
- #region messages
-
- [Serializable]
- public sealed class Increment
- {
- public static readonly Increment Instance = new Increment();
-
- private Increment()
- {
- }
- }
-
- [Serializable]
- public sealed class Decrement
- {
- public static readonly Decrement Instance = new Decrement();
-
- private Decrement()
- {
- }
- }
-
- [Serializable]
- public sealed class Get
- {
- public readonly long CounterId;
- public Get(long counterId)
- {
- CounterId = counterId;
- }
- }
-
- [Serializable]
- public sealed class EntityEnvelope
- {
- public readonly long Id;
- public readonly object Payload;
- public EntityEnvelope(long id, object payload)
- {
- Id = id;
- Payload = payload;
- }
- }
-
- [Serializable]
- public sealed class CounterChanged
- {
- public readonly int Delta;
- public CounterChanged(int delta)
- {
- Delta = delta;
- }
- }
-
- [Serializable]
- public sealed class Stop
- {
- public static readonly Stop Instance = new Stop();
-
- private Stop()
- {
- }
- }
-
- #endregion
-
- public static readonly IdExtractor ExtractEntityId = message =>
- {
- if (message is EntityEnvelope)
- {
- var env = (EntityEnvelope)message;
- return Tuple.Create(env.Id.ToString(), env.Payload);
- }
- if (message is Get)
- {
- return Tuple.Create(((Get)message).CounterId.ToString(), message);
- }
- return null;
- };
-
- public static readonly ShardResolver ExtractShardId = message =>
- {
- if (message is EntityEnvelope)
- return (((EntityEnvelope)message).Id % ShardsCount).ToString();
- if (message is Get)
- return (((Get)message).CounterId % ShardsCount).ToString();
- return null;
-
- };
-
- public const int ShardsCount = 12;
- private int _count = 0;
-
- public Counter()
- {
- Context.SetReceiveTimeout(TimeSpan.FromMinutes(2));
- }
-
- protected override void PostStop()
- {
- base.PostStop();
- // Simulate that the passivation takes some time, to verify passivation buffering
- Thread.Sleep(500);
- }
-
- public override string PersistenceId { get { return Self.Path.Parent.Name + "-" + Self.Path.Name; } }
- protected override bool ReceiveRecover(object message)
- {
- return message.Match()
- .With(UpdateState)
- .WasHandled;
- }
-
- protected override bool ReceiveCommand(object message)
- {
- return message.Match()
- .With(_ => Persist(new CounterChanged(1), UpdateState))
- .With(_ => Persist(new CounterChanged(-1), UpdateState))
- .With(_ => Sender.Tell(_count))
- .With(_ => Context.Parent.Tell(new ShardRegion.Passivate(Stop.Instance)))
- .With(_ => Context.Stop(Self))
- .WasHandled;
- }
-
- private void UpdateState(CounterChanged e)
- {
- _count += e.Delta;
- }
- }
- public class ClusterShardingNode1 : ClusterShardingSpec { }
- public class ClusterShardingNode2 : ClusterShardingSpec { }
- public class ClusterShardingNode3 : ClusterShardingSpec { }
-
- public abstract class ClusterShardingSpec : MultiNodeClusterSpec
- {
- #region Setup
-
- private readonly DirectoryInfo[] _storageLocations;
- private readonly RoleName _controller;
- private readonly RoleName _second;
- private readonly RoleName _first;
- private readonly RoleName _third;
- private readonly RoleName _fourth;
- private readonly RoleName _sixth;
- private readonly RoleName _fifth;
-
- private readonly Lazy _region;
- private readonly Lazy _rebalancingRegion;
- private readonly Lazy _persistentEntitiesRegion;
- private readonly Lazy _anotherPersistentRegion;
- private readonly Lazy _persistentRegion;
- private readonly Lazy _rebalancingPersistentRegion;
- private readonly Lazy _autoMigrateRegion;
-
- protected ClusterShardingSpec() : base(new ClusterShardingSpecConfig())
- {
- _storageLocations = new[]
- {
- "akka.persistence.journal.leveldb.dir",
- "akka.persistence.journal.leveldb-shared.store.dir",
- "akka.persistence.snapshot-store.local.dir"
- }.Select(s => new DirectoryInfo(Sys.Settings.Config.GetString(s))).ToArray();
-
- _controller = new RoleName("controller");
- _first = new RoleName("first");
- _second = new RoleName("second");
- _third = new RoleName("third");
- _fourth = new RoleName("fourth");
- _fifth = new RoleName("fifth");
- _sixth = new RoleName("sixth");
-
- _region = new Lazy(() => CreateRegion("counter", false));
- _rebalancingRegion = new Lazy(() => CreateRegion("rebalancingCounter", false));
-
- _persistentEntitiesRegion = new Lazy(() => CreateRegion("PersistentCounterEntities", true));
- _anotherPersistentRegion = new Lazy(() => CreateRegion("AnotherPersistentCounter", true));
- _persistentRegion = new Lazy(() => CreateRegion("PersistentCounter", true));
- _rebalancingPersistentRegion = new Lazy(() => CreateRegion("RebalancingPersistentCounter", true));
- _autoMigrateRegion = new Lazy(() => CreateRegion("AutoMigrateRegionTest", true));
- }
-
- protected override int InitialParticipantsValueFactory { get { return Roles.Count; } }
-
- protected override void AtStartup()
- {
- base.AtStartup();
- RunOn(() =>
- {
- foreach (var dir in _storageLocations)
- {
- if (dir.Exists) dir.Delete();
- }
- }, _controller);
- }
-
- protected override void AfterTermination()
- {
- base.AfterTermination();
- RunOn(() =>
- {
- foreach (var dir in _storageLocations)
- {
- if (dir.Exists) dir.Delete();
- }
- }, _controller);
- }
-
- private void Join(RoleName from, RoleName to)
- {
- RunOn(() =>
- {
- Cluster.Join(Node(to).Address);
- }, from);
-
- EnterBarrier(from.Name + "-joined");
- }
-
- private void CreateCoordinator()
- {
- var typeNames = new[]
- {
- "counter", "rebalancingCounter", "PersistentCounterEntities", "AnotherPersistentCounter",
- "PersistentCounter", "RebalancingPersistentCounter", "AutoMigrateRegionTest"
- };
-
- foreach (var typeName in typeNames)
- {
- var rebalanceEnabled = string.Equals(typeName, "rebalancing", StringComparison.InvariantCultureIgnoreCase);
- var singletonProps = Props.Create(() => new BackoffSupervisor(
- CoordinatorProps(typeName, rebalanceEnabled),
- "coordinator",
- TimeSpan.FromSeconds(5),
- TimeSpan.FromSeconds(5),
- 0.1)).WithDeploy(Deploy.Local);
-
- Sys.ActorOf(ClusterSingletonManager.Props(
- singletonProps,
- PoisonPill.Instance,
- ClusterSingletonManagerSettings.Create(Sys)),
- typeName + "Coordinator");
- }
- }
-
- private Props CoordinatorProps(string typeName, bool rebalanceEntities)
- {
- var allocationStrategy = new LeastShardAllocationStrategy(2, 1);
- var config = ConfigurationFactory.ParseString(string.Format(""));
- var settings = ClusterShardingSettings.Create(config, Sys.Settings.Config.GetConfig("akka.cluster.singleton"));
-
- return PersistentShardCoordinator.Props(typeName, settings, allocationStrategy);
- }
-
- private IActorRef CreateRegion(string typeName, bool rememberEntities)
- {
- var config = ConfigurationFactory.ParseString(@"
- retry-interval = 1s
- shard-failure-backoff = 1s
- entity-restart-backoff = 1s
- buffer-size = 1000").WithFallback(Sys.Settings.Config.GetConfig("akka.cluster.sharding"));
- var settings = ClusterShardingSettings.Create(config, Sys.Settings.Config.GetConfig("akka.cluster.singleton")).WithRememberEntities(rememberEntities);
-
- return Sys.ActorOf(Props.Create(() => new ShardRegion(
- typeName,
- Props.Create(),
- settings,
- "/user/" + typeName + "Coordinator/singleton/coordinator",
- Counter.ExtractEntityId,
- Counter.ExtractShardId,
- PoisonPill.Instance)),
- typeName + "Region");
- }
-
- #endregion
-
- #region Cluster shardings specs
-
- [MultiNodeFact(Skip = "TODO")]
- public void ClusterSharding_should_setup_shared_journal()
- {
- // start the Persistence extension
- Persistence.Persistence.Instance.Apply(Sys);
- RunOn(() => Sys.ActorOf("store"), _controller);
- EnterBarrier("persistence-started");
-
- RunOn(() =>
- {
- Sys.ActorSelection(Node(_controller) / "user" / "store").Tell(new Identify(null));
- var sharedStore = ExpectMsg().Subject;
- //SharedLeveldbJournal.setStore(sharedStore, system)
- }, _first, _second, _third, _fourth, _fifth, _sixth);
-
- EnterBarrier("after-1");
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void ClusterSharding_should_work_in_single_node_cluster()
- {
- ClusterSharding_should_setup_shared_journal();
-
- Within(TimeSpan.FromSeconds(20), () =>
- {
- Join(_first, _first);
-
- RunOn(() =>
- {
- var r = _region.Value;
- r.Tell(new Counter.EntityEnvelope(1, Counter.Increment.Instance));
- r.Tell(new Counter.EntityEnvelope(1, Counter.Increment.Instance));
- r.Tell(new Counter.EntityEnvelope(1, Counter.Increment.Instance));
- r.Tell(new Counter.EntityEnvelope(1, Counter.Decrement.Instance));
- r.Tell(new Counter.Get(1));
-
- ExpectMsg(2);
- r.Tell(ShardRegion.GetCurrentRegions.Instance);
- ExpectMsg(m => m.Regions.Length == 1 && m.Regions[0].Equals(Cluster.SelfAddress));
- }, _first);
-
- EnterBarrier("after-2");
- });
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void ClusterSharding_should_use_second_node()
- {
- ClusterSharding_should_work_in_single_node_cluster();
-
- Within(TimeSpan.FromSeconds(20), () =>
- {
- Join(_second, _first);
-
- RunOn(() =>
- {
- var r = _region.Value;
- r.Tell(new Counter.EntityEnvelope(2, Counter.Increment.Instance));
- r.Tell(new Counter.EntityEnvelope(2, Counter.Increment.Instance));
- r.Tell(new Counter.EntityEnvelope(2, Counter.Increment.Instance));
- r.Tell(new Counter.EntityEnvelope(2, Counter.Decrement.Instance));
- r.Tell(new Counter.Get(2));
-
- ExpectMsg(2);
-
- r.Tell(new Counter.EntityEnvelope(11, Counter.Increment.Instance));
- r.Tell(new Counter.EntityEnvelope(12, Counter.Increment.Instance));
- r.Tell(new Counter.Get(11));
- ExpectMsg(1);
- r.Tell(new Counter.Get(12));
- ExpectMsg(1);
- }, _second);
- EnterBarrier("second-update");
-
- RunOn(() =>
- {
- var r = _region.Value;
- r.Tell(new Counter.EntityEnvelope(2, Counter.Increment.Instance));
- r.Tell(new Counter.Get(2));
- ExpectMsg(3);
- Assert.Equal(Node(_second) / "user" / "counterRegion" / "2" / "2", LastSender.Path);
-
- r.Tell(new Counter.Get(11));
- ExpectMsg(1);
- // local on first
- Assert.Equal(r.Path / "11" / "11", LastSender.Path);
- r.Tell(new Counter.Get(12));
- ExpectMsg(1);
- Assert.Equal(Node(_second) / "user" / "counterRegion" / "0" / "12", LastSender.Path);
- }, _first);
- EnterBarrier("first-update");
-
- RunOn(() =>
- {
- var r = _region.Value;
- r.Tell(new Counter.Get(2));
- ExpectMsg(3);
- Assert.Equal(r.Path / "2" / "2", LastSender.Path);
-
- r.Tell(ShardRegion.GetCurrentRegions.Instance);
- ExpectMsg(x => x.Regions.Length == 2
- && x.Regions[0].Equals(Cluster.SelfAddress)
- && x.Regions[1].Equals(Node(_first).Address));
- }, _second);
- EnterBarrier("after-3");
- });
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void ClusterSharding_should_support_passivation_and_activation_of_entities()
- {
- ClusterSharding_should_use_second_node();
-
- RunOn(() =>
- {
- var r = _region.Value;
- r.Tell(new Counter.Get(2));
- ExpectMsg(3); //TODO: shouldn't we tell increment 3x first?
- r.Tell(new Counter.EntityEnvelope(2, ReceiveTimeout.Instance));
- // let the Passivate-Stop roundtrip begin to trigger buffering of subsequent messages
- Thread.Sleep(200);
- r.Tell(new Counter.EntityEnvelope(2, Counter.Increment.Instance));
- r.Tell(new Counter.Get(2));
- ExpectMsg(4);
- }, _second);
- EnterBarrier("after-4");
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void ClusterSharding_should_support_proxy_only_mode()
- {
- ClusterSharding_should_support_passivation_and_activation_of_entities();
-
- Within(TimeSpan.FromSeconds(10), () =>
- {
- RunOn(() =>
- {
- var cfg = ConfigurationFactory.ParseString(@"
- retry-interval = 1s
- buffer-size = 1000")
- .WithFallback(Sys.Settings.Config.GetConfig("akka.cluster.sharding"));
-
- var settings = ClusterShardingSettings.Create(cfg, Sys.Settings.Config.GetConfig("akka.cluster.singleton"));
- var proxy = Sys.ActorOf(ShardRegion.ProxyProps(
- typeName: "counter",
- settings: settings,
- coordinatorPath: "/user/counterCoordinator/singleton/coordinator",
- extractEntityId: Counter.ExtractEntityId,
- extractShardId: Counter.ExtractShardId));
-
- proxy.Tell(new Counter.EntityEnvelope(1, Counter.Increment.Instance));
- proxy.Tell(new Counter.EntityEnvelope(1, Counter.Increment.Instance));
- proxy.Tell(new Counter.EntityEnvelope(2, Counter.Increment.Instance));
- proxy.Tell(new Counter.EntityEnvelope(2, Counter.Increment.Instance));
- proxy.Tell(new Counter.EntityEnvelope(2, Counter.Increment.Instance));
- proxy.Tell(new Counter.EntityEnvelope(2, Counter.Increment.Instance));
-
- proxy.Tell(new Counter.Get(1));
- ExpectMsg(2);
- proxy.Tell(new Counter.Get(2));
- ExpectMsg(4);
- }, _second);
- EnterBarrier("after-5");
- });
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void ClusterSharding_should_failover_shards_on_crashed_node()
- {
- ClusterSharding_should_support_proxy_only_mode();
-
- Within(TimeSpan.FromSeconds(30), () =>
- {
- // mute logging of deadLetters during shutdown of systems
- if (!Log.IsDebugEnabled) Sys.EventStream.Publish(new Mute(new DeadLettersFilter(new PredicateMatcher(x => true), new PredicateMatcher(x => true))));
- EnterBarrier("logs-muted");
-
- RunOn(() =>
- {
- TestConductor.Exit(_second, 0).Wait();
- }, _controller);
- EnterBarrier("crash-second");
-
- RunOn(() =>
- {
- var probe1 = CreateTestProbe();
- AwaitAssert(() =>
- {
- Within(TimeSpan.FromSeconds(1), () =>
- {
- var r = _region.Value;
- r.Tell(new Counter.Get(2), probe1.Ref);
- probe1.ExpectMsg(4);
- Assert.Equal(r.Path / "2" / "2", probe1.LastSender.Path);
- });
- });
-
- var probe2 = CreateTestProbe();
- AwaitAssert(() =>
- {
- Within(TimeSpan.FromSeconds(1), () =>
- {
- var r = _region.Value;
- r.Tell(new Counter.Get(12), probe2.Ref);
- probe2.ExpectMsg(1);
- Assert.Equal(r.Path / "0" / "12", probe2.LastSender.Path);
- });
- });
- }, _first);
- EnterBarrier("after-6");
- });
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void ClusterSharding_should_use_third_and_fourth_node()
- {
- ClusterSharding_should_failover_shards_on_crashed_node();
-
- Within(TimeSpan.FromSeconds(15), () =>
- {
- Join(_third, _first);
- Join(_fourth, _first);
-
- RunOn(() =>
- {
- var r = _region.Value;
- for (int i = 0; i < 10; i++)
- r.Tell(new Counter.EntityEnvelope(3, Counter.Increment.Instance));
-
- r.Tell(new Counter.Get(3));
- ExpectMsg(10);
- Assert.Equal(r.Path / "3" / "3", LastSender.Path);
- }, _third);
- EnterBarrier("third-update");
-
- RunOn(() =>
- {
- var r = _region.Value;
- for (int i = 0; i < 20; i++)
- r.Tell(new Counter.EntityEnvelope(4, Counter.Increment.Instance));
-
- r.Tell(new Counter.Get(4));
- ExpectMsg(20);
- Assert.Equal(r.Path / "4" / "4", LastSender.Path);
- }, _fourth);
- EnterBarrier("fourth-update");
-
- RunOn(() =>
- {
- var r = _region.Value;
- r.Tell(new Counter.EntityEnvelope(3, Counter.Increment.Instance));
- r.Tell(new Counter.Get(3));
- ExpectMsg(11);
- Assert.Equal(Node(_third) / "user" / "counterRegion" / "3" / "3", LastSender.Path);
-
- r.Tell(new Counter.EntityEnvelope(4, Counter.Increment.Instance));
- r.Tell(new Counter.Get(4));
- ExpectMsg(21);
- Assert.Equal(Node(_third) / "user" / "counterRegion" / "4" / "4", LastSender.Path);
- }, _first);
- EnterBarrier("first-update");
-
- RunOn(() =>
- {
- var r = _region.Value;
- r.Tell(new Counter.Get(3));
- ExpectMsg(11);
- Assert.Equal(r.Path / "3" / "3", LastSender.Path);
- }, _third);
-
- RunOn(() =>
- {
- var r = _region.Value;
- r.Tell(new Counter.Get(4));
- ExpectMsg(21);
- Assert.Equal(r.Path / "4" / "4", LastSender.Path);
- }, _fourth);
- EnterBarrier("after-7");
- });
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void ClusterSharding_should_recover_coordinator_state_after_coordinator_crash()
- {
- ClusterSharding_should_use_third_and_fourth_node();
-
- Within(TimeSpan.FromSeconds(60), () =>
- {
- Join(_fifth, _fourth);
- RunOn(() =>
- {
- TestConductor.Exit(_first, 0).Wait();
- }, _controller);
- EnterBarrier("crash-first");
-
- RunOn(() =>
- {
- var probe3 = CreateTestProbe();
- AwaitAssert(() =>
- {
- Within(TimeSpan.FromSeconds(1), () =>
- {
- _region.Value.Tell(new Counter.Get(3), probe3.Ref);
- probe3.ExpectMsg(11);
- Assert.Equal(Node(_third) / "user" / "counterRegion" / "3" / "3", probe3.LastSender.Path);
- });
- });
-
- var probe4 = CreateTestProbe();
- AwaitAssert(() =>
- {
- Within(TimeSpan.FromSeconds(1), () =>
- {
- _region.Value.Tell(new Counter.Get(4), probe4.Ref);
- probe4.ExpectMsg(21);
- Assert.Equal(Node(_fourth) / "user" / "counterRegion" / "4" / "4", probe4.LastSender.Path);
- });
- });
- }, _fifth);
- EnterBarrier("after-8");
- });
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void ClusterSharding_should_rebalance_to_nodes_with_less_shards()
- {
- ClusterSharding_should_recover_coordinator_state_after_coordinator_crash();
-
- Within(TimeSpan.FromSeconds(60), () =>
- {
- RunOn(() =>
- {
- for (int i = 1; i <= 10; i++)
- {
- var rebalancingRegion = _rebalancingRegion.Value;
- rebalancingRegion.Tell(new Counter.EntityEnvelope(i, Counter.Increment.Instance));
- rebalancingRegion.Tell(new Counter.Get(i));
- ExpectMsg(1);
- }
- }, _fourth);
- EnterBarrier("rebalancing-shards-allocated");
-
- Join(_sixth, _third);
-
- RunOn(() =>
- {
- AwaitAssert(() =>
- {
- var probe = CreateTestProbe();
- Within(TimeSpan.FromSeconds(3), () =>
- {
- var count = 0;
- for (int i = 1; i <= 10; i++)
- {
- var rebalancingRegion = _rebalancingRegion.Value;
- rebalancingRegion.Tell(new Counter.Get(i), probe.Ref);
- probe.ExpectMsg();
- if (probe.LastSender.Path.Equals(rebalancingRegion.Path / (i % 12).ToString() / i.ToString()))
- count++;
- }
-
- Assert.True(count >= 2);
- });
- });
- }, _sixth);
- EnterBarrier("after-9");
- });
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void ClusterSharding_should_be_easy_to_use_with_extensions()
- {
- ClusterSharding_should_rebalance_to_nodes_with_less_shards();
-
- Within(TimeSpan.FromSeconds(50), () =>
- {
- RunOn(() =>
- {
- //#counter-start
- ClusterSharding.Get(Sys).Start(
- typeName: "Counter",
- entityProps: Props.Create(),
- settings: ClusterShardingSettings.Create(Sys),
- idExtractor: Counter.ExtractEntityId,
- shardResolver: Counter.ExtractShardId);
-
- //#counter-start
- ClusterSharding.Get(Sys).Start(
- typeName: "AnotherCounter",
- entityProps: Props.Create(),
- settings: ClusterShardingSettings.Create(Sys),
- idExtractor: Counter.ExtractEntityId,
- shardResolver: Counter.ExtractShardId);
- }, _third, _fourth, _fifth, _sixth);
- EnterBarrier("extension-started");
-
- RunOn(() =>
- {
- //#counter-usage
- var counterRegion = ClusterSharding.Get(Sys).ShardRegion("Counter");
- counterRegion.Tell(new Counter.Get(123));
- ExpectMsg(0);
-
- counterRegion.Tell(new Counter.EntityEnvelope(123, Counter.Increment.Instance));
- counterRegion.Tell(new Counter.Get(123));
- ExpectMsg(1);
-
- //#counter-usage
- var anotherCounterRegion = ClusterSharding.Get(Sys).ShardRegion("AnotherCounter");
- anotherCounterRegion.Tell(new Counter.EntityEnvelope(123, Counter.Decrement.Instance));
- anotherCounterRegion.Tell(new Counter.Get(123));
- ExpectMsg(-1);
- }, _fifth);
- EnterBarrier("extension-used");
-
- // sixth is a frontend node, i.e. proxy only
- RunOn(() =>
- {
- for (int i = 1000; i <= 1010; i++)
- {
- ClusterSharding.Get(Sys).ShardRegion("Counter").Tell(new Counter.EntityEnvelope(i, Counter.Increment.Instance));
- ClusterSharding.Get(Sys).ShardRegion("Counter").Tell(new Counter.Get(i));
- ExpectMsg(1);
- Assert.NotEqual(Cluster.SelfAddress, LastSender.Path.Address);
- }
- }, _sixth);
- EnterBarrier("after-10");
- });
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void ClusterSharding_should_be_easy_API_for_starting()
- {
- ClusterSharding_should_be_easy_to_use_with_extensions();
-
- Within(TimeSpan.FromSeconds(50), () =>
- {
- RunOn(() =>
- {
- var counterRegionViaStart = ClusterSharding.Get(Sys).Start(
- typeName: "ApiTest",
- entityProps: Props.Create(),
- settings: ClusterShardingSettings.Create(Sys),
- idExtractor: Counter.ExtractEntityId,
- shardResolver: Counter.ExtractShardId);
-
- var counterRegionViaGet = ClusterSharding.Get(Sys).ShardRegion("ApiTest");
-
- Assert.Equal(counterRegionViaGet, counterRegionViaStart);
- }, _first);
- EnterBarrier("after-11");
- });
- }
-
- #endregion
-
- #region Persistent cluster shards specs
-
- [MultiNodeFact(Skip = "TODO")]
- 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(s => s.Shard == "1", TimeSpan.FromSeconds(10));
-
- var probe = CreateTestProbe();
- AwaitAssert(() =>
- {
- shard.Tell(new Identify(1), probe.Ref);
- probe.ExpectMsg(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(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(i => i.MessageId.Equals(3) && i.Subject == null, TimeSpan.FromSeconds(3));
- }, _fourth);
- EnterBarrier("after-12");
- });
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void Persistent_cluster_shards_should_permanently_stop_entities_which_passivate()
- {
- Persistent_cluster_shards_should_recover_entities_upon_restart();
-
- Within(TimeSpan.FromSeconds(15), () =>
- {
- RunOn(() =>
- {
- var x = _persistentRegion.Value;
- }, _third, _fourth, _fifth);
- EnterBarrier("cluster-started-12");
-
- RunOn(() =>
- {
- //create and increment counter 1
- _persistentRegion.Value.Tell(new Counter.EntityEnvelope(1, Counter.Increment.Instance));
- _persistentRegion.Value.Tell(new Counter.Get(1));
- ExpectMsg(1);
-
- var counter1 = LastSender;
- var shard = Sys.ActorSelection(counter1.Path.Parent);
- var region = Sys.ActorSelection(counter1.Path.Parent.Parent);
-
- //create and increment counter 13
- _persistentRegion.Value.Tell(new Counter.EntityEnvelope(13, Counter.Increment.Instance));
- _persistentRegion.Value.Tell(new Counter.Get(13));
- ExpectMsg(1);
-
- var counter13 = LastSender;
-
- Assert.Equal(counter1.Path.Parent, counter13.Path.Parent);
-
- //Send the shard the passivate message from the counter
- Watch(counter1);
- shard.Tell(new ShardRegion.Passivate(Counter.Stop.Instance), counter1);
-
- // watch for the Terminated message
- ExpectTerminated(counter1, TimeSpan.FromSeconds(5));
-
- var probe1 = CreateTestProbe();
- AwaitAssert(() =>
- {
- // check counter 1 is dead
- counter1.Tell(new Identify(1), probe1.Ref);
- probe1.ExpectMsg(i => i.MessageId.Equals(1) && i.Subject == null, TimeSpan.FromSeconds(1));
- }, TimeSpan.FromSeconds(5), TimeSpan.FromMilliseconds(500));
-
- // stop shard cleanly
- region.Tell(new PersistentShardCoordinator.HandOff("1"));
- ExpectMsg(s => s.Shard == "1", TimeSpan.FromSeconds(10));
-
- var probe2 = CreateTestProbe();
- AwaitAssert(() =>
- {
- shard.Tell(new Identify(2), probe2.Ref);
- probe1.ExpectMsg(i => i.MessageId.Equals(1) && i.Subject == null, TimeSpan.FromSeconds(1));
- }, TimeSpan.FromSeconds(5), TimeSpan.FromMilliseconds(500));
-
- }, _third);
- EnterBarrier("shard-shutdonw-12");
-
- RunOn(() =>
- {
- // force shard backup
- _persistentRegion.Value.Tell(new Counter.Get(25));
- ExpectMsg(0);
-
- var shard = LastSender.Path.Parent;
-
- // check counter 1 is still dead
- Sys.ActorSelection(shard / "1").Tell(new Identify(3));
- ExpectMsg(i => i.MessageId.Equals(3) && i.Subject == null);
-
- // check counter 13 is alive again
- Sys.ActorSelection(shard / "13").Tell(new Identify(4));
- ExpectMsg(i => i.MessageId.Equals(4) && i.Subject != null);
-
- }, _fourth);
- EnterBarrier("after-13");
- });
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void Persistent_cluster_shards_should_restart_entities_which_stop_without_passivation()
- {
- Persistent_cluster_shards_should_permanently_stop_entities_which_passivate();
-
- Within(TimeSpan.FromSeconds(50), () =>
- {
- RunOn(() =>
- {
- var x = _persistentRegion.Value;
- }, _third, _fourth);
- EnterBarrier("cluster-started-12");
-
- RunOn(() =>
- {
- //create and increment counter 1
- _persistentRegion.Value.Tell(new Counter.EntityEnvelope(1, Counter.Increment.Instance));
- _persistentRegion.Value.Tell(new Counter.Get(1));
- ExpectMsg(2);
-
- var counter1 = Sys.ActorSelection(LastSender.Path);
- counter1.Tell(Counter.Stop.Instance);
-
- var probe = CreateTestProbe();
- AwaitAssert(() =>
- {
- counter1.Tell(new Identify(1), probe.Ref);
- Assert.NotNull(probe.ExpectMsg(TimeSpan.FromSeconds(1)).Subject);
- }, TimeSpan.FromSeconds(5), TimeSpan.FromMilliseconds(500));
- }, _third);
- EnterBarrier("after-14");
- });
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void Persistent_cluster_shards_should_be_migrated_to_new_regions_upon_region_failure()
- {
- Persistent_cluster_shards_should_restart_entities_which_stop_without_passivation();
-
- Within(TimeSpan.FromSeconds(15), () =>
- {
- //Start only one region, and force an entity onto that region
- RunOn(() =>
- {
- _autoMigrateRegion.Value.Tell(new Counter.EntityEnvelope(1, Counter.Increment.Instance));
- _autoMigrateRegion.Value.Tell(new Counter.Get(1));
- ExpectMsg(1);
- }, _third);
- EnterBarrier("shard1-region3");
-
- //Start another region and test it talks to node 3
- RunOn(() =>
- {
- _autoMigrateRegion.Value.Tell(new Counter.EntityEnvelope(1, Counter.Increment.Instance));
- _autoMigrateRegion.Value.Tell(new Counter.Get(1));
- ExpectMsg(2);
-
- Assert.Equal(Node(_third) / "user" / "AutoMigrateRegionTestRegion" / "1" / "1", LastSender.Path);
-
- // kill region 3
- Sys.ActorSelection(LastSender.Path.Parent.Parent).Tell(PoisonPill.Instance);
- }, _fourth);
- EnterBarrier("region4-up");
-
- // Wait for migration to happen
- //Test the shard, thus counter was moved onto node 4 and started.
- RunOn(() =>
- {
- var counter1 = Sys.ActorSelection(ActorPath.Parse("user") / "AutoMigrateRegionTestRegion" / "1" / "1");
- var probe = CreateTestProbe();
- AwaitAssert(() =>
- {
- counter1.Tell(new Identify(1), probe.Ref);
- Assert.NotNull(probe.ExpectMsg(TimeSpan.FromSeconds(1)).Subject);
- }, TimeSpan.FromSeconds(5), TimeSpan.FromMilliseconds(500));
-
- counter1.Tell(new Counter.Get(1));
- ExpectMsg(2);
- }, _fourth);
- EnterBarrier("after-15");
- });
- }
-
- [MultiNodeFact(Skip = "TODO")]
- public void Persistent_cluster_shards_should_ensure_rebalance_restarts_shards()
- {
- Persistent_cluster_shards_should_be_migrated_to_new_regions_upon_region_failure();
-
- Within(TimeSpan.FromSeconds(50), () =>
- {
- RunOn(() =>
- {
- for (int i = 1; i <= 12; i++)
- _rebalancingPersistentRegion.Value.Tell(new Counter.EntityEnvelope(i, Counter.Increment.Instance));
-
- for (int i = 1; i <= 12; i++)
- {
- _rebalancingPersistentRegion.Value.Tell(new Counter.Get(i));
- ExpectMsg(1);
- }
- }, _fourth);
- EnterBarrier("entities-started");
-
- RunOn(() =>
- {
- var r = _rebalancingPersistentRegion.Value;
- }, _fifth);
- EnterBarrier("fifth-joined-shard");
-
- RunOn(() =>
- {
- AwaitAssert(() =>
- {
- var count = 0;
- for (int i = 2; i <= 12; i++)
- {
- var entity = Sys.ActorSelection(_rebalancingPersistentRegion.Value.Path / (i % 12).ToString() / i.ToString());
- entity.Tell(new Identify(i));
-
- var msg = ReceiveOne(TimeSpan.FromSeconds(3)) as ActorIdentity;
- if (msg != null && msg.Subject != null)
- count++;
- }
-
- Assert.True(count >= 2);
- });
- }, _fifth);
- EnterBarrier("after-16");
- });
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/LeastShardAllocationStrategySpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/LeastShardAllocationStrategySpec.cs
deleted file mode 100644
index f1f701a1391..00000000000
--- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/LeastShardAllocationStrategySpec.cs
+++ /dev/null
@@ -1,94 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright (C) 2009-2015 Typesafe Inc.
-// Copyright (C) 2013-2015 Akka.NET project
-//
-//-----------------------------------------------------------------------
-
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Linq;
-using Akka.Actor;
-using Akka.TestKit;
-using Akka.TestKit.Xunit2;
-using Xunit;
-
-namespace Akka.Cluster.Sharding.Tests
-{
- public class LeastShardAllocationStrategySpec : TestKitBase
- {
- private readonly IShardAllocationStrategy _allocationStrategy;
- private readonly IActorRef _regionA;
- private readonly IActorRef _regionB;
- private readonly IActorRef _regionC;
-
- public LeastShardAllocationStrategySpec() : base(new XunitAssertions(), "LeastShardAllocationStrategySpec")
- {
- _regionA = Sys.ActorOf(Props.Empty, "regionA");
- _regionB = Sys.ActorOf(Props.Empty, "regionB");
- _regionC = Sys.ActorOf(Props.Empty, "regionC");
-
- _allocationStrategy = new LeastShardAllocationStrategy(3, 2);
- }
-
- [Fact]
- public void LeastShardAllocationStrategy_should_allocate_to_region_with_least_number_of_shards()
- {
- var allocations = new Dictionary>
- {
- {_regionA, new []{"shard1"}.ToImmutableList() },
- {_regionB, new []{"shard2"}.ToImmutableList() },
- {_regionC, ImmutableList.Empty }
- }.ToImmutableDictionary();
-
- var result = _allocationStrategy.AllocateShard(_regionA, "shard3", allocations).Result;
- Assert.Equal(result, _regionC);
- }
-
- [Fact]
- public void LeastShardAllocationStrategy_should_reallocate_from_region_with_most_number_of_shards()
- {
- var allocations = new Dictionary>
- {
- {_regionA, new []{"shard1"}.ToImmutableList() },
- {_regionB, new []{"shard2", "shard3"}.ToImmutableList() },
- {_regionC, ImmutableList.Empty }
- }.ToImmutableDictionary();
-
- // so far regionB has 2 shards and regionC has 0 shards, but the diff is less than rebalanceThreshold
- var r1 = _allocationStrategy.Rebalance(allocations, ImmutableHashSet.Empty).Result;
- Assert.Equal(r1.Count, 0);
-
- allocations = allocations.SetItem(_regionB, new[] { "shard2", "shard3", "shard4" }.ToImmutableList());
- var r2 = _allocationStrategy.Rebalance(allocations, ImmutableHashSet.Empty).Result;
- Assert.Equal(r2.Count, 1);
- Assert.Equal(r2.First(), "shard2");
-
- var r3 = _allocationStrategy.Rebalance(allocations, ImmutableHashSet.Empty.Add("shard4")).Result;
- Assert.Equal(r3.Count, 0);
-
- allocations = allocations.SetItem(_regionA, new[] { "shard1", "shard5", "shard6" }.ToImmutableList());
- var r4 = _allocationStrategy.Rebalance(allocations, ImmutableHashSet.Empty.Add("shard1")).Result;
- Assert.Equal(r4.Count, 1);
- Assert.Equal(r2.First(), "shard2");
- }
-
- [Fact]
- public void LeastShardAllocationStrategy_should_limit_number_of_simultanious_rebalances()
- {
- var allocations = new Dictionary>
- {
- {_regionA, new []{"shard1"}.ToImmutableList() },
- {_regionB, new []{ "shard2", "shard3", "shard4", "shard5", "shard6" }.ToImmutableList() },
- {_regionC, ImmutableList.Empty}
- }.ToImmutableDictionary();
-
- var r1 = _allocationStrategy.Rebalance(allocations, ImmutableHashSet.Empty.Add("shard2")).Result;
- Assert.Equal(r1.Count, 1);
- Assert.Equal(r1.First(), "shard3");
-
- var r2 = _allocationStrategy.Rebalance(allocations, ImmutableHashSet.Empty.Add("shard2").Add("shard3")).Result;
- Assert.Equal(r2.Count, 0);
- }
- }
-}
\ No newline at end of file
diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/Properties/AssemblyInfo.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/Properties/AssemblyInfo.cs
deleted file mode 100644
index 5f5029bda60..00000000000
--- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("Akka.Cluster.Sharding.Tests")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("Akka.Cluster.Sharding.Tests")]
-[assembly: AssemblyCopyright("Copyright © 2015")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("b369f314-4d37-4ac1-b4fb-64ff671af0bc")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/packages.config b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/packages.config
deleted file mode 100644
index 1c51a9333a8..00000000000
--- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/packages.config
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/Akka.Cluster.Sharding.csproj b/src/contrib/cluster/Akka.Cluster.Sharding/Akka.Cluster.Sharding.csproj
deleted file mode 100644
index f2229d5617b..00000000000
--- a/src/contrib/cluster/Akka.Cluster.Sharding/Akka.Cluster.Sharding.csproj
+++ /dev/null
@@ -1,179 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {A05C31E8-0246-46A1-B3BC-4D6FE7A9AA49}
- Library
- Properties
- Akka.Cluster.Sharding
- Akka.Cluster.Sharding
- v4.5
- 512
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
- ..\..\..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.dll
- True
-
-
- ..\..\..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.Serialization.dll
- True
-
-
-
- ..\..\..\packages\System.Collections.Immutable.1.1.37\lib\dotnet\System.Collections.Immutable.dll
- True
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {6ab00f61-269a-4501-b06a-026707f000a7}
- Akka.Cluster
-
-
- {fca84dea-c118-424b-9eb8-34375dfef18a}
- Akka.Persistence
-
-
- {ea4ff8fd-7c53-49c8-b9aa-02e458b3e6a7}
- Akka.Remote
-
-
- {5deddf90-37f0-48d3-a0b0-a5cbd8a7e377}
- Akka
-
-
- {5cf8a8be-b634-473f-bb01-eba878746bd4}
- Akka.Cluster.Tools
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ..\..\..\..\packages\Google.ProtocolBuffers\lib\net35\Google.ProtocolBuffers.Serialization.dll
- True
- True
-
-
- ..\..\..\..\packages\Google.ProtocolBuffers\lib\net35\Google.ProtocolBuffers.dll
- True
- True
-
-
-
-
-
-
- ..\..\..\..\packages\Google.ProtocolBuffers\lib\net20\Google.ProtocolBuffers.Serialization.dll
- True
- True
-
-
- ..\..\..\..\packages\Google.ProtocolBuffers\lib\net20\Google.ProtocolBuffers.dll
- True
- True
-
-
-
-
-
-
-
- ..\..\..\..\packages\Google.ProtocolBuffers\lib\sl30\Google.ProtocolBuffers.Serialization.dll
- True
- True
-
-
- ..\..\..\..\packages\Google.ProtocolBuffers\lib\sl30\Google.ProtocolBuffers.dll
- True
- True
-
-
-
-
-
-
- ..\..\..\..\packages\Google.ProtocolBuffers\lib\sl40\Google.ProtocolBuffers.Serialization.dll
- True
- True
-
-
- ..\..\..\..\packages\Google.ProtocolBuffers\lib\sl40\Google.ProtocolBuffers.dll
- True
- True
-
-
-
-
-
-
- ..\..\..\..\packages\Google.ProtocolBuffers\lib\portable-net40+sl4+sl5+wp7+wp8+win8\Google.ProtocolBuffers.Serialization.dll
- True
- True
-
-
- ..\..\..\..\packages\Google.ProtocolBuffers\lib\portable-net40+sl4+sl5+wp7+wp8+win8\Google.ProtocolBuffers.dll
- True
- True
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/ClusterSharding.cs b/src/contrib/cluster/Akka.Cluster.Sharding/ClusterSharding.cs
deleted file mode 100644
index ca55cbcb8d0..00000000000
--- a/src/contrib/cluster/Akka.Cluster.Sharding/ClusterSharding.cs
+++ /dev/null
@@ -1,620 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright (C) 2009-2015 Typesafe Inc.
-// Copyright (C) 2013-2015 Akka.NET project
-//
-//-----------------------------------------------------------------------
-
-using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using Akka.Actor;
-using Akka.Configuration;
-using Akka.Dispatch;
-using Akka.Pattern;
-
-namespace Akka.Cluster.Sharding
-{
- using Msg = Object;
- using EntityId = String;
- using ShardId = String;
-
- ///
- /// Marker trait for remote messages and persistent events/snapshots with special serializer.
- ///
- public interface IClusterShardingSerializable { }
-
- public class ClusterShardingExtensionProvider : ExtensionIdProvider
- {
- public override ClusterSharding CreateExtension(ExtendedActorSystem system)
- {
- var extension = new ClusterSharding(system);
- return extension;
- }
- }
-
- ///
- /// Convenience implementation of that
- /// construct ShardId based on the of the EntityId.
- /// The number of unique shards is limited by the given MaxNumberOfShards.
- ///
- public abstract class HashCodeMessageExtractor : IMessageExtractor
- {
- public readonly int MaxNumberOfShards;
-
- protected HashCodeMessageExtractor(int maxNumberOfShards)
- {
- MaxNumberOfShards = maxNumberOfShards;
- }
-
- public abstract string EntityId(object message);
-
- public virtual object EntityMessage(object message)
- {
- return message;
- }
-
- public virtual string ShardId(object message)
- {
- return (Math.Abs(EntityId(message).GetHashCode())%MaxNumberOfShards).ToString();
- }
- }
-
- ///
- ///
- /// This extension provides sharding functionality of actors in a cluster.
- /// The typical use case is when you have many stateful actors that together consume
- /// more resources (e.g. memory) than fit on one machine. You need to distribute them across
- /// several nodes in the cluster and you want to be able to interact with them using their
- /// logical identifier, but without having to care about their physical location in the cluster,
- /// which might also change over time. It could for example be actors representing Aggregate Roots in
- /// Domain-Driven Design terminology. Here we call these actors "entries". These actors
- /// typically have persistent (durable) state, but this feature is not limited to
- /// actors with persistent state.
- ///
- ///
- /// In this context sharding means that actors with an identifier, so called entries,
- /// can be automatically distributed across multiple nodes in the cluster. Each entity
- /// actor runs only at one place, and messages can be sent to the entity without requiring
- /// the sender to know the location of the destination actor. This is achieved by sending
- /// the messages via a actor provided by this extension, which knows how
- /// to route the message with the entity id to the final destination.
- ///
- ///
- /// This extension is supposed to be used by first, typically at system startup on each node
- /// in the cluster, registering the supported entity types with the
- /// method and then the actor for a named entity type can be retrieved with
- /// . Messages to the entries are always sent via the local
- /// . Some settings can be configured as described in the `akka.contrib.cluster.sharding`
- /// section of the `reference.conf`.
- ///
- ///
- /// The actor is started on each node in the cluster, or group of nodes
- /// tagged with a specific role. The is created with two application specific
- /// functions to extract the entity identifier and the shard identifier from incoming messages.
- /// A shard is a group of entries that will be managed together. For the first message in a
- /// specific shard the request the location of the shard from a central coordinator,
- /// the . The decides which that
- /// owns the shard. The receives the decided home of the shard
- /// and if that is the instance itself it will create a local child
- /// actor representing the entity and direct all messages for that entity to it.
- /// If the shard home is another instance messages will be forwarded
- /// to that instance instead. While resolving the location of a
- /// shard incoming messages for that shard are buffered and later delivered when the
- /// shard home is known. Subsequent messages to the resolved shard can be delivered
- /// to the target destination immediately without involving the .
- ///
- ///
- /// To make sure that at most one instance of a specific entity actor is running somewhere
- /// in the cluster it is important that all nodes have the same view of where the shards
- /// are located. Therefore the shard allocation decisions are taken by the central
- /// , which is running as a cluster singleton, i.e. one instance on
- /// the oldest member among all cluster nodes or a group of nodes tagged with a specific
- /// role. The oldest member can be determined by .
- ///
- ///
- /// The logic that decides where a shard is to be located is defined in a pluggable shard
- /// allocation strategy. The default implementation
- /// allocates new shards to the with least number of previously allocated shards.
- /// This strategy can be replaced by an application specific implementation.
- ///
- ///
- /// To be able to use newly added members in the cluster the coordinator facilitates rebalancing
- /// of shards, i.e. migrate entries from one node to another. In the rebalance process the
- /// coordinator first notifies all actors that a handoff for a shard has started.
- /// That means they will start buffering incoming messages for that shard, in the same way as if the
- /// shard location is unknown. During the rebalance process the coordinator will not answer any
- /// requests for the location of shards that are being rebalanced, i.e. local buffering will
- /// continue until the handoff is completed. The responsible for the rebalanced shard
- /// will stop all entries in that shard by sending `PoisonPill` to them. When all entries have
- /// been terminated the owning the entries will acknowledge the handoff as completed
- /// to the coordinator. Thereafter the coordinator will reply to requests for the location of
- /// the shard and thereby allocate a new home for the shard and then buffered messages in the
- /// actors are delivered to the new location. This means that the state of the entries
- /// are not transferred or migrated. If the state of the entries are of importance it should be
- /// persistent (durable), e.g. with `Akka.Persistence`, so that it can be recovered at the new
- /// location.
- ///
- ///
- /// The logic that decides which shards to rebalance is defined in a pluggable shard
- /// allocation strategy. The default implementation
- /// picks shards for handoff from the with most number of previously allocated shards.
- /// They will then be allocated to the with least number of previously allocated shards,
- /// i.e. new members in the cluster. There is a configurable threshold of how large the difference
- /// must be to begin the rebalancing. This strategy can be replaced by an application specific
- /// implementation.
- ///
- ///
- /// The state of shard locations in the is persistent (durable) with
- /// `Akka.Persistence` to survive failures. Since it is running in a cluster `Akka.Persistence`
- /// must be configured with a distributed journal. When a crashed or unreachable coordinator
- /// node has been removed (via down) from the cluster a new singleton
- /// actor will take over and the state is recovered. During such a failure period shards
- /// with known location are still available, while messages for new (unknown) shards
- /// are buffered until the new becomes available.
- ///
- ///
- /// As long as a sender uses the same actor to deliver messages to an entity
- /// actor the order of the messages is preserved. As long as the buffer limit is not reached
- /// messages are delivered on a best effort basis, with at-most once delivery semantics,
- /// in the same way as ordinary message sending. Reliable end-to-end messaging, with
- /// at-least-once semantics can be added by using in `Akka.Persistence`.
- ///
- /// Some additional latency is introduced for messages targeted to new or previously
- /// unused shards due to the round-trip to the coordinator. Rebalancing of shards may
- /// also add latency. This should be considered when designing the application specific
- /// shard resolution, e.g. to avoid too fine grained shards.
- ///
- /// The actor can also be started in proxy only mode, i.e. it will not
- /// host any entries itself, but knows how to delegate messages to the right location.
- /// A starts in proxy only mode if the roles of the node does not include
- /// the node role specified in `akka.contrib.cluster.sharding.role` config property
- /// or if the specified `EntityProps` is `null`.
- ///
- ///
- /// If the state of the entries are persistent you may stop entries that are not used to
- /// reduce memory consumption. This is done by the application specific implementation of
- /// the entity actors for example by defining receive timeout ().
- /// If a message is already enqueued to the entity when it stops itself the enqueued message
- /// in the mailbox will be dropped. To support graceful passivation without loosing such
- /// messages the entity actor can send to its parent .
- /// The specified wrapped message in will be sent back to the entity, which is
- /// then supposed to stop itself. Incoming messages will be buffered by the
- /// between reception of and termination of the entity. Such buffered messages
- /// are thereafter delivered to a new incarnation of the entity.
- ///
- ///
- public class ClusterSharding : IExtension
- {
- private readonly Lazy _guardian;
- private readonly ConcurrentDictionary _regions = new ConcurrentDictionary();
- private readonly ExtendedActorSystem _system;
- private readonly Cluster _cluster;
-
- public static ClusterSharding Get(ActorSystem system)
- {
- return system.WithExtension();
- }
-
- public ClusterSharding(ExtendedActorSystem system)
- {
- _system = system;
- _system.Settings.InjectTopLevelFallback(DefaultConfig());
- _cluster = Cluster.Get(_system);
- Settings = ClusterShardingSettings.Create(system);
-
- _guardian = new Lazy(() =>
- {
- var guardianName = system.Settings.Config.GetString("akka.cluster.sharding.guardian-name");
- var dispatcher = system.Settings.Config.GetString("akka.cluster.sharding.use-dispatcher");
- if (string.IsNullOrEmpty(dispatcher)) dispatcher = Dispatchers.DefaultDispatcherId;
- return system.ActorOf(Props.Create(() => new ClusterShardingGuardian()).WithDispatcher(dispatcher), guardianName);
- });
- }
-
- public ClusterShardingSettings Settings { get; private set; }
-
- public static Config DefaultConfig()
- {
- return ConfigurationFactory.FromResource("Akka.Cluster.Sharding.reference.conf");
- }
-
- ///
- /// Register a named entity type by defining the of the entity actor and
- /// functions to extract entity and shard identifier from messages. The
- /// actor for this type can later be retrieved with the method.
- ///
- /// The name of the entity type
- ///
- /// The of the entity actors that will be created by the
- ///
- /// Configuration settings, see
- ///
- /// Partial function to extract the entity id and the message to send to the entity from the incoming message,
- /// if the partial function does not match the message will be `unhandled`,
- /// i.e.posted as `Unhandled` messages on the event stream
- ///
- ///
- /// Function to determine the shard id for an incoming message, only messages that passed the `extractEntityId` will be used
- ///
- /// Possibility to use a custom shard allocation and rebalancing logic
- ///
- /// The message that will be sent to entities when they are to be stopped for a rebalance or
- /// graceful shutdown of a , e.g. .
- ///
- /// The actor ref of the that is to be responsible for the shard.
- public IActorRef Start(
- string typeName, //TODO: change type name to type instance?
- Props entityProps,
- ClusterShardingSettings settings,
- IdExtractor idExtractor,
- ShardResolver shardResolver,
- IShardAllocationStrategy allocationStrategy,
- object handOffStopMessage)
- {
- RequireClusterRole(settings.Role);
-
- var timeout = _system.Settings.CreationTimeout;
- var startMsg = new ClusterShardingGuardian.Start(typeName, entityProps, settings, idExtractor, shardResolver, allocationStrategy, handOffStopMessage);
-
- var started = _guardian.Value.Ask(startMsg, timeout).Result;
- var shardRegion = started.ShardRegion;
- _regions.TryAdd(typeName, shardRegion);
- return shardRegion;
- }
-
- ///
- /// Register a named entity type by defining the of the entity actor and
- /// functions to extract entity and shard identifier from messages. The
- /// actor for this type can later be retrieved with the method.
- ///
- /// The name of the entity type
- ///
- /// The of the entity actors that will be created by the
- ///
- /// Configuration settings, see
- ///
- /// Partial function to extract the entity id and the message to send to the entity from the incoming message,
- /// if the partial function does not match the message will be `unhandled`,
- /// i.e.posted as `Unhandled` messages on the event stream
- ///
- ///
- /// Function to determine the shard id for an incoming message, only messages that passed the `extractEntityId` will be used
- ///
- /// The actor ref of the that is to be responsible for the shard.
- public IActorRef Start(
- string typeName, //TODO: change type name to type instance?
- Props entityProps,
- ClusterShardingSettings settings,
- IdExtractor idExtractor,
- ShardResolver shardResolver)
- {
- var allocationStrategy = new LeastShardAllocationStrategy(
- Settings.TunningParameters.LeastShardAllocationRebalanceThreshold,
- Settings.TunningParameters.LeastShardAllocationMaxSimultaneousRebalance);
- return Start(typeName, entityProps, settings, idExtractor, shardResolver, allocationStrategy, PoisonPill.Instance);
- }
-
- ///
- /// Register a named entity type by defining the of the entity actor and
- /// functions to extract entity and shard identifier from messages. The
- /// actor for this type can later be retrieved with the method.
- ///
- /// The name of the entity type
- ///
- /// The of the entity actors that will be created by the
- ///
- /// Configuration settings, see
- ///
- /// Functions to extract the entity id, shard id, and the message to send to the entity from the incoming message.
- ///
- /// Possibility to use a custom shard allocation and rebalancing logic
- ///
- /// The message that will be sent to entities when they are to be stopped for a rebalance or
- /// graceful shutdown of a , e.g. .
- ///
- /// The actor ref of the that is to be responsible for the shard.
- public IActorRef Start(string typeName, Props entityProps, ClusterShardingSettings settings,
- IMessageExtractor messageExtractor, IShardAllocationStrategy allocationStrategy, object handOffMessage)
- {
- IdExtractor idExtractor = messageExtractor.ToIdExtractor();
- ShardResolver shardResolver = messageExtractor.ShardId;
-
- return Start(typeName, entityProps, settings, idExtractor, shardResolver, allocationStrategy, handOffMessage);
- }
-
- ///
- /// Register a named entity type by defining the of the entity actor and
- /// functions to extract entity and shard identifier from messages. The
- /// actor for this type can later be retrieved with the method.
- ///
- /// The name of the entity type
- ///
- /// The of the entity actors that will be created by the
- ///
- /// Configuration settings, see
- ///
- /// Functions to extract the entity id, shard id, and the message to send to the entity from the incoming message.
- ///
- /// The actor ref of the that is to be responsible for the shard.
- public IActorRef Start(string typeName, Props entityProps, ClusterShardingSettings settings,
- IMessageExtractor messageExtractor)
- {
- return Start(typeName,
- entityProps,
- settings,
- messageExtractor,
- new LeastShardAllocationStrategy(
- Settings.TunningParameters.LeastShardAllocationRebalanceThreshold,
- Settings.TunningParameters.LeastShardAllocationMaxSimultaneousRebalance),
- PoisonPill.Instance);
- }
-
- ///
- /// Register a named entity type `ShardRegion` on this node that will run in proxy only mode, i.e.it will
- /// delegate messages to other `ShardRegion` actors on other nodes, but not host any entity actors itself.
- /// The actor for this type can later be retrieved with the
- /// method.
- ///
- /// The name of the entity type.
- ///
- /// Specifies that this entity type is located on cluster nodes with a specific role.
- /// If the role is not specified all nodes in the cluster are used.
- ///
- ///
- /// Partial function to extract the entity id and the message to send to the entity from the incoming message,
- /// if the partial function does not match the message will be `unhandled`, i.e.posted as `Unhandled` messages
- /// on the event stream
- ///
- ///
- /// Function to determine the shard id for an incoming message, only messages that passed the `extractEntityId` will be used
- ///
- /// The actor ref of the that is to be responsible for the shard.
- public IActorRef StartProxy(string typeName, string role, IdExtractor idExtractor, ShardResolver shardResolver)
- {
- var timeout = _system.Settings.CreationTimeout;
- var settings = ClusterShardingSettings.Create(_system).WithRole(role);
- var startMsg = new ClusterShardingGuardian.StartProxy(typeName, settings, idExtractor, shardResolver);
- var started = _guardian.Value.Ask(startMsg, timeout).Result;
- _regions.TryAdd(typeName, started.ShardRegion);
- return started.ShardRegion;
- }
-
- ///
- /// Register a named entity type `ShardRegion` on this node that will run in proxy only mode, i.e.it will
- /// delegate messages to other `ShardRegion` actors on other nodes, but not host any entity actors itself.
- /// The actor for this type can later be retrieved with the
- /// method.
- ///
- /// The name of the entity type.
- ///
- /// Specifies that this entity type is located on cluster nodes with a specific role.
- /// If the role is not specified all nodes in the cluster are used.
- ///
- ///
- /// Functions to extract the entity id, shard id, and the message to send to the entity from the incoming message.
- ///
- /// The actor ref of the that is to be responsible for the shard.
- public IActorRef StartProxy(string typeName, string role, IMessageExtractor messageExtractor)
- {
- IdExtractor extractEntityId = msg =>
- {
- var entityId = messageExtractor.EntityId(msg);
- var entityMessage = messageExtractor.EntityMessage(msg);
- return Tuple.Create(entityId, entityMessage);
- };
-
- return StartProxy(typeName, role, extractEntityId, messageExtractor.ShardId);
- }
-
- ///
- /// Retrieve the actor reference of the actor responsible for the named entity type.
- /// The entity type must be registered with the method before it can be used here.
- /// Messages to the entity is always sent via the .
- ///
- public IActorRef ShardRegion(string typeName)
- {
- IActorRef region;
- if (_regions.TryGetValue(typeName, out region))
- {
- return region;
- }
- throw new ArgumentException(string.Format("Shard type [{0}] must be started first", typeName));
- }
-
- private void RequireClusterRole(string role)
- {
- if (!(string.IsNullOrEmpty(role) || _cluster.SelfRoles.Contains(role)))
- {
- throw new IllegalStateException(string.Format("This cluster member [{0}] doesn't have the role [{1}]", _cluster.SelfAddress, role));
- }
- }
- }
-
- ///
- /// Interface of the function used by the to
- /// extract the shard id from an incoming message.
- /// Only messages that passed the will be used
- /// as input to this function.
- ///
- public delegate ShardId ShardResolver(Msg message);
-
- public static class ShardResolvers
- {
- public static readonly ShardResolver Default = msg => (ShardId)msg;
- }
-
- ///
- /// Interface of the partial function used by the to
- /// extract the entity id and the message to send to the entity from an
- /// incoming message. The implementation is application specific.
- /// If the partial function does not match the message will be
- /// `unhandled`, i.e. posted as `Unhandled` messages on the event stream.
- /// Note that the extracted message does not have to be the same as the incoming
- /// message to support wrapping in message envelope that is unwrapped before
- /// sending to the entity actor.
- ///
- public delegate Tuple IdExtractor(Msg message);
-
- ///
- /// Interface of functions to extract entity id, shard id, and the message to send
- /// to the entity from an incoming message.
- ///
- public interface IMessageExtractor
- {
- ///
- /// Extract the entity id from an incoming .
- /// If `null` is returned the message will be `unhandled`, i.e. posted as `Unhandled`
- /// messages on the event stream
- ///
- EntityId EntityId(object message);
-
- ///
- /// Extract the message to send to the entity from an incoming .
- /// Note that the extracted message does not have to be the same as the incoming
- /// message to support wrapping in message envelope that is unwrapped before
- /// sending to the entity actor.
- ///
- object EntityMessage(object message);
-
- ///
- /// Extract the entity id from an incoming . Only messages that
- /// passed the method will be used as input to this method.
- ///
- string ShardId(object message);
- }
-
- public static class Extensions
- {
- public static IdExtractor ToIdExtractor(this IMessageExtractor self)
- {
- IdExtractor idExtractor = msg =>
- {
- if (self.EntityId(msg) != null)
- return Tuple.Create(self.EntityId(msg), self.EntityMessage(msg));
- //TODO: should we really use tuples?
-
- return null;
- };
-
- return idExtractor;
- }
- }
-
- ///
- /// Periodic message to trigger rebalance.
- ///
- internal sealed class RebalanceTick
- {
- public static readonly RebalanceTick Instance = new RebalanceTick();
- private RebalanceTick() { }
- }
-
- ///
- /// End of rebalance process performed by .
- ///
- internal sealed class RebalanceDone
- {
- public readonly ShardId Shard;
- public readonly bool Ok;
-
- public RebalanceDone(string shard, bool ok)
- {
- Shard = shard;
- Ok = ok;
- }
- }
-
- ///
- /// INTERNAL API. Rebalancing process is performed by this actor. It sends
- /// to all actors followed
- /// by to the responsible for
- /// the shard. When the handoff is completed it sends to its parent
- /// . If the process takes longer than the `handOffTimeout` it
- /// also sends .
- ///
- public class RebalanceWorker : ActorBase
- {
- public static Props Props(string shard, IActorRef @from, TimeSpan handOffTimeout, IEnumerable regions)
- {
- return Actor.Props.Create(() => new RebalanceWorker(shard, @from, handOffTimeout, regions));
- }
-
- private readonly ShardId _shard;
- private readonly IActorRef _from;
- private readonly ISet _remaining;
-
- public RebalanceWorker(string shard, IActorRef @from, TimeSpan handOffTimeout, IEnumerable regions)
- {
- _shard = shard;
- _from = @from;
-
- _remaining = new HashSet(regions);
- foreach (var region in _remaining)
- region.Tell(new PersistentShardCoordinator.BeginHandOff(shard));
-
- Context.System.Scheduler.ScheduleTellOnce(handOffTimeout, Self, ReceiveTimeout.Instance, Self);
- }
-
- protected override bool Receive(object message)
- {
- if (message is PersistentShardCoordinator.BeginHandOffAck)
- {
- var shard = ((PersistentShardCoordinator.BeginHandOffAck)message).Shard;
- _remaining.Remove(Sender);
- if (_remaining.Count == 0)
- {
- _from.Tell(new PersistentShardCoordinator.HandOff(shard));
- Context.Become(StoppingShard);
- }
- }
- else if (message is ReceiveTimeout)
- {
- Done(false);
- }
- else return false;
- return true;
- }
-
- private bool StoppingShard(object message)
- {
- if (message is PersistentShardCoordinator.ShardStopped) Done(true);
- else if (message is ReceiveTimeout) Done(false);
- else return false;
- return true;
- }
-
- private void Done(bool ok)
- {
- Context.Parent.Tell(new RebalanceDone(_shard, ok));
- Context.Stop(Self);
- }
- }
-
- ///
- /// Check if we've received a shard start request.
- ///
- [Serializable]
- public sealed class ResendShardHost
- {
- public readonly ShardId Shard;
- public readonly IActorRef Region;
-
- public ResendShardHost(string shard, IActorRef region)
- {
- Shard = shard;
- Region = region;
- }
- }
-
- [Serializable]
- public sealed class DelayedShardRegionTerminated
- {
- public readonly IActorRef Region;
-
- public DelayedShardRegionTerminated(IActorRef region)
- {
- Region = region;
- }
- }
-}
\ No newline at end of file
diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/ClusterShardingGuardian.cs b/src/contrib/cluster/Akka.Cluster.Sharding/ClusterShardingGuardian.cs
deleted file mode 100644
index ce6e2da4852..00000000000
--- a/src/contrib/cluster/Akka.Cluster.Sharding/ClusterShardingGuardian.cs
+++ /dev/null
@@ -1,145 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright (C) 2009-2015 Typesafe Inc.
-// Copyright (C) 2013-2015 Akka.NET project
-//
-//-----------------------------------------------------------------------
-
-using System;
-using Akka.Actor;
-using Akka.Cluster.Tools.Singleton;
-using Akka.Pattern;
-
-namespace Akka.Cluster.Sharding
-{
- ///
- /// INTERNAL API: and actors are createad as children of this actor.
- ///
- public sealed class ClusterShardingGuardian : ReceiveActor
- {
- #region messages
-
- [Serializable]
- public sealed class Started : INoSerializationVerificationNeeded
- {
- public readonly IActorRef ShardRegion;
-
- public Started(IActorRef shardRegion)
- {
- ShardRegion = shardRegion;
- }
- }
-
- [Serializable]
- public sealed class Start : INoSerializationVerificationNeeded
- {
- public readonly string TypeName;
- public readonly Props EntityProps;
- public readonly ClusterShardingSettings Settings;
- public readonly IdExtractor IdExtractor;
- public readonly ShardResolver ShardResolver;
- public readonly IShardAllocationStrategy AllocationStrategy;
- public readonly object HandOffStopMessage;
-
- public Start(string typeName, Props entityProps, ClusterShardingSettings settings,
- IdExtractor idIdExtractor, ShardResolver shardResolver, IShardAllocationStrategy allocationStrategy, object handOffStopMessage)
- {
- if (string.IsNullOrEmpty(typeName)) throw new ArgumentNullException("typeName", "ClusterSharding start requires type name to be provided");
- if (entityProps == null) throw new ArgumentNullException("entityProps", string.Format("ClusterSharding start requires Props for [{0}] to be provided", typeName));
-
- TypeName = typeName;
- EntityProps = entityProps;
- Settings = settings;
- IdExtractor = idIdExtractor;
- ShardResolver = shardResolver;
- AllocationStrategy = allocationStrategy;
- HandOffStopMessage = handOffStopMessage;
- }
- }
-
- [Serializable]
- public sealed class StartProxy : INoSerializationVerificationNeeded
- {
- public readonly string TypeName;
- public readonly ClusterShardingSettings Settings;
- public readonly IdExtractor ExtractEntityId;
- public readonly ShardResolver ExtractShardId;
-
- public StartProxy(string typeName, ClusterShardingSettings settings, IdExtractor extractEntityId, ShardResolver extractShardId)
- {
- if (string.IsNullOrEmpty(typeName)) throw new ArgumentNullException("typeName", "ClusterSharding start proxy requires type name to be provided");
-
- TypeName = typeName;
- Settings = settings;
- ExtractEntityId = extractEntityId;
- ExtractShardId = extractShardId;
- }
- }
-
- #endregion
-
- private readonly Cluster _cluster = Cluster.Get(Context.System);
- private readonly ClusterSharding _sharding = ClusterSharding.Get(Context.System);
-
- public ClusterShardingGuardian()
- {
- Receive(start =>
- {
- var settings = start.Settings;
- var encName = Uri.EscapeDataString(start.TypeName);
- var coordinatorSingletonManagerName = CoordinatorSingletonManagerName(encName);
- var coordinatorPath = CoordinatorPath(encName);
- var shardRegion = Context.Child(encName);
-
- if (Equals(shardRegion, ActorRefs.Nobody))
- {
- var minBackoff = settings.TunningParameters.CoordinatorFailureBackoff;
- var maxBackoff = new TimeSpan(minBackoff.Ticks * 5);
- var coordinatorProps = PersistentShardCoordinator.Props(start.TypeName, settings, start.AllocationStrategy);
- var singletonProps = Props.Create(() => new BackoffSupervisor(coordinatorProps, "coordinator", minBackoff, maxBackoff, 0.2)).WithDeploy(Deploy.Local);
- var singletonSettings = settings.CoordinatorSingletonSettings.WithSingletonName("singleton").WithRole(settings.Role);
-
- var shardCoordinatorSingleton = Context.ActorOf(ClusterSingletonManager.Props(singletonProps, PoisonPill.Instance, singletonSettings), coordinatorSingletonManagerName);
- }
-
- shardRegion = Context.ActorOf(ShardRegion.Props(
- typeName: start.TypeName,
- entityProps: start.EntityProps,
- settings: settings,
- coordinatorPath: coordinatorPath,
- extractEntityId: start.IdExtractor,
- extractShardId: start.ShardResolver,
- handOffStopMessage: start.HandOffStopMessage), encName);
-
- Sender.Tell(new Started(shardRegion));
- });
-
- Receive(startProxy =>
- {
- var settings = startProxy.Settings;
- var encName = Uri.EscapeDataString(startProxy.TypeName);
- var coordinatorSingletonManagerName = CoordinatorSingletonManagerName(encName);
- var coordinatorPath = CoordinatorPath(encName);
-
- var shardRegion = Context.ActorOf(ShardRegion.ProxyProps(
- typeName: startProxy.TypeName,
- settings: settings,
- coordinatorPath: coordinatorPath,
- extractEntityId: startProxy.ExtractEntityId,
- extractShardId: startProxy.ExtractShardId), encName);
-
- Sender.Tell(new Started(shardRegion));
- });
- }
-
- private string CoordinatorPath(string encName)
- {
- return (Self.Path / CoordinatorSingletonManagerName(encName) / "singleton" / "coordinator").ToStringWithoutAddress();
- }
-
- private static string CoordinatorSingletonManagerName(string encName)
- {
- return encName + "Coordinator";
- }
- }
-}
\ No newline at end of file
diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/ClusterShardingSettings.cs b/src/contrib/cluster/Akka.Cluster.Sharding/ClusterShardingSettings.cs
deleted file mode 100644
index 3000c798f17..00000000000
--- a/src/contrib/cluster/Akka.Cluster.Sharding/ClusterShardingSettings.cs
+++ /dev/null
@@ -1,204 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright (C) 2009-2015 Typesafe Inc.
-// Copyright (C) 2013-2015 Akka.NET project
-//
-//-----------------------------------------------------------------------
-
-using System;
-using Akka.Actor;
-using Akka.Cluster.Tools.Singleton;
-using Akka.Configuration;
-
-namespace Akka.Cluster.Sharding
-{
- [Serializable]
- public class TunningParameters
- {
- public readonly TimeSpan CoordinatorFailureBackoff;
- public readonly TimeSpan RetryInterval;
- public readonly int BufferSize;
- public readonly TimeSpan HandOffTimeout;
- public readonly TimeSpan ShardStartTimeout;
- public readonly TimeSpan ShardFailureBackoff;
- public readonly TimeSpan EntityRestartBackoff;
- public readonly TimeSpan RebalanceInterval;
- public readonly int SnapshotAfter;
- public readonly int LeastShardAllocationRebalanceThreshold;
- public readonly int LeastShardAllocationMaxSimultaneousRebalance;
-
- public TunningParameters(
- TimeSpan coordinatorFailureBackoff,
- TimeSpan retryInterval,
- int bufferSize,
- TimeSpan handOffTimeout,
- TimeSpan shardStartTimeout,
- TimeSpan shardFailureBackoff,
- TimeSpan entityRestartBackoff,
- TimeSpan rebalanceInterval,
- int snapshotAfter,
- int leastShardAllocationRebalanceThreshold,
- int leastShardAllocationMaxSimultaneousRebalance)
- {
- CoordinatorFailureBackoff = coordinatorFailureBackoff;
- RetryInterval = retryInterval;
- BufferSize = bufferSize;
- HandOffTimeout = handOffTimeout;
- ShardStartTimeout = shardStartTimeout;
- ShardFailureBackoff = shardFailureBackoff;
- EntityRestartBackoff = entityRestartBackoff;
- RebalanceInterval = rebalanceInterval;
- SnapshotAfter = snapshotAfter;
- LeastShardAllocationRebalanceThreshold = leastShardAllocationRebalanceThreshold;
- LeastShardAllocationMaxSimultaneousRebalance = leastShardAllocationMaxSimultaneousRebalance;
- }
- }
-
- [Serializable]
- public sealed class ClusterShardingSettings : INoSerializationVerificationNeeded
- {
- ///
- /// Specifies that this entity type requires cluster nodes with a specific role.
- /// If the role is not specified all nodes in the cluster are used.
- ///
- public readonly string Role;
-
- ///
- /// True if active entity actors shall be automatically restarted upon restart.i.e.
- /// if the is started on a different due to rebalance or crash.
- ///
- public readonly bool RememberEntities;
-
- ///
- /// Absolute path to the journal plugin configuration entity that is to be used for the internal
- /// persistence of ClusterSharding.If not defined the default journal plugin is used. Note that
- /// this is not related to persistence used by the entity actors.
- ///
- public readonly string JournalPluginId;
-
- ///
- /// Absolute path to the snapshot plugin configuration entity that is to be used for the internal persistence
- /// of ClusterSharding. If not defined the default snapshot plugin is used.Note that this is not related
- /// to persistence used by the entity actors.
- ///
- public readonly string SnapshotPluginId;
-
- public readonly TunningParameters TunningParameters;
-
- public readonly ClusterSingletonManagerSettings CoordinatorSingletonSettings;
-
- ///
- /// Create settings from the default configuration `akka.cluster.sharding`.
- ///
- public static ClusterShardingSettings Create(ActorSystem system)
- {
- var config = system.Settings.Config.GetConfig("akka.cluster.sharding");
- var coordinatorSingletonPath = config.GetString("coordinator-singleton");
-
- return Create(config, system.Settings.Config.GetConfig(coordinatorSingletonPath));
- }
-
- public static ClusterShardingSettings Create(Config config, Config singletonConfig)
- {
- var tuningParameters = new TunningParameters(
- coordinatorFailureBackoff: config.GetTimeSpan("coordinator-failure-backoff"),
- retryInterval: config.GetTimeSpan("retry-interval"),
- bufferSize: config.GetInt("buffer-size"),
- handOffTimeout: config.GetTimeSpan("handoff-timeout"),
- shardStartTimeout: config.GetTimeSpan("shard-start-timeout"),
- shardFailureBackoff: config.GetTimeSpan("shard-failure-backoff"),
- entityRestartBackoff: config.GetTimeSpan("entity-restart-backoff"),
- rebalanceInterval: config.GetTimeSpan("rebalance-interval"),
- snapshotAfter: config.GetInt("snapshot-after"),
- leastShardAllocationRebalanceThreshold: config.GetInt("least-shard-allocation-strategy.rebalance-threshold"),
- leastShardAllocationMaxSimultaneousRebalance: config.GetInt("least-shard-allocation-strategy.max-simultaneous-rebalance"));
-
- var coordinatorSingletonSettings = ClusterSingletonManagerSettings.Create(singletonConfig);
- var role = config.GetString("role");
- if (role == string.Empty) role = null;
-
- return new ClusterShardingSettings(
- role: role,
- rememberEntities: config.GetBoolean("remember-entities"),
- journalPluginId: config.GetString("journal-plugin-id"),
- snapshotPluginId: config.GetString("snapshot-plugin-id"),
- tunningParameters: tuningParameters,
- coordinatorSingletonSettings: coordinatorSingletonSettings);
- }
-
- public ClusterShardingSettings(
- string role,
- bool rememberEntities,
- string journalPluginId,
- string snapshotPluginId,
- TunningParameters tunningParameters,
- ClusterSingletonManagerSettings coordinatorSingletonSettings)
- {
- Role = role;
- RememberEntities = rememberEntities;
- JournalPluginId = journalPluginId;
- SnapshotPluginId = snapshotPluginId;
- TunningParameters = tunningParameters;
- CoordinatorSingletonSettings = coordinatorSingletonSettings;
- }
-
- public ClusterShardingSettings WithRole(string role)
- {
- return new ClusterShardingSettings(
- role: role,
- rememberEntities: RememberEntities,
- journalPluginId: JournalPluginId,
- snapshotPluginId: SnapshotPluginId,
- tunningParameters: TunningParameters,
- coordinatorSingletonSettings: CoordinatorSingletonSettings);
- }
-
- public ClusterShardingSettings WithRememberEntities(bool rememberEntities)
- {
- return Copy(rememberEntities: rememberEntities);
- }
-
- public ClusterShardingSettings WithJournalPluginId(string journalPluginId)
- {
- return Copy(journalPluginId: journalPluginId ?? string.Empty);
- }
-
- public ClusterShardingSettings WithSnapshotPluginId(string snapshotPluginId)
- {
- return Copy(snapshotPluginId: snapshotPluginId ?? string.Empty);
- }
-
- public ClusterShardingSettings WithTuningParameters(TunningParameters tunningParameters)
- {
- if (tunningParameters == null)
- throw new ArgumentNullException("tunningParameters");
-
- return Copy(tunningParameters: tunningParameters);
- }
-
- public ClusterShardingSettings WithCoordinatorSingletonSettings(ClusterSingletonManagerSettings coordinatorSingletonSettings)
- {
- if (coordinatorSingletonSettings == null)
- throw new ArgumentNullException("coordinatorSingletonSettings");
-
- return Copy(coordinatorSingletonSettings: coordinatorSingletonSettings);
- }
-
- private ClusterShardingSettings Copy(
- string role = null,
- bool? rememberEntities = null,
- string journalPluginId = null,
- string snapshotPluginId = null,
- TunningParameters tunningParameters = null,
- ClusterSingletonManagerSettings coordinatorSingletonSettings = null)
- {
- return new ClusterShardingSettings(
- role: role ?? Role,
- rememberEntities: rememberEntities ?? RememberEntities,
- journalPluginId: journalPluginId ?? JournalPluginId,
- snapshotPluginId: snapshotPluginId ?? SnapshotPluginId,
- tunningParameters: tunningParameters ?? TunningParameters,
- coordinatorSingletonSettings: coordinatorSingletonSettings ?? CoordinatorSingletonSettings);
- }
- }
-}
\ No newline at end of file
diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/PersistentShard.cs b/src/contrib/cluster/Akka.Cluster.Sharding/PersistentShard.cs
deleted file mode 100644
index 72e151aa14e..00000000000
--- a/src/contrib/cluster/Akka.Cluster.Sharding/PersistentShard.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-using System;
-using System.Collections.Immutable;
-using Akka.Actor;
-using Akka.Persistence;
-
-namespace Akka.Cluster.Sharding
-{
- using ShardId = String;
- using EntryId = String;
- using Msg = Object;
-
- ///
- /// This actor creates children entity actors on demand that it is told to be
- /// responsible for. It is used when `rememberEntities` is enabled.
- ///
- public class PersistentShard : Shard
- {
- protected int PersistCount = 0;
-
- private readonly string _persistenceId;
- public override string PersistenceId { get { return _persistenceId; } }
-
- public PersistentShard(
- string typeName,
- string shardId,
- Props entityProps,
- ClusterShardingSettings settings,
- IdExtractor extractEntityId,
- ShardResolver extractShardId,
- object handOffStopMessage)
- : base(typeName, shardId, entityProps, settings, extractEntityId, extractShardId, handOffStopMessage)
- {
- _persistenceId = "/sharding/" + TypeName + "Shard/" + ShardId;
- JournalPluginId = Settings.JournalPluginId;
- SnapshotPluginId = Settings.SnapshotPluginId;
-
- }
-
- protected override bool ReceiveCommand(object message)
- {
- return HandleCommand(message);
- }
-
- protected override bool ReceiveRecover(object message)
- {
- SnapshotOffer offer;
- if (message is EntityStarted)
- {
- var started = (EntityStarted)message;
- State = new ShardState(State.Entries.Add(started.EntityId));
- }
- else if (message is EntityStopped)
- {
- var stopped = (EntityStopped)message;
- State = new ShardState(State.Entries.Remove(stopped.EntityId));
- }
- else if ((offer = message as SnapshotOffer) != null && offer.Snapshot is ShardState)
- {
- State = (ShardState)offer.Snapshot;
- }
- else if (message is RecoveryCompleted)
- {
- foreach (var entry in State.Entries)
- GetEntity(entry);
-
- base.Initialized();
- Log.Debug("Shard recovery completed [{0}]", ShardId);
- }
- else return false;
- return true;
- }
-
- protected override void ProcessChange(T evt, Action handler)
- {
- SaveSnapshotIfNeeded();
- Persist(evt, handler);
- }
-
- protected void SaveSnapshotIfNeeded()
- {
- PersistCount++;
- if ((PersistCount & Settings.TunningParameters.SnapshotAfter) == 0)
- {
- Log.Debug("Saving snapshot, sequence number [{0}]", SnapshotSequenceNr);
- SaveSnapshot(State);
- }
- }
-
- protected override void EntityTerminated(IActorRef tref)
- {
- ShardId id;
- IImmutableList> buffer;
-
- if (IdByRef.TryGetValue(tref, out id))
- {
- if (MessageBuffers.TryGetValue(id, out buffer) && buffer.Count != 0)
- {
- // Note; because we're not persisting the EntityStopped, we don't need
- // to persist the EntityStarted either.
- Log.Debug("Starting entity [{0}] again, there are buffered messages for it", id);
- SendMessageBuffer(new EntityStarted(id));
- }
- else
- {
- if (!Passivating.Contains(tref))
- {
- Log.Debug("Entity [{0}] stopped without passivating, will restart after backoff", id);
- Context.System.Scheduler.ScheduleTellOnce(Settings.TunningParameters.EntityRestartBackoff, Sender, new RestartEntity(id), Self);
- }
- else
- {
- ProcessChange(new EntityStopped(id), PassivateCompleted);
- }
- }
- }
-
- Passivating = Passivating.Remove(tref);
- }
-
- protected override void DeliverTo(string id, object message, object payload, IActorRef sender)
- {
- var name = Uri.EscapeDataString(id);
- var child = Context.Child(name);
- if (Equals(child, ActorRefs.Nobody))
- {
- // Note; we only do this if remembering, otherwise the buffer is an overhead
- MessageBuffers = MessageBuffers.SetItem(id, ImmutableList>.Empty.Add(Tuple.Create(message, sender)));
- SaveSnapshotIfNeeded();
- Persist(new EntityStarted(id), SendMessageBuffer);
- }
- else
- child.Tell(payload, sender);
- }
-
- public static Actor.Props Props(string typeName, ShardId shardId, Props entryProps, ClusterShardingSettings settings, IdExtractor idExtractor, ShardResolver shardResolver, object handOffStopMessage)
- {
- return Actor.Props.Create(() => new PersistentShard(typeName, shardId, entryProps, settings, idExtractor, shardResolver, handOffStopMessage)).WithDeploy(Deploy.Local);
- }
- }
-}
\ No newline at end of file
diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/PersistentShardCoordinator.Messages.cs b/src/contrib/cluster/Akka.Cluster.Sharding/PersistentShardCoordinator.Messages.cs
deleted file mode 100644
index cd2e3e66741..00000000000
--- a/src/contrib/cluster/Akka.Cluster.Sharding/PersistentShardCoordinator.Messages.cs
+++ /dev/null
@@ -1,319 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright (C) 2009-2015 Typesafe Inc.
-// Copyright (C) 2013-2015 Akka.NET project
-//
-//-----------------------------------------------------------------------
-
-using System;
-using System.Collections.Generic;
-using Akka.Actor;
-
-namespace Akka.Cluster.Sharding
-{
- using ShardId = String;
-
- partial class PersistentShardCoordinator
- {
- #region Message types
-
- ///
- /// Messages sent to the coordinator.
- ///
- public interface ICoordinatorCommand : IClusterShardingSerializable { }
-
- ///
- /// Messages sent from the coordinator.
- ///
- public interface ICoordinatorMessage : IClusterShardingSerializable { }
-
- ///
- /// registers to , until it receives .
- ///
- [Serializable]
- public sealed class Register : ICoordinatorCommand
- {
- public readonly IActorRef ShardRegion;
-
- public Register(IActorRef shardRegion)
- {
- ShardRegion = shardRegion;
- }
- }
-
- ///
- /// in proxy only mode registers to , until it receives .
- ///
- [Serializable]
- public sealed class RegisterProxy : ICoordinatorCommand
- {
- public readonly IActorRef ShardRegionProxy;
-
- public RegisterProxy(IActorRef shardRegionProxy)
- {
- ShardRegionProxy = shardRegionProxy;
- }
- }
-
- ///
- /// Acknowledgement from that or was sucessful.
- ///
- public sealed class RegisterAck : ICoordinatorMessage
- {
- public readonly IActorRef Coordinator;
-
- public RegisterAck(IActorRef coordinator)
- {
- Coordinator = coordinator;
- }
- }
-
- ///
- /// requests the location of a shard by sending this message
- /// to the .
- ///
- [Serializable]
- public sealed class GetShardHome : ICoordinatorCommand
- {
- public readonly ShardId Shard;
-
- public GetShardHome(string shard)
- {
- Shard = shard;
- }
- }
-
- ///
- /// replies with this message for requests.
- ///
- [Serializable]
- public sealed class ShardHome : ICoordinatorMessage
- {
- public readonly ShardId Shard;
- public readonly IActorRef Ref;
-
- public ShardHome(string shard, IActorRef @ref)
- {
- Shard = shard;
- Ref = @ref;
- }
- }
-
- ///
- /// informs a that it is hosting this shard
- ///
- [Serializable]
- public sealed class HostShard : ICoordinatorMessage
- {
- public readonly ShardId Shard;
-
- public HostShard(string shard)
- {
- Shard = shard;
- }
- }
-
- ///
- /// replies with this message for requests which lead to it hosting the shard
- ///
- [Serializable]
- public sealed class ShardStarted : ICoordinatorMessage
- {
- public readonly ShardId Shard;
-
- public ShardStarted(string shard)
- {
- Shard = shard;
- }
- }
-
- ///
- /// initiates rebalancing process by sending this message
- /// to all registered actors (including proxy only). They are
- /// supposed to discard their known location of the shard, i.e. start buffering
- /// incoming messages for the shard. They reply with .
- /// When all have replied the continues by sending
- /// to the responsible for the shard.
- ///
- [Serializable]
- public sealed class BeginHandOff : ICoordinatorMessage
- {
- public readonly ShardId Shard;
-
- public BeginHandOff(string shard)
- {
- Shard = shard;
- }
- }
-
- ///
- /// Acknowledgement of
- ///
- [Serializable]
- public sealed class BeginHandOffAck : ICoordinatorCommand
- {
- public readonly ShardId Shard;
-
- public BeginHandOffAck(string shard)
- {
- Shard = shard;
- }
- }
-
- ///
- /// When all actors have acknoledged the the
- /// sends this message to the responsible for the
- /// shard. The is supposed to stop all entries in that shard and when
- /// all entries have terminated reply with to the .
- ///
- [Serializable]
- public sealed class HandOff : ICoordinatorMessage
- {
- public readonly ShardId Shard;
-
- public HandOff(string shard)
- {
- Shard = shard;
- }
- }
-
- ///
- /// Reply to when all entries in the shard have been terminated.
- ///
- [Serializable]
- public sealed class ShardStopped : ICoordinatorCommand
- {
- public readonly ShardId Shard;
-
- public ShardStopped(string shard)
- {
- Shard = shard;
- }
- }
-
- ///
- /// Result of is piped to self with this message.
- ///
- [Serializable]
- public sealed class AllocateShardResult : ICoordinatorCommand
- {
- public readonly ShardId Shard;
- public readonly IActorRef ShardRegion; // option
- public readonly IActorRef GetShardHomeSender;
-
- public AllocateShardResult(string shard, IActorRef shardRegion, IActorRef getShardHomeSender)
- {
- Shard = shard;
- ShardRegion = shardRegion;
- GetShardHomeSender = getShardHomeSender;
- }
- }
-
- ///
- /// Result of `rebalance` is piped to self with this message.
- ///
- [Serializable]
- public sealed class RebalanceResult : ICoordinatorCommand
- {
- public readonly IEnumerable Shards;
-
- public RebalanceResult(IEnumerable shards)
- {
- Shards = shards;
- }
- }
-
- ///
- /// requests full handoff to be able to shutdown gracefully.
- ///
- [Serializable]
- public sealed class GracefulShutdownRequest : ICoordinatorCommand
- {
- public readonly IActorRef ShardRegion;
- public GracefulShutdownRequest(IActorRef shardRegion)
- {
- ShardRegion = shardRegion;
- }
- }
-
- ///
- /// DomainEvents for the persistent state of the event sourced PersistentShardCoordinator
- ///
- public interface IDomainEvent { }
-
- [Serializable]
- public class ShardRegionRegistered : IDomainEvent
- {
- public readonly IActorRef Region;
-
- public ShardRegionRegistered(IActorRef region)
- {
- Region = region;
- }
- }
-
- [Serializable]
- public class ShardRegionProxyRegistered : IDomainEvent
- {
- public readonly IActorRef RegionProxy;
- public ShardRegionProxyRegistered(IActorRef regionProxy)
- {
- RegionProxy = regionProxy;
- }
- }
-
- [Serializable]
- public class ShardRegionTerminated : IDomainEvent
- {
- public readonly IActorRef Region;
- public ShardRegionTerminated(IActorRef region)
- {
- Region = region;
- }
- }
-
- [Serializable]
- public class ShardRegionProxyTerminated : IDomainEvent
- {
- public readonly IActorRef RegionProxy;
- public ShardRegionProxyTerminated(IActorRef regionProxy)
- {
- RegionProxy = regionProxy;
- }
- }
-
- [Serializable]
- public class ShardHomeAllocated : IDomainEvent
- {
- public readonly ShardId Shard;
- public readonly IActorRef Region;
-
- public ShardHomeAllocated(string shard, IActorRef region)
- {
- Shard = shard;
- Region = region;
- }
- }
-
- [Serializable]
- public class ShardHomeDeallocated : IDomainEvent
- {
- public readonly ShardId Shard;
-
- public ShardHomeDeallocated(string shard)
- {
- Shard = shard;
- }
- }
-
- [Serializable]
- public sealed class StateInitialized
- {
- public static readonly StateInitialized Instance = new StateInitialized();
- private StateInitialized() { }
- }
-
- #endregion
-
- }
-}
diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/PersistentShardCoordinator.cs b/src/contrib/cluster/Akka.Cluster.Sharding/PersistentShardCoordinator.cs
deleted file mode 100644
index 6bd92586bd9..00000000000
--- a/src/contrib/cluster/Akka.Cluster.Sharding/PersistentShardCoordinator.cs
+++ /dev/null
@@ -1,668 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright (C) 2009-2015 Typesafe Inc.
-// Copyright (C) 2013-2015 Akka.NET project
-//
-//-----------------------------------------------------------------------
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Linq;
-using System.Threading.Tasks;
-using Akka.Actor;
-using Akka.Event;
-using Akka.Persistence;
-
-namespace Akka.Cluster.Sharding
-{
- using ShardId = String;
-
- ///
- /// Singleton coordinator that decides where shards should be allocated.
- ///
- public partial class PersistentShardCoordinator : PersistentActor
- {
- #region State data type definition
-
- ///
- /// Persistent state of the event sourced PersistentShardCoordinator.
- ///
- [Serializable]
- public sealed class State
- {
- public static readonly State Empty = new State();
-
- ///
- /// Region for each shard.
- ///
- public readonly IImmutableDictionary Shards;
-
- ///
- /// Shards for each region.
- ///
- public readonly IImmutableDictionary> Regions;
- public readonly IImmutableSet RegionProxies;
- public readonly IImmutableSet UnallocatedShards;
-
- private State() : this(
- shards: ImmutableDictionary.Empty,
- regions: ImmutableDictionary>.Empty,
- regionProxies: ImmutableHashSet.Empty,
- unallocatedShards: ImmutableHashSet.Empty)
- { }
-
- public State(
- IImmutableDictionary shards,
- IImmutableDictionary> regions,
- IImmutableSet regionProxies,
- IImmutableSet unallocatedShards)
- {
- Shards = shards;
- Regions = regions;
- RegionProxies = regionProxies;
- UnallocatedShards = unallocatedShards;
- }
-
- public State Updated(IDomainEvent e)
- {
- if (e is ShardRegionRegistered)
- {
- var message = e as ShardRegionRegistered;
- if (Regions.ContainsKey(message.Region)) throw new ArgumentException(string.Format("Region {0} is already registered", message.Region));
-
- return Copy(regions: Regions.SetItem(message.Region, ImmutableList.Empty));
- }
- else if (e is ShardRegionProxyRegistered)
- {
- var message = e as ShardRegionProxyRegistered;
- if (RegionProxies.Contains(message.RegionProxy)) throw new ArgumentException(string.Format("Region proxy {0} is already registered", message.RegionProxy));
-
- return Copy(regionProxies: RegionProxies.Add(message.RegionProxy));
- }
- else if (e is ShardRegionTerminated)
- {
- IImmutableList shardRegions;
- var message = e as ShardRegionTerminated;
- if (!Regions.TryGetValue(message.Region, out shardRegions)) throw new ArgumentException(string.Format("Region {0} not registered", message.Region));
-
- return Copy(
- regions: Regions.Remove(message.Region),
- shards: Shards.RemoveRange(shardRegions),
- unallocatedShards: shardRegions.Aggregate(UnallocatedShards, (set, shard) => set.Add(shard)));
- }
- else if (e is ShardRegionProxyTerminated)
- {
- var message = e as ShardRegionProxyTerminated;
- if (!RegionProxies.Contains(message.RegionProxy)) throw new ArgumentException(string.Format("Region proxy {0} not registered", message.RegionProxy));
-
- return Copy(regionProxies: RegionProxies.Remove(message.RegionProxy));
- }
- else if (e is ShardHomeAllocated)
- {
- IImmutableList shardRegions;
- var message = e as ShardHomeAllocated;
- if (!Regions.TryGetValue(message.Region, out shardRegions)) throw new ArgumentException(string.Format("Region {0} not registered", message.Region));
- if (Shards.ContainsKey(message.Shard)) throw new ArgumentException(string.Format("Shard {0} is already allocated", message.Shard));
-
- return Copy(
- shards: Shards.SetItem(message.Shard, message.Region),
- regions: Regions.SetItem(message.Region, shardRegions.Add(message.Shard)),
- unallocatedShards: UnallocatedShards.Remove(message.Shard));
- }
- else if (e is ShardHomeDeallocated)
- {
- IActorRef region;
- IImmutableList shardRegions;
- var message = e as ShardHomeDeallocated;
- if (!Shards.TryGetValue(message.Shard, out region)) throw new ArgumentException(string.Format("Shard {0} not allocated", message.Shard));
- if (!Regions.TryGetValue(region, out shardRegions)) throw new ArgumentException(string.Format("Region {0} for shard {1} not registered", region, message.Shard));
-
- return Copy(
- shards: Shards.Remove(message.Shard),
- regions: Regions.SetItem(region, shardRegions.Where(s => s != message.Shard).ToImmutableList()),
- unallocatedShards: UnallocatedShards.Add(message.Shard));
- }
- else return this;
- }
-
- public State Copy(IImmutableDictionary shards = null,
- IImmutableDictionary> regions = null,
- IImmutableSet regionProxies = null,
- IImmutableSet unallocatedShards = null)
- {
- if (shards == null && regions == null && regionProxies == null && unallocatedShards == null) return this;
-
- return new State(shards ?? Shards, regions ?? Regions, regionProxies ?? RegionProxies, unallocatedShards ?? UnallocatedShards);
- }
- }
-
- #endregion
-
- ///
- /// Factory method for the of the actor.
- ///
- public static Props Props(string typeName, ClusterShardingSettings settings, IShardAllocationStrategy allocationStrategy)
- {
- return Actor.Props.Create(() => new PersistentShardCoordinator(typeName, settings, allocationStrategy)).WithDeploy(Deploy.Local);
- }
-
- public readonly Cluster Cluster = Cluster.Get(Context.System);
- public readonly TimeSpan DownRemovalMargin;
- public readonly string TypeName;
- public readonly ClusterShardingSettings Settings;
- public readonly IShardAllocationStrategy AllocationStrategy;
-
- private IImmutableDictionary _unAckedHostShards = ImmutableDictionary.Empty;
- private IImmutableSet _rebalanceInProgress = ImmutableHashSet.Empty;
- // regions that have requested handoff, for graceful shutdown
- private IImmutableSet _gracefullShutdownInProgress = ImmutableHashSet.Empty;
- private IImmutableSet _aliveRegions = ImmutableHashSet.Empty;
- private IImmutableSet _regionTerminationInProgress = ImmutableHashSet.Empty;
-
- private readonly ICancelable _rebalanceTask;
-
- private int _persistCount = 0;
- private State _currentState = State.Empty;
-
- public PersistentShardCoordinator(string typeName, ClusterShardingSettings settings, IShardAllocationStrategy allocationStrategy)
- {
- TypeName = typeName;
- Settings = settings;
- AllocationStrategy = allocationStrategy;
- DownRemovalMargin = Cluster.Settings.DownRemovalMargin;
-
- JournalPluginId = Settings.JournalPluginId;
- SnapshotPluginId = Settings.SnapshotPluginId;
-
- _rebalanceTask = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(Settings.TunningParameters.RebalanceInterval, Settings.TunningParameters.RebalanceInterval, Self, RebalanceTick.Instance, Self);
-
- Cluster.Subscribe(Self, ClusterEvent.SubscriptionInitialStateMode.InitialStateAsEvents, new[] { typeof(ClusterEvent.ClusterShuttingDown) });
- }
-
- private ILoggingAdapter _log;
- public ILoggingAdapter Log { get { return _log ?? (_log = Context.GetLogger()); } }
- protected State CurrentState { get { return _currentState; } }
-
- #region shared part
-
- protected override void PostStop()
- {
- base.PostStop();
- _rebalanceTask.Cancel();
- Cluster.Unsubscribe(Self);
- }
-
- private bool IsMember(IActorRef region)
- {
- var addr = region.Path.Address;
- return addr == Self.Path.Address || Cluster.ReadView.Members.Any(m => m.Address == addr && m.Status == MemberStatus.Up);
- }
-
- protected bool Active(object message)
- {
- if (message is Register) HandleRegister(message as Register);
- else if (message is RegisterProxy) HandleRegisterProxy(message as RegisterProxy);
- else if (message is GetShardHome) HandleGetShardHome(message as GetShardHome);
- else if (message is AllocateShardResult) HandleAllocateShardResult(message as AllocateShardResult);
- else if (message is ShardStarted) HandleShardStated(message as ShardStarted);
- else if (message is ResendShardHost) HandleResendShardHost(message as ResendShardHost);
- else if (message is RebalanceTick) HandleRebalanceTick();
- else if (message is RebalanceResult) ContinueRebalance(((RebalanceResult)message).Shards.ToImmutableHashSet());
- else if (message is RebalanceDone) HandleRebalanceDone(message as RebalanceDone);
- else if (message is GracefulShutdownRequest) HandleGracefulShutdownRequest(message as GracefulShutdownRequest);
- else if (message is ShardHome)
- {
- // On rebalance, we send ourselves a GetShardHome message to reallocate a
- // shard. This recieve handles the "response" from that message. i.e. Ingores it.
- }
- else if (message is ClusterEvent.ClusterShuttingDown)
- {
- Log.Debug("Shutting down shard coordinator");
- // can't stop because supervisor will start it again,
- // it will soon be stopped when singleton is stopped
- Context.Become(ShuttingDown);
- }
- else if (message is ShardRegion.GetCurrentRegions)
- {
- var regions = _currentState.Regions.Keys
- .Select(region => string.IsNullOrEmpty(region.Path.Address.Host) ? Cluster.SelfAddress : region.Path.Address)
- .ToArray();
- Sender.Tell(new ShardRegion.CurrentRegions(regions));
- }
- else if (message is ClusterEvent.CurrentClusterState)
- {
- /* ignore */
- }
- else return ReceiveTerminated(message);
- return true;
- }
-
- private void AllocateShardHomes()
- {
- foreach (var unallocatedShard in _currentState.UnallocatedShards)
- {
- Self.Tell(new GetShardHome(unallocatedShard));
- }
- }
-
- private void SendHostShardMessage(String shard, IActorRef region)
- {
- region.Tell(new HostShard(shard));
- var cancelable = new Cancelable(Context.System.Scheduler);
- Context.System.Scheduler.ScheduleTellOnce(Settings.TunningParameters.ShardStartTimeout, Self, new ResendShardHost(shard, region), Self, cancelable);
- _unAckedHostShards = _unAckedHostShards.SetItem(shard, cancelable);
- }
-
- protected void ApplyStateInitialized()
- {
- foreach (var entry in _currentState.Shards)
- SendHostShardMessage(entry.Key, entry.Value);
-
- AllocateShardHomes();
- }
-
- private void WatchStateActors()
- {
- // Optimization:
- // Consider regions that don't belong to the current cluster to be terminated.
- // This is an optimization that makes it operational faster and reduces the
- // amount of lost messages during startup.
- var nodes = Cluster.ReadView.Members.Select(x => x.Address).ToImmutableHashSet();
-
- foreach (var entry in _currentState.Regions)
- {
- var a = entry.Key.Path.Address;
- if ((string.IsNullOrEmpty(a.Host) && a.Port == null) || nodes.Contains(a))
- Context.Watch(entry.Key);
- else
- RegionTerminated(entry.Key); // not part of the cluster
- }
-
- foreach (var proxy in _currentState.RegionProxies)
- {
- var a = proxy.Path.Address;
- if ((string.IsNullOrEmpty(a.Host) && a.Port == null) || nodes.Contains(a))
- Context.Watch(proxy);
- else
- RegionTerminated(proxy); // not part of the cluster
- }
-
- // Let the quick (those not involving failure detection) Terminated messages
- // be processed before starting to reply to GetShardHome.
- // This is an optimization that makes it operational faster and reduces the
- // amount of lost messages during startup.
- Context.System.Scheduler.ScheduleTellOnce(TimeSpan.FromMilliseconds(500), Self, StateInitialized.Instance, Self);
- }
-
- private bool ReceiveTerminated(object message)
- {
- if (message is Terminated)
- {
- var terminated = (Terminated)message;
- var terminatedRef = terminated.ActorRef;
- if (_currentState.Regions.ContainsKey(terminatedRef))
- {
- if (DownRemovalMargin != TimeSpan.Zero && terminated.AddressTerminated && _aliveRegions.Contains(terminatedRef))
- {
- Context.System.Scheduler.ScheduleTellOnce(DownRemovalMargin, Self, new DelayedShardRegionTerminated(terminatedRef), Self);
- _regionTerminationInProgress = _regionTerminationInProgress.Add(terminatedRef);
- }
- else
- RegionTerminated(terminatedRef);
- }
- else if (_currentState.RegionProxies.Contains(terminatedRef))
- RegionProxyTerminated(terminatedRef);
- }
- else if (message is DelayedShardRegionTerminated)
- RegionTerminated(((DelayedShardRegionTerminated)message).Region);
- else return false;
- return true;
- }
-
- private void HandleGracefulShutdownRequest(GracefulShutdownRequest request)
- {
- if (!_gracefullShutdownInProgress.Contains(request.ShardRegion))
- {
- IImmutableList shards;
- if (_currentState.Regions.TryGetValue(request.ShardRegion, out shards))
- {
- Log.Debug("Graceful shutdown of region [{0}] with shards [{1}]", request.ShardRegion, string.Join(", ", shards));
- _gracefullShutdownInProgress = _gracefullShutdownInProgress.Add(request.ShardRegion);
- ContinueRebalance(shards.ToImmutableHashSet());
- }
- }
- }
-
- private void HandleRebalanceDone(RebalanceDone done)
- {
- _rebalanceInProgress = _rebalanceInProgress.Remove(done.Shard);
- Log.Debug("Rebalance shard [{0}] done [{1}]", done.Shard, done.Ok);
-
- IActorRef region;
- // The shard could have been removed by ShardRegionTerminated
- if (_currentState.Shards.ContainsKey(done.Shard))
- {
- if (done.Ok)
- Update(new ShardHomeDeallocated(done.Shard), e =>
- {
- _currentState = _currentState.Updated(e);
- Log.Debug("Shard [{0}] deallocated", e.Shard);
- AllocateShardHomes();
- });
- else if (_currentState.Shards.TryGetValue(done.Shard, out region))
- // rebalance not completed, graceful shutdown will be retried
- _gracefullShutdownInProgress = _gracefullShutdownInProgress.Remove(region);
- }
- }
-
- private void HandleRebalanceTick()
- {
- if (_currentState.Regions.Count != 0)
- {
- var shardsTask = AllocationStrategy.Rebalance(_currentState.Regions, _rebalanceInProgress);
- if (shardsTask.IsCompleted && !shardsTask.IsFaulted)
- ContinueRebalance(shardsTask.Result);
- else
- shardsTask.ContinueWith(t => !(t.IsFaulted || t.IsCanceled)
- ? new RebalanceResult(t.Result)
- : new RebalanceResult(Enumerable.Empty()))
- .PipeTo(Self);
- }
- }
-
- private void HandleResendShardHost(ResendShardHost resend)
- {
- IActorRef region;
- if (_currentState.Shards.TryGetValue(resend.Shard, out region) && region.Equals(resend.Region))
- SendHostShardMessage(resend.Shard, region);
- }
-
- private void HandleShardStated(ShardStarted message)
- {
- var shard = message.Shard;
- ICancelable cancel;
- if (_unAckedHostShards.TryGetValue(shard, out cancel))
- {
- cancel.Cancel();
- _unAckedHostShards = _unAckedHostShards.Remove(shard);
- }
- }
-
- private void HandleAllocateShardResult(AllocateShardResult allocateResult)
- {
- if (allocateResult.ShardRegion == null)
- Log.Debug("Shard [{0}] allocation failed. It will be retried", allocateResult.Shard);
- else
- ContinueGetShardHome(allocateResult.Shard, allocateResult.ShardRegion, allocateResult.GetShardHomeSender);
- }
-
- private void HandleGetShardHome(GetShardHome getShardHome)
- {
- var shard = getShardHome.Shard;
- if (!_rebalanceInProgress.Contains(shard))
- {
- IActorRef region;
- if (_currentState.Shards.TryGetValue(shard, out region))
- {
- if (_regionTerminationInProgress.Contains(region))
- Log.Debug("GetShardHome [{0}] request ignored, due to region [{1}] termination in progress.", shard, region);
- else
- Sender.Tell(new ShardHome(shard, region));
- }
- else
- {
- var activeRegions = _currentState.Regions.RemoveRange(_gracefullShutdownInProgress);
- if (activeRegions.Count != 0)
- {
- var getShardHomeSender = Sender;
- var regionTask = AllocationStrategy.AllocateShard(getShardHomeSender, shard, activeRegions);
-
- // if task completed immediately, just continue
- if (regionTask.IsCompleted && !regionTask.IsFaulted)
- ContinueGetShardHome(shard, regionTask.Result, getShardHomeSender);
- else
- regionTask.ContinueWith(t => !(t.IsFaulted || t.IsCanceled)
- ? new AllocateShardResult(shard, t.Result, getShardHomeSender)
- : new AllocateShardResult(shard, null, getShardHomeSender))
- .PipeTo(Self);
- }
- }
- }
- }
-
- private void RegionTerminated(IActorRef terminatedRef)
- {
- IImmutableList shards;
- if (_currentState.Regions.TryGetValue(terminatedRef, out shards))
- {
- Log.Debug("Shard region terminated: [{0}]", terminatedRef);
- foreach (var shard in shards)
- Self.Tell(new GetShardHome(shard));
-
- Update(new ShardRegionTerminated(terminatedRef), e =>
- {
- _currentState = _currentState.Updated(e);
- _gracefullShutdownInProgress = _gracefullShutdownInProgress.Remove(terminatedRef);
- _regionTerminationInProgress = _regionTerminationInProgress.Remove(terminatedRef);
- AllocateShardHomes();
- });
- }
- }
-
- private void RegionProxyTerminated(IActorRef proxyRef)
- {
- if (_currentState.RegionProxies.Contains(proxyRef))
- {
- Log.Debug("ShardRegion proxy terminated: [{0}]", proxyRef);
- Update(new ShardRegionProxyTerminated(proxyRef), e => _currentState = _currentState.Updated(e));
- }
- }
-
- private void HandleRegisterProxy(RegisterProxy registerProxy)
- {
- var proxy = registerProxy.ShardRegionProxy;
- Log.Debug("Shard region proxy registered: [{0}]", proxy);
- if (_currentState.RegionProxies.Contains(proxy))
- Sender.Tell(new RegisterAck(Self));
- else
- {
- var context = Context;
- var self = Self;
- Update(new ShardRegionProxyRegistered(proxy), e =>
- {
- _currentState = _currentState.Updated(e);
- context.Watch(proxy);
- proxy.Tell(new RegisterAck(self));
- });
- }
- }
-
- private void HandleRegister(Register message)
- {
- var region = message.ShardRegion;
- if (IsMember(region))
- {
- Log.Debug("Shard region registered: [{0}]", region);
- _aliveRegions = _aliveRegions.Add(region);
-
- if (_currentState.Regions.ContainsKey(region))
- Sender.Tell(new RegisterAck(Self));
- else
- {
- var context = Context;
- var self = Self;
-
- _gracefullShutdownInProgress = _gracefullShutdownInProgress.Remove(region);
- Update(new ShardRegionRegistered(region), e =>
- {
- var isFirstRegion = _currentState.Regions.Count == 0;
- _currentState = _currentState.Updated(e);
- context.Watch(region);
- region.Tell(new RegisterAck(self));
-
- if (isFirstRegion) AllocateShardHomes();
- });
- }
- }
- else Log.Debug("ShardRegion [{0}] was not registered since the coordinator currently does not know about a node of that region", region);
- }
-
- private void SaveSnapshotIfNeeded()
- {
- _persistCount++;
- if (_persistCount % Settings.TunningParameters.SnapshotAfter == 0)
- {
- Log.Debug("Saving snapshot, sequence number [{0}]", SnapshotSequenceNr);
- SaveSnapshot(_currentState);
- }
- }
-
- private bool ShuttingDown(object message)
- {
- // ignore all
- return true;
- }
-
- private void ContinueRebalance(IImmutableSet shards)
- {
- foreach (var shard in shards)
- {
- if (!_rebalanceInProgress.Contains(shard))
- {
- IActorRef rebalanceFromRegion;
- if (_currentState.Shards.TryGetValue(shard, out rebalanceFromRegion))
- {
- _rebalanceInProgress = _rebalanceInProgress.Add(shard);
- Log.Debug("Rebalance shard [{0}] from [{1}]", shard, rebalanceFromRegion);
-
- var regions = _currentState.Regions.Keys.Union(_currentState.RegionProxies);
- Context.ActorOf(RebalanceWorker.Props(shard, rebalanceFromRegion, Settings.TunningParameters.HandOffTimeout, regions)
- .WithDispatcher(Context.Props.Dispatcher));
- }
- else
- Log.Debug("Rebalance of non-existing shard [{0}] is ignored", shard);
- }
- }
- }
-
- private void ContinueGetShardHome(string shard, IActorRef region, IActorRef getShardHomeSender)
- {
- if (!_rebalanceInProgress.Contains(shard))
- {
- IActorRef aref;
- if (_currentState.Shards.TryGetValue(shard, out aref))
- getShardHomeSender.Tell(new ShardHome(shard, aref));
- else
- {
- if (_currentState.Regions.ContainsKey(region) && !_gracefullShutdownInProgress.Contains(region))
- {
- Update(new ShardHomeAllocated(shard, region), e =>
- {
- _currentState = _currentState.Updated(e);
- Log.Debug("Shard [{0}] allocated at [{1}]", e.Shard, e.Region);
-
- SendHostShardMessage(e.Shard, e.Region);
- getShardHomeSender.Tell(new ShardHome(e.Shard, e.Region));
- });
- }
- else
- Log.Debug("Allocated region {0} for shard [{1}] is not (any longer) one of the registered regions", region, shard);
- }
- }
- }
-
- #endregion
-
- #region persistent part
-
- public override String PersistenceId { get { return Self.Path.ToStringWithoutAddress(); } }
-
- protected override bool ReceiveRecover(Object message)
- {
- if (message is IDomainEvent)
- {
- var evt = message as IDomainEvent;
- Log.Debug("ReceiveRecover {0}", evt);
-
- if (message is ShardRegionRegistered) _currentState = _currentState.Updated(evt);
- else if (message is ShardRegionProxyRegistered) _currentState = _currentState.Updated(evt);
- else if (message is ShardRegionTerminated)
- {
- var regionTerminated = (ShardRegionTerminated)message;
- if (_currentState.Regions.ContainsKey(regionTerminated.Region))
- _currentState = _currentState.Updated(evt);
- else
- Log.Debug("ShardRegionTerminated but region {0} was not registered", regionTerminated.Region);
- }
- else if (message is ShardRegionProxyTerminated)
- {
- var proxyTerminated = (ShardRegionProxyTerminated)message;
- if (_currentState.RegionProxies.Contains(proxyTerminated.RegionProxy))
- _currentState = _currentState.Updated(evt);
- }
- else if (message is ShardHomeAllocated) _currentState = _currentState.Updated(evt);
- else if (message is ShardHomeDeallocated) _currentState = _currentState.Updated(evt);
- else return false;
- return true;
- }
- else if (message is SnapshotOffer)
- {
- var state = ((SnapshotOffer)message).Snapshot as State;
- if (state != null)
- {
- Log.Debug("ReceiveRecover SnapshotOffer {0}", state);
-
- // Old versions of the state object may not have unallocatedShard set,
- // thus it will be null.
- if (state.UnallocatedShards == null)
- _currentState = state.Copy(unallocatedShards: ImmutableHashSet.Empty);
- else
- _currentState = state;
-
- return true;
- }
- }
- else if (message is RecoveryCompleted)
- {
- WatchStateActors();
- return true;
- }
- return false;
- }
-
- protected override bool ReceiveCommand(object message)
- {
- return WaitingForStateInitialized(message);
- }
-
- private bool WaitingForStateInitialized(object message)
- {
- if (message is StateInitialized)
- {
- ApplyStateInitialized();
- Context.Become(msg => Active(msg) || HandleSnapshotResult(msg));
- return true;
- }
- else if (ReceiveTerminated(message)) return true;
- else return HandleSnapshotResult(message);
- }
-
- private bool HandleSnapshotResult(object message)
- {
- if (message is SaveSnapshotSuccess) Log.Debug("Persistent snapshot saved successfully");
- else if (message is SaveSnapshotFailure) Log.Warning("Persistent snapshot failure: {0}", ((SaveSnapshotFailure)message).Cause.Message);
- else return false;
- return true;
- }
-
- protected void Update(TEvent e, Action handler) where TEvent : IDomainEvent
- {
- SaveSnapshotIfNeeded();
- Persist(e, handler);
- }
-
- #endregion
- }
-
-}
\ No newline at end of file
diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/Properties/AssemblyInfo.cs b/src/contrib/cluster/Akka.Cluster.Sharding/Properties/AssemblyInfo.cs
deleted file mode 100644
index e4b191ab2d8..00000000000
--- a/src/contrib/cluster/Akka.Cluster.Sharding/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("Akka.Cluster.Sharding")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("Akka.Cluster.Sharding")]
-[assembly: AssemblyCopyright("Copyright © 2015")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("a05c31e8-0246-46a1-b3bc-4d6fe7a9aa49")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/Serialization/Proto/ClusterShardingMessages.cs b/src/contrib/cluster/Akka.Cluster.Sharding/Serialization/Proto/ClusterShardingMessages.cs
deleted file mode 100644
index c0ceeec3270..00000000000
--- a/src/contrib/cluster/Akka.Cluster.Sharding/Serialization/Proto/ClusterShardingMessages.cs
+++ /dev/null
@@ -1,3640 +0,0 @@
-// Generated by ProtoGen, Version=2.4.1.521, Culture=neutral, PublicKeyToken=55f7125234beb589. DO NOT EDIT!
-#pragma warning disable 1591, 0612, 3021
-#region Designer generated code
-
-using pb = global::Google.ProtocolBuffers;
-using pbc = global::Google.ProtocolBuffers.Collections;
-using pbd = global::Google.ProtocolBuffers.Descriptors;
-using scg = global::System.Collections.Generic;
-[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-public static partial class ClusterShardingMessages
-{
-
- #region Extension registration
- public static void RegisterAllExtensions(pb::ExtensionRegistry registry)
- {
- }
- #endregion
- #region Static variables
- internal static pbd::MessageDescriptor internal__static_CoordinatorState__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable internal__static_CoordinatorState__FieldAccessorTable;
- internal static pbd::MessageDescriptor internal__static_CoordinatorState_ShardEntry__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable internal__static_CoordinatorState_ShardEntry__FieldAccessorTable;
- internal static pbd::MessageDescriptor internal__static_ActorRefMessage__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable internal__static_ActorRefMessage__FieldAccessorTable;
- internal static pbd::MessageDescriptor internal__static_ShardIdMessage__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable internal__static_ShardIdMessage__FieldAccessorTable;
- internal static pbd::MessageDescriptor internal__static_ShardHomeAllocated__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable internal__static_ShardHomeAllocated__FieldAccessorTable;
- internal static pbd::MessageDescriptor internal__static_ShardHome__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable internal__static_ShardHome__FieldAccessorTable;
- internal static pbd::MessageDescriptor internal__static_EntityState__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable internal__static_EntityState__FieldAccessorTable;
- internal static pbd::MessageDescriptor internal__static_EntityStarted__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable internal__static_EntityStarted__FieldAccessorTable;
- internal static pbd::MessageDescriptor internal__static_EntityStopped__Descriptor;
- internal static pb::FieldAccess.FieldAccessorTable internal__static_EntityStopped__FieldAccessorTable;
- #endregion
- #region Descriptor
- public static pbd::FileDescriptor Descriptor
- {
- get { return descriptor; }
- }
- private static pbd::FileDescriptor descriptor;
-
- static ClusterShardingMessages()
- {
- byte[] descriptorData = global::System.Convert.FromBase64String(
- "Ch1DbHVzdGVyU2hhcmRpbmdNZXNzYWdlcy5wcm90byK1AQoQQ29vcmRpbmF0" +
- "b3JTdGF0ZRIsCgZzaGFyZHMYASADKAsyHC5Db29yZGluYXRvclN0YXRlLlNo" +
- "YXJkRW50cnkSDwoHcmVnaW9ucxgCIAMoCRIVCg1yZWdpb25Qcm94aWVzGAMg" +
- "AygJEhkKEXVuYWxsb2NhdGVkU2hhcmRzGAQgAygJGjAKClNoYXJkRW50cnkS" +
- "DwoHc2hhcmRJZBgBIAIoCRIRCglyZWdpb25SZWYYAiACKAkiHgoPQWN0b3JS" +
- "ZWZNZXNzYWdlEgsKA3JlZhgBIAIoCSIfCg5TaGFyZElkTWVzc2FnZRINCgVz" +
- "aGFyZBgBIAIoCSIzChJTaGFyZEhvbWVBbGxvY2F0ZWQSDQoFc2hhcmQYASAC" +
- "KAkSDgoGcmVnaW9uGAIgAigJIioKCVNoYXJkSG9tZRINCgVzaGFyZBgBIAIo" +
- "CRIOCgZyZWdpb24YAiACKAkiHwoLRW50aXR5U3RhdGUSEAoIZW50aXRpZXMY" +
- "ASADKAkiIQoNRW50aXR5U3RhcnRlZBIQCghlbnRpdHlJZBgBIAIoCSIhCg1F" +
- "bnRpdHlTdG9wcGVkEhAKCGVudGl0eUlkGAEgAigJQiYKImFra2EuY2x1c3Rl" +
- "ci5zaGFyZGluZy5wcm90b2J1Zi5tc2dIAQ==");
- pbd::FileDescriptor.InternalDescriptorAssigner assigner = delegate (pbd::FileDescriptor root) {
- descriptor = root;
- internal__static_CoordinatorState__Descriptor = Descriptor.MessageTypes[0];
- internal__static_CoordinatorState__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable(internal__static_CoordinatorState__Descriptor,
- new string[] { "Shards", "Regions", "RegionProxies", "UnallocatedShards", });
- internal__static_CoordinatorState_ShardEntry__Descriptor = internal__static_CoordinatorState__Descriptor.NestedTypes[0];
- internal__static_CoordinatorState_ShardEntry__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable(internal__static_CoordinatorState_ShardEntry__Descriptor,
- new string[] { "ShardId", "RegionRef", });
- internal__static_ActorRefMessage__Descriptor = Descriptor.MessageTypes[1];
- internal__static_ActorRefMessage__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable(internal__static_ActorRefMessage__Descriptor,
- new string[] { "Ref", });
- internal__static_ShardIdMessage__Descriptor = Descriptor.MessageTypes[2];
- internal__static_ShardIdMessage__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable(internal__static_ShardIdMessage__Descriptor,
- new string[] { "Shard", });
- internal__static_ShardHomeAllocated__Descriptor = Descriptor.MessageTypes[3];
- internal__static_ShardHomeAllocated__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable(internal__static_ShardHomeAllocated__Descriptor,
- new string[] { "Shard", "Region", });
- internal__static_ShardHome__Descriptor = Descriptor.MessageTypes[4];
- internal__static_ShardHome__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable(internal__static_ShardHome__Descriptor,
- new string[] { "Shard", "Region", });
- internal__static_EntityState__Descriptor = Descriptor.MessageTypes[5];
- internal__static_EntityState__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable(internal__static_EntityState__Descriptor,
- new string[] { "Entities", });
- internal__static_EntityStarted__Descriptor = Descriptor.MessageTypes[6];
- internal__static_EntityStarted__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable(internal__static_EntityStarted__Descriptor,
- new string[] { "EntityId", });
- internal__static_EntityStopped__Descriptor = Descriptor.MessageTypes[7];
- internal__static_EntityStopped__FieldAccessorTable =
- new pb::FieldAccess.FieldAccessorTable(internal__static_EntityStopped__Descriptor,
- new string[] { "EntityId", });
- return null;
- };
- pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,
- new pbd::FileDescriptor[] {
- }, assigner);
- }
- #endregion
-
-}
-#region Messages
-[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-public sealed partial class CoordinatorState : pb::GeneratedMessage
-{
- private CoordinatorState() { }
- private static readonly CoordinatorState defaultInstance = new CoordinatorState().MakeReadOnly();
- private static readonly string[] _coordinatorStateFieldNames = new string[] { "regionProxies", "regions", "shards", "unallocatedShards" };
- private static readonly uint[] _coordinatorStateFieldTags = new uint[] { 26, 18, 10, 34 };
- public static CoordinatorState DefaultInstance
- {
- get { return defaultInstance; }
- }
-
- public override CoordinatorState DefaultInstanceForType
- {
- get { return DefaultInstance; }
- }
-
- protected override CoordinatorState ThisMessage
- {
- get { return this; }
- }
-
- public static pbd::MessageDescriptor Descriptor
- {
- get { return global::ClusterShardingMessages.internal__static_CoordinatorState__Descriptor; }
- }
-
- protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors
- {
- get { return global::ClusterShardingMessages.internal__static_CoordinatorState__FieldAccessorTable; }
- }
-
- #region Nested types
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public static partial class Types
- {
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class ShardEntry : pb::GeneratedMessage
- {
- private ShardEntry() { }
- private static readonly ShardEntry defaultInstance = new ShardEntry().MakeReadOnly();
- private static readonly string[] _shardEntryFieldNames = new string[] { "regionRef", "shardId" };
- private static readonly uint[] _shardEntryFieldTags = new uint[] { 18, 10 };
- public static ShardEntry DefaultInstance
- {
- get { return defaultInstance; }
- }
-
- public override ShardEntry DefaultInstanceForType
- {
- get { return DefaultInstance; }
- }
-
- protected override ShardEntry ThisMessage
- {
- get { return this; }
- }
-
- public static pbd::MessageDescriptor Descriptor
- {
- get { return global::ClusterShardingMessages.internal__static_CoordinatorState_ShardEntry__Descriptor; }
- }
-
- protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors
- {
- get { return global::ClusterShardingMessages.internal__static_CoordinatorState_ShardEntry__FieldAccessorTable; }
- }
-
- public const int ShardIdFieldNumber = 1;
- private bool hasShardId;
- private string shardId_ = "";
- public bool HasShardId
- {
- get { return hasShardId; }
- }
- public string ShardId
- {
- get { return shardId_; }
- }
-
- public const int RegionRefFieldNumber = 2;
- private bool hasRegionRef;
- private string regionRef_ = "";
- public bool HasRegionRef
- {
- get { return hasRegionRef; }
- }
- public string RegionRef
- {
- get { return regionRef_; }
- }
-
- public override bool IsInitialized
- {
- get
- {
- if (!hasShardId) return false;
- if (!hasRegionRef) return false;
- return true;
- }
- }
-
- public override void WriteTo(pb::ICodedOutputStream output)
- {
- int size = SerializedSize;
- string[] field_names = _shardEntryFieldNames;
- if (hasShardId)
- {
- output.WriteString(1, field_names[1], ShardId);
- }
- if (hasRegionRef)
- {
- output.WriteString(2, field_names[0], RegionRef);
- }
- UnknownFields.WriteTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public override int SerializedSize
- {
- get
- {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (hasShardId)
- {
- size += pb::CodedOutputStream.ComputeStringSize(1, ShardId);
- }
- if (hasRegionRef)
- {
- size += pb::CodedOutputStream.ComputeStringSize(2, RegionRef);
- }
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- }
-
- public static ShardEntry ParseFrom(pb::ByteString data)
- {
- return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static ShardEntry ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static ShardEntry ParseFrom(byte[] data)
- {
- return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static ShardEntry ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static ShardEntry ParseFrom(global::System.IO.Stream input)
- {
- return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static ShardEntry ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static ShardEntry ParseDelimitedFrom(global::System.IO.Stream input)
- {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static ShardEntry ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
- {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static ShardEntry ParseFrom(pb::ICodedInputStream input)
- {
- return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static ShardEntry ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private ShardEntry MakeReadOnly()
- {
- return this;
- }
-
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(ShardEntry prototype)
- {
- return new Builder(prototype);
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder
- {
- protected override Builder ThisBuilder
- {
- get { return this; }
- }
- public Builder()
- {
- result = DefaultInstance;
- resultIsReadOnly = true;
- }
- internal Builder(ShardEntry cloneFrom)
- {
- result = cloneFrom;
- resultIsReadOnly = true;
- }
-
- private bool resultIsReadOnly;
- private ShardEntry result;
-
- private ShardEntry PrepareBuilder()
- {
- if (resultIsReadOnly)
- {
- ShardEntry original = result;
- result = new ShardEntry();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
- }
-
- public override bool IsInitialized
- {
- get { return result.IsInitialized; }
- }
-
- protected override ShardEntry MessageBeingBuilt
- {
- get { return PrepareBuilder(); }
- }
-
- public override Builder Clear()
- {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
- }
-
- public override Builder Clone()
- {
- if (resultIsReadOnly)
- {
- return new Builder(result);
- }
- else
- {
- return new Builder().MergeFrom(result);
- }
- }
-
- public override pbd::MessageDescriptor DescriptorForType
- {
- get { return global::CoordinatorState.Types.ShardEntry.Descriptor; }
- }
-
- public override ShardEntry DefaultInstanceForType
- {
- get { return global::CoordinatorState.Types.ShardEntry.DefaultInstance; }
- }
-
- public override ShardEntry BuildPartial()
- {
- if (resultIsReadOnly)
- {
- return result;
- }
- resultIsReadOnly = true;
- return result.MakeReadOnly();
- }
-
- public override Builder MergeFrom(pb::IMessage other)
- {
- if (other is ShardEntry)
- {
- return MergeFrom((ShardEntry)other);
- }
- else
- {
- base.MergeFrom(other);
- return this;
- }
- }
-
- public override Builder MergeFrom(ShardEntry other)
- {
- if (other == global::CoordinatorState.Types.ShardEntry.DefaultInstance) return this;
- PrepareBuilder();
- if (other.HasShardId)
- {
- ShardId = other.ShardId;
- }
- if (other.HasRegionRef)
- {
- RegionRef = other.RegionRef;
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input)
- {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
- {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name))
- {
- if (tag == 0 && field_name != null)
- {
- int field_ordinal = global::System.Array.BinarySearch(_shardEntryFieldNames, field_name, global::System.StringComparer.Ordinal);
- if (field_ordinal >= 0)
- tag = _shardEntryFieldTags[field_ordinal];
- else
- {
- if (unknownFields == null)
- {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
- }
- }
- switch (tag)
- {
- case 0:
- {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default:
- {
- if (pb::WireFormat.IsEndGroupTag(tag))
- {
- if (unknownFields != null)
- {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null)
- {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 10:
- {
- result.hasShardId = input.ReadString(ref result.shardId_);
- break;
- }
- case 18:
- {
- result.hasRegionRef = input.ReadString(ref result.regionRef_);
- break;
- }
- }
- }
-
- if (unknownFields != null)
- {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public bool HasShardId
- {
- get { return result.hasShardId; }
- }
- public string ShardId
- {
- get { return result.ShardId; }
- set { SetShardId(value); }
- }
- public Builder SetShardId(string value)
- {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasShardId = true;
- result.shardId_ = value;
- return this;
- }
- public Builder ClearShardId()
- {
- PrepareBuilder();
- result.hasShardId = false;
- result.shardId_ = "";
- return this;
- }
-
- public bool HasRegionRef
- {
- get { return result.hasRegionRef; }
- }
- public string RegionRef
- {
- get { return result.RegionRef; }
- set { SetRegionRef(value); }
- }
- public Builder SetRegionRef(string value)
- {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasRegionRef = true;
- result.regionRef_ = value;
- return this;
- }
- public Builder ClearRegionRef()
- {
- PrepareBuilder();
- result.hasRegionRef = false;
- result.regionRef_ = "";
- return this;
- }
- }
- static ShardEntry()
- {
- object.ReferenceEquals(global::ClusterShardingMessages.Descriptor, null);
- }
- }
-
- }
- #endregion
-
- public const int ShardsFieldNumber = 1;
- private pbc::PopsicleList shards_ = new pbc::PopsicleList();
- public scg::IList ShardsList
- {
- get { return shards_; }
- }
- public int ShardsCount
- {
- get { return shards_.Count; }
- }
- public global::CoordinatorState.Types.ShardEntry GetShards(int index)
- {
- return shards_[index];
- }
-
- public const int RegionsFieldNumber = 2;
- private pbc::PopsicleList regions_ = new pbc::PopsicleList();
- public scg::IList RegionsList
- {
- get { return pbc::Lists.AsReadOnly(regions_); }
- }
- public int RegionsCount
- {
- get { return regions_.Count; }
- }
- public string GetRegions(int index)
- {
- return regions_[index];
- }
-
- public const int RegionProxiesFieldNumber = 3;
- private pbc::PopsicleList regionProxies_ = new pbc::PopsicleList();
- public scg::IList RegionProxiesList
- {
- get { return pbc::Lists.AsReadOnly(regionProxies_); }
- }
- public int RegionProxiesCount
- {
- get { return regionProxies_.Count; }
- }
- public string GetRegionProxies(int index)
- {
- return regionProxies_[index];
- }
-
- public const int UnallocatedShardsFieldNumber = 4;
- private pbc::PopsicleList unallocatedShards_ = new pbc::PopsicleList();
- public scg::IList UnallocatedShardsList
- {
- get { return pbc::Lists.AsReadOnly(unallocatedShards_); }
- }
- public int UnallocatedShardsCount
- {
- get { return unallocatedShards_.Count; }
- }
- public string GetUnallocatedShards(int index)
- {
- return unallocatedShards_[index];
- }
-
- public override bool IsInitialized
- {
- get
- {
- foreach (global::CoordinatorState.Types.ShardEntry element in ShardsList)
- {
- if (!element.IsInitialized) return false;
- }
- return true;
- }
- }
-
- public override void WriteTo(pb::ICodedOutputStream output)
- {
- int size = SerializedSize;
- string[] field_names = _coordinatorStateFieldNames;
- if (shards_.Count > 0)
- {
- output.WriteMessageArray(1, field_names[2], shards_);
- }
- if (regions_.Count > 0)
- {
- output.WriteStringArray(2, field_names[1], regions_);
- }
- if (regionProxies_.Count > 0)
- {
- output.WriteStringArray(3, field_names[0], regionProxies_);
- }
- if (unallocatedShards_.Count > 0)
- {
- output.WriteStringArray(4, field_names[3], unallocatedShards_);
- }
- UnknownFields.WriteTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public override int SerializedSize
- {
- get
- {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- foreach (global::CoordinatorState.Types.ShardEntry element in ShardsList)
- {
- size += pb::CodedOutputStream.ComputeMessageSize(1, element);
- }
- {
- int dataSize = 0;
- foreach (string element in RegionsList)
- {
- dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element);
- }
- size += dataSize;
- size += 1 * regions_.Count;
- }
- {
- int dataSize = 0;
- foreach (string element in RegionProxiesList)
- {
- dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element);
- }
- size += dataSize;
- size += 1 * regionProxies_.Count;
- }
- {
- int dataSize = 0;
- foreach (string element in UnallocatedShardsList)
- {
- dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element);
- }
- size += dataSize;
- size += 1 * unallocatedShards_.Count;
- }
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- }
-
- public static CoordinatorState ParseFrom(pb::ByteString data)
- {
- return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static CoordinatorState ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static CoordinatorState ParseFrom(byte[] data)
- {
- return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static CoordinatorState ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static CoordinatorState ParseFrom(global::System.IO.Stream input)
- {
- return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static CoordinatorState ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static CoordinatorState ParseDelimitedFrom(global::System.IO.Stream input)
- {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static CoordinatorState ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
- {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static CoordinatorState ParseFrom(pb::ICodedInputStream input)
- {
- return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static CoordinatorState ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private CoordinatorState MakeReadOnly()
- {
- shards_.MakeReadOnly();
- regions_.MakeReadOnly();
- regionProxies_.MakeReadOnly();
- unallocatedShards_.MakeReadOnly();
- return this;
- }
-
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(CoordinatorState prototype)
- {
- return new Builder(prototype);
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder
- {
- protected override Builder ThisBuilder
- {
- get { return this; }
- }
- public Builder()
- {
- result = DefaultInstance;
- resultIsReadOnly = true;
- }
- internal Builder(CoordinatorState cloneFrom)
- {
- result = cloneFrom;
- resultIsReadOnly = true;
- }
-
- private bool resultIsReadOnly;
- private CoordinatorState result;
-
- private CoordinatorState PrepareBuilder()
- {
- if (resultIsReadOnly)
- {
- CoordinatorState original = result;
- result = new CoordinatorState();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
- }
-
- public override bool IsInitialized
- {
- get { return result.IsInitialized; }
- }
-
- protected override CoordinatorState MessageBeingBuilt
- {
- get { return PrepareBuilder(); }
- }
-
- public override Builder Clear()
- {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
- }
-
- public override Builder Clone()
- {
- if (resultIsReadOnly)
- {
- return new Builder(result);
- }
- else
- {
- return new Builder().MergeFrom(result);
- }
- }
-
- public override pbd::MessageDescriptor DescriptorForType
- {
- get { return global::CoordinatorState.Descriptor; }
- }
-
- public override CoordinatorState DefaultInstanceForType
- {
- get { return global::CoordinatorState.DefaultInstance; }
- }
-
- public override CoordinatorState BuildPartial()
- {
- if (resultIsReadOnly)
- {
- return result;
- }
- resultIsReadOnly = true;
- return result.MakeReadOnly();
- }
-
- public override Builder MergeFrom(pb::IMessage other)
- {
- if (other is CoordinatorState)
- {
- return MergeFrom((CoordinatorState)other);
- }
- else
- {
- base.MergeFrom(other);
- return this;
- }
- }
-
- public override Builder MergeFrom(CoordinatorState other)
- {
- if (other == global::CoordinatorState.DefaultInstance) return this;
- PrepareBuilder();
- if (other.shards_.Count != 0)
- {
- result.shards_.Add(other.shards_);
- }
- if (other.regions_.Count != 0)
- {
- result.regions_.Add(other.regions_);
- }
- if (other.regionProxies_.Count != 0)
- {
- result.regionProxies_.Add(other.regionProxies_);
- }
- if (other.unallocatedShards_.Count != 0)
- {
- result.unallocatedShards_.Add(other.unallocatedShards_);
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input)
- {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
- {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name))
- {
- if (tag == 0 && field_name != null)
- {
- int field_ordinal = global::System.Array.BinarySearch(_coordinatorStateFieldNames, field_name, global::System.StringComparer.Ordinal);
- if (field_ordinal >= 0)
- tag = _coordinatorStateFieldTags[field_ordinal];
- else
- {
- if (unknownFields == null)
- {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
- }
- }
- switch (tag)
- {
- case 0:
- {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default:
- {
- if (pb::WireFormat.IsEndGroupTag(tag))
- {
- if (unknownFields != null)
- {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null)
- {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 10:
- {
- input.ReadMessageArray(tag, field_name, result.shards_, global::CoordinatorState.Types.ShardEntry.DefaultInstance, extensionRegistry);
- break;
- }
- case 18:
- {
- input.ReadStringArray(tag, field_name, result.regions_);
- break;
- }
- case 26:
- {
- input.ReadStringArray(tag, field_name, result.regionProxies_);
- break;
- }
- case 34:
- {
- input.ReadStringArray(tag, field_name, result.unallocatedShards_);
- break;
- }
- }
- }
-
- if (unknownFields != null)
- {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public pbc::IPopsicleList ShardsList
- {
- get { return PrepareBuilder().shards_; }
- }
- public int ShardsCount
- {
- get { return result.ShardsCount; }
- }
- public global::CoordinatorState.Types.ShardEntry GetShards(int index)
- {
- return result.GetShards(index);
- }
- public Builder SetShards(int index, global::CoordinatorState.Types.ShardEntry value)
- {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.shards_[index] = value;
- return this;
- }
- public Builder SetShards(int index, global::CoordinatorState.Types.ShardEntry.Builder builderForValue)
- {
- pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
- PrepareBuilder();
- result.shards_[index] = builderForValue.Build();
- return this;
- }
- public Builder AddShards(global::CoordinatorState.Types.ShardEntry value)
- {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.shards_.Add(value);
- return this;
- }
- public Builder AddShards(global::CoordinatorState.Types.ShardEntry.Builder builderForValue)
- {
- pb::ThrowHelper.ThrowIfNull(builderForValue, "builderForValue");
- PrepareBuilder();
- result.shards_.Add(builderForValue.Build());
- return this;
- }
- public Builder AddRangeShards(scg::IEnumerable values)
- {
- PrepareBuilder();
- result.shards_.Add(values);
- return this;
- }
- public Builder ClearShards()
- {
- PrepareBuilder();
- result.shards_.Clear();
- return this;
- }
-
- public pbc::IPopsicleList RegionsList
- {
- get { return PrepareBuilder().regions_; }
- }
- public int RegionsCount
- {
- get { return result.RegionsCount; }
- }
- public string GetRegions(int index)
- {
- return result.GetRegions(index);
- }
- public Builder SetRegions(int index, string value)
- {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.regions_[index] = value;
- return this;
- }
- public Builder AddRegions(string value)
- {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.regions_.Add(value);
- return this;
- }
- public Builder AddRangeRegions(scg::IEnumerable values)
- {
- PrepareBuilder();
- result.regions_.Add(values);
- return this;
- }
- public Builder ClearRegions()
- {
- PrepareBuilder();
- result.regions_.Clear();
- return this;
- }
-
- public pbc::IPopsicleList RegionProxiesList
- {
- get { return PrepareBuilder().regionProxies_; }
- }
- public int RegionProxiesCount
- {
- get { return result.RegionProxiesCount; }
- }
- public string GetRegionProxies(int index)
- {
- return result.GetRegionProxies(index);
- }
- public Builder SetRegionProxies(int index, string value)
- {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.regionProxies_[index] = value;
- return this;
- }
- public Builder AddRegionProxies(string value)
- {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.regionProxies_.Add(value);
- return this;
- }
- public Builder AddRangeRegionProxies(scg::IEnumerable values)
- {
- PrepareBuilder();
- result.regionProxies_.Add(values);
- return this;
- }
- public Builder ClearRegionProxies()
- {
- PrepareBuilder();
- result.regionProxies_.Clear();
- return this;
- }
-
- public pbc::IPopsicleList UnallocatedShardsList
- {
- get { return PrepareBuilder().unallocatedShards_; }
- }
- public int UnallocatedShardsCount
- {
- get { return result.UnallocatedShardsCount; }
- }
- public string GetUnallocatedShards(int index)
- {
- return result.GetUnallocatedShards(index);
- }
- public Builder SetUnallocatedShards(int index, string value)
- {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.unallocatedShards_[index] = value;
- return this;
- }
- public Builder AddUnallocatedShards(string value)
- {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.unallocatedShards_.Add(value);
- return this;
- }
- public Builder AddRangeUnallocatedShards(scg::IEnumerable values)
- {
- PrepareBuilder();
- result.unallocatedShards_.Add(values);
- return this;
- }
- public Builder ClearUnallocatedShards()
- {
- PrepareBuilder();
- result.unallocatedShards_.Clear();
- return this;
- }
- }
- static CoordinatorState()
- {
- object.ReferenceEquals(global::ClusterShardingMessages.Descriptor, null);
- }
-}
-
-[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-public sealed partial class ActorRefMessage : pb::GeneratedMessage
-{
- private ActorRefMessage() { }
- private static readonly ActorRefMessage defaultInstance = new ActorRefMessage().MakeReadOnly();
- private static readonly string[] _actorRefMessageFieldNames = new string[] { "ref" };
- private static readonly uint[] _actorRefMessageFieldTags = new uint[] { 10 };
- public static ActorRefMessage DefaultInstance
- {
- get { return defaultInstance; }
- }
-
- public override ActorRefMessage DefaultInstanceForType
- {
- get { return DefaultInstance; }
- }
-
- protected override ActorRefMessage ThisMessage
- {
- get { return this; }
- }
-
- public static pbd::MessageDescriptor Descriptor
- {
- get { return global::ClusterShardingMessages.internal__static_ActorRefMessage__Descriptor; }
- }
-
- protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors
- {
- get { return global::ClusterShardingMessages.internal__static_ActorRefMessage__FieldAccessorTable; }
- }
-
- public const int RefFieldNumber = 1;
- private bool hasRef;
- private string ref_ = "";
- public bool HasRef
- {
- get { return hasRef; }
- }
- public string Ref
- {
- get { return ref_; }
- }
-
- public override bool IsInitialized
- {
- get
- {
- if (!hasRef) return false;
- return true;
- }
- }
-
- public override void WriteTo(pb::ICodedOutputStream output)
- {
- int size = SerializedSize;
- string[] field_names = _actorRefMessageFieldNames;
- if (hasRef)
- {
- output.WriteString(1, field_names[0], Ref);
- }
- UnknownFields.WriteTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public override int SerializedSize
- {
- get
- {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (hasRef)
- {
- size += pb::CodedOutputStream.ComputeStringSize(1, Ref);
- }
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- }
-
- public static ActorRefMessage ParseFrom(pb::ByteString data)
- {
- return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static ActorRefMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static ActorRefMessage ParseFrom(byte[] data)
- {
- return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static ActorRefMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static ActorRefMessage ParseFrom(global::System.IO.Stream input)
- {
- return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static ActorRefMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static ActorRefMessage ParseDelimitedFrom(global::System.IO.Stream input)
- {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static ActorRefMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
- {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static ActorRefMessage ParseFrom(pb::ICodedInputStream input)
- {
- return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static ActorRefMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private ActorRefMessage MakeReadOnly()
- {
- return this;
- }
-
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(ActorRefMessage prototype)
- {
- return new Builder(prototype);
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder
- {
- protected override Builder ThisBuilder
- {
- get { return this; }
- }
- public Builder()
- {
- result = DefaultInstance;
- resultIsReadOnly = true;
- }
- internal Builder(ActorRefMessage cloneFrom)
- {
- result = cloneFrom;
- resultIsReadOnly = true;
- }
-
- private bool resultIsReadOnly;
- private ActorRefMessage result;
-
- private ActorRefMessage PrepareBuilder()
- {
- if (resultIsReadOnly)
- {
- ActorRefMessage original = result;
- result = new ActorRefMessage();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
- }
-
- public override bool IsInitialized
- {
- get { return result.IsInitialized; }
- }
-
- protected override ActorRefMessage MessageBeingBuilt
- {
- get { return PrepareBuilder(); }
- }
-
- public override Builder Clear()
- {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
- }
-
- public override Builder Clone()
- {
- if (resultIsReadOnly)
- {
- return new Builder(result);
- }
- else
- {
- return new Builder().MergeFrom(result);
- }
- }
-
- public override pbd::MessageDescriptor DescriptorForType
- {
- get { return global::ActorRefMessage.Descriptor; }
- }
-
- public override ActorRefMessage DefaultInstanceForType
- {
- get { return global::ActorRefMessage.DefaultInstance; }
- }
-
- public override ActorRefMessage BuildPartial()
- {
- if (resultIsReadOnly)
- {
- return result;
- }
- resultIsReadOnly = true;
- return result.MakeReadOnly();
- }
-
- public override Builder MergeFrom(pb::IMessage other)
- {
- if (other is ActorRefMessage)
- {
- return MergeFrom((ActorRefMessage)other);
- }
- else
- {
- base.MergeFrom(other);
- return this;
- }
- }
-
- public override Builder MergeFrom(ActorRefMessage other)
- {
- if (other == global::ActorRefMessage.DefaultInstance) return this;
- PrepareBuilder();
- if (other.HasRef)
- {
- Ref = other.Ref;
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input)
- {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
- {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name))
- {
- if (tag == 0 && field_name != null)
- {
- int field_ordinal = global::System.Array.BinarySearch(_actorRefMessageFieldNames, field_name, global::System.StringComparer.Ordinal);
- if (field_ordinal >= 0)
- tag = _actorRefMessageFieldTags[field_ordinal];
- else
- {
- if (unknownFields == null)
- {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
- }
- }
- switch (tag)
- {
- case 0:
- {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default:
- {
- if (pb::WireFormat.IsEndGroupTag(tag))
- {
- if (unknownFields != null)
- {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null)
- {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 10:
- {
- result.hasRef = input.ReadString(ref result.ref_);
- break;
- }
- }
- }
-
- if (unknownFields != null)
- {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public bool HasRef
- {
- get { return result.hasRef; }
- }
- public string Ref
- {
- get { return result.Ref; }
- set { SetRef(value); }
- }
- public Builder SetRef(string value)
- {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasRef = true;
- result.ref_ = value;
- return this;
- }
- public Builder ClearRef()
- {
- PrepareBuilder();
- result.hasRef = false;
- result.ref_ = "";
- return this;
- }
- }
- static ActorRefMessage()
- {
- object.ReferenceEquals(global::ClusterShardingMessages.Descriptor, null);
- }
-}
-
-[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-public sealed partial class ShardIdMessage : pb::GeneratedMessage
-{
- private ShardIdMessage() { }
- private static readonly ShardIdMessage defaultInstance = new ShardIdMessage().MakeReadOnly();
- private static readonly string[] _shardIdMessageFieldNames = new string[] { "shard" };
- private static readonly uint[] _shardIdMessageFieldTags = new uint[] { 10 };
- public static ShardIdMessage DefaultInstance
- {
- get { return defaultInstance; }
- }
-
- public override ShardIdMessage DefaultInstanceForType
- {
- get { return DefaultInstance; }
- }
-
- protected override ShardIdMessage ThisMessage
- {
- get { return this; }
- }
-
- public static pbd::MessageDescriptor Descriptor
- {
- get { return global::ClusterShardingMessages.internal__static_ShardIdMessage__Descriptor; }
- }
-
- protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors
- {
- get { return global::ClusterShardingMessages.internal__static_ShardIdMessage__FieldAccessorTable; }
- }
-
- public const int ShardFieldNumber = 1;
- private bool hasShard;
- private string shard_ = "";
- public bool HasShard
- {
- get { return hasShard; }
- }
- public string Shard
- {
- get { return shard_; }
- }
-
- public override bool IsInitialized
- {
- get
- {
- if (!hasShard) return false;
- return true;
- }
- }
-
- public override void WriteTo(pb::ICodedOutputStream output)
- {
- int size = SerializedSize;
- string[] field_names = _shardIdMessageFieldNames;
- if (hasShard)
- {
- output.WriteString(1, field_names[0], Shard);
- }
- UnknownFields.WriteTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public override int SerializedSize
- {
- get
- {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (hasShard)
- {
- size += pb::CodedOutputStream.ComputeStringSize(1, Shard);
- }
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- }
-
- public static ShardIdMessage ParseFrom(pb::ByteString data)
- {
- return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static ShardIdMessage ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static ShardIdMessage ParseFrom(byte[] data)
- {
- return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static ShardIdMessage ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static ShardIdMessage ParseFrom(global::System.IO.Stream input)
- {
- return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static ShardIdMessage ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static ShardIdMessage ParseDelimitedFrom(global::System.IO.Stream input)
- {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static ShardIdMessage ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
- {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static ShardIdMessage ParseFrom(pb::ICodedInputStream input)
- {
- return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static ShardIdMessage ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private ShardIdMessage MakeReadOnly()
- {
- return this;
- }
-
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(ShardIdMessage prototype)
- {
- return new Builder(prototype);
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder
- {
- protected override Builder ThisBuilder
- {
- get { return this; }
- }
- public Builder()
- {
- result = DefaultInstance;
- resultIsReadOnly = true;
- }
- internal Builder(ShardIdMessage cloneFrom)
- {
- result = cloneFrom;
- resultIsReadOnly = true;
- }
-
- private bool resultIsReadOnly;
- private ShardIdMessage result;
-
- private ShardIdMessage PrepareBuilder()
- {
- if (resultIsReadOnly)
- {
- ShardIdMessage original = result;
- result = new ShardIdMessage();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
- }
-
- public override bool IsInitialized
- {
- get { return result.IsInitialized; }
- }
-
- protected override ShardIdMessage MessageBeingBuilt
- {
- get { return PrepareBuilder(); }
- }
-
- public override Builder Clear()
- {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
- }
-
- public override Builder Clone()
- {
- if (resultIsReadOnly)
- {
- return new Builder(result);
- }
- else
- {
- return new Builder().MergeFrom(result);
- }
- }
-
- public override pbd::MessageDescriptor DescriptorForType
- {
- get { return global::ShardIdMessage.Descriptor; }
- }
-
- public override ShardIdMessage DefaultInstanceForType
- {
- get { return global::ShardIdMessage.DefaultInstance; }
- }
-
- public override ShardIdMessage BuildPartial()
- {
- if (resultIsReadOnly)
- {
- return result;
- }
- resultIsReadOnly = true;
- return result.MakeReadOnly();
- }
-
- public override Builder MergeFrom(pb::IMessage other)
- {
- if (other is ShardIdMessage)
- {
- return MergeFrom((ShardIdMessage)other);
- }
- else
- {
- base.MergeFrom(other);
- return this;
- }
- }
-
- public override Builder MergeFrom(ShardIdMessage other)
- {
- if (other == global::ShardIdMessage.DefaultInstance) return this;
- PrepareBuilder();
- if (other.HasShard)
- {
- Shard = other.Shard;
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input)
- {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
- {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name))
- {
- if (tag == 0 && field_name != null)
- {
- int field_ordinal = global::System.Array.BinarySearch(_shardIdMessageFieldNames, field_name, global::System.StringComparer.Ordinal);
- if (field_ordinal >= 0)
- tag = _shardIdMessageFieldTags[field_ordinal];
- else
- {
- if (unknownFields == null)
- {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
- }
- }
- switch (tag)
- {
- case 0:
- {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default:
- {
- if (pb::WireFormat.IsEndGroupTag(tag))
- {
- if (unknownFields != null)
- {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null)
- {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 10:
- {
- result.hasShard = input.ReadString(ref result.shard_);
- break;
- }
- }
- }
-
- if (unknownFields != null)
- {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public bool HasShard
- {
- get { return result.hasShard; }
- }
- public string Shard
- {
- get { return result.Shard; }
- set { SetShard(value); }
- }
- public Builder SetShard(string value)
- {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasShard = true;
- result.shard_ = value;
- return this;
- }
- public Builder ClearShard()
- {
- PrepareBuilder();
- result.hasShard = false;
- result.shard_ = "";
- return this;
- }
- }
- static ShardIdMessage()
- {
- object.ReferenceEquals(global::ClusterShardingMessages.Descriptor, null);
- }
-}
-
-[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-public sealed partial class ShardHomeAllocated : pb::GeneratedMessage
-{
- private ShardHomeAllocated() { }
- private static readonly ShardHomeAllocated defaultInstance = new ShardHomeAllocated().MakeReadOnly();
- private static readonly string[] _shardHomeAllocatedFieldNames = new string[] { "region", "shard" };
- private static readonly uint[] _shardHomeAllocatedFieldTags = new uint[] { 18, 10 };
- public static ShardHomeAllocated DefaultInstance
- {
- get { return defaultInstance; }
- }
-
- public override ShardHomeAllocated DefaultInstanceForType
- {
- get { return DefaultInstance; }
- }
-
- protected override ShardHomeAllocated ThisMessage
- {
- get { return this; }
- }
-
- public static pbd::MessageDescriptor Descriptor
- {
- get { return global::ClusterShardingMessages.internal__static_ShardHomeAllocated__Descriptor; }
- }
-
- protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors
- {
- get { return global::ClusterShardingMessages.internal__static_ShardHomeAllocated__FieldAccessorTable; }
- }
-
- public const int ShardFieldNumber = 1;
- private bool hasShard;
- private string shard_ = "";
- public bool HasShard
- {
- get { return hasShard; }
- }
- public string Shard
- {
- get { return shard_; }
- }
-
- public const int RegionFieldNumber = 2;
- private bool hasRegion;
- private string region_ = "";
- public bool HasRegion
- {
- get { return hasRegion; }
- }
- public string Region
- {
- get { return region_; }
- }
-
- public override bool IsInitialized
- {
- get
- {
- if (!hasShard) return false;
- if (!hasRegion) return false;
- return true;
- }
- }
-
- public override void WriteTo(pb::ICodedOutputStream output)
- {
- int size = SerializedSize;
- string[] field_names = _shardHomeAllocatedFieldNames;
- if (hasShard)
- {
- output.WriteString(1, field_names[1], Shard);
- }
- if (hasRegion)
- {
- output.WriteString(2, field_names[0], Region);
- }
- UnknownFields.WriteTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public override int SerializedSize
- {
- get
- {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (hasShard)
- {
- size += pb::CodedOutputStream.ComputeStringSize(1, Shard);
- }
- if (hasRegion)
- {
- size += pb::CodedOutputStream.ComputeStringSize(2, Region);
- }
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- }
-
- public static ShardHomeAllocated ParseFrom(pb::ByteString data)
- {
- return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static ShardHomeAllocated ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static ShardHomeAllocated ParseFrom(byte[] data)
- {
- return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static ShardHomeAllocated ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static ShardHomeAllocated ParseFrom(global::System.IO.Stream input)
- {
- return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static ShardHomeAllocated ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static ShardHomeAllocated ParseDelimitedFrom(global::System.IO.Stream input)
- {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static ShardHomeAllocated ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
- {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static ShardHomeAllocated ParseFrom(pb::ICodedInputStream input)
- {
- return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static ShardHomeAllocated ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private ShardHomeAllocated MakeReadOnly()
- {
- return this;
- }
-
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(ShardHomeAllocated prototype)
- {
- return new Builder(prototype);
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder
- {
- protected override Builder ThisBuilder
- {
- get { return this; }
- }
- public Builder()
- {
- result = DefaultInstance;
- resultIsReadOnly = true;
- }
- internal Builder(ShardHomeAllocated cloneFrom)
- {
- result = cloneFrom;
- resultIsReadOnly = true;
- }
-
- private bool resultIsReadOnly;
- private ShardHomeAllocated result;
-
- private ShardHomeAllocated PrepareBuilder()
- {
- if (resultIsReadOnly)
- {
- ShardHomeAllocated original = result;
- result = new ShardHomeAllocated();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
- }
-
- public override bool IsInitialized
- {
- get { return result.IsInitialized; }
- }
-
- protected override ShardHomeAllocated MessageBeingBuilt
- {
- get { return PrepareBuilder(); }
- }
-
- public override Builder Clear()
- {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
- }
-
- public override Builder Clone()
- {
- if (resultIsReadOnly)
- {
- return new Builder(result);
- }
- else
- {
- return new Builder().MergeFrom(result);
- }
- }
-
- public override pbd::MessageDescriptor DescriptorForType
- {
- get { return global::ShardHomeAllocated.Descriptor; }
- }
-
- public override ShardHomeAllocated DefaultInstanceForType
- {
- get { return global::ShardHomeAllocated.DefaultInstance; }
- }
-
- public override ShardHomeAllocated BuildPartial()
- {
- if (resultIsReadOnly)
- {
- return result;
- }
- resultIsReadOnly = true;
- return result.MakeReadOnly();
- }
-
- public override Builder MergeFrom(pb::IMessage other)
- {
- if (other is ShardHomeAllocated)
- {
- return MergeFrom((ShardHomeAllocated)other);
- }
- else
- {
- base.MergeFrom(other);
- return this;
- }
- }
-
- public override Builder MergeFrom(ShardHomeAllocated other)
- {
- if (other == global::ShardHomeAllocated.DefaultInstance) return this;
- PrepareBuilder();
- if (other.HasShard)
- {
- Shard = other.Shard;
- }
- if (other.HasRegion)
- {
- Region = other.Region;
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input)
- {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
- {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name))
- {
- if (tag == 0 && field_name != null)
- {
- int field_ordinal = global::System.Array.BinarySearch(_shardHomeAllocatedFieldNames, field_name, global::System.StringComparer.Ordinal);
- if (field_ordinal >= 0)
- tag = _shardHomeAllocatedFieldTags[field_ordinal];
- else
- {
- if (unknownFields == null)
- {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
- }
- }
- switch (tag)
- {
- case 0:
- {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default:
- {
- if (pb::WireFormat.IsEndGroupTag(tag))
- {
- if (unknownFields != null)
- {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null)
- {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 10:
- {
- result.hasShard = input.ReadString(ref result.shard_);
- break;
- }
- case 18:
- {
- result.hasRegion = input.ReadString(ref result.region_);
- break;
- }
- }
- }
-
- if (unknownFields != null)
- {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public bool HasShard
- {
- get { return result.hasShard; }
- }
- public string Shard
- {
- get { return result.Shard; }
- set { SetShard(value); }
- }
- public Builder SetShard(string value)
- {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasShard = true;
- result.shard_ = value;
- return this;
- }
- public Builder ClearShard()
- {
- PrepareBuilder();
- result.hasShard = false;
- result.shard_ = "";
- return this;
- }
-
- public bool HasRegion
- {
- get { return result.hasRegion; }
- }
- public string Region
- {
- get { return result.Region; }
- set { SetRegion(value); }
- }
- public Builder SetRegion(string value)
- {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasRegion = true;
- result.region_ = value;
- return this;
- }
- public Builder ClearRegion()
- {
- PrepareBuilder();
- result.hasRegion = false;
- result.region_ = "";
- return this;
- }
- }
- static ShardHomeAllocated()
- {
- object.ReferenceEquals(global::ClusterShardingMessages.Descriptor, null);
- }
-}
-
-[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-public sealed partial class ShardHome : pb::GeneratedMessage
-{
- private ShardHome() { }
- private static readonly ShardHome defaultInstance = new ShardHome().MakeReadOnly();
- private static readonly string[] _shardHomeFieldNames = new string[] { "region", "shard" };
- private static readonly uint[] _shardHomeFieldTags = new uint[] { 18, 10 };
- public static ShardHome DefaultInstance
- {
- get { return defaultInstance; }
- }
-
- public override ShardHome DefaultInstanceForType
- {
- get { return DefaultInstance; }
- }
-
- protected override ShardHome ThisMessage
- {
- get { return this; }
- }
-
- public static pbd::MessageDescriptor Descriptor
- {
- get { return global::ClusterShardingMessages.internal__static_ShardHome__Descriptor; }
- }
-
- protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors
- {
- get { return global::ClusterShardingMessages.internal__static_ShardHome__FieldAccessorTable; }
- }
-
- public const int ShardFieldNumber = 1;
- private bool hasShard;
- private string shard_ = "";
- public bool HasShard
- {
- get { return hasShard; }
- }
- public string Shard
- {
- get { return shard_; }
- }
-
- public const int RegionFieldNumber = 2;
- private bool hasRegion;
- private string region_ = "";
- public bool HasRegion
- {
- get { return hasRegion; }
- }
- public string Region
- {
- get { return region_; }
- }
-
- public override bool IsInitialized
- {
- get
- {
- if (!hasShard) return false;
- if (!hasRegion) return false;
- return true;
- }
- }
-
- public override void WriteTo(pb::ICodedOutputStream output)
- {
- int size = SerializedSize;
- string[] field_names = _shardHomeFieldNames;
- if (hasShard)
- {
- output.WriteString(1, field_names[1], Shard);
- }
- if (hasRegion)
- {
- output.WriteString(2, field_names[0], Region);
- }
- UnknownFields.WriteTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public override int SerializedSize
- {
- get
- {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (hasShard)
- {
- size += pb::CodedOutputStream.ComputeStringSize(1, Shard);
- }
- if (hasRegion)
- {
- size += pb::CodedOutputStream.ComputeStringSize(2, Region);
- }
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- }
-
- public static ShardHome ParseFrom(pb::ByteString data)
- {
- return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static ShardHome ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static ShardHome ParseFrom(byte[] data)
- {
- return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static ShardHome ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static ShardHome ParseFrom(global::System.IO.Stream input)
- {
- return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static ShardHome ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static ShardHome ParseDelimitedFrom(global::System.IO.Stream input)
- {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static ShardHome ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
- {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static ShardHome ParseFrom(pb::ICodedInputStream input)
- {
- return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static ShardHome ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private ShardHome MakeReadOnly()
- {
- return this;
- }
-
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(ShardHome prototype)
- {
- return new Builder(prototype);
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder
- {
- protected override Builder ThisBuilder
- {
- get { return this; }
- }
- public Builder()
- {
- result = DefaultInstance;
- resultIsReadOnly = true;
- }
- internal Builder(ShardHome cloneFrom)
- {
- result = cloneFrom;
- resultIsReadOnly = true;
- }
-
- private bool resultIsReadOnly;
- private ShardHome result;
-
- private ShardHome PrepareBuilder()
- {
- if (resultIsReadOnly)
- {
- ShardHome original = result;
- result = new ShardHome();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
- }
-
- public override bool IsInitialized
- {
- get { return result.IsInitialized; }
- }
-
- protected override ShardHome MessageBeingBuilt
- {
- get { return PrepareBuilder(); }
- }
-
- public override Builder Clear()
- {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
- }
-
- public override Builder Clone()
- {
- if (resultIsReadOnly)
- {
- return new Builder(result);
- }
- else
- {
- return new Builder().MergeFrom(result);
- }
- }
-
- public override pbd::MessageDescriptor DescriptorForType
- {
- get { return global::ShardHome.Descriptor; }
- }
-
- public override ShardHome DefaultInstanceForType
- {
- get { return global::ShardHome.DefaultInstance; }
- }
-
- public override ShardHome BuildPartial()
- {
- if (resultIsReadOnly)
- {
- return result;
- }
- resultIsReadOnly = true;
- return result.MakeReadOnly();
- }
-
- public override Builder MergeFrom(pb::IMessage other)
- {
- if (other is ShardHome)
- {
- return MergeFrom((ShardHome)other);
- }
- else
- {
- base.MergeFrom(other);
- return this;
- }
- }
-
- public override Builder MergeFrom(ShardHome other)
- {
- if (other == global::ShardHome.DefaultInstance) return this;
- PrepareBuilder();
- if (other.HasShard)
- {
- Shard = other.Shard;
- }
- if (other.HasRegion)
- {
- Region = other.Region;
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input)
- {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
- {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name))
- {
- if (tag == 0 && field_name != null)
- {
- int field_ordinal = global::System.Array.BinarySearch(_shardHomeFieldNames, field_name, global::System.StringComparer.Ordinal);
- if (field_ordinal >= 0)
- tag = _shardHomeFieldTags[field_ordinal];
- else
- {
- if (unknownFields == null)
- {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
- }
- }
- switch (tag)
- {
- case 0:
- {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default:
- {
- if (pb::WireFormat.IsEndGroupTag(tag))
- {
- if (unknownFields != null)
- {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null)
- {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 10:
- {
- result.hasShard = input.ReadString(ref result.shard_);
- break;
- }
- case 18:
- {
- result.hasRegion = input.ReadString(ref result.region_);
- break;
- }
- }
- }
-
- if (unknownFields != null)
- {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public bool HasShard
- {
- get { return result.hasShard; }
- }
- public string Shard
- {
- get { return result.Shard; }
- set { SetShard(value); }
- }
- public Builder SetShard(string value)
- {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasShard = true;
- result.shard_ = value;
- return this;
- }
- public Builder ClearShard()
- {
- PrepareBuilder();
- result.hasShard = false;
- result.shard_ = "";
- return this;
- }
-
- public bool HasRegion
- {
- get { return result.hasRegion; }
- }
- public string Region
- {
- get { return result.Region; }
- set { SetRegion(value); }
- }
- public Builder SetRegion(string value)
- {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasRegion = true;
- result.region_ = value;
- return this;
- }
- public Builder ClearRegion()
- {
- PrepareBuilder();
- result.hasRegion = false;
- result.region_ = "";
- return this;
- }
- }
- static ShardHome()
- {
- object.ReferenceEquals(global::ClusterShardingMessages.Descriptor, null);
- }
-}
-
-[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-public sealed partial class EntityState : pb::GeneratedMessage
-{
- private EntityState() { }
- private static readonly EntityState defaultInstance = new EntityState().MakeReadOnly();
- private static readonly string[] _entityStateFieldNames = new string[] { "entities" };
- private static readonly uint[] _entityStateFieldTags = new uint[] { 10 };
- public static EntityState DefaultInstance
- {
- get { return defaultInstance; }
- }
-
- public override EntityState DefaultInstanceForType
- {
- get { return DefaultInstance; }
- }
-
- protected override EntityState ThisMessage
- {
- get { return this; }
- }
-
- public static pbd::MessageDescriptor Descriptor
- {
- get { return global::ClusterShardingMessages.internal__static_EntityState__Descriptor; }
- }
-
- protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors
- {
- get { return global::ClusterShardingMessages.internal__static_EntityState__FieldAccessorTable; }
- }
-
- public const int EntitiesFieldNumber = 1;
- private pbc::PopsicleList entities_ = new pbc::PopsicleList();
- public scg::IList EntitiesList
- {
- get { return pbc::Lists.AsReadOnly(entities_); }
- }
- public int EntitiesCount
- {
- get { return entities_.Count; }
- }
- public string GetEntities(int index)
- {
- return entities_[index];
- }
-
- public override bool IsInitialized
- {
- get
- {
- return true;
- }
- }
-
- public override void WriteTo(pb::ICodedOutputStream output)
- {
- int size = SerializedSize;
- string[] field_names = _entityStateFieldNames;
- if (entities_.Count > 0)
- {
- output.WriteStringArray(1, field_names[0], entities_);
- }
- UnknownFields.WriteTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public override int SerializedSize
- {
- get
- {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- {
- int dataSize = 0;
- foreach (string element in EntitiesList)
- {
- dataSize += pb::CodedOutputStream.ComputeStringSizeNoTag(element);
- }
- size += dataSize;
- size += 1 * entities_.Count;
- }
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- }
-
- public static EntityState ParseFrom(pb::ByteString data)
- {
- return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static EntityState ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static EntityState ParseFrom(byte[] data)
- {
- return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static EntityState ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static EntityState ParseFrom(global::System.IO.Stream input)
- {
- return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static EntityState ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static EntityState ParseDelimitedFrom(global::System.IO.Stream input)
- {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static EntityState ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
- {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static EntityState ParseFrom(pb::ICodedInputStream input)
- {
- return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static EntityState ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private EntityState MakeReadOnly()
- {
- entities_.MakeReadOnly();
- return this;
- }
-
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(EntityState prototype)
- {
- return new Builder(prototype);
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder
- {
- protected override Builder ThisBuilder
- {
- get { return this; }
- }
- public Builder()
- {
- result = DefaultInstance;
- resultIsReadOnly = true;
- }
- internal Builder(EntityState cloneFrom)
- {
- result = cloneFrom;
- resultIsReadOnly = true;
- }
-
- private bool resultIsReadOnly;
- private EntityState result;
-
- private EntityState PrepareBuilder()
- {
- if (resultIsReadOnly)
- {
- EntityState original = result;
- result = new EntityState();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
- }
-
- public override bool IsInitialized
- {
- get { return result.IsInitialized; }
- }
-
- protected override EntityState MessageBeingBuilt
- {
- get { return PrepareBuilder(); }
- }
-
- public override Builder Clear()
- {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
- }
-
- public override Builder Clone()
- {
- if (resultIsReadOnly)
- {
- return new Builder(result);
- }
- else
- {
- return new Builder().MergeFrom(result);
- }
- }
-
- public override pbd::MessageDescriptor DescriptorForType
- {
- get { return global::EntityState.Descriptor; }
- }
-
- public override EntityState DefaultInstanceForType
- {
- get { return global::EntityState.DefaultInstance; }
- }
-
- public override EntityState BuildPartial()
- {
- if (resultIsReadOnly)
- {
- return result;
- }
- resultIsReadOnly = true;
- return result.MakeReadOnly();
- }
-
- public override Builder MergeFrom(pb::IMessage other)
- {
- if (other is EntityState)
- {
- return MergeFrom((EntityState)other);
- }
- else
- {
- base.MergeFrom(other);
- return this;
- }
- }
-
- public override Builder MergeFrom(EntityState other)
- {
- if (other == global::EntityState.DefaultInstance) return this;
- PrepareBuilder();
- if (other.entities_.Count != 0)
- {
- result.entities_.Add(other.entities_);
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input)
- {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
- {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name))
- {
- if (tag == 0 && field_name != null)
- {
- int field_ordinal = global::System.Array.BinarySearch(_entityStateFieldNames, field_name, global::System.StringComparer.Ordinal);
- if (field_ordinal >= 0)
- tag = _entityStateFieldTags[field_ordinal];
- else
- {
- if (unknownFields == null)
- {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
- }
- }
- switch (tag)
- {
- case 0:
- {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default:
- {
- if (pb::WireFormat.IsEndGroupTag(tag))
- {
- if (unknownFields != null)
- {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null)
- {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 10:
- {
- input.ReadStringArray(tag, field_name, result.entities_);
- break;
- }
- }
- }
-
- if (unknownFields != null)
- {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public pbc::IPopsicleList EntitiesList
- {
- get { return PrepareBuilder().entities_; }
- }
- public int EntitiesCount
- {
- get { return result.EntitiesCount; }
- }
- public string GetEntities(int index)
- {
- return result.GetEntities(index);
- }
- public Builder SetEntities(int index, string value)
- {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.entities_[index] = value;
- return this;
- }
- public Builder AddEntities(string value)
- {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.entities_.Add(value);
- return this;
- }
- public Builder AddRangeEntities(scg::IEnumerable values)
- {
- PrepareBuilder();
- result.entities_.Add(values);
- return this;
- }
- public Builder ClearEntities()
- {
- PrepareBuilder();
- result.entities_.Clear();
- return this;
- }
- }
- static EntityState()
- {
- object.ReferenceEquals(global::ClusterShardingMessages.Descriptor, null);
- }
-}
-
-[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-public sealed partial class EntityStarted : pb::GeneratedMessage
-{
- private EntityStarted() { }
- private static readonly EntityStarted defaultInstance = new EntityStarted().MakeReadOnly();
- private static readonly string[] _entityStartedFieldNames = new string[] { "entityId" };
- private static readonly uint[] _entityStartedFieldTags = new uint[] { 10 };
- public static EntityStarted DefaultInstance
- {
- get { return defaultInstance; }
- }
-
- public override EntityStarted DefaultInstanceForType
- {
- get { return DefaultInstance; }
- }
-
- protected override EntityStarted ThisMessage
- {
- get { return this; }
- }
-
- public static pbd::MessageDescriptor Descriptor
- {
- get { return global::ClusterShardingMessages.internal__static_EntityStarted__Descriptor; }
- }
-
- protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors
- {
- get { return global::ClusterShardingMessages.internal__static_EntityStarted__FieldAccessorTable; }
- }
-
- public const int EntityIdFieldNumber = 1;
- private bool hasEntityId;
- private string entityId_ = "";
- public bool HasEntityId
- {
- get { return hasEntityId; }
- }
- public string EntityId
- {
- get { return entityId_; }
- }
-
- public override bool IsInitialized
- {
- get
- {
- if (!hasEntityId) return false;
- return true;
- }
- }
-
- public override void WriteTo(pb::ICodedOutputStream output)
- {
- int size = SerializedSize;
- string[] field_names = _entityStartedFieldNames;
- if (hasEntityId)
- {
- output.WriteString(1, field_names[0], EntityId);
- }
- UnknownFields.WriteTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public override int SerializedSize
- {
- get
- {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (hasEntityId)
- {
- size += pb::CodedOutputStream.ComputeStringSize(1, EntityId);
- }
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- }
-
- public static EntityStarted ParseFrom(pb::ByteString data)
- {
- return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static EntityStarted ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static EntityStarted ParseFrom(byte[] data)
- {
- return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static EntityStarted ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static EntityStarted ParseFrom(global::System.IO.Stream input)
- {
- return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static EntityStarted ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static EntityStarted ParseDelimitedFrom(global::System.IO.Stream input)
- {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static EntityStarted ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
- {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static EntityStarted ParseFrom(pb::ICodedInputStream input)
- {
- return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static EntityStarted ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private EntityStarted MakeReadOnly()
- {
- return this;
- }
-
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(EntityStarted prototype)
- {
- return new Builder(prototype);
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder
- {
- protected override Builder ThisBuilder
- {
- get { return this; }
- }
- public Builder()
- {
- result = DefaultInstance;
- resultIsReadOnly = true;
- }
- internal Builder(EntityStarted cloneFrom)
- {
- result = cloneFrom;
- resultIsReadOnly = true;
- }
-
- private bool resultIsReadOnly;
- private EntityStarted result;
-
- private EntityStarted PrepareBuilder()
- {
- if (resultIsReadOnly)
- {
- EntityStarted original = result;
- result = new EntityStarted();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
- }
-
- public override bool IsInitialized
- {
- get { return result.IsInitialized; }
- }
-
- protected override EntityStarted MessageBeingBuilt
- {
- get { return PrepareBuilder(); }
- }
-
- public override Builder Clear()
- {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
- }
-
- public override Builder Clone()
- {
- if (resultIsReadOnly)
- {
- return new Builder(result);
- }
- else
- {
- return new Builder().MergeFrom(result);
- }
- }
-
- public override pbd::MessageDescriptor DescriptorForType
- {
- get { return global::EntityStarted.Descriptor; }
- }
-
- public override EntityStarted DefaultInstanceForType
- {
- get { return global::EntityStarted.DefaultInstance; }
- }
-
- public override EntityStarted BuildPartial()
- {
- if (resultIsReadOnly)
- {
- return result;
- }
- resultIsReadOnly = true;
- return result.MakeReadOnly();
- }
-
- public override Builder MergeFrom(pb::IMessage other)
- {
- if (other is EntityStarted)
- {
- return MergeFrom((EntityStarted)other);
- }
- else
- {
- base.MergeFrom(other);
- return this;
- }
- }
-
- public override Builder MergeFrom(EntityStarted other)
- {
- if (other == global::EntityStarted.DefaultInstance) return this;
- PrepareBuilder();
- if (other.HasEntityId)
- {
- EntityId = other.EntityId;
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input)
- {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
- {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name))
- {
- if (tag == 0 && field_name != null)
- {
- int field_ordinal = global::System.Array.BinarySearch(_entityStartedFieldNames, field_name, global::System.StringComparer.Ordinal);
- if (field_ordinal >= 0)
- tag = _entityStartedFieldTags[field_ordinal];
- else
- {
- if (unknownFields == null)
- {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
- }
- }
- switch (tag)
- {
- case 0:
- {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default:
- {
- if (pb::WireFormat.IsEndGroupTag(tag))
- {
- if (unknownFields != null)
- {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null)
- {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 10:
- {
- result.hasEntityId = input.ReadString(ref result.entityId_);
- break;
- }
- }
- }
-
- if (unknownFields != null)
- {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public bool HasEntityId
- {
- get { return result.hasEntityId; }
- }
- public string EntityId
- {
- get { return result.EntityId; }
- set { SetEntityId(value); }
- }
- public Builder SetEntityId(string value)
- {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasEntityId = true;
- result.entityId_ = value;
- return this;
- }
- public Builder ClearEntityId()
- {
- PrepareBuilder();
- result.hasEntityId = false;
- result.entityId_ = "";
- return this;
- }
- }
- static EntityStarted()
- {
- object.ReferenceEquals(global::ClusterShardingMessages.Descriptor, null);
- }
-}
-
-[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
-public sealed partial class EntityStopped : pb::GeneratedMessage
-{
- private EntityStopped() { }
- private static readonly EntityStopped defaultInstance = new EntityStopped().MakeReadOnly();
- private static readonly string[] _entityStoppedFieldNames = new string[] { "entityId" };
- private static readonly uint[] _entityStoppedFieldTags = new uint[] { 10 };
- public static EntityStopped DefaultInstance
- {
- get { return defaultInstance; }
- }
-
- public override EntityStopped DefaultInstanceForType
- {
- get { return DefaultInstance; }
- }
-
- protected override EntityStopped ThisMessage
- {
- get { return this; }
- }
-
- public static pbd::MessageDescriptor Descriptor
- {
- get { return global::ClusterShardingMessages.internal__static_EntityStopped__Descriptor; }
- }
-
- protected override pb::FieldAccess.FieldAccessorTable InternalFieldAccessors
- {
- get { return global::ClusterShardingMessages.internal__static_EntityStopped__FieldAccessorTable; }
- }
-
- public const int EntityIdFieldNumber = 1;
- private bool hasEntityId;
- private string entityId_ = "";
- public bool HasEntityId
- {
- get { return hasEntityId; }
- }
- public string EntityId
- {
- get { return entityId_; }
- }
-
- public override bool IsInitialized
- {
- get
- {
- if (!hasEntityId) return false;
- return true;
- }
- }
-
- public override void WriteTo(pb::ICodedOutputStream output)
- {
- int size = SerializedSize;
- string[] field_names = _entityStoppedFieldNames;
- if (hasEntityId)
- {
- output.WriteString(1, field_names[0], EntityId);
- }
- UnknownFields.WriteTo(output);
- }
-
- private int memoizedSerializedSize = -1;
- public override int SerializedSize
- {
- get
- {
- int size = memoizedSerializedSize;
- if (size != -1) return size;
-
- size = 0;
- if (hasEntityId)
- {
- size += pb::CodedOutputStream.ComputeStringSize(1, EntityId);
- }
- size += UnknownFields.SerializedSize;
- memoizedSerializedSize = size;
- return size;
- }
- }
-
- public static EntityStopped ParseFrom(pb::ByteString data)
- {
- return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static EntityStopped ParseFrom(pb::ByteString data, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static EntityStopped ParseFrom(byte[] data)
- {
- return ((Builder)CreateBuilder().MergeFrom(data)).BuildParsed();
- }
- public static EntityStopped ParseFrom(byte[] data, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(data, extensionRegistry)).BuildParsed();
- }
- public static EntityStopped ParseFrom(global::System.IO.Stream input)
- {
- return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static EntityStopped ParseFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- public static EntityStopped ParseDelimitedFrom(global::System.IO.Stream input)
- {
- return CreateBuilder().MergeDelimitedFrom(input).BuildParsed();
- }
- public static EntityStopped ParseDelimitedFrom(global::System.IO.Stream input, pb::ExtensionRegistry extensionRegistry)
- {
- return CreateBuilder().MergeDelimitedFrom(input, extensionRegistry).BuildParsed();
- }
- public static EntityStopped ParseFrom(pb::ICodedInputStream input)
- {
- return ((Builder)CreateBuilder().MergeFrom(input)).BuildParsed();
- }
- public static EntityStopped ParseFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
- {
- return ((Builder)CreateBuilder().MergeFrom(input, extensionRegistry)).BuildParsed();
- }
- private EntityStopped MakeReadOnly()
- {
- return this;
- }
-
- public static Builder CreateBuilder() { return new Builder(); }
- public override Builder ToBuilder() { return CreateBuilder(this); }
- public override Builder CreateBuilderForType() { return new Builder(); }
- public static Builder CreateBuilder(EntityStopped prototype)
- {
- return new Builder(prototype);
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class Builder : pb::GeneratedBuilder
- {
- protected override Builder ThisBuilder
- {
- get { return this; }
- }
- public Builder()
- {
- result = DefaultInstance;
- resultIsReadOnly = true;
- }
- internal Builder(EntityStopped cloneFrom)
- {
- result = cloneFrom;
- resultIsReadOnly = true;
- }
-
- private bool resultIsReadOnly;
- private EntityStopped result;
-
- private EntityStopped PrepareBuilder()
- {
- if (resultIsReadOnly)
- {
- EntityStopped original = result;
- result = new EntityStopped();
- resultIsReadOnly = false;
- MergeFrom(original);
- }
- return result;
- }
-
- public override bool IsInitialized
- {
- get { return result.IsInitialized; }
- }
-
- protected override EntityStopped MessageBeingBuilt
- {
- get { return PrepareBuilder(); }
- }
-
- public override Builder Clear()
- {
- result = DefaultInstance;
- resultIsReadOnly = true;
- return this;
- }
-
- public override Builder Clone()
- {
- if (resultIsReadOnly)
- {
- return new Builder(result);
- }
- else
- {
- return new Builder().MergeFrom(result);
- }
- }
-
- public override pbd::MessageDescriptor DescriptorForType
- {
- get { return global::EntityStopped.Descriptor; }
- }
-
- public override EntityStopped DefaultInstanceForType
- {
- get { return global::EntityStopped.DefaultInstance; }
- }
-
- public override EntityStopped BuildPartial()
- {
- if (resultIsReadOnly)
- {
- return result;
- }
- resultIsReadOnly = true;
- return result.MakeReadOnly();
- }
-
- public override Builder MergeFrom(pb::IMessage other)
- {
- if (other is EntityStopped)
- {
- return MergeFrom((EntityStopped)other);
- }
- else
- {
- base.MergeFrom(other);
- return this;
- }
- }
-
- public override Builder MergeFrom(EntityStopped other)
- {
- if (other == global::EntityStopped.DefaultInstance) return this;
- PrepareBuilder();
- if (other.HasEntityId)
- {
- EntityId = other.EntityId;
- }
- this.MergeUnknownFields(other.UnknownFields);
- return this;
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input)
- {
- return MergeFrom(input, pb::ExtensionRegistry.Empty);
- }
-
- public override Builder MergeFrom(pb::ICodedInputStream input, pb::ExtensionRegistry extensionRegistry)
- {
- PrepareBuilder();
- pb::UnknownFieldSet.Builder unknownFields = null;
- uint tag;
- string field_name;
- while (input.ReadTag(out tag, out field_name))
- {
- if (tag == 0 && field_name != null)
- {
- int field_ordinal = global::System.Array.BinarySearch(_entityStoppedFieldNames, field_name, global::System.StringComparer.Ordinal);
- if (field_ordinal >= 0)
- tag = _entityStoppedFieldTags[field_ordinal];
- else
- {
- if (unknownFields == null)
- {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- continue;
- }
- }
- switch (tag)
- {
- case 0:
- {
- throw pb::InvalidProtocolBufferException.InvalidTag();
- }
- default:
- {
- if (pb::WireFormat.IsEndGroupTag(tag))
- {
- if (unknownFields != null)
- {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
- if (unknownFields == null)
- {
- unknownFields = pb::UnknownFieldSet.CreateBuilder(this.UnknownFields);
- }
- ParseUnknownField(input, unknownFields, extensionRegistry, tag, field_name);
- break;
- }
- case 10:
- {
- result.hasEntityId = input.ReadString(ref result.entityId_);
- break;
- }
- }
- }
-
- if (unknownFields != null)
- {
- this.UnknownFields = unknownFields.Build();
- }
- return this;
- }
-
-
- public bool HasEntityId
- {
- get { return result.hasEntityId; }
- }
- public string EntityId
- {
- get { return result.EntityId; }
- set { SetEntityId(value); }
- }
- public Builder SetEntityId(string value)
- {
- pb::ThrowHelper.ThrowIfNull(value, "value");
- PrepareBuilder();
- result.hasEntityId = true;
- result.entityId_ = value;
- return this;
- }
- public Builder ClearEntityId()
- {
- PrepareBuilder();
- result.hasEntityId = false;
- result.entityId_ = "";
- return this;
- }
- }
- static EntityStopped()
- {
- object.ReferenceEquals(global::ClusterShardingMessages.Descriptor, null);
- }
-}
-
-#endregion
-
-
-#endregion Designer generated code
diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/Shard.cs b/src/contrib/cluster/Akka.Cluster.Sharding/Shard.cs
deleted file mode 100644
index de9bd4746d8..00000000000
--- a/src/contrib/cluster/Akka.Cluster.Sharding/Shard.cs
+++ /dev/null
@@ -1,441 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright (C) 2009-2015 Typesafe Inc.
-// Copyright (C) 2013-2015 Akka.NET project
-//
-//-----------------------------------------------------------------------
-
-using System;
-using System.Collections.Immutable;
-using System.Linq;
-using Akka.Actor;
-using Akka.Event;
-using Akka.Persistence;
-
-namespace Akka.Cluster.Sharding
-{
- using ShardId = String;
- using EntityId = String;
- using Msg = Object;
-
- //TODO: figure out how not to derive from persistent actor for the sake of alternative ddata based impl
- public abstract class Shard : PersistentActor
- {
- #region messages
-
- public interface IShardCommand { }
- public interface IShardQuery { }
-
- ///
- /// When a fails to write to the journal, we will retry it after a back off.
- ///
- [Serializable]
- public class RetryPersistence : IShardCommand
- {
- public readonly StateChange Payload;
-
- public RetryPersistence(StateChange payload)
- {
- Payload = payload;
- }
- }
-
- ///
- /// The Snapshot tick for the shards.
- ///
- [Serializable]
- public sealed class SnapshotTick : IShardCommand
- {
- public static readonly SnapshotTick Instance = new SnapshotTick();
-
- private SnapshotTick()
- {
- }
- }
-
- ///
- /// When an remembering entries and the entity stops without issuing a ,
- /// we restart it after a back off using this message.
- ///
- [Serializable]
- public sealed class RestartEntity : IShardCommand
- {
- public readonly EntityId EntityId;
-
- public RestartEntity(string entityId)
- {
- EntityId = entityId;
- }
- }
-
- public abstract class StateChange
- {
- public readonly EntityId EntityId;
-
- protected StateChange(EntityId entityId)
- {
- EntityId = entityId;
- }
- }
-
- ///
- /// change for starting an entity in this `Shard`
- ///
- [Serializable]
- public sealed class EntityStarted : StateChange
- {
- public EntityStarted(string entityId) : base(entityId)
- {
- }
- }
-
- ///
- /// change for an entity which has terminated.
- ///
- [Serializable]
- public sealed class EntityStopped : StateChange
- {
- public EntityStopped(string entityId) : base(entityId)
- {
- }
- }
-
- [Serializable]
- public sealed class GetCurrentShardState : IShardQuery
- {
- public static readonly GetCurrentShardState Instance = new GetCurrentShardState();
-
- private GetCurrentShardState()
- {
- }
- }
-
- [Serializable]
- public sealed class CurrentShardState
- {
- public readonly string ShardId;
- public readonly string[] EntityIds;
-
- public CurrentShardState(string shardId, string[] entityIds)
- {
- ShardId = shardId;
- EntityIds = entityIds;
- }
- }
-
- [Serializable]
- public sealed class GetShardStats : IShardQuery
- {
- public static readonly GetShardStats Instance = new GetShardStats();
-
- private GetShardStats()
- {
- }
- }
-
- [Serializable]
- public sealed class ShardStats
- {
- public readonly string ShardId;
- public readonly int EntityCount;
-
- public ShardStats(string shardId, int entityCount)
- {
- ShardId = shardId;
- EntityCount = entityCount;
- }
- }
-
- #endregion
-
- ///
- /// Persistent state of the Shard.
- ///
- [Serializable]
- public struct ShardState : IClusterShardingSerializable
- {
- public static readonly ShardState Empty = new ShardState(ImmutableHashSet.Empty);
- public readonly IImmutableSet Entries;
-
- public ShardState(IImmutableSet entries) : this()
- {
- Entries = entries;
- }
- }
-
- public readonly string TypeName;
- public readonly ShardId ShardId;
- public readonly Actor.Props EntityProps;
- public readonly ClusterShardingSettings Settings;
- public readonly IdExtractor ExtractEntityId;
- public readonly ShardResolver ExtractShardId;
- public readonly object HandOffStopMessage;
-
- protected IImmutableDictionary IdByRef = ImmutableDictionary.Empty;
- protected IImmutableDictionary RefById = ImmutableDictionary.Empty;
- protected IImmutableSet Passivating = ImmutableHashSet.Empty;
-
- protected IImmutableDictionary>> MessageBuffers =
- ImmutableDictionary>>.Empty;
-
- protected IActorRef HandOffStopper = null;
-
- protected ShardState State = ShardState.Empty;
-
- private ILoggingAdapter _log;
-
- protected Shard(
- string typeName,
- string shardId,
- Props entityProps,
- ClusterShardingSettings settings,
- IdExtractor extractEntityId,
- ShardResolver extractShardId,
- object handOffStopMessage)
- {
- TypeName = typeName;
- ShardId = shardId;
- EntityProps = entityProps;
- Settings = settings;
- ExtractEntityId = extractEntityId;
- ExtractShardId = extractShardId;
- HandOffStopMessage = handOffStopMessage;
- }
-
- protected ILoggingAdapter Log
- {
- get { return _log ?? (_log = Context.GetLogger()); }
- }
-
- protected int TotalBufferSize
- {
- get { return MessageBuffers.Aggregate(0, (sum, entity) => sum + entity.Value.Count); }
- }
-
- #region common shard methods
-
- protected virtual void Initialized()
- {
- Context.Parent.Tell(new ShardRegion.ShardInitialized(ShardId));
- }
-
- protected virtual void ProcessChange(T evt, Action handler)
- {
- handler(evt);
- }
-
- protected bool HandleCommand(object message)
- {
- if (message is Terminated) HandleTerminated(((Terminated) message).ActorRef);
- else if (message is PersistentShardCoordinator.ICoordinatorMessage) HandleCoordinatorMessage(message as PersistentShardCoordinator.ICoordinatorMessage);
- else if (message is IShardCommand) HandleShardCommand(message as IShardCommand);
- else if (message is ShardRegion.IShardRegionCommand) HandleShardRegionCommand(message as ShardRegion.IShardRegionCommand);
- else if (message is IShardQuery) HandleShardRegionQuery(message as IShardQuery);
- else if (ExtractEntityId(message) != null) DeliverMessage(message, Sender);
- else return false;
- return true;
- }
-
- private void HandleShardRegionQuery(IShardQuery query)
- {
- if(query is GetCurrentShardState) Sender.Tell(new CurrentShardState(ShardId, RefById.Keys.ToArray()));
- else if (query is GetShardStats) Sender.Tell(new ShardStats(ShardId, State.Entries.Count));
- }
-
- protected virtual void EntityTerminated(IActorRef tref)
- {
- ShardId id;
- IImmutableList> buffer;
- if (IdByRef.TryGetValue(tref, out id) && MessageBuffers.TryGetValue(id, out buffer) && buffer.Count != 0)
- {
- Log.Debug("Starting entity [{0}] again, there are buffered messages for it", id);
- SendMessageBuffer(new EntityStarted(id));
- }
- else
- {
- ProcessChange(new EntityStopped(id), PassivateCompleted);
- }
-
- Passivating = Passivating.Remove(tref);
- }
-
- protected void HandleShardCommand(IShardCommand message)
- {
- var restart = message as RestartEntity;
- if (restart != null)
- GetEntity(restart.EntityId);
- }
-
- protected void HandleShardRegionCommand(ShardRegion.IShardRegionCommand message)
- {
- var passivate = message as ShardRegion.Passivate;
- if (passivate != null)
- Passivate(Sender, passivate.StopMessage);
- else
- Unhandled(message);
- }
-
- protected void HandleCoordinatorMessage(PersistentShardCoordinator.ICoordinatorMessage message)
- {
- var handOff = message as PersistentShardCoordinator.HandOff;
- if (handOff != null)
- {
- if (handOff.Shard == ShardId) HandOff(Sender);
- else Log.Warning("Shard [{0}] can not hand off for another Shard [{1}]", ShardId, handOff.Shard);
- }
- else Unhandled(message);
- }
-
- protected void HandOff(IActorRef replyTo)
- {
- if (HandOffStopper != null) Log.Warning("HandOff shard [{0}] received during existing handOff", ShardId);
- else
- {
- Log.Debug("HandOff shard [{0}]", ShardId);
-
- if (State.Entries.Count != 0)
- {
- // handOffStopper = Some(context.watch(context.actorOf(
- // handOffStopperProps(shardId, replyTo, idByRef.keySet, handOffStopMessage))))
- HandOffStopper = Context.Watch(Context.ActorOf(
- ShardRegion.HandOffStopper.Props(ShardId, replyTo, IdByRef.Keys, HandOffStopMessage)));
-
- //During hand off we only care about watching for termination of the hand off stopper
- Context.Become(message =>
- {
- var terminated = message as Terminated;
- if (terminated != null)
- {
- HandleTerminated(terminated.ActorRef);
- return true;
- }
- return false;
- });
- }
- else
- {
- replyTo.Tell(new PersistentShardCoordinator.ShardStopped(ShardId));
- Context.Stop(Self);
- }
- }
- }
-
- protected void HandleTerminated(IActorRef terminatedRef)
- {
- if (Equals(HandOffStopper, terminatedRef))
- Context.Stop(Self);
- else if (IdByRef.ContainsKey(terminatedRef) && HandOffStopper == null)
- EntityTerminated(terminatedRef);
- }
-
- protected void Passivate(IActorRef entity, object stopMessage)
- {
- ShardId id;
- if (IdByRef.TryGetValue(entity, out id) && !MessageBuffers.ContainsKey(id))
- {
- Log.Debug("Passivating started on entity {0}", id);
-
- Passivating = Passivating.Add(entity);
- MessageBuffers = MessageBuffers.Add(id, ImmutableList>.Empty);
-
- entity.Tell(stopMessage);
- }
- }
-
- protected void PassivateCompleted(EntityStopped evt)
- {
- var id = evt.EntityId;
- Log.Debug("Entity stopped [{0}]", id);
-
- var entity = RefById[id];
- IdByRef = IdByRef.Remove(entity);
- RefById = RefById.Remove(id);
-
- State = new ShardState(State.Entries.Remove(id));
- MessageBuffers = MessageBuffers.Remove(id);
- }
-
- protected void SendMessageBuffer(EntityStarted message)
- {
- var id = message.EntityId;
-
- // Get the buffered messages and remove the buffer
- IImmutableList> buffer;
- if (MessageBuffers.TryGetValue(id, out buffer)) MessageBuffers = MessageBuffers.Remove(id);
-
- if (buffer.Count != 0)
- {
- Log.Debug("Sending message buffer for entity [{0}] ([{1}] messages)", id, buffer.Count);
-
- GetEntity(id);
-
- // Now there is no deliveryBuffer we can try to redeliver
- // and as the child exists, the message will be directly forwarded
- foreach (var pair in buffer)
- DeliverMessage(pair.Item1, pair.Item2);
- }
- }
-
- protected void DeliverMessage(object message, IActorRef sender)
- {
- var t = ExtractEntityId(message);
- var id = t.Item1;
- var payload = t.Item2;
-
- if (string.IsNullOrEmpty(id))
- {
- Log.Warning("Id must not be empty, dropping message [{0}]", message.GetType());
- Context.System.DeadLetters.Tell(message);
- }
- else
- {
- IImmutableList> buffer;
- if (MessageBuffers.TryGetValue(id, out buffer))
- {
- if (TotalBufferSize >= Settings.TunningParameters.BufferSize)
- {
- Log.Warning("Buffer is full, dropping message for entity [{0}]", message.GetType());
- Context.System.DeadLetters.Tell(message);
- }
- else
- {
- Log.Debug("Message for entity [{0}] buffered", id);
- MessageBuffers.SetItem(id, buffer.Add(Tuple.Create(message, sender)));
- }
- }
- else
- DeliverTo(id, message, payload, sender);
- }
- }
-
- protected virtual void DeliverTo(string id, object message, object payload, IActorRef sender)
- {
- var name = Uri.EscapeDataString(id);
- var child = Context.Child(name);
-
- if (Equals(child, ActorRefs.Nobody))
- GetEntity(id).Tell(payload, sender);
- else
- child.Tell(payload, sender);
- }
-
- protected IActorRef GetEntity(string id)
- {
- var name = Uri.EscapeDataString(id);
- var child = Context.Child(name);
- if (Equals(child, ActorRefs.Nobody))
- {
- Log.Debug("Starting entity [{0}] in shard [{1}]", id, ShardId);
-
- child = Context.Watch(Context.ActorOf(EntityProps, name));
- IdByRef = IdByRef.SetItem(child, id);
- RefById = RefById.SetItem(id, child);
- State = new ShardState(State.Entries.Add(id));
- }
-
- return child;
- }
-
- #endregion
- }
-}
\ No newline at end of file
diff --git a/src/contrib/cluster/Akka.Cluster.Sharding/ShardAllocationStrategy.cs b/src/contrib/cluster/Akka.Cluster.Sharding/ShardAllocationStrategy.cs
deleted file mode 100644
index e213f59aea9..00000000000
--- a/src/contrib/cluster/Akka.Cluster.Sharding/ShardAllocationStrategy.cs
+++ /dev/null
@@ -1,130 +0,0 @@
-//-----------------------------------------------------------------------
-//
-// Copyright (C) 2009-2015 Typesafe Inc.
-// Copyright (C) 2013-2015 Akka.NET project
-//
-//-----------------------------------------------------------------------
-
-using System;
-using System.Collections.Generic;
-using System.Collections.Immutable;
-using System.Linq;
-using System.Threading.Tasks;
-using Akka.Actor;
-
-namespace Akka.Cluster.Sharding
-{
- using ShardId = String;
-
- ///
- /// Interface of the pluggable shard allocation and rebalancing logic used by the .
- ///
- public interface IShardAllocationStrategy : INoSerializationVerificationNeeded
- {
- ///
- /// Invoked when the location of a new shard is to be decided.
- ///
- ///
- /// Actor reference to the that requested the location of the shard, can be returned
- /// if preference should be given to the node where the shard was first accessed.
- ///
- /// The id of the shard to allocate.
- ///
- /// All actor refs to and their current allocated shards, in the order they were allocated
- ///
- ///
- /// of the actor ref of the that is to be responsible for the shard,
- /// must be one of the references included in the parameter.
- ///
- Task AllocateShard(IActorRef requester, ShardId shardId, IImmutableDictionary> currentShardAllocations);
-
- ///
- /// Invoked periodically to decide which shards to rebalance to another location.
- ///
- ///
- /// All actor refs to and their current allocated shards, in the order they were allocated.
- ///
- ///
- /// Set of shards that are currently being rebalanced, i.e. you should not include these in the returned set.
- ///
- /// of the shards to be migrated, may be empty to skip rebalance in this round.
- Task> Rebalance(IImmutableDictionary> currentShardAllocations, IImmutableSet rebalanceInProgress);
- }
-
- ///
- /// The default implementation of allocates new shards
- /// to the with least number of previously allocated shards. It picks shards
- /// for rebalancing handoff from the with most number of previously allocated shards.
- /// They will then be allocated to the with least number of previously allocated shards,
- /// i.e. new members in the cluster. There is a configurable threshold of how large the difference
- /// must be to begin the rebalancing. The number of ongoing rebalancing processes can be limited.
- ///
- [Serializable]
- public class LeastShardAllocationStrategy : IShardAllocationStrategy
- {
- private readonly int _rebalanceThreshold;
- private readonly int _maxSimultaneousRebalance;
-
- public LeastShardAllocationStrategy(int rebalanceThreshold, int maxSimultaneousRebalance)
- {
- _rebalanceThreshold = rebalanceThreshold;
- _maxSimultaneousRebalance = maxSimultaneousRebalance;
- }
-
- public Task AllocateShard(IActorRef requester, string shardId, IImmutableDictionary> currentShardAllocations)
- {
- var min = GetMinBy(currentShardAllocations, kv => kv.Value.Count);
- return Task.FromResult(min.Key);
- }
-
- public Task> Rebalance(IImmutableDictionary> currentShardAllocations, IImmutableSet rebalanceInProgress)
- {
- if (rebalanceInProgress.Count < _maxSimultaneousRebalance)
- {
- var leastShardsRegion = GetMinBy(currentShardAllocations, kv => kv.Value.Count);
- var shards =
- currentShardAllocations.Select(kv => kv.Value.Where(s => !rebalanceInProgress.Contains(s)).ToArray());
- var mostShards = GetMaxBy(shards, x => x.Length);
-
- if (mostShards.Length - leastShardsRegion.Value.Count >= _rebalanceThreshold)
- {
- return Task.FromResult>(ImmutableHashSet.Create(mostShards.First()));
- }
- }
-
- return Task.FromResult>(ImmutableHashSet.Empty);
- }
-
- private static T GetMinBy(IEnumerable collection, Func