libfoedus-core
FOEDUS Core Library
foedus::snapshot::SnapshotManager Class Referencefinal

Snapshot manager that atomically and durably writes out a snapshot file. More...

Detailed Description

Snapshot manager that atomically and durably writes out a snapshot file.

Definition at line 31 of file snapshot_manager.hpp.

#include <snapshot_manager.hpp>

Inheritance diagram for foedus::snapshot::SnapshotManager:
Collaboration diagram for foedus::snapshot::SnapshotManager:

Public Member Functions

 SnapshotManager (Engine *engine)
 
 ~SnapshotManager ()
 
 SnapshotManager ()=delete
 
 SnapshotManager (const SnapshotManager &)=delete
 
SnapshotManageroperator= (const SnapshotManager &)=delete
 
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...
 
Epoch get_snapshot_epoch () const
 Returns the most recently snapshot-ed epoch, all logs upto this epoch is safe to delete. More...
 
Epoch get_snapshot_epoch_weak () const
 Non-atomic version. More...
 
SnapshotId get_previous_snapshot_id () const
 Returns the most recent snapshot's ID. More...
 
SnapshotId get_previous_snapshot_id_weak () const
 Non-atomic version. More...
 
ErrorStack read_snapshot_metadata (SnapshotId snapshot_id, SnapshotMetadata *out)
 Read the snapshot metadata file that contains storages as of the snapshot. More...
 
void trigger_snapshot_immediate (bool wait_completion, Epoch suggested_snapshot_epoch=INVALID_EPOCH)
 Immediately take a snapshot. More...
 
SnapshotManagerPimplget_pimpl ()
 Do not use this unless you know what you are doing. More...
 
- Public Member Functions inherited from foedus::Initializable
virtual ~Initializable ()
 

Constructor & Destructor Documentation

foedus::snapshot::SnapshotManager::SnapshotManager ( Engine engine)
explicit

Definition at line 22 of file snapshot_manager.cpp.

22  : pimpl_(nullptr) {
23  pimpl_ = new SnapshotManagerPimpl(engine);
24 }
foedus::snapshot::SnapshotManager::~SnapshotManager ( )

Definition at line 25 of file snapshot_manager.cpp.

25  {
26  delete pimpl_;
27  pimpl_ = nullptr;
28 }
foedus::snapshot::SnapshotManager::SnapshotManager ( )
delete
foedus::snapshot::SnapshotManager::SnapshotManager ( const SnapshotManager )
delete

Member Function Documentation

SnapshotManagerPimpl* foedus::snapshot::SnapshotManager::get_pimpl ( )
inline

Do not use this unless you know what you are doing.

Definition at line 79 of file snapshot_manager.hpp.

Referenced by foedus::restart::RestartManagerPimpl::recover(), and foedus::restart::RestartManagerPimpl::uninitialize_once().

79 { return pimpl_; }

Here is the caller graph for this function:

SnapshotId foedus::snapshot::SnapshotManager::get_previous_snapshot_id ( ) const

Returns the most recent snapshot's ID.

kNullSnapshotId if no snapshot is taken.

Definition at line 39 of file snapshot_manager.cpp.

References foedus::snapshot::SnapshotManagerPimpl::get_previous_snapshot_id().

39  {
40  return pimpl_->get_previous_snapshot_id();
41 }

Here is the call graph for this function:

SnapshotId foedus::snapshot::SnapshotManager::get_previous_snapshot_id_weak ( ) const

Non-atomic version.

Definition at line 43 of file snapshot_manager.cpp.

References foedus::snapshot::SnapshotManagerPimpl::get_previous_snapshot_id_weak().

43  {
44  return pimpl_->get_previous_snapshot_id_weak();
45 }

Here is the call graph for this function:

Epoch foedus::snapshot::SnapshotManager::get_snapshot_epoch ( ) const

Returns the most recently snapshot-ed epoch, all logs upto this epoch is safe to delete.

If not snapshot has been taken, invalid epoch.

Definition at line 34 of file snapshot_manager.cpp.

References foedus::snapshot::SnapshotManagerPimpl::get_snapshot_epoch().

Referenced by foedus::restart::RestartManagerPimpl::recover().

34 { return pimpl_->get_snapshot_epoch(); }

Here is the call graph for this function:

Here is the caller graph for this function:

Epoch foedus::snapshot::SnapshotManager::get_snapshot_epoch_weak ( ) const

Non-atomic version.

Definition at line 35 of file snapshot_manager.cpp.

References foedus::snapshot::SnapshotManagerPimpl::get_snapshot_epoch_weak().

35  {
36  return pimpl_->get_snapshot_epoch_weak();
37 }

Here is the call graph for this function:

ErrorStack foedus::snapshot::SnapshotManager::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 30 of file snapshot_manager.cpp.

References foedus::DefaultInitializable::initialize().

30 { 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::snapshot::SnapshotManager::is_initialized ( ) const
overridevirtual

Returns whether the object has been already initialized or not.

Implements foedus::Initializable.

Definition at line 31 of file snapshot_manager.cpp.

References foedus::DefaultInitializable::is_initialized().

31 { 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:

SnapshotManager& foedus::snapshot::SnapshotManager::operator= ( const SnapshotManager )
delete
ErrorStack foedus::snapshot::SnapshotManager::read_snapshot_metadata ( SnapshotId  snapshot_id,
SnapshotMetadata out 
)

Read the snapshot metadata file that contains storages as of the snapshot.

This is used only when the engine starts up.

Definition at line 47 of file snapshot_manager.cpp.

References foedus::snapshot::SnapshotManagerPimpl::read_snapshot_metadata().

Referenced by foedus::storage::StorageManagerPimpl::initialize_read_latest_snapshot().

47  {
48  return pimpl_->read_snapshot_metadata(snapshot_id, out);
49 }
ErrorStack read_snapshot_metadata(SnapshotId snapshot_id, SnapshotMetadata *out)

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::snapshot::SnapshotManager::trigger_snapshot_immediate ( bool  wait_completion,
Epoch  suggested_snapshot_epoch = INVALID_EPOCH 
)

Immediately take a snapshot.

Parameters
[in]wait_completionwhether to block until the completion of entire snapshotting
[in]suggested_snapshot_epochthe epoch up to which we will snapshot. Must be a durable epoch that is after the previous snapshot epoch. If not specified, the latest durable epoch is used, which is in most cases what you want.

This method is used to immediately take snapshot for either recovery or memory-saving purpose.

Definition at line 52 of file snapshot_manager.cpp.

References foedus::snapshot::SnapshotManagerPimpl::trigger_snapshot_immediate().

54  {
55  pimpl_->trigger_snapshot_immediate(wait_completion, suggested_snapshot_epoch);
56 }
void trigger_snapshot_immediate(bool wait_completion, Epoch suggested_snapshot_epoch)

Here is the call graph for this function:

ErrorStack foedus::snapshot::SnapshotManager::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 32 of file snapshot_manager.cpp.

References foedus::DefaultInitializable::uninitialize().

32 { 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: