pub struct ObjectManager { /* private fields */ }Expand description
ObjectManager is a global loading cache for object stores and other special objects.
Implementations§
Source§impl ObjectManager
impl ObjectManager
pub fn new( on_new_store: Option<Box<dyn Fn(&ObjectStore) + Send + Sync>>, ) -> ObjectManager
pub fn required_reservation(&self) -> u64
Sourcepub fn tree_reservation(&self, object_id: u64, layer_size: u64) -> u64
pub fn tree_reservation(&self, object_id: u64, layer_size: u64) -> u64
Returns the total reservation for object_id given its layer_size.
pub fn root_parent_store_object_id(&self) -> u64
pub fn root_parent_store(&self) -> Arc<ObjectStore> ⓘ
pub fn set_root_parent_store(&self, store: Arc<ObjectStore>)
pub fn root_store_object_id(&self) -> u64
pub fn root_store(&self) -> Arc<ObjectStore> ⓘ
pub fn set_root_store(&self, store: Arc<ObjectStore>)
Sourcepub fn is_system_store(&self, store_id: u64) -> bool
pub fn is_system_store(&self, store_id: u64) -> bool
Returns true if store_id is a system store (root_store or root_parent_store).
Sourcepub fn store(&self, store_object_id: u64) -> Option<Arc<ObjectStore>>
pub fn store(&self, store_object_id: u64) -> Option<Arc<ObjectStore>>
Returns the store which might or might not be locked.
Sourcepub fn compaction_bytes_written(&self) -> u64
pub fn compaction_bytes_written(&self) -> u64
Returns the total bytes written to the LSM trees in the allocator and all object stores during compaction operations.
Sourcepub async fn on_replay_complete(&self) -> Result<(), Error>
pub async fn on_replay_complete(&self) -> Result<(), Error>
This is not thread-safe: it assumes that a store won’t be forgotten whilst the loop is running. This is to be used after replaying the journal.
pub fn volume_directory(&self) -> &Directory<ObjectStore>
pub fn set_volume_directory(&self, volume_directory: Directory<ObjectStore>)
pub fn add_store(&self, store: Arc<ObjectStore>)
pub fn forget_store(&self, store_object_id: u64)
pub fn set_allocator(&self, allocator: Arc<Allocator>)
pub fn allocator(&self) -> Arc<Allocator> ⓘ
Sourcepub fn apply_mutation(
&self,
object_id: u64,
mutation: Mutation,
context: &ApplyContext<'_, '_>,
associated_object: AssocObj<'_>,
) -> Result<(), Error>
pub fn apply_mutation( &self, object_id: u64, mutation: Mutation, context: &ApplyContext<'_, '_>, associated_object: AssocObj<'_>, ) -> Result<(), Error>
Applies mutation to object with context.
Sourcepub async fn replay_mutations(
&self,
mutations: Vec<(u64, Mutation)>,
object_journal_usage: &[(u64, u64)],
journal_offsets: &HashMap<u64, u64>,
context: &ApplyContext<'_, '_>,
end_offset: u64,
borrowed_metadata: BorrowedMetadata,
) -> Result<(), Error>
pub async fn replay_mutations( &self, mutations: Vec<(u64, Mutation)>, object_journal_usage: &[(u64, u64)], journal_offsets: &HashMap<u64, u64>, context: &ApplyContext<'_, '_>, end_offset: u64, borrowed_metadata: BorrowedMetadata, ) -> Result<(), Error>
Replays mutations for a single transaction. journal_offsets contains the per-object
starting offsets; if the current transaction offset precedes an offset, the mutations for
that object are ignored. context contains the location in the journal file for this
transaction and end_offset is the ending journal offset for this transaction.
Sourcepub fn apply_transaction(
&self,
transaction: &mut Transaction<'_>,
checkpoint: &JournalCheckpoint,
) -> Result<(), Error>
pub fn apply_transaction( &self, transaction: &mut Transaction<'_>, checkpoint: &JournalCheckpoint, ) -> Result<(), Error>
Called by the journaling system to apply a transaction. checkpoint indicates the location
in the journal file for this transaction.
Sourcepub fn did_commit_transaction(
&self,
transaction: &mut Transaction<'_>,
end_offset: u64,
object_usages: &[(u64, u64)],
)
pub fn did_commit_transaction( &self, transaction: &mut Transaction<'_>, end_offset: u64, object_usages: &[(u64, u64)], )
Called by the journaling system after a transaction has been written providing the end offset for the transaction so that we can adjust metadata reservations accordingly.
Sourcepub fn drop_transaction(&self, transaction: &mut Transaction<'_>)
pub fn drop_transaction(&self, transaction: &mut Transaction<'_>)
Drops a transaction. This is called automatically when a transaction is dropped. If the transaction has been committed, it should contain no mutations and so nothing will get rolled back. For each mutation, drop_mutation is called to allow for roll back (e.g. the allocator will unreserve allocations).
Sourcepub fn journal_file_offsets(
&self,
) -> (HashMap<u64, u64>, Option<JournalCheckpoint>)
pub fn journal_file_offsets( &self, ) -> (HashMap<u64, u64>, Option<JournalCheckpoint>)
Returns the journal file offsets that each object depends on and the checkpoint for the minimum offset.
Sourcepub fn journal_checkpoint(&self, object_id: u64) -> Option<JournalCheckpoint>
pub fn journal_checkpoint(&self, object_id: u64) -> Option<JournalCheckpoint>
Returns the checkpoint into the journal that the object depends on, or None if the object has no journaled updates.
Sourcepub fn needs_flush(&self, object_id: u64) -> bool
pub fn needs_flush(&self, object_id: u64) -> bool
Returns true if the object identified by object_id is known to have updates recorded in
the journal that the object depends upon.
Sourcepub async fn flush(&self, reason: FlushReason) -> Result<Version, Error>
pub async fn flush(&self, reason: FlushReason) -> Result<Version, Error>
Flushes changes to device with the given reason. Also returns the earliest known version of a struct on the filesystem.
pub fn journaling_object( &self, object_id: u64, ) -> Option<Arc<dyn JournalingObject>>
Sourcepub async fn init_metadata_reservation(&self) -> Result<(), Error>
pub async fn init_metadata_reservation(&self) -> Result<(), Error>
Initializes the live metadata_reservation from the allocator after journal replay and
opening all volumes.
pub fn metadata_reservation(&self) -> &Reservation
pub fn is_metadata_reservation(&self, reservation: &Reservation) -> bool
Sourcepub fn reconcile_metadata_reservation(
&self,
checkpoint_offset: u64,
) -> HashMap<u64, u64>
pub fn reconcile_metadata_reservation( &self, checkpoint_offset: u64, ) -> HashMap<u64, u64>
Reconciles the metadata reservation at checkpoint_offset (returning any excess over
required_reservation() to the allocator) and returns the map to persist in the
super-block (key 0 for M_total, and child store IDs for each child store’s flushed
store_borrowed).
Sourcepub fn update_layer_size(&self, object_id: u64, layer_size: u64)
pub fn update_layer_size(&self, object_id: u64, layer_size: u64)
Sets the tree layer size (layer_size) for object_id.
Sourcepub fn store_borrowed_for_flush(
&self,
object_id: u64,
old_size: u64,
new_size: u64,
total_layer_size: u64,
) -> u64
pub fn store_borrowed_for_flush( &self, object_id: u64, old_size: u64, new_size: u64, total_layer_size: u64, ) -> u64
Returns the new flushed layer borrowing (store_borrowed) for object_id when a minor or
locked flush changes its layer size from old_size to new_size (with total layer size
total_layer_size).
pub fn reservation(&self, object_id: u64) -> Option<u64>
Sourcepub fn max_store_reservation(&self) -> u64
pub fn max_store_reservation(&self) -> u64
Returns the maximum layer reservation held by any object.
pub fn set_reserved_space(&self, amount: u64)
pub fn last_end_offset(&self) -> u64
pub fn set_last_end_offset(&self, v: u64)
Sourcepub fn borrowed_metadata_space(&self) -> u64
pub fn borrowed_metadata_space(&self) -> u64
Returns the total borrowed metadata space.
Sourcepub fn stores_borrowed(&self) -> HashMap<u64, u64>
pub fn stores_borrowed(&self) -> HashMap<u64, u64>
Returns the total borrowed metadata space for each child store.
Sourcepub fn init_replay_metadata_reservation(
&self,
version: Version,
reserved: &HashMap<u64, u64>,
)
pub fn init_replay_metadata_reservation( &self, version: Version, reserved: &HashMap<u64, u64>, )
Initializes the replay metadata reservation state from the super-block header before
replaying the journal. For < V61 super-blocks, key 0 holds the legacy borrowed
scalar; for >= V61 super-blocks, key 0 holds M_total and non-zero keys hold each
child store’s borrowed space B_S.
pub fn write_mutations( &self, object_id: u64, mutations: ObjectMutationIterator<'_, '_>, writer: Writer<'_>, )
pub fn unlocked_stores(&self) -> Vec<Arc<ObjectStore>>
Sourcepub fn track_statistics(self: &Arc<Self>, parent: &Node, name: &str)
pub fn track_statistics(self: &Arc<Self>, parent: &Node, name: &str)
Creates a lazy inspect node named str under parent which will yield statistics for the
object manager when queried.
Sourcepub fn needs_borrow_for_journal(&self, checkpoint: u64) -> bool
pub fn needs_borrow_for_journal(&self, checkpoint: u64) -> bool
Normally, we make new transactions pay for overheads incurred by the journal, such as checksums and padding, but if the journal has discarded a significant amount after a replay, we run the risk of there not being enough reserved. To handle this, if the amount is significant, we force the journal to borrow the space (using a journal created transaction).
We allow up to BLOCK_SIZE + 64 bytes before borrowing to cover up to a full block of
padding (from pad_to_block or skip_to_end_of_block) plus any RESET version, Discard,
or DidFlushDevice records written in pre_commit.
Auto Trait Implementations§
impl !Freeze for ObjectManager
impl !RefUnwindSafe for ObjectManager
impl !Unpin for ObjectManager
impl !UnwindSafe for ObjectManager
impl Send for ObjectManager
impl Sync for ObjectManager
impl UnsafeUnpin for ObjectManager
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
fn fidl_into_native(self) -> Box<N>
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