feat: execute post-baseline jetstream parity plan
This commit is contained in:
@@ -42,6 +42,30 @@ public sealed class StreamReplicaGroup
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task ApplyPlacementAsync(IReadOnlyList<int> placement, CancellationToken ct)
|
||||
{
|
||||
_ = ct;
|
||||
var targetCount = Math.Max(placement.Count, 1);
|
||||
if (targetCount == _nodes.Count)
|
||||
return Task.CompletedTask;
|
||||
|
||||
if (targetCount > _nodes.Count)
|
||||
{
|
||||
for (var i = _nodes.Count + 1; i <= targetCount; i++)
|
||||
_nodes.Add(new RaftNode($"{streamNamePrefix()}-r{i}"));
|
||||
}
|
||||
else
|
||||
{
|
||||
_nodes.RemoveRange(targetCount, _nodes.Count - targetCount);
|
||||
}
|
||||
|
||||
foreach (var node in _nodes)
|
||||
node.ConfigureCluster(_nodes);
|
||||
|
||||
Leader = ElectLeader(_nodes[0]);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private RaftNode SelectNextCandidate(RaftNode currentLeader)
|
||||
{
|
||||
if (_nodes.Count == 1)
|
||||
@@ -62,4 +86,6 @@ public sealed class StreamReplicaGroup
|
||||
|
||||
return candidate;
|
||||
}
|
||||
|
||||
private string streamNamePrefix() => StreamName.ToLowerInvariant();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user