libfoedus-core
FOEDUS Core Library
foedus::storage::StorageManager Class Referencefinal

Storage Manager class that provides API to create/open/close/drop key-value stores. More...

Detailed Description

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>

Inheritance diagram for foedus::storage::StorageManager:
Collaboration diagram for foedus::storage::StorageManager:

Public Member Functions

 StorageManager (Engine *engine)
 
 ~StorageManager ()
 
 StorageManager ()=delete
 
 StorageManager (const StorageManager &)=delete
 
StorageManageroperator= (const StorageManager &)=delete
 
Engineget_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 StorageNameget_name (StorageId id)
 Returns the name of the given storage ID. More...
 
StorageControlBlockget_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...
 
StorageControlBlockget_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...
 
StorageManagerPimplget_pimpl ()
 Returns pimpl object. More...
 
- Public Member Functions inherited from foedus::Initializable
virtual ~Initializable ()
 

Constructor & Destructor Documentation

foedus::storage::StorageManager::StorageManager ( Engine engine)
explicit

Definition at line 34 of file storage_manager.cpp.

34  : pimpl_(nullptr) {
35  pimpl_ = new StorageManagerPimpl(engine);
36 }
foedus::storage::StorageManager::~StorageManager ( )

Definition at line 37 of file storage_manager.cpp.

37  {
38  delete pimpl_;
39  pimpl_ = nullptr;
40 }
foedus::storage::StorageManager::StorageManager ( )
delete
foedus::storage::StorageManager::StorageManager ( const StorageManager )
delete

Member Function Documentation

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().

119  {
120  return pimpl_->clone_all_storage_metadata(metadata);
121 }
ErrorStack clone_all_storage_metadata(snapshot::SnapshotMetadata *metadata)

Here is the call graph for this function:

Here is the caller graph for this function:

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.

See also
create_storage()

Definition at line 83 of file storage_manager.cpp.

References CHECK_ERROR, create_storage(), get_array(), foedus::storage::Metadata::id_, and foedus::kRetOk.

86  {
87  CHECK_ERROR(create_storage(metadata, commit_epoch));
88  *storage = get_array(metadata->id_);
89  return kRetOk;
90 }
array::ArrayStorage get_array(StorageId id)
Returns the array storage of given ID.
#define CHECK_ERROR(x)
This macro calls x and checks its returned value.
const ErrorStack kRetOk
Normal return value for no-error case.
ErrorStack create_storage(Metadata *metadata, Epoch *commit_epoch)
Newly creates a storage with the specified metadata and registers it to this manager.

Here is the call graph for this function:

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.

See also
create_storage()

Definition at line 92 of file storage_manager.cpp.

References CHECK_ERROR, create_storage(), get_hash(), foedus::storage::Metadata::id_, and foedus::kRetOk.

95  {
96  CHECK_ERROR(create_storage(metadata, commit_epoch));
97  *storage = get_hash(metadata->id_);
98  return kRetOk;
99 }
#define CHECK_ERROR(x)
This macro calls x and checks its returned value.
const ErrorStack kRetOk
Normal return value for no-error case.
ErrorStack create_storage(Metadata *metadata, Epoch *commit_epoch)
Newly creates a storage with the specified metadata and registers it to this manager.
hash::HashStorage get_hash(StorageId id)
Returns the hash storage of given ID.

Here is the call graph for this function:

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.

See also
create_storage()

Definition at line 110 of file storage_manager.cpp.

References CHECK_ERROR, create_storage(), get_masstree(), foedus::storage::Metadata::id_, and foedus::kRetOk.

113  {
114  CHECK_ERROR(create_storage(metadata, commit_epoch));
115  *storage = get_masstree(metadata->id_);
116  return kRetOk;
117 }
masstree::MasstreeStorage get_masstree(StorageId id)
Returns the masstree storage of given ID.
#define CHECK_ERROR(x)
This macro calls x and checks its returned value.
const ErrorStack kRetOk
Normal return value for no-error case.
ErrorStack create_storage(Metadata *metadata, Epoch *commit_epoch)
Newly creates a storage with the specified metadata and registers it to this manager.

Here is the call graph for this function:

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.

See also
create_storage()

Definition at line 101 of file storage_manager.cpp.

References CHECK_ERROR, create_storage(), get_sequential(), foedus::storage::Metadata::id_, and foedus::kRetOk.

104  {
105  CHECK_ERROR(create_storage(metadata, commit_epoch));
106  *storage = get_sequential(metadata->id_);
107  return kRetOk;
108 }
sequential::SequentialStorage get_sequential(StorageId id)
Returns the sequential storage of given ID.
#define CHECK_ERROR(x)
This macro calls x and checks its returned value.
const ErrorStack kRetOk
Normal return value for no-error case.
ErrorStack create_storage(Metadata *metadata, Epoch *commit_epoch)
Newly creates a storage with the specified metadata and registers it to this manager.

