libfoedus-core
FOEDUS Core Library
|
Storage Manager class that provides API to create/open/close/drop key-value stores. More...
Storage Manager class that provides API to create/open/close/drop key-value stores.
Definition at line 46 of file storage_manager.hpp.
#include <storage_manager.hpp>
Public Member Functions | |
StorageManager (Engine *engine) | |
~StorageManager () | |
StorageManager ()=delete | |
StorageManager (const StorageManager &)=delete | |
StorageManager & | operator= (const StorageManager &)=delete |
Engine * | get_engine () const |
ErrorStack | initialize () override |
Acquires resources in this object, usually called right after constructor. More... | |
bool | is_initialized () const override |
Returns whether the object has been already initialized or not. More... | |
ErrorStack | uninitialize () override |
An idempotent method to release all resources of this object, if any. More... | |
ErrorStack | reinitialize_for_recovered_snapshot () |
Special method called only from recovery manager. More... | |
StorageId | issue_next_storage_id () |
Issue a unique and atomically/monotonically increasing storage ID for a new storage. More... | |
StorageId | get_largest_storage_id () |
Returns the largest StorageId that does or did exist. More... | |
const StorageName & | get_name (StorageId id) |
Returns the name of the given storage ID. More... | |
StorageControlBlock * | get_storage (StorageId id) |
Returns the storage of given ID. More... | |
array::ArrayStorage | get_array (StorageId id) |
Returns the array storage of given ID. More... | |
hash::HashStorage | get_hash (StorageId id) |
Returns the hash storage of given ID. More... | |
sequential::SequentialStorage | get_sequential (StorageId id) |
Returns the sequential storage of given ID. More... | |
masstree::MasstreeStorage | get_masstree (StorageId id) |
Returns the masstree storage of given ID. More... | |
StorageControlBlock * | get_storage (const StorageName &name) |
Returns the storage of given name. More... | |
array::ArrayStorage | get_array (const StorageName &name) |
Returns the array storage of given name. More... | |
hash::HashStorage | get_hash (const StorageName &name) |
Returns the hash storage of given name. More... | |
sequential::SequentialStorage | get_sequential (const StorageName &name) |
Returns the sequential storage of given name. More... | |
masstree::MasstreeStorage | get_masstree (const StorageName &name) |
Returns the masstree storage of given name. More... | |
ErrorStack | drop_storage (StorageId id, Epoch *commit_epoch) |
Removes the storage object. More... | |
void | drop_storage_apply (StorageId id) |
This is called while restart to apply DROP STORAGE logs. More... | |
ErrorStack | create_storage (Metadata *metadata, Epoch *commit_epoch) |
Newly creates a storage with the specified metadata and registers it to this manager. More... | |
void | create_storage_apply (const Metadata &metadata) |
This is called while restart to apply CREATE STORAGE logs. More... | |
ErrorStack | create_array (array::ArrayMetadata *metadata, array::ArrayStorage *storage, Epoch *commit_epoch) |
Just a type-wrapper of create_storage() for array storages. More... | |
ErrorStack | create_hash (hash::HashMetadata *metadata, hash::HashStorage *storage, Epoch *commit_epoch) |
Just a type-wrapper of create_storage() for hash storages. More... | |
ErrorStack | create_sequential (sequential::SequentialMetadata *metadata, sequential::SequentialStorage *storage, Epoch *commit_epoch) |
Just a type-wrapper of create_storage() for sequential storages. More... | |
ErrorStack | create_masstree (masstree::MasstreeMetadata *metadata, masstree::MasstreeStorage *storage, Epoch *commit_epoch) |
Just a type-wrapper of create_storage() for masstree storages. More... | |
ErrorStack | clone_all_storage_metadata (snapshot::SnapshotMetadata *metadata) |
This method is called during snapshotting to clone metadata of all existing storages to the given object. More... | |
xct::TrackMovedRecordResult | track_moved_record (StorageId storage_id, xct::RwLockableXctId *old_address, xct::WriteXctAccess *write_set) |
Resolves a "moved" record. More... | |
StorageManagerPimpl * | get_pimpl () |
Returns pimpl object. More... | |
![]() | |
virtual | ~Initializable () |
|
explicit |
Definition at line 34 of file storage_manager.cpp.
foedus::storage::StorageManager::~StorageManager | ( | ) |
Definition at line 37 of file storage_manager.cpp.
|
delete |
|
delete |
ErrorStack foedus::storage::StorageManager::clone_all_storage_metadata | ( | snapshot::SnapshotMetadata * | metadata | ) |
This method is called during snapshotting to clone metadata of all existing storages to the given object.
Definition at line 119 of file storage_manager.cpp.
References foedus::storage::StorageManagerPimpl::clone_all_storage_metadata().
Referenced by foedus::snapshot::SnapshotManagerPimpl::snapshot_metadata().
ErrorStack foedus::storage::StorageManager::create_array | ( | array::ArrayMetadata * | metadata, |
array::ArrayStorage * | storage, | ||
Epoch * | commit_epoch | ||
) |
Just a type-wrapper of create_storage() for array storages.
Definition at line 83 of file storage_manager.cpp.
References CHECK_ERROR, create_storage(), get_array(), foedus::storage::Metadata::id_, and foedus::kRetOk.
ErrorStack foedus::storage::StorageManager::create_hash | ( | hash::HashMetadata * | metadata, |
hash::HashStorage * | storage, | ||
Epoch * | commit_epoch | ||
) |
Just a type-wrapper of create_storage() for hash storages.
Definition at line 92 of file storage_manager.cpp.
References CHECK_ERROR, create_storage(), get_hash(), foedus::storage::Metadata::id_, and foedus::kRetOk.
ErrorStack foedus::storage::StorageManager::create_masstree | ( | masstree::MasstreeMetadata * | metadata, |
masstree::MasstreeStorage * | storage, | ||
Epoch * | commit_epoch | ||
) |
Just a type-wrapper of create_storage() for masstree storages.
Definition at line 110 of file storage_manager.cpp.
References CHECK_ERROR, create_storage(), get_masstree(), foedus::storage::Metadata::id_, and foedus::kRetOk.
ErrorStack foedus::storage::StorageManager::create_sequential | ( | sequential::SequentialMetadata * | metadata, |
sequential::SequentialStorage * | storage, | ||
Epoch * | commit_epoch | ||
) |
Just a type-wrapper of create_storage() for sequential storages.
Definition at line 101 of file storage_manager.cpp.
References CHECK_ERROR, create_storage(), get_sequential(), foedus::storage::Metadata::id_, and foedus::kRetOk.
ErrorStack foedus::storage::StorageManager::create_storage | ( | Metadata * | metadata, |
Epoch * | commit_epoch | ||
) |
Newly creates a storage with the specified metadata and registers it to this manager.
[in,out] | metadata | Specifies metadata of the newly created storage, such as name. The metadata object must be an instance of derived metadata such as ArrayMetadata. This method, when succeeded, changes only one property of the given metadata; id_. |
[out] | commit_epoch | The epoch at whose end the storage is really deemed as created. |
Definition at line 76 of file storage_manager.cpp.
References foedus::storage::StorageManagerPimpl::create_storage().
Referenced by create_array(), create_hash(), create_masstree(), and create_sequential().
void foedus::storage::StorageManager::create_storage_apply | ( | const Metadata & | metadata | ) |
This is called while restart to apply CREATE STORAGE logs.
Definition at line 79 of file storage_manager.cpp.
References foedus::storage::StorageManagerPimpl::create_storage_apply().
Referenced by foedus::storage::CreateLogType::apply_storage().
ErrorStack foedus::storage::StorageManager::drop_storage | ( | StorageId | id, |
Epoch * | commit_epoch | ||
) |
Removes the storage object.
[in] | id | ID of the storage to remove |
[out] | commit_epoch | The epoch at whose end the storage is really deemed as deleted. |
This method is idempotent, although it logs warning for non-existing id.
Definition at line 69 of file storage_manager.cpp.
References foedus::storage::StorageManagerPimpl::drop_storage().
void foedus::storage::StorageManager::drop_storage_apply | ( | StorageId | id | ) |
This is called while restart to apply DROP STORAGE logs.
Definition at line 72 of file storage_manager.cpp.
References foedus::storage::StorageManagerPimpl::drop_storage_apply().
Referenced by foedus::storage::DropLogType::apply_storage(), and foedus::restart::RestartManagerPimpl::redo_meta_logs().
|
inline |
Returns the array storage of given ID.
[in] | id | Storage ID |
Definition at line 94 of file storage_manager.hpp.
References get_engine(), and get_storage().
Referenced by create_array().
|
inline |
Returns the array storage of given name.
[in] | name | Storage name |
Definition at line 140 of file storage_manager.hpp.
References get_engine(), and get_storage().
Engine * foedus::storage::StorageManager::get_engine | ( | ) | const |
Definition at line 42 of file storage_manager.cpp.
References foedus::storage::StorageManagerPimpl::engine_.
Referenced by get_array(), get_hash(), get_masstree(), and get_sequential().
|
inline |
Returns the hash storage of given ID.
[in] | id | Storage ID |
Definition at line 103 of file storage_manager.hpp.
References get_engine(), and get_storage().
Referenced by create_hash().
|
inline |
Returns the hash storage of given name.
[in] | name | Storage name |
Definition at line 149 of file storage_manager.hpp.
References get_engine(), and get_storage().
StorageId foedus::storage::StorageManager::get_largest_storage_id | ( | ) |
Returns the largest StorageId that does or did exist.
Definition at line 55 of file storage_manager.cpp.
References foedus::storage::StorageManagerPimpl::control_block_, and foedus::storage::StorageManagerControlBlock::largest_storage_id_.
Referenced by foedus::snapshot::SnapshotManagerPimpl::handle_snapshot_triggered().
|
inline |
Returns the masstree storage of given ID.
[in] | id | Storage ID |
Definition at line 121 of file storage_manager.hpp.
References get_engine(), and get_storage().
Referenced by create_masstree().
|
inline |
Returns the masstree storage of given name.
[in] | name | Storage name |
Definition at line 167 of file storage_manager.hpp.
References get_engine(), and get_storage().
const StorageName & foedus::storage::StorageManager::get_name | ( | StorageId | id | ) |
Returns the name of the given storage ID.
Definition at line 60 of file storage_manager.cpp.
References foedus::storage::StorageControlBlock::exists(), get_storage(), foedus::storage::kEmptyString, foedus::storage::StorageControlBlock::meta_, and foedus::storage::Metadata::name_.
Referenced by foedus::xct::XctManagerPimpl::precommit_xct_apply(), foedus::xct::XctManagerPimpl::precommit_xct_verify_readonly(), and foedus::xct::XctManagerPimpl::precommit_xct_verify_readwrite().
|
inline |
Returns pimpl object.
Use this only if you know what you are doing.
Definition at line 252 of file storage_manager.hpp.
|
inline |
Returns the sequential storage of given ID.
[in] | id | Storage ID |
Definition at line 112 of file storage_manager.hpp.
References get_engine(), and get_storage().
Referenced by foedus::storage::sequential::SequentialAppendLogType::apply_record(), and create_sequential().
|
inline |
Returns the sequential storage of given name.
[in] | name | Storage name |
Definition at line 158 of file storage_manager.hpp.
References get_engine(), and get_storage().
StorageControlBlock * foedus::storage::StorageManager::get_storage | ( | StorageId | id | ) |
Returns the storage of given ID.
[in] | id | Storage ID |
Definition at line 47 of file storage_manager.cpp.
References foedus::storage::StorageManagerPimpl::get_storage().
Referenced by foedus::snapshot::SnapshotManagerPimpl::drop_volatile_pages_parallel(), get_array(), get_hash(), get_masstree(), get_name(), get_sequential(), foedus::storage::get_storage_control_block(), and foedus::storage::Partitioner::Partitioner().
StorageControlBlock * foedus::storage::StorageManager::get_storage | ( | const StorageName & | name | ) |
Returns the storage of given name.
This one is convenient, but prefer get_storage(StorageId) for better performance. Or, write your code so that you don't have to invoke this method too often.
[in] | name | Storage name |
Definition at line 50 of file storage_manager.cpp.
References foedus::storage::StorageManagerPimpl::get_storage().
|
overridevirtual |
Acquires resources in this object, usually called right after constructor.
If and only if the return value was not an error, is_initialized() will return TRUE. This method is usually not idempotent, but some implementation can choose to be. In that case, the implementation class should clarify that it's idempotent. This method is responsible for releasing all acquired resources when initialization fails. This method itself is NOT thread-safe. Do not call this in a racy situation.
Implements foedus::Initializable.
Definition at line 43 of file storage_manager.cpp.
References foedus::DefaultInitializable::initialize().
|
overridevirtual |
Returns whether the object has been already initialized or not.
Implements foedus::Initializable.
Definition at line 44 of file storage_manager.cpp.
References foedus::DefaultInitializable::is_initialized().
Referenced by foedus::snapshot::SnapshotManagerPimpl::handle_snapshot_triggered(), foedus::xct::XctManagerPimpl::initialize_once(), and foedus::xct::XctManagerPimpl::uninitialize_once().
StorageId foedus::storage::StorageManager::issue_next_storage_id | ( | ) |
Issue a unique and atomically/monotonically increasing storage ID for a new storage.
The caller might later fail, so StorageId might have holes.
Definition at line 54 of file storage_manager.cpp.
References foedus::storage::StorageManagerPimpl::issue_next_storage_id().
|
delete |
ErrorStack foedus::storage::StorageManager::reinitialize_for_recovered_snapshot | ( | ) |
Special method called only from recovery manager.
Definition at line 154 of file storage_manager_pimpl.cpp.
References foedus::storage::StorageManagerPimpl::reinitialize_for_recovered_snapshot().
Referenced by foedus::restart::RestartManagerPimpl::recover().
xct::TrackMovedRecordResult foedus::storage::StorageManager::track_moved_record | ( | StorageId | storage_id, |
xct::RwLockableXctId * | old_address, | ||
xct::WriteXctAccess * | write_set | ||
) |
Resolves a "moved" record.
This is the core of the moved-bit protocol. Receiving a xct_id address that points to a moved record, track the physical record in another page. This method does not take lock, so it is possible that concurrent threads again move the record after this. The only case it fails to track is the record moved to deeper layers. If the write-set is supplied, we use the key information in it to track even in that case.
Definition at line 445 of file storage_manager_pimpl.cpp.
References foedus::storage::StorageManagerPimpl::track_moved_record().
Referenced by foedus::xct::XctManagerPimpl::precommit_xct_verify_track_read().
|
overridevirtual |
An idempotent method to release all resources of this object, if any.
After this method, is_initialized() will return FALSE. Whether this method encounters an error or not, the implementation should make the best effort to release as many resources as possible. In other words, Do not leak all resources because of one issue. This method itself is NOT thread-safe. Do not call this in a racy situation.
Implements foedus::Initializable.
Definition at line 45 of file storage_manager.cpp.
References foedus::DefaultInitializable::uninitialize().