Struct mz_controller::Controller
source · pub struct Controller<T = Timestamp> {
pub storage: Box<dyn StorageController<Timestamp = T>>,
pub compute: ComputeController<T>,
/* private fields */
}
Expand description
A client that maintains soft state and validates commands, in addition to forwarding them.
Fields§
§storage: Box<dyn StorageController<Timestamp = T>>
§compute: ComputeController<T>
Implementations§
source§impl<T> Controller<T>
impl<T> Controller<T>
sourcepub fn create_cluster(
&mut self,
id: ClusterId,
config: ClusterConfig
) -> Result<(), Error>
pub fn create_cluster( &mut self, id: ClusterId, config: ClusterConfig ) -> Result<(), Error>
Creates a cluster with the specified identifier and configuration.
A cluster is a combination of a storage instance and a compute instance. A cluster has zero or more replicas; each replica colocates the storage and compute layers on the same physical resources.
sourcepub fn drop_cluster(&mut self, id: ClusterId)
pub fn drop_cluster(&mut self, id: ClusterId)
sourcepub async fn create_replicas(
&mut self,
replicas: Vec<CreateReplicaConfig>,
enable_worker_core_affinity: bool
) -> Result<(), Error>
pub async fn create_replicas( &mut self, replicas: Vec<CreateReplicaConfig>, enable_worker_core_affinity: bool ) -> Result<(), Error>
Creates a replica of the specified cluster with the specified identifier and configuration.
This method is NOT idempotent; It can fail between processing of different
replicas and leave the controller in an inconsistent state. It is almost
always wrong to do anything but abort the process on Err
.
sourcepub async fn drop_replica(
&mut self,
cluster_id: ClusterId,
replica_id: ReplicaId
) -> Result<(), Error>
pub async fn drop_replica( &mut self, cluster_id: ClusterId, replica_id: ReplicaId ) -> Result<(), Error>
Drops the specified replica of the specified cluster.
sourcepub async fn remove_orphaned_replicas(
&mut self,
next_user_replica_id: u64,
next_system_replica_id: u64
) -> Result<(), Error>
pub async fn remove_orphaned_replicas( &mut self, next_user_replica_id: u64, next_system_replica_id: u64 ) -> Result<(), Error>
Remove orphaned replicas.
pub fn events_stream(&self) -> BoxStream<'static, ClusterEvent>
source§impl<T: Timestamp> Controller<T>
impl<T: Timestamp> Controller<T>
pub fn active_compute(&mut self) -> ActiveComputeController<'_, T>
pub fn set_arrangement_exert_proportionality(&mut self, value: u32)
sourcepub fn connection_context(&self) -> &ConnectionContext
pub fn connection_context(&self) -> &ConnectionContext
Returns the connection context installed in the controller.
This is purely a helper, and can be obtained from self.storage
.
sourcepub fn storage_configuration(&self) -> &StorageConfiguration
pub fn storage_configuration(&self) -> &StorageConfiguration
Returns the storage configuration installed in the storage controller.
This is purely a helper, and can be obtained from self.storage
.
source§impl<T> Controller<T>
impl<T> Controller<T>
pub fn update_orchestrator_scheduling_config( &mut self, config: ServiceSchedulingConfig )
sourcepub fn initialization_complete(&mut self)
pub fn initialization_complete(&mut self)
Marks the end of any initialization commands.
The implementor may wait for this method to be called before implementing prior commands, and so it is important for a user to invoke this method as soon as it is comfortable. This method can be invoked immediately, at the potential expense of performance.
sourcepub async fn ready(&mut self)
pub async fn ready(&mut self)
Waits until the controller is ready to process a response.
This method may block for an arbitrarily long time.
When the method returns, the owner should call Controller::ready
to
process the ready message.
This method is cancellation safe.
sourcepub fn install_compute_watch_set(
&mut self,
objects: BTreeSet<GlobalId>,
t: T,
token: Box<dyn Any>
)
pub fn install_compute_watch_set( &mut self, objects: BTreeSet<GlobalId>, t: T, token: Box<dyn Any> )
Install a watch set in the controller.
A watch set is a request to be informed by the controller when all of the frontiers of a particular set of objects have advanced at least to a particular timestamp.
When all the objects in objects
have advanced to t
, the object
token
is returned to the client on the next call to Self::process
.
sourcepub fn install_storage_watch_set(
&mut self,
objects: BTreeSet<GlobalId>,
t: T,
token: Box<dyn Any>
)
pub fn install_storage_watch_set( &mut self, objects: BTreeSet<GlobalId>, t: T, token: Box<dyn Any> )
Install a watch set in the controller.
A watch set is a request to be informed by the controller when all of the frontiers of a particular set of objects have advanced at least to a particular timestamp.
When all the objects in objects
have advanced to t
, the object
token
is returned to the client on the next call to Self::process
.
sourcepub async fn process(
&mut self,
storage_metadata: &StorageMetadata
) -> Result<Option<ControllerResponse<T>>, Error>
pub async fn process( &mut self, storage_metadata: &StorageMetadata ) -> Result<Option<ControllerResponse<T>>, Error>
Processes the work queued by Controller::ready
.
This method is guaranteed to return “quickly” unless doing so would compromise the correctness of the system.
This method is not guaranteed to be cancellation safe. It must be awaited to completion.
sourcepub fn recent_timestamp(
&self,
source_ids: impl Iterator<Item = GlobalId>
) -> BoxFuture<'static, T>
pub fn recent_timestamp( &self, source_ids: impl Iterator<Item = GlobalId> ) -> BoxFuture<'static, T>
Produces a timestamp that reflects all data available in
source_ids
at the time of the function call.
source§impl<T> Controller<T>where
T: Timestamp + Lattice + TotalOrder + TryInto<i64> + TryFrom<i64> + Codec64 + Unpin + From<EpochMillis> + TimestampManipulation + Display + Into<Timestamp>,
<T as TryInto<i64>>::Error: Debug,
<T as TryFrom<i64>>::Error: Debug,
StorageCommand<T>: RustType<ProtoStorageCommand>,
StorageResponse<T>: RustType<ProtoStorageResponse>,
impl<T> Controller<T>where
T: Timestamp + Lattice + TotalOrder + TryInto<i64> + TryFrom<i64> + Codec64 + Unpin + From<EpochMillis> + TimestampManipulation + Display + Into<Timestamp>,
<T as TryInto<i64>>::Error: Debug,
<T as TryFrom<i64>>::Error: Debug,
StorageCommand<T>: RustType<ProtoStorageCommand>,
StorageResponse<T>: RustType<ProtoStorageResponse>,
sourcepub async fn new(
config: ControllerConfig,
envd_epoch: NonZeroI64,
persist_txn_tables: PersistTxnTablesImpl,
storage_txn: &dyn StorageTxn<T>
) -> Self
pub async fn new( config: ControllerConfig, envd_epoch: NonZeroI64, persist_txn_tables: PersistTxnTablesImpl, storage_txn: &dyn StorageTxn<T> ) -> Self
Creates a new controller.
For correctness, this function expects to have access to the mutations
to the storage_txn
that occurred in prepare_initialization
.
§Panics
If this function is called before prepare_initialization
.
Auto Trait Implementations§
impl<T = Timestamp> !RefUnwindSafe for Controller<T>
impl<T = Timestamp> !Send for Controller<T>
impl<T = Timestamp> !Sync for Controller<T>
impl<T> Unpin for Controller<T>where
T: Unpin,
impl<T = Timestamp> !UnwindSafe for Controller<T>
Blanket Implementations§
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
source§impl<T> FmtForward for T
impl<T> FmtForward for T
source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
source§impl<T, U> OverrideFrom<Option<&T>> for Uwhere
U: OverrideFrom<T>,
impl<T, U> OverrideFrom<Option<&T>> for Uwhere
U: OverrideFrom<T>,
source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
source§fn into_rust(self) -> Result<R, TryFromProtoError>
fn into_rust(self) -> Result<R, TryFromProtoError>
RustType::from_proto
.source§fn from_rust(rust: &R) -> P
fn from_rust(rust: &R) -> P
RustType::into_proto
.source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.