Here is the call graph for this function:

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.

Parameters
[in,out]metadataSpecifies 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_epochThe 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().

76  {
77  return pimpl_->create_storage(metadata, commit_epoch);
78 }
ErrorStack create_storage(Metadata *metadata, Epoch *commit_epoch)

Here is the call graph for this function:

Here is the caller graph for this function:

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().

79  {
80  pimpl_->create_storage_apply(metadata);
81 }
void create_storage_apply(const Metadata &metadata)

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorStack foedus::storage::StorageManager::drop_storage ( StorageId  id,
Epoch commit_epoch 
)

Removes the storage object.

Parameters
[in]idID of the storage to remove
[out]commit_epochThe 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().

69  {
70  return pimpl_->drop_storage(id, commit_epoch);
71 }
ErrorStack drop_storage(StorageId id, Epoch *commit_epoch)

Here is the call graph for this function:

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().

72  {
73  pimpl_->drop_storage_apply(id);
74 }

Here is the call graph for this function:

Here is the caller graph for this function:

array::ArrayStorage foedus::storage::StorageManager::get_array ( StorageId  id)
inline

Returns the array storage of given ID.

Parameters
[in]idStorage ID
Returns
Array Storage. If there is no storage with the ID, an empty object.

Definition at line 94 of file storage_manager.hpp.

References get_engine(), and get_storage().

Referenced by create_array().

94  {
95  return array::ArrayStorage(get_engine(), get_storage(id));
96  }
StorageControlBlock * get_storage(StorageId id)
Returns the storage of given ID.

Here is the call graph for this function:

Here is the caller graph for this function:

array::ArrayStorage foedus::storage::StorageManager::get_array ( const StorageName name)
inline

Returns the array storage of given name.

Parameters
[in]nameStorage name
Returns
Array Storage. If there is no storage with the name, an empty object.

Definition at line 140 of file storage_manager.hpp.

References get_engine(), and get_storage().

140  {
141  return array::ArrayStorage(get_engine(), get_storage(name));
142  }
StorageControlBlock * get_storage(StorageId id)
Returns the storage of given ID.

Here is the call graph for this function:

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().

42 { return pimpl_->engine_; }

Here is the caller graph for this function:

hash::HashStorage foedus::storage::StorageManager::get_hash ( StorageId  id)
inline

Returns the hash storage of given ID.

Parameters
[in]idStorage ID
Returns
Hash Storage. If there is no storage with the ID, an empty object.

Definition at line 103 of file storage_manager.hpp.

References get_engine(), and get_storage().

Referenced by create_hash().

103  {
104  return hash::HashStorage(get_engine(), get_storage(id));
105  }
StorageControlBlock * get_storage(StorageId id)
Returns the storage of given ID.

Here is the call graph for this function:

Here is the caller graph for this function:

hash::HashStorage foedus::storage::StorageManager::get_hash ( const StorageName name)
inline

Returns the hash storage of given name.

Parameters
[in]nameStorage name
Returns
Hash Storage. If there is no storage with the name, an empty object.

Definition at line 149 of file storage_manager.hpp.

References get_engine(), and get_storage().

149  {
150  return hash::HashStorage(get_engine(), get_storage(name));
151  }
StorageControlBlock * get_storage(StorageId id)
Returns the storage of given ID.

Here is the call graph for this function:

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().

55  {
56  return pimpl_->control_block_->largest_storage_id_;
57 }
StorageManagerControlBlock * control_block_
StorageId largest_storage_id_
The largest StorageId we so far observed.

Here is the caller graph for this function:

masstree::MasstreeStorage foedus::storage::StorageManager::get_masstree ( StorageId  id)
inline

Returns the masstree storage of given ID.

Parameters
[in]idStorage ID
Returns
Masstree Storage. If there is no storage with the ID, an empty object.

Definition at line 121 of file storage_manager.hpp.

References get_engine(), and get_storage().

Referenced by create_masstree().

121  {
122  return masstree::MasstreeStorage(get_engine(), get_storage(id));
123  }
StorageControlBlock * get_storage(StorageId id)
Returns the storage of given ID.

Here is the call graph for this function:

Here is the caller graph for this function:

masstree::MasstreeStorage foedus::storage::StorageManager::get_masstree ( const StorageName name)
inline

Returns the masstree storage of given name.

Parameters
[in]nameStorage name
Returns
Masstree Storage. If there is no storage with the name, an empty object.

Definition at line 167 of file storage_manager.hpp.

References get_engine(), and get_storage().

167  {
168  return masstree::MasstreeStorage(get_engine(), get_storage(name));
169  }
StorageControlBlock * get_storage(StorageId id)
Returns the storage of given ID.

