libfoedus-core
FOEDUS Core Library
foedus::savepoint::SavepointManager Class Referencefinal

Savepoint manager that atomically and durably writes out a savepoint file. More...

Detailed Description

Savepoint manager that atomically and durably writes out a savepoint file.

Definition at line 32 of file savepoint_manager.hpp.

#include <savepoint_manager.hpp>

Inheritance diagram for foedus::savepoint::SavepointManager:
Collaboration diagram for foedus::savepoint::SavepointManager:

Public Member Functions

 SavepointManager (Engine *engine)
 
 ~SavepointManager ()
 
 SavepointManager ()=delete
 
 SavepointManager (const SavepointManager &)=delete
 
SavepointManageroperator= (const SavepointManager &)=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...
 
LoggerSavepointInfo get_logger_savepoint (log::LoggerId logger_id)
 Returns the saved information of the given logger in latest savepoint. More...
 
void get_meta_logger_offsets (uint64_t *oldest_offset, uint64_t *durable_offset) const
 Returns the saved information of metadata logger in lateset savepoint. More...
 
void change_meta_logger_durable_offset (uint64_t durable_offset)
 Rewrites meta logger's durable_offset. More...
 
Epoch get_initial_current_epoch () const
 
Epoch get_initial_durable_epoch () const
 
Epoch get_earliest_epoch () const
 
Epoch get_saved_durable_epoch () const
 
snapshot::SnapshotId get_latest_snapshot_id () const
 
Epoch get_latest_snapshot_epoch () const
 
ErrorStack take_savepoint (Epoch new_global_durable_epoch)
 Atomically and durably takes a savepoint for the given epoch advancement. More...
 
ErrorStack take_savepoint_after_snapshot (snapshot::SnapshotId new_snapshot_id, Epoch new_snapshot_epoch)
 Takes a savepoint just to remember the newly taken snapshot. More...
 
- Public Member Functions inherited from foedus::Initializable
virtual ~Initializable ()
 

Constructor & Destructor Documentation

foedus::savepoint::SavepointManager::SavepointManager ( Engine engine)
explicit

Definition at line 24 of file savepoint_manager.cpp.

24  : pimpl_(nullptr) {
25  pimpl_ = new SavepointManagerPimpl(engine);
26 }
foedus::savepoint::SavepointManager::~SavepointManager ( )

Definition at line 27 of file savepoint_manager.cpp.

27  {
28  delete pimpl_;
29  pimpl_ = nullptr;
30 }
foedus::savepoint::SavepointManager::SavepointManager ( )
delete
foedus::savepoint::SavepointManager::SavepointManager ( const SavepointManager )
delete

Member Function Documentation

void foedus::savepoint::SavepointManager::change_meta_logger_durable_offset ( uint64_t  durable_offset)

Rewrites meta logger's durable_offset.

This is required because meta logger might adjust its "locally durable" offset at startup. Once we emit "globally durable" offset of meta logger in savepoint, we won't need it. but we do for now.

Definition at line 76 of file savepoint_manager.cpp.

References ASSERT_ND, foedus::savepoint::SavepointManagerPimpl::control_block_, foedus::savepoint::FixedSavepoint::meta_log_durable_offset_, and foedus::savepoint::SavepointManagerControlBlock::savepoint_.

76  {
77  ASSERT_ND(pimpl_->control_block_->savepoint_.meta_log_durable_offset_ >= durable_offset);
78  pimpl_->control_block_->savepoint_.meta_log_durable_offset_ = durable_offset;
79 }
FixedSavepoint savepoint_
The content of latest savepoint.
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72
Epoch foedus::savepoint::SavepointManager::get_earliest_epoch ( ) const

Definition at line 42 of file savepoint_manager.cpp.

References foedus::savepoint::SavepointManagerPimpl::get_earliest_epoch().

Referenced by foedus::Engine::get_earliest_epoch().

42  {
43  return pimpl_->get_earliest_epoch();
44 }

Here is the call graph for this function:

Here is the caller graph for this function:

Epoch foedus::savepoint::SavepointManager::get_initial_current_epoch ( ) const
Epoch foedus::savepoint::SavepointManager::get_initial_durable_epoch ( ) const
Epoch foedus::savepoint::SavepointManager::get_latest_snapshot_epoch ( ) const

Definition at line 52 of file savepoint_manager.cpp.

References foedus::savepoint::SavepointManagerPimpl::get_latest_snapshot_epoch().

Referenced by foedus::snapshot::SnapshotManagerPimpl::initialize_once(), and foedus::snapshot::SnapshotManagerPimpl::snapshot_savepoint().

52  {
53  return pimpl_->get_latest_snapshot_epoch();
54 }

Here is the call graph for this function:

Here is the caller graph for this function:

snapshot::SnapshotId foedus::savepoint::SavepointManager::get_latest_snapshot_id ( ) const
LoggerSavepointInfo foedus::savepoint::SavepointManager::get_logger_savepoint ( log::LoggerId  logger_id)

Returns the saved information of the given logger in latest savepoint.

Note that this is a read-only access, which might see a stale information if it's in race condition. However, we take a lock before copying the entire information. Thus, this method is slow but safe. No garbage information returned.

Definition at line 65 of file savepoint_manager.cpp.

References foedus::savepoint::SavepointManagerPimpl::get_logger_savepoint().

Referenced by foedus::log::Logger::initialize_once().

65  {
66  return pimpl_->get_logger_savepoint(logger_id);
67 }
LoggerSavepointInfo get_logger_savepoint(log::LoggerId logger_id)

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::savepoint::SavepointManager::get_meta_logger_offsets ( uint64_t *  oldest_offset,
uint64_t *  durable_offset 
) const
Epoch foedus::savepoint::SavepointManager::get_saved_durable_epoch ( ) const

Definition at line 46 of file savepoint_manager.cpp.

References foedus::savepoint::SavepointManagerPimpl::get_saved_durable_epoch().

Referenced by foedus::log::MetaLogger::initialize_once().

46  {
47  return pimpl_->get_saved_durable_epoch();
48 }

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorStack foedus::savepoint::SavepointManager::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 32 of file savepoint_manager.cpp.

References foedus::DefaultInitializable::initialize().

32 { 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::savepoint::SavepointManager::is_initialized ( ) const
overridevirtual

Returns whether the object has been already initialized or not.

Implements foedus::Initializable.

Definition at line 33 of file savepoint_manager.cpp.

References foedus::DefaultInitializable::is_initialized().

Referenced by foedus::log::LogManagerPimpl::initialize_once(), and foedus::log::LogManagerPimpl::uninitialize_once().

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

SavepointManager& foedus::savepoint::SavepointManager::operator= ( const SavepointManager )
delete
ErrorStack foedus::savepoint::SavepointManager::take_savepoint ( Epoch  new_global_durable_epoch)

Atomically and durably takes a savepoint for the given epoch advancement.

This is called from log manager when it sees all loggers flushed their logs up to the given epoch BEFORE the log manager announces the new global durable epoch to others. This is the last step in the system to adavance a global durable epoch, thus officially committing transactions in the epoch. Until this method completes, the transactions are not yet committed.

Definition at line 56 of file savepoint_manager.cpp.

References foedus::savepoint::SavepointManagerPimpl::take_savepoint().

Referenced by foedus::log::LogManagerPimpl::refresh_global_durable_epoch().

56  {
57  return pimpl_->take_savepoint(new_global_durable_epoch);
58 }
ErrorStack take_savepoint(Epoch new_global_durable_epoch)

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorStack foedus::savepoint::SavepointManager::take_savepoint_after_snapshot ( snapshot::SnapshotId  new_snapshot_id,
Epoch  new_snapshot_epoch 
)

Takes a savepoint just to remember the newly taken snapshot.

This is only called from snapshot manager after it writes out all snapshot files and metadata. The new snapshot is deemed as effective once this method completes.

Definition at line 59 of file savepoint_manager.cpp.

References foedus::savepoint::SavepointManagerPimpl::take_savepoint_after_snapshot().

Referenced by foedus::snapshot::SnapshotManagerPimpl::snapshot_savepoint().

61  {
62  return pimpl_->take_savepoint_after_snapshot(new_snapshot_id, new_snapshot_epoch);
63 }
ErrorStack take_savepoint_after_snapshot(snapshot::SnapshotId new_snapshot_id, Epoch new_snapshot_epoch)

Here is the call graph for this function:

Here is the caller graph for this function:

ErrorStack foedus::savepoint::SavepointManager::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 34 of file savepoint_manager.cpp.

References foedus::DefaultInitializable::uninitialize().

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