pub struct ClusterController { /* private fields */ }Expand description
Facade composing the cluster-control primitives.
Implementations§
Source§impl ClusterController
impl ClusterController
Sourcepub fn new(
instance_id: NodeId,
kv: Arc<dyn ClusterKv>,
snapshot: Option<Arc<AssignmentSnapshotStore>>,
members_rx: Receiver<Vec<NodeInfo>>,
) -> Self
pub fn new( instance_id: NodeId, kv: Arc<dyn ClusterKv>, snapshot: Option<Arc<AssignmentSnapshotStore>>, members_rx: Receiver<Vec<NodeInfo>>, ) -> Self
Wrap the given primitives.
Sourcepub fn register_query_handler(&self, handler: Arc<dyn RemoteQueryHandler>)
pub fn register_query_handler(&self, handler: Arc<dyn RemoteQueryHandler>)
Register the handler serving cross-node RemoteScan.
Sourcepub fn query_client_pool(&self) -> &QueryClientPool
pub fn query_client_pool(&self) -> &QueryClientPool
Access the connection pool for remote queries.
Sourcepub fn cluster_min_watermark(&self) -> Option<i64>
pub fn cluster_min_watermark(&self) -> Option<i64>
Latest cluster-wide minimum watermark seen by this instance.
None until the leader has published a Commit with a
populated min_watermark_ms.
Sourcepub fn publish_cluster_min_watermark(&self, wm: i64)
pub fn publish_cluster_min_watermark(&self, wm: i64)
Leader-side monotonic publish. The leader computes the
cluster-wide minimum watermark in await_prepare_quorum
(its own local watermark folded with every follower’s ack)
and must mirror it into the controller atomic so its own
operators see the same value that followers pick up via
observe_barrier on the matching Commit. Never lowers the
published value — event-time progress is monotonic.
Sourcepub fn instance_id(&self) -> NodeId
pub fn instance_id(&self) -> NodeId
This instance’s ID.
Sourcepub fn kv(&self) -> &Arc<dyn ClusterKv> ⓘ
pub fn kv(&self) -> &Arc<dyn ClusterKv> ⓘ
The cluster gossip KV, exposed so higher layers can advertise/discover per-stream state alongside the control-plane keys.
Sourcepub fn current_leader(&self) -> Option<NodeId>
pub fn current_leader(&self) -> Option<NodeId>
Current leader (lowest id among Active peers plus self).
Sourcepub fn set_active(&self, active: bool)
pub fn set_active(&self, active: bool)
Mark this node’s active status.
Sourcepub fn live_instances(&self) -> Vec<NodeId>
pub fn live_instances(&self) -> Vec<NodeId>
Live instance IDs: Active peers plus self.
Sourcepub fn note_unresponsive(&self, peers: &[NodeId])
pub fn note_unresponsive(&self, peers: &[NodeId])
Record peers that failed to ack a capture quorum in time.
Sourcepub fn note_responsive(&self, peers: &[NodeId])
pub fn note_responsive(&self, peers: &[NodeId])
Clear peers that acked (they are demonstrably alive).
Sourcepub fn is_recently_unresponsive(&self, peer: NodeId) -> bool
pub fn is_recently_unresponsive(&self, peer: NodeId) -> bool
Whether peer failed a capture quorum within the TTL window.
Sourcepub fn begin_drain(&self)
pub fn begin_drain(&self)
Mark this node as draining. Idempotent.
Sourcepub fn is_draining(&self) -> bool
pub fn is_draining(&self) -> bool
Whether this node is draining.
Sourcepub fn assignable_instances(&self) -> Vec<NodeId>
pub fn assignable_instances(&self) -> Vec<NodeId>
Node ids eligible to own vnodes: Active peers, plus self unless
this node is draining. Mirrors how Self::live_instances folds
self in, but filters non-Active peers (see assignable_node_ids)
so Joining/Suspected/Draining/Left nodes never receive vnodes.
Sourcepub fn set_self_locality(&self, locality: Locality)
pub fn set_self_locality(&self, locality: Locality)
Record this node’s own locality. Call once at startup.
Sourcepub fn assignable_with_locality(&self) -> Vec<(NodeId, Locality)>
pub fn assignable_with_locality(&self) -> Vec<(NodeId, Locality)>
Self::assignable_instances paired with each node’s Locality
(peers’ from members_rx, self’s from Self::set_self_locality).
Sourcepub fn members_watch(&self) -> Receiver<Vec<NodeInfo>>
pub fn members_watch(&self) -> Receiver<Vec<NodeInfo>>
Cloneable membership watch. Background tasks subscribe to
this to react to join/leave events (changed().await) without
polling Self::live_instances on a timer.
Sourcepub async fn announce_snapshot_version(&self, version: u64)
pub async fn announce_snapshot_version(&self, version: u64)
Write the current assignment snapshot version to gossip KV.
Sourcepub async fn read_snapshot_version(&self) -> Option<u64>
pub async fn read_snapshot_version(&self) -> Option<u64>
Read the snapshot version from all peers in gossip KV and return the maximum version.
Sourcepub async fn start_barrier_server(
&self,
bind_addr: SocketAddr,
advertise_host: Option<String>,
) -> Result<SocketAddr, String>
pub async fn start_barrier_server( &self, bind_addr: SocketAddr, advertise_host: Option<String>, ) -> Result<SocketAddr, String>
Start the direct gRPC barrier sync server.
§Errors
Propagates BarrierCoordinator::start_server errors.
Sourcepub async fn announce_barrier(
&self,
ann: &BarrierAnnouncement,
) -> Result<(), String>
pub async fn announce_barrier( &self, ann: &BarrierAnnouncement, ) -> Result<(), String>
Sourcepub async fn observe_barrier(
&self,
) -> Result<Option<BarrierAnnouncement>, String>
pub async fn observe_barrier( &self, ) -> Result<Option<BarrierAnnouncement>, String>
Follower-side observe; Ok(None) if no leader is visible.
As a side effect, an Aligned or Commit announcement with a
populated min_watermark_ms updates the shared
cluster-min-watermark atomic so operators on this instance see
the cluster-wide minimum without a separate polling path
(Aligned carries it so a resuming pipeline sees fresh
event-time progress before the upload-gated Commit).
§Errors
Propagates BarrierCoordinator::observe errors.
Sourcepub async fn ack_barrier(&self, ack: &BarrierAck) -> Result<(), String>
pub async fn ack_barrier(&self, ack: &BarrierAck) -> Result<(), String>
Sourcepub async fn wait_for_barrier<F>(
&self,
pred: F,
timeout: Duration,
) -> Option<BarrierAnnouncement>
pub async fn wait_for_barrier<F>( &self, pred: F, timeout: Duration, ) -> Option<BarrierAnnouncement>
Wait until Self::observe_barrier yields an announcement
matching pred, or timeout expires (→ None). Push-driven
off the gRPC announcement watch when available; gossip-KV-only
deployments (and KV-only announcements) are covered by a
fallback poll — 250ms with the watch, 25ms without.
Sourcepub async fn wait_for_quorum(
&self,
epoch: u64,
expected: &[NodeId],
deadline: Duration,
) -> QuorumOutcome
pub async fn wait_for_quorum( &self, epoch: u64, expected: &[NodeId], deadline: Duration, ) -> QuorumOutcome
Leader-side: poll until quorum or deadline.
Sourcepub fn snapshot_store(&self) -> Option<&AssignmentSnapshotStore>
pub fn snapshot_store(&self) -> Option<&AssignmentSnapshotStore>
Assignment snapshot store, if configured.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ClusterController
impl !RefUnwindSafe for ClusterController
impl !UnwindSafe for ClusterController
impl Send for ClusterController
impl Sync for ClusterController
impl Unpin for ClusterController
impl UnsafeUnpin for ClusterController
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].