Here is the call graph for this function:

const StorageName & foedus::storage::StorageManager::get_name ( StorageId  id)

Returns the name of the given storage ID.

Returns
name of the storage. If the ID doesn't exist, an empty string.

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().

60  {
61  StorageControlBlock* block = get_storage(id);
62  if (block->exists()) {
63  return block->meta_.name_;
64  } else {
65  return kEmptyString;
66  }
67 }
const StorageName kEmptyString
StorageControlBlock * get_storage(StorageId id)
Returns the storage of given ID.

Here is the call graph for this function:

Here is the caller graph for this function:

StorageManagerPimpl* foedus::storage::StorageManager::get_pimpl ( )
inline

Returns pimpl object.

Use this only if you know what you are doing.

Definition at line 252 of file storage_manager.hpp.

252 { return pimpl_; }
sequential::SequentialStorage foedus::storage::StorageManager::get_sequential ( StorageId  id)
inline

Returns the sequential storage of given ID.

Parameters
[in]idStorage ID
Returns
Sequential Storage. If there is no storage with the ID, an empty object.

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().

112  {
113  return sequential::SequentialStorage(get_engine(), get_storage(id));
114  }
StorageControlBlock * get_storage(StorageId id)
Returns the storage of given ID.

Here is the call graph for this function:

Here is the caller graph for this function:

sequential::SequentialStorage foedus::storage::StorageManager::get_sequential ( const StorageName name)
inline

Returns the sequential storage of given name.

Parameters
[in]nameStorage name
Returns
Sequential Storage. If there is no storage with the name, an empty object.

Definition at line 158 of file storage_manager.hpp.

References get_engine(), and get_storage().

158  {
159  return sequential::SequentialStorage(get_engine(), get_storage(name));
160  }
StorageControlBlock * get_storage(StorageId id)
Returns the storage of given ID.

Here is the call graph for this function:

StorageControlBlock * foedus::storage::StorageManager::get_storage ( StorageId  id)

Returns the storage of given ID.

Parameters
[in]idStorage ID
Returns
Control block of the storage in this engine. If there is no storage with the ID, the returned control block is not initialized (though not null).

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().

47  {
48  return pimpl_->get_storage(id);
49 }
StorageControlBlock * get_storage(StorageId id)

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
[in]nameStorage name
Returns
Control block of the storage in this engine. If there is no storage with the name, the returned control block is not initialized (though not null).

Definition at line 50 of file storage_manager.cpp.

References foedus::storage::StorageManagerPimpl::get_storage().

50  {
51  return pimpl_->get_storage(name);
52 }
StorageControlBlock * get_storage(StorageId id)

Here is the call graph for this function:

ErrorStack foedus::storage::StorageManager::initialize ( )
overridevirtual

Acquires resources in this object, usually called right after constructor.

Precondition
is_initialized() == FALSE

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().

43 { return pimpl_->initialize(); }
ErrorStack initialize() override final
Typical implementation of Initializable::initialize() that provides initialize-once semantics...

Here is the call graph for this function:

bool foedus::storage::StorageManager::is_initialized ( ) const
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().

44 { return pimpl_->is_initialized(); }
bool is_initialized() const override final
Returns whether the object has been already initialized or not.

Here is the call graph for this function:

Here is the caller graph for this function:

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().

54 { return pimpl_->issue_next_storage_id(); }

Here is the call graph for this function:

StorageManager& foedus::storage::StorageManager::operator= ( const StorageManager )
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().

154  {
155  return pimpl_->reinitialize_for_recovered_snapshot();
156 }
ErrorStack reinitialize_for_recovered_snapshot()
Special method called only from recovery manager.

Here is the call graph for this function:

Here is the caller graph for this function:

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().

448  {
449  return pimpl_->track_moved_record(storage_id, old_address, write_set);
450 }
xct::TrackMovedRecordResult track_moved_record(StorageId storage_id, xct::RwLockableXctId *old_address, xct::WriteXctAccess *write)

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorStack foedus::storage::StorageManager::uninitialize ( )
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.

Attention
This method is NOT automatically called from the destructor. This is due to the fundamental limitation in C++. Explicitly call this method as soon as you are done, checking the returned value. You can also use UninitializeGuard to ameliorate the issue, but it's not perfect.
Returns
The error this method encounters, if any. In case there are multiple errors while uninitialization, the implementation should use ErrorStackBatch to produce a batched ErrorStack object.

Implements foedus::Initializable.

Definition at line 45 of file storage_manager.cpp.

References foedus::DefaultInitializable::uninitialize().

45 { return pimpl_->uninitialize(); }
ErrorStack uninitialize() override final
Typical implementation of Initializable::uninitialize() that provides uninitialize-once semantics...

Here is the call graph for this function:


The documentation for this class was generated from the following files: