-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ddata ReadMajorityPlus and WriteMajorityPlus #5146
Changes from 2 commits
e72ab40
14d37a2
cb574bc
066060d
946136e
65fda04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,15 +28,15 @@ internal class TestWriteAggregator<T> : WriteAggregator where T : IReplicatedDat | |
|
||
public TestWriteAggregator( | ||
IKey<T> key, | ||
T data, | ||
T data, | ||
Delta delta, | ||
IWriteConsistency consistency, | ||
IWriteConsistency consistency, | ||
IImmutableDictionary<Address, IActorRef> probes, | ||
IImmutableSet<Address> nodes, | ||
IImmutableList<Address> nodes, | ||
IImmutableSet<Address> unreachable, | ||
IActorRef replyTo, | ||
bool durable) | ||
: base(key, new DataEnvelope(data), delta, consistency, null, nodes, unreachable, replyTo, durable) | ||
bool durable) | ||
: base(key, new DataEnvelope(data), delta, consistency, null, nodes, unreachable, false, replyTo, durable) | ||
{ | ||
_probes = probes; | ||
} | ||
|
@@ -64,7 +64,7 @@ public WriteAckAdapter(IActorRef replica) | |
private static Props TestWriteAggregatorProps(GSet<string> data, | ||
IWriteConsistency consistency, | ||
IImmutableDictionary<Address, IActorRef> probes, | ||
IImmutableSet<Address> nodes, | ||
IImmutableList<Address> nodes, | ||
IImmutableSet<Address> unreachable, | ||
IActorRef replyTo, | ||
bool durable) => Actor.Props.Create(() => new TestWriteAggregator<GSet<string>>(KeyA, data, null, consistency, probes, nodes, unreachable, replyTo, durable)); | ||
|
@@ -73,7 +73,7 @@ public WriteAckAdapter(IActorRef replica) | |
Delta delta, | ||
IWriteConsistency consistency, | ||
IImmutableDictionary<Address, IActorRef> probes, | ||
IImmutableSet<Address> nodes, | ||
IImmutableList<Address> nodes, | ||
IImmutableSet<Address> unreachable, | ||
IActorRef replyTo, | ||
bool durable) => Actor.Props.Create(() => new TestWriteAggregator<ORSet<string>>(KeyB, data, delta, consistency, probes, nodes, unreachable, replyTo, durable)); | ||
|
@@ -85,7 +85,7 @@ public WriteAckAdapter(IActorRef replica) | |
private readonly Address _nodeB = new Address("akka.tcp", "Sys", "b", 2552); | ||
private readonly Address _nodeC = new Address("akka.tcp", "Sys", "c", 2552); | ||
private readonly Address _nodeD = new Address("akka.tcp", "Sys", "d", 2552); | ||
private readonly IImmutableSet<Address> _nodes; | ||
private readonly IImmutableList<Address> _nodes; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the change from set to list? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because the base class There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, thank you |
||
|
||
private readonly GSet<string> _data = GSet.Create("A", "B"); | ||
private readonly WriteTo _writeThree = new WriteTo(3, TimeSpan.FromSeconds(3)); | ||
|
@@ -104,7 +104,7 @@ public WriteAckAdapter(IActorRef replica) | |
map-size = 10MiB | ||
}}"), "WriteAggregatorSpec", output) | ||
{ | ||
_nodes = ImmutableHashSet.CreateRange(new[] {_nodeA, _nodeB, _nodeC, _nodeD}); | ||
_nodes = ImmutableList.CreateRange(new[] {_nodeA, _nodeB, _nodeC, _nodeD}); | ||
|
||
var cluster = Akka.Cluster.Cluster.Get(Sys); | ||
_fullState1 = ORSet<string>.Empty.Add(cluster, "a").Add(cluster, "b"); | ||
|
@@ -169,24 +169,50 @@ public void WriteAggregator_must_timeout_when_less_than_required_ACKs() | |
Watch(aggregator); | ||
ExpectTerminated(aggregator); | ||
}); | ||
|
||
} | ||
|
||
[Fact] | ||
public void WriteAggregator_must_callculate_majority_with_min_capactiy() | ||
{ | ||
var minCap = 5; | ||
|
||
ReadWriteAggregator.CalculateMajorityWithMinCapacity(minCap, 3).Should().Be(3); | ||
ReadWriteAggregator.CalculateMajorityWithMinCapacity(minCap, 4).Should().Be(4); | ||
ReadWriteAggregator.CalculateMajorityWithMinCapacity(minCap, 5).Should().Be(5); | ||
ReadWriteAggregator.CalculateMajorityWithMinCapacity(minCap, 6).Should().Be(5); | ||
ReadWriteAggregator.CalculateMajorityWithMinCapacity(minCap, 7).Should().Be(5); | ||
ReadWriteAggregator.CalculateMajorityWithMinCapacity(minCap, 8).Should().Be(5); | ||
ReadWriteAggregator.CalculateMajorityWithMinCapacity(minCap, 9).Should().Be(5); | ||
ReadWriteAggregator.CalculateMajorityWithMinCapacity(minCap, 10).Should().Be(6); | ||
ReadWriteAggregator.CalculateMajorityWithMinCapacity(minCap, 11).Should().Be(6); | ||
ReadWriteAggregator.CalculateMajorityWithMinCapacity(minCap, 12).Should().Be(7); | ||
ReadWriteAggregator.CalculateMajority(minCap, 3, 0).Should().Be(3); | ||
ReadWriteAggregator.CalculateMajority(minCap, 4, 0).Should().Be(4); | ||
ReadWriteAggregator.CalculateMajority(minCap, 5, 0).Should().Be(5); | ||
ReadWriteAggregator.CalculateMajority(minCap, 6, 0).Should().Be(5); | ||
ReadWriteAggregator.CalculateMajority(minCap, 7, 0).Should().Be(5); | ||
ReadWriteAggregator.CalculateMajority(minCap, 8, 0).Should().Be(5); | ||
ReadWriteAggregator.CalculateMajority(minCap, 9, 0).Should().Be(5); | ||
ReadWriteAggregator.CalculateMajority(minCap, 10, 0).Should().Be(6); | ||
ReadWriteAggregator.CalculateMajority(minCap, 11, 0).Should().Be(6); | ||
ReadWriteAggregator.CalculateMajority(minCap, 12, 0).Should().Be(7); | ||
} | ||
|
||
[Fact] | ||
public void WriteAggregator_must_callculate_majority_with_additional() | ||
{ | ||
ReadWriteAggregator.CalculateMajority(0, 3, 1).Should().Be(3); | ||
ReadWriteAggregator.CalculateMajority(0, 3, 2).Should().Be(3); | ||
ReadWriteAggregator.CalculateMajority(0, 4, 1).Should().Be(4); | ||
ReadWriteAggregator.CalculateMajority(0, 5, 1).Should().Be(4); | ||
ReadWriteAggregator.CalculateMajority(0, 5, 2).Should().Be(5); | ||
ReadWriteAggregator.CalculateMajority(0, 6, 1).Should().Be(5); | ||
ReadWriteAggregator.CalculateMajority(0, 7, 1).Should().Be(5); | ||
ReadWriteAggregator.CalculateMajority(0, 8, 1).Should().Be(6); | ||
ReadWriteAggregator.CalculateMajority(0, 8, 2).Should().Be(7); | ||
ReadWriteAggregator.CalculateMajority(0, 9, 1).Should().Be(6); | ||
ReadWriteAggregator.CalculateMajority(0, 10, 1).Should().Be(7); | ||
ReadWriteAggregator.CalculateMajority(0, 11, 1).Should().Be(7); | ||
ReadWriteAggregator.CalculateMajority(0, 11, 3).Should().Be(9); | ||
} | ||
|
||
[Fact] | ||
public void WriteAggregator_must_callculate_majority_with_additional_and_min_capactiy() | ||
{ | ||
ReadWriteAggregator.CalculateMajority(5, 9, 1).Should().Be(6); | ||
ReadWriteAggregator.CalculateMajority(7, 9, 1).Should().Be(7); | ||
ReadWriteAggregator.CalculateMajority(10, 9, 1).Should().Be(9); | ||
} | ||
|
||
[Fact] | ||
|
@@ -274,7 +300,7 @@ public void Durable_WriteAggregator_must_not_reply_before_local_confirmation() | |
var probe = CreateTestProbe(); | ||
var aggregator = Sys.ActorOf(TestWriteAggregatorProps(_data, _writeThree, Probes(probe.Ref), _nodes, ImmutableHashSet<Address>.Empty, TestActor, true)); | ||
Watch(aggregator); | ||
|
||
probe.ExpectMsg<Write>(); | ||
probe.LastSender.Tell(WriteAck.Instance); | ||
probe.ExpectMsg<Write>(); | ||
|
@@ -294,7 +320,7 @@ public void Durable_WriteAggregator_must_tolerate_WriteNack_if_enough_WriteAck() | |
var probe = CreateTestProbe(); | ||
var aggregator = Sys.ActorOf(TestWriteAggregatorProps(_data, _writeThree, Probes(probe.Ref), _nodes, ImmutableHashSet<Address>.Empty, TestActor, true)); | ||
Watch(aggregator); | ||
|
||
aggregator.Tell(new UpdateSuccess(KeyA, null)); | ||
probe.ExpectMsg<Write>(); | ||
probe.LastSender.Tell(WriteAck.Instance); | ||
|
@@ -353,7 +379,7 @@ public void Durable_WriteAggregator_must_timeout_when_less_than_required_ACKs() | |
} | ||
|
||
private IImmutableDictionary<Address, IActorRef> Probes(IActorRef probe) => | ||
_nodes.Select(address => | ||
_nodes.Select(address => | ||
new KeyValuePair<Address, IActorRef>( | ||
address, | ||
Sys.ActorOf(Props.Create(() => new WriteAckAdapter(probe))))) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, that should make this test less racy