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
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>)
pub fn is_system_store(&self, store_id: u64) -> bool
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 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)>,
journal_offsets: &HashMap<u64, u64>,
context: &ApplyContext<'_, '_>,
end_offset: u64,
) -> Result<(), Error>
pub async fn replay_mutations( &self, mutations: Vec<(u64, Mutation)>, journal_offsets: &HashMap<u64, u64>, context: &ApplyContext<'_, '_>, end_offset: u64, ) -> 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<Option<Mutation>, Error>
pub fn apply_transaction( &self, transaction: &mut Transaction<'_>, checkpoint: &JournalCheckpoint, ) -> Result<Option<Mutation>, Error>
Called by the journaling system to apply a transaction. checkpoint
indicates the location
in the journal file for this transaction. Returns an optional mutation to be written to be
included with the transaction.
Sourcepub fn did_commit_transaction(
&self,
transaction: &mut Transaction<'_>,
_checkpoint: &JournalCheckpoint,
end_offset: u64,
)
pub fn did_commit_transaction( &self, transaction: &mut Transaction<'_>, _checkpoint: &JournalCheckpoint, end_offset: u64, )
Called by the journaling system after a transaction has been written providing the end offset for the transaction so that we can adjust borrowed metadata space 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) -> Result<Version, Error>
pub async fn flush(&self) -> Result<Version, Error>
Flushes all known objects. This will then allow the journal space to be freed.
Also returns the earliest known version of a struct on the filesystem.
pub fn init_metadata_reservation(&self) -> Result<(), Error>
pub fn metadata_reservation(&self) -> &Reservation
pub fn update_reservation(&self, object_id: u64, amount: u64)
pub fn reservation(&self, object_id: u64) -> Option<u64>
pub fn set_reserved_space(&self, amount: u64)
pub fn last_end_offset(&self) -> u64
pub fn set_last_end_offset(&self, v: u64)
pub fn borrowed_metadata_space(&self) -> u64
pub fn set_borrowed_metadata_space(&self, v: u64)
pub fn write_mutation( &self, object_id: u64, mutation: &Mutation, 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).
Auto Trait Implementations§
impl !Freeze for ObjectManager
impl !RefUnwindSafe for ObjectManager
impl Send for ObjectManager
impl Sync for ObjectManager
impl !Unpin for ObjectManager
impl !UnwindSafe 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
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
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