2using System.Collections.Generic;
4using System.Threading.Tasks;
18 public IReadOnlyList<SwarmServerInformation>
InvolvedServers =>
initialInvolvedServers ??
throw new InvalidOperationException(
"This property can only be checked on controller SwarmUpdateOperations!");
52 TargetVersion = targetVersion ??
throw new ArgumentNullException(nameof(targetVersion));
53 commitTcs =
new TaskCompletionSource<bool>();
67 .Where(node => !node.Controller)
68 .Select(node => node.Identifier!)
81 return commitTcs.Task.Result
82 ? SwarmUpdateAbortResult.CantAbortCommitted
93 throw new InvalidOperationException($
"Cannot commit! There are still {nodesThatNeedToBeReadyToCommit.Count} nodes that need to be ready!");
109 ArgumentNullException.ThrowIfNull(nodeIdentifier);
112 throw new InvalidOperationException(
"A non-controller node tried to mark a node as ready!");
Represents the state of a distributed swarm update.
Task< bool > CommitGate
The Task<TResult> that represents the final commit. If it results in true the update has been committ...
readonly? HashSet< string > nodesThatNeedToBeReadyToCommit
HashSet<T> of SwarmServer.Identifier that need to send a ready-commit to the controller before the co...
bool MarkNodeReady(string nodeIdentifier)
Marks a SwarmServer identified by nodeIdentifier as ready to commit.
SwarmUpdateOperation(Version targetVersion)
Initializes a new instance of the SwarmUpdateOperation class.
Version TargetVersion
The Version being updated to.
IReadOnlyList< SwarmServerInformation > InvolvedServers
All of the SwarmServers that are involved in the updates.
readonly? IReadOnlyList< SwarmServerInformation > initialInvolvedServers
Backing field for InvolvedServers.
readonly TaskCompletionSource< bool > commitTcs
The backing TaskCompletionSource<TResult> for CommitGate.
SwarmUpdateOperation(Version targetVersion, IEnumerable< SwarmServerInformation > currentNodes)
Initializes a new instance of the SwarmUpdateOperation class.
bool Commit()
Attempt to commit the update.
SwarmUpdateAbortResult Abort()
Attempt to abort the update operation.
SwarmUpdateAbortResult
Result of attempting to abort a SwarmUpdateOperation.