Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cluster - Add app-version to the Member information #4577

Merged
merged 2 commits into from Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions build.fsx
Expand Up @@ -545,6 +545,7 @@ Target "Protobuf" <| fun _ ->
|> append (sprintf "-I=%s" (__SOURCE_DIRECTORY__ @@ "/src/protobuf/common") )
|> append (sprintf "--csharp_out=internal_access:%s" (__SOURCE_DIRECTORY__ @@ destinationPath))
|> append "--csharp_opt=file_extension=.g.cs"
|> append "--experimental_allow_proto3_optional"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed for optional proto members

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

|> append (__SOURCE_DIRECTORY__ @@ "/src/protobuf" @@ protoName)
|> toText

Expand Down
2 changes: 1 addition & 1 deletion build.ps1
Expand Up @@ -35,7 +35,7 @@ $DotNetVersion = "3.1.105";
$DotNetInstallerUri = "https://dot.net/v1/dotnet-install.ps1";
$NugetVersion = "4.3.0";
$NugetUrl = "https://dist.nuget.org/win-x86-commandline/v$NugetVersion/nuget.exe"
$ProtobufVersion = "3.4.0"
$ProtobufVersion = "3.13.0"
Aaronontheweb marked this conversation as resolved.
Show resolved Hide resolved
$DocfxVersion = "2.48.1"

$IncrementalistVersion = "0.2.2";
Expand Down
Expand Up @@ -73,6 +73,7 @@ namespace Akka.Cluster
public CurrentClusterState() { }
public CurrentClusterState(System.Collections.Immutable.ImmutableSortedSet<Akka.Cluster.Member> members, System.Collections.Immutable.ImmutableHashSet<Akka.Cluster.Member> unreachable, System.Collections.Immutable.ImmutableHashSet<Akka.Actor.Address> seenBy, Akka.Actor.Address leader, System.Collections.Immutable.ImmutableDictionary<string, Akka.Actor.Address> roleLeaderMap) { }
public System.Collections.Immutable.ImmutableHashSet<string> AllRoles { get; }
public bool HasMoreThanOneAppVersion { get; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran into this issue the other day with a large user cluster - looks like a good addition

public Akka.Actor.Address Leader { get; }
public System.Collections.Immutable.ImmutableSortedSet<Akka.Cluster.Member> Members { get; }
public System.Collections.Immutable.ImmutableHashSet<Akka.Actor.Address> SeenBy { get; }
Expand Down Expand Up @@ -184,6 +185,7 @@ namespace Akka.Cluster
{
public ClusterSettings(Akka.Configuration.Config config, string systemName) { }
public bool AllowWeaklyUpMembers { get; }
public Akka.Util.AkkaVersion AppVersion { get; }
public System.Nullable<System.TimeSpan> AutoDownUnreachableAfter { get; }
[System.ObsoleteAttribute("Use Cluster.DowningProvider.DownRemovalMargin [1.1.2]")]
public System.TimeSpan DownRemovalMargin { get; }
Expand Down Expand Up @@ -230,6 +232,7 @@ namespace Akka.Cluster
public static readonly System.Collections.Generic.IComparer<Akka.Actor.Address> AddressOrdering;
public static readonly System.Collections.Generic.IComparer<Akka.Cluster.Member> AgeOrdering;
public Akka.Actor.Address Address { get; }
public Akka.Util.AkkaVersion AppVersion { get; }
public System.Collections.Immutable.ImmutableHashSet<string> Roles { get; }
public Akka.Cluster.MemberStatus Status { get; }
public Akka.Cluster.UniqueAddress UniqueAddress { get; }
Expand Down
13 changes: 13 additions & 0 deletions src/core/Akka.API.Tests/CoreAPISpec.ApproveCore.approved.txt
Expand Up @@ -4677,6 +4677,19 @@ namespace Akka.Serialization
}
namespace Akka.Util
{
public class AkkaVersion : System.IComparable<Akka.Util.AkkaVersion>, System.IEquatable<Akka.Util.AkkaVersion>
{
public static readonly Akka.Util.AkkaVersion Zero;
public string Version { get; }
public int CompareTo(Akka.Util.AkkaVersion other) { }
public static Akka.Util.AkkaVersion Create(string version) { }
public bool Equals(Akka.Util.AkkaVersion other) { }
public override bool Equals(object obj) { }
public override int GetHashCode() { }
public override string ToString() { }
public static bool ==(Akka.Util.AkkaVersion first, Akka.Util.AkkaVersion second) { }
public static bool !=(Akka.Util.AkkaVersion first, Akka.Util.AkkaVersion second) { }
}
public class AtomicBoolean
{
public AtomicBoolean(bool initialValue = False) { }
Expand Down
Expand Up @@ -11,6 +11,7 @@
using Akka.Cluster.Routing;
using Akka.Cluster.Serialization;
using Akka.Routing;
using Akka.Util;
using Akka.Util.Internal;
using NBench;

Expand All @@ -36,8 +37,8 @@ public class ClusterMessageSerializerSpec

internal Lazy<InternalClusterAction.Welcome> WelcomeMessage { get; } = new Lazy<InternalClusterAction.Welcome>(() =>
{
var member1 = new Member(new UniqueAddress(new Address("akka.tcp", "system", "some.host.org", 4718), 34), 1, MemberStatus.Joining, ImmutableHashSet<string>.Empty);
var member2 = new Member(new UniqueAddress(new Address("akka.tcp", "system", "some.host.org", 4710), 35), 1, MemberStatus.Joining, ImmutableHashSet<string>.Empty);
var member1 = new Member(new UniqueAddress(new Address("akka.tcp", "system", "some.host.org", 4718), 34), 1, MemberStatus.Joining, ImmutableHashSet<string>.Empty, AkkaVersion.Zero);
var member2 = new Member(new UniqueAddress(new Address("akka.tcp", "system", "some.host.org", 4710), 35), 1, MemberStatus.Joining, ImmutableHashSet<string>.Empty, AkkaVersion.Zero);

var node1 = new VectorClock.Node("node1");
var node2 = new VectorClock.Node("node2");
Expand Down
2 changes: 2 additions & 0 deletions src/core/Akka.Cluster.Tests/ClusterConfigSpec.cs
Expand Up @@ -11,6 +11,7 @@
using Akka.Dispatch;
using Akka.Remote;
using Akka.TestKit;
using Akka.Util;
using FluentAssertions;
using Xunit;

Expand Down Expand Up @@ -45,6 +46,7 @@ public void Clustering_must_be_able_to_parse_generic_cluster_config_elements()
settings.MinNrOfMembers.Should().Be(1);
settings.MinNrOfMembersOfRole.Should().Equal(ImmutableDictionary<string, int>.Empty);
settings.Roles.Should().BeEquivalentTo(ImmutableHashSet<string>.Empty);
settings.AppVersion.Should().Be(AkkaVersion.Zero);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

settings.UseDispatcher.Should().Be(Dispatchers.InternalDispatcherId);
settings.GossipDifferentViewProbability.Should().Be(0.8);
settings.ReduceGossipDifferentViewProbability.Should().Be(400);
Expand Down
5 changes: 5 additions & 0 deletions src/core/Akka.Cluster.Tests/ClusterSpec.cs
Expand Up @@ -17,6 +17,7 @@
using Xunit;
using FluentAssertions;
using Xunit.Abstractions;
using Akka.Util;

namespace Akka.Cluster.Tests
{
Expand All @@ -34,6 +35,7 @@ public class ClusterSpec : AkkaSpec
periodic-tasks-initial-delay = 120 s
publish-stats-interval = 0 s # always, when it happens
run-coordinated-shutdown-when-down = off
app-version = ""1.2.3""
}
akka.actor.serialize-messages = on
akka.actor.provider = ""Akka.Cluster.ClusterActorRefProvider, Akka.Cluster""
Expand Down Expand Up @@ -78,6 +80,9 @@ public void A_cluster_must_initially_become_singleton_cluster_when_joining_itsel
ClusterView.Members.Select(m => m.Address).ToImmutableHashSet()
.Should().BeEquivalentTo(ImmutableHashSet.Create(_selfAddress));
AwaitAssert(() => ClusterView.Status.Should().Be(MemberStatus.Up));
ClusterView.Self.AppVersion.Should().Be(AkkaVersion.Create("1.2.3"));
ClusterView.Members.FirstOrDefault(i => i.Address == _selfAddress).AppVersion.Should().Be(AkkaVersion.Create("1.2.3"));
ClusterView.State.HasMoreThanOneAppVersion.Should().BeFalse();
}

[Fact]
Expand Down
7 changes: 4 additions & 3 deletions src/core/Akka.Cluster.Tests/MemberOrderingSpec.cs
Expand Up @@ -9,6 +9,7 @@
using System.Collections.Immutable;
using System.Linq;
using Akka.Actor;
using Akka.Util;
using Akka.Util.Internal.Collections;
using FluentAssertions;
using Xunit;
Expand All @@ -20,7 +21,7 @@ public class MemberOrderingSpec
[Fact]
public void MemberOrdering_must_order_members_by_host_and_port()
{
var members = new SortedSet<Member>
var members = new SortedSet<Member>
{
TestMember.Create(Address.Parse("akka://sys@darkstar:1112"), MemberStatus.Up),
TestMember.Create(Address.Parse("akka://sys@darkstar:1113"), MemberStatus.Joining),
Expand Down Expand Up @@ -55,7 +56,7 @@ public void MemberOrdering_must_have_stable_equals_and_hash_code()
{
var address = new Address("akka.tcp", "sys1", "host1", 9000);
var m1 = TestMember.Create(address, MemberStatus.Joining);
var m11 = Member.Create(new UniqueAddress(address, -3), ImmutableHashSet<string>.Empty);
var m11 = Member.Create(new UniqueAddress(address, -3), ImmutableHashSet<string>.Empty, AkkaVersion.Zero);
var m2 = m1.Copy(status: MemberStatus.Up);
var m22 = m11.Copy(status: MemberStatus.Up);
var m3 = TestMember.Create(address.WithPort(10000), MemberStatus.Up);
Expand Down Expand Up @@ -88,7 +89,7 @@ public void MemberOrdering_must_consistent_ordering_and_equals()

//different uid
var a = TestMember.Create(address1, MemberStatus.Joining);
var b = Member.Create(new UniqueAddress(address1, -3), ImmutableHashSet<string>.Empty);
var b = Member.Create(new UniqueAddress(address1, -3), ImmutableHashSet<string>.Empty, AkkaVersion.Zero);
Member.Ordering.Compare(a, b).Should().Be(1);
Member.Ordering.Compare(b, a).Should().Be(-1);
}
Expand Down
Expand Up @@ -12,6 +12,7 @@
using Akka.TestKit;
using Xunit;
using FluentAssertions;
using Akka.Util;

namespace Akka.Cluster.Tests.Serialization
{
Expand All @@ -22,9 +23,9 @@ public ClusterMessageSerializerSpec()
{
}

private static readonly Member a1 = TestMember.Create(new Address("akka.tcp", "sys", "a", 2552), MemberStatus.Joining);
private static readonly Member b1 = TestMember.Create(new Address("akka.tcp", "sys", "b", 2552), MemberStatus.Up, ImmutableHashSet.Create("r1"));
private static readonly Member c1 = TestMember.Create(new Address("akka.tcp", "sys", "c", 2552), MemberStatus.Leaving, ImmutableHashSet.Create("r2"));
private static readonly Member a1 = TestMember.Create(new Address("akka.tcp", "sys", "a", 2552), MemberStatus.Joining, appVersion: AkkaVersion.Create("1.0.0"));
private static readonly Member b1 = TestMember.Create(new Address("akka.tcp", "sys", "b", 2552), MemberStatus.Up, ImmutableHashSet.Create("r1"), appVersion: AkkaVersion.Create("1.1.0"));
private static readonly Member c1 = TestMember.Create(new Address("akka.tcp", "sys", "c", 2552), MemberStatus.Leaving, ImmutableHashSet.Create("r2"), appVersion: AkkaVersion.Create("1.1.0"));
private static readonly Member d1 = TestMember.Create(new Address("akka.tcp", "sys", "d", 2552), MemberStatus.Exiting, ImmutableHashSet.Create("r1", "r2"));
private static readonly Member e1 = TestMember.Create(new Address("akka.tcp", "sys", "e", 2552), MemberStatus.Down, ImmutableHashSet.Create("r3"));

Expand Down Expand Up @@ -93,7 +94,10 @@ public void Can_serialize_Join()
{
var address = new Address("akka.tcp", "system", "some.host.org", 4711);
var uniqueAddress = new UniqueAddress(address, 17);
var message = new InternalClusterAction.Join(uniqueAddress, ImmutableHashSet.Create("foo", "bar"));
var message = new InternalClusterAction.Join(uniqueAddress, ImmutableHashSet.Create("foo", "bar"), AkkaVersion.Zero);
AssertEqual(message);

message = new InternalClusterAction.Join(uniqueAddress, ImmutableHashSet.Create("foo", "bar"), AkkaVersion.Create("1.2.3"));
AssertEqual(message);
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Cluster.Tests/SplitBrainStrategySpec.cs
Expand Up @@ -18,7 +18,7 @@ namespace Akka.Cluster.Tests
public class SplitBrainStrategySpec
{
private static Member Member(Address address, int upNumber = 1, MemberStatus status = MemberStatus.Up, string role = null) =>
new Member(new UniqueAddress(address, ThreadLocalRandom.Current.Next()), upNumber, status, role == null ? ImmutableHashSet<string>.Empty : ImmutableHashSet.Create(role));
new Member(new UniqueAddress(address, ThreadLocalRandom.Current.Next()), upNumber, status, role == null ? ImmutableHashSet<string>.Empty : ImmutableHashSet.Create(role), AkkaVersion.Zero);

private static ImmutableSortedSet<Member> Members(params Member[] members) => ImmutableSortedSet.CreateRange(Akka.Cluster.Member.AgeOrdering, members);

Expand Down
9 changes: 5 additions & 4 deletions src/core/Akka.Cluster.Tests/TestMember.cs
Expand Up @@ -8,6 +8,7 @@
using System.Collections.Immutable;
using Akka.Actor;
using Akka.Annotations;
using Akka.Util;

namespace Akka.Cluster.Tests
{
Expand All @@ -17,14 +18,14 @@ namespace Akka.Cluster.Tests
[InternalApi]
public static class TestMember
{
public static Member Create(Address address, MemberStatus status, int uid = 0)
public static Member Create(Address address, MemberStatus status, int uid = 0, AkkaVersion appVersion = null)
{
return Create(address, status, ImmutableHashSet.Create<string>(), uid);
return Create(address, status, ImmutableHashSet.Create<string>(), uid, appVersion: appVersion);
}

public static Member Create(Address address, MemberStatus status, ImmutableHashSet<string> roles, int uid = 0, int upNumber = 0)
public static Member Create(Address address, MemberStatus status, ImmutableHashSet<string> roles, int uid = 0, int upNumber = 0, AkkaVersion appVersion = null)
{
return Member.Create(new UniqueAddress(address, uid), upNumber, status, roles);
return Member.Create(new UniqueAddress(address, uid), upNumber, status, roles, appVersion ?? AkkaVersion.Zero);
}
}
}
Expand Down