laminar_core/cluster/control/topology/
restore.rs1use super::{
4 ClusterTopologyValidation, TopologyAdmissionPlan, TopologyAdmissionStatus,
5 TopologyMigrationRoot,
6};
7use crate::checkpoint::{CheckpointAssignmentFence, CommittedCheckpointIndex, LeaderProof};
8use crate::checkpoint_decision::CheckpointOutcome;
9use crate::cluster::control::{CatalogManifest, LocalProcessAuthorityIdentity};
10
11#[derive(Debug, Clone, PartialEq, Eq)]
16pub struct TopologyRestoreInput {
17 pub(crate) operation: TopologyAdmissionStatus,
18 pub(crate) plan: TopologyAdmissionPlan,
19 pub(crate) parent: CatalogManifest,
20 pub(crate) target: CatalogManifest,
21 pub(crate) descriptor: ClusterTopologyValidation,
22 pub(crate) root: TopologyMigrationRoot,
23 pub(crate) outcome: CheckpointOutcome,
24 pub(crate) checkpoint: CommittedCheckpointIndex,
25 pub(crate) owned_vnodes: Vec<u32>,
26 pub(crate) process: LocalProcessAuthorityIdentity,
27 pub(crate) restore_assignment: CheckpointAssignmentFence,
28 pub(crate) restore_processes: Vec<LocalProcessAuthorityIdentity>,
29 pub(crate) committed_leader: Option<LeaderProof>,
30}
31
32impl TopologyRestoreInput {
33 #[must_use]
35 pub fn processes(&self) -> &[LocalProcessAuthorityIdentity] {
36 &self.restore_processes
37 }
38
39 #[must_use]
41 pub fn current_leader(&self) -> Option<LeaderProof> {
42 self.committed_leader.clone()
43 }
44 #[must_use]
48 pub fn same_restore_requirements(&self, other: &Self) -> bool {
49 self.same_installed_generation(other) && self.committed_leader == other.committed_leader
50 }
51
52 #[must_use]
55 pub fn same_installed_generation(&self, other: &Self) -> bool {
56 self.operation.same_restore_binding(&other.operation)
57 && self.plan == other.plan
58 && self.parent == other.parent
59 && self.target == other.target
60 && self.descriptor == other.descriptor
61 && self.root == other.root
62 && self.outcome == other.outcome
63 && self.checkpoint == other.checkpoint
64 && self.owned_vnodes == other.owned_vnodes
65 && self.process == other.process
66 && self.restore_assignment == other.restore_assignment
67 && self.restore_processes == other.restore_processes
68 }
69
70 #[must_use]
73 pub fn is_committed_successor_of(&self, prepared: &Self) -> bool {
74 self.operation.has_target_commit()
75 && self.committed_leader.is_some()
76 && prepared.operation.phase == super::TopologyAdmissionPhase::CutPrepared
77 && prepared.operation.commit.is_none()
78 && self.operation.same_migration_binding(&prepared.operation)
79 && self.plan == prepared.plan
80 && self.parent == prepared.parent
81 && self.target == prepared.target
82 && self.descriptor == prepared.descriptor
83 && self.root == prepared.root
84 && self.outcome == prepared.outcome
85 && self.checkpoint == prepared.checkpoint
86 && self.owned_vnodes == prepared.owned_vnodes
87 && self.process == prepared.process
88 && self.restore_assignment == prepared.restore_assignment
89 }
90
91 #[must_use]
94 pub const fn assignment(&self) -> &CheckpointAssignmentFence {
95 &self.restore_assignment
96 }
97
98 #[must_use]
100 pub const fn is_committed(&self) -> bool {
101 self.committed_leader.is_some()
102 }
103 #[must_use]
105 pub const fn operation(&self) -> &TopologyAdmissionStatus {
106 &self.operation
107 }
108 #[must_use]
110 pub const fn plan(&self) -> &TopologyAdmissionPlan {
111 &self.plan
112 }
113 #[must_use]
115 pub const fn parent(&self) -> &CatalogManifest {
116 &self.parent
117 }
118 #[must_use]
120 pub const fn target(&self) -> &CatalogManifest {
121 &self.target
122 }
123 #[must_use]
125 pub const fn descriptor(&self) -> &ClusterTopologyValidation {
126 &self.descriptor
127 }
128 #[must_use]
130 pub const fn root(&self) -> &TopologyMigrationRoot {
131 &self.root
132 }
133 #[must_use]
135 pub const fn outcome(&self) -> &CheckpointOutcome {
136 &self.outcome
137 }
138 #[must_use]
140 pub const fn checkpoint(&self) -> &CommittedCheckpointIndex {
141 &self.checkpoint
142 }
143 #[must_use]
145 pub fn owned_vnodes(&self) -> &[u32] {
146 &self.owned_vnodes
147 }
148 #[must_use]
150 pub const fn process(&self) -> LocalProcessAuthorityIdentity {
151 self.process
152 }
153}