Struct mz_storage::controller::hosts::StorageHosts
source · [−]pub struct StorageHosts<T> {
pub build_info: &'static BuildInfo,
orchestrator: Arc<dyn NamespacedOrchestrator>,
storaged_image: String,
hosts: HashMap<String, StorageHost<T>>,
objects: HashMap<GlobalId, String>,
initialized: bool,
persist: Arc<Mutex<PersistClientCache>>,
}
Expand description
Manages provisioning of storage hosts and assignment of storage objects to those hosts.
See the module documentation for details.
Fields
build_info: &'static BuildInfo
The build information for this process.
orchestrator: Arc<dyn NamespacedOrchestrator>
An orchestrator to start and stop storage hosts.
storaged_image: String
The storaged image to use when starting new storage hosts.
hosts: HashMap<String, StorageHost<T>>
The known storage hosts, identified by network address.
objects: HashMap<GlobalId, String>
The assignment of storage objects to storage hosts.
initialized: bool
Set to true
once initialization_complete
has been called.
persist: Arc<Mutex<PersistClientCache>>
A handle to Persist
Implementations
sourceimpl<T> StorageHosts<T>where
T: Timestamp + Lattice + Codec64,
StorageCommand<T>: RustType<ProtoStorageCommand>,
StorageResponse<T>: RustType<ProtoStorageResponse>,
impl<T> StorageHosts<T>where
T: Timestamp + Lattice + Codec64,
StorageCommand<T>: RustType<ProtoStorageCommand>,
StorageResponse<T>: RustType<ProtoStorageResponse>,
sourcepub fn new(
config: StorageHostsConfig,
persist: Arc<Mutex<PersistClientCache>>
) -> StorageHosts<T>
pub fn new(
config: StorageHostsConfig,
persist: Arc<Mutex<PersistClientCache>>
) -> StorageHosts<T>
Constructs a new StorageHosts
from its configuration.
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 provision(
&mut self,
id: GlobalId,
host_config: StorageHostConfig
) -> Result<&mut RehydratingStorageClient<T>, Error>where
StorageCommand<T>: RustType<ProtoStorageCommand>,
StorageResponse<T>: RustType<ProtoStorageResponse>,
pub async fn provision(
&mut self,
id: GlobalId,
host_config: StorageHostConfig
) -> Result<&mut RehydratingStorageClient<T>, Error>where
StorageCommand<T>: RustType<ProtoStorageCommand>,
StorageResponse<T>: RustType<ProtoStorageResponse>,
Provisions a storage host for the storage object with the specified ID. If the storage host is managed, this will ensure that the backing orchestrator allocates resources, either by creating or updating the existing service. (For ‘remote’ storaged instances, the user is required to independently make sure that any resources exist – if the orchestrator had provisioned a service for this host in the past, it will be dropped.)
At present, the policy for storage host assignment creates a new storage host for each storage object. This policy is subject to change.
Returns a client to the provisioned host. The client may be
retrieved in the future via the client
method.
sourcepub async fn deprovision(&mut self, id: GlobalId) -> Result<(), Error>
pub async fn deprovision(&mut self, id: GlobalId) -> Result<(), Error>
Deprovisions the storage host for the storage object with the specified ID: ensures we’re not orchestrating any resources for this id, and cleans up any internal state.
sourcefn remove_id_from_host(&mut self, id: GlobalId, host_addr: String)
fn remove_id_from_host(&mut self, id: GlobalId, host_addr: String)
If a id no longer maps to a particular host_addr, this removes the id from the host’s set – and, if the set is empty, shuts down the client.
sourcepub fn client(
&mut self,
id: GlobalId
) -> Option<&mut RehydratingStorageClient<T>>
pub fn client(
&mut self,
id: GlobalId
) -> Option<&mut RehydratingStorageClient<T>>
Retrives the client for the storage host for the given ID, if the ID is currently provisioned.
sourcepub fn clients(
&mut self
) -> impl Iterator<Item = &mut RehydratingStorageClient<T>>
pub fn clients(
&mut self
) -> impl Iterator<Item = &mut RehydratingStorageClient<T>>
Returns an iterator over clients for all known storage hosts.
sourceasync fn ensure_storage_host(
&self,
id: GlobalId,
allocation: StorageHostResourceAllocation
) -> Result<String, Error>
async fn ensure_storage_host(
&self,
id: GlobalId,
allocation: StorageHostResourceAllocation
) -> Result<String, Error>
Starts a orchestrated storage host for the specified ID.
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for StorageHosts<T>
impl<T> Send for StorageHosts<T>where
T: Send,
impl<T> Sync for StorageHosts<T>where
T: Send,
impl<T> Unpin for StorageHosts<T>
impl<T> !UnwindSafe for StorageHosts<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> FutureExt for T
impl<T> FutureExt for T
sourcefn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
sourcefn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
sourcefn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
sourceimpl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
sourcefn into_rust(self) -> Result<R, TryFromProtoError>
fn into_rust(self) -> Result<R, TryFromProtoError>
RustType::from_proto
.sourcefn from_rust(rust: &R) -> P
fn from_rust(rust: &R) -> P
RustType::into_proto
.