diff options
Diffstat (limited to 'src/remake')
| -rw-r--r-- | src/remake/catchup.rs | 8 | ||||
| -rw-r--r-- | src/remake/local.rs | 25 | ||||
| -rw-r--r-- | src/remake/mod.rs | 3 | ||||
| -rw-r--r-- | src/remake/switch.rs | 4 |
4 files changed, 10 insertions, 30 deletions
diff --git a/src/remake/catchup.rs b/src/remake/catchup.rs index b8dc1b9..685385a 100644 --- a/src/remake/catchup.rs +++ b/src/remake/catchup.rs @@ -279,7 +279,7 @@ async fn start<H: Host>(host: &H, local: Epoch, target: Epoch, attempts: u32) { })); let actor = ActorId::random(); - host.remake().add_own_actor(actor.clone()); + host.own_writers().add(actor.clone()); // At once: the fresh document takes no writes until the rejoin is done; a ready // node's document so far answers reads, marked stale, and takes its writes // meanwhile (`Host::begin_rejoin`). @@ -386,7 +386,7 @@ async fn finish<H: Host>(host: &H) { // meanwhile, and those after `began` are replayed under the lock in the end. let copy = host.read_doc(|doc| doc.clone()).await; let kept = host.rejoin_document().await; - let own = host.remake().own_actors(); + let own = host.own_writers().all(); let now = host.now_millis(); #[cfg(feature = "federation")] let (holding, store) = (host.holding(), host.store_id()); @@ -560,7 +560,7 @@ async fn finish<H: Host>(host: &H) { ); host.remake().set_catch_up(None); let actor = host.read_doc(|doc| doc.get_actor().clone()).await; - host.remake().reset_own_actors(actor); + host.own_writers().reset(actor); info!( from = %previous, @@ -578,7 +578,7 @@ async fn finish<H: Host>(host: &H) { /// Verifies the synced document `copy` and decides about the old document's own /// changes: those up to `began` (when the rejoin began) by the replay window, those /// after it (made during the rejoin) whatever it says. `own`: this node's actors -/// (`RemakeState::own_actors`); the old document's own actor counts in any case. +/// (`document::own::OwnWriters`); the old document's own actor counts in any case. /// `now`: Unix milliseconds, by the node's clock. fn prepare( copy: &Document, diff --git a/src/remake/local.rs b/src/remake/local.rs index cdf2d6f..cf6f566 100644 --- a/src/remake/local.rs +++ b/src/remake/local.rs @@ -16,7 +16,7 @@ use super::records::Retention; use super::snapshot::Snapshot; use crate::clock::UnixMillis; use crate::document::replica::Epoch; -use crate::document::{ActorId, ChangeHash, Document}; +use crate::document::{ChangeHash, Document}; use crate::locks::MutexExt; pub(crate) struct RemakeState { @@ -68,11 +68,6 @@ struct Inner { missed: HashSet<String>, /// Strict remakes this node won't vote for (`vote::cast`), each logged once. refused_strict: HashSet<String>, - /// The actors this node writes or wrote with in the current document: this run's, - /// and those of earlier runs it knows of (`--document-file`). Its own writes, for a - /// rejoin. A switch or rejoin starts the list over with the new document's actor, so - /// it only grows with restarts within one epoch. - own_actors: Vec<ActorId>, } /// Content no remake refers to any more is kept this long after it was stored, for @@ -170,24 +165,6 @@ impl RemakeState { self.started_at } - /// This node writes with `actor` from now on (or did, in an earlier run). - pub(crate) fn add_own_actor(&self, actor: ActorId) { - let mut inner = self.lock(); - if !inner.own_actors.contains(&actor) { - inner.own_actors.push(actor); - } - } - - /// The current document is a new one, written with `actor` only (a switch or rejoin - /// is done). - pub(crate) fn reset_own_actors(&self, actor: ActorId) { - self.lock().own_actors = vec![actor]; - } - - pub(crate) fn own_actors(&self) -> Vec<ActorId> { - self.lock().own_actors.clone() - } - /// Whether this node starts coordinating `id` now (false if it already does). pub(crate) fn start_coordinating(&self, id: &str) -> bool { self.lock().coordinating.insert(id.to_owned()) diff --git a/src/remake/mod.rs b/src/remake/mod.rs index 1f7a644..6b1103e 100644 --- a/src/remake/mod.rs +++ b/src/remake/mod.rs @@ -200,6 +200,9 @@ pub(crate) trait Host: Clone + Send + Sync + 'static { /// This node's in-memory remake state. fn remake(&self) -> &RemakeState; + /// The writers this node writes or wrote under in its current document. + fn own_writers(&self) -> &crate::document::own::OwnWriters; + /// This node's wall clock (`clock`): deadlines, votes and decisions are stamped and /// judged with it. Shared, so closures run under the document lock can read it. fn clock(&self) -> Arc<crate::clock::Clock>; diff --git a/src/remake/switch.rs b/src/remake/switch.rs index e56cd8c..ef616dc 100644 --- a/src/remake/switch.rs +++ b/src/remake/switch.rs @@ -254,7 +254,7 @@ async fn switch<H: Host>( .filter(|snapshot| snapshot.epoch == expected); let actor = ActorId::random(); - host.remake().add_own_actor(actor.clone()); + host.own_writers().add(actor.clone()); let new_actor = actor.clone(); let node = host.node_id(); @@ -309,7 +309,7 @@ async fn switch<H: Host>( // 3. Swap, replaying what arrived since the copy. let (old, late) = swap_in(host, expected, new_doc, copy_heads, late_translator).await?; stats.absorb(late); - host.remake().reset_own_actors(new_actor); + host.own_writers().reset(new_actor); // 4. Writes the remake had no place for wait for an operator (the old document // holds them); the old document is kept as configured either way. |
