libfoedus-core
FOEDUS Core Library
foedus::log::LogManager Class Referencefinal

Log Manager class that provides API to write/read transaction logs. More...

Detailed Description

Log Manager class that provides API to write/read transaction logs.

Definition at line 36 of file log_manager.hpp.

#include <log_manager.hpp>

Inheritance diagram for foedus::log::LogManager:
Collaboration diagram for foedus::log::LogManager:

Public Member Functions

 LogManager (Engine *engine)
 
 ~LogManager ()
 
 LogManager ()=delete
 
 LogManager (const LogManager &)=delete
 
LogManageroperator= (const LogManager &)=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...
 
void copy_logger_states (savepoint::Savepoint *new_savepoint)
 Fillup the given savepoint with the current information of the loggers. More...
 
void wakeup_loggers ()
 Wake up loggers if they are sleeping. More...
 
LoggerRef get_logger (LoggerId logger_id)
 Returns a reference to the logger of the given ID. More...
 
Epoch get_durable_global_epoch () const
 Returns the durable epoch of the entire engine. More...
 
Epoch get_durable_global_epoch_weak () const
 Non-atomic version of the method. More...
 
void announce_new_durable_global_epoch (Epoch new_epoch)
 Sets the new global durable epoch and also wakes up threads that were waiting for it. More...
 
ErrorCode wait_until_durable (Epoch commit_epoch, int64_t wait_microseconds=-1)
 Synchronously blocks until the durable global epoch reaches the given commit epoch or the given duration elapses. More...
 
ErrorStack refresh_global_durable_epoch ()
 Called whenever there is a chance that the global durable epoch advances. More...
 
MetaLoggerget_meta_logger ()
 
MetaLogBufferget_meta_buffer ()
 
- Public Member Functions inherited from foedus::Initializable
virtual ~Initializable ()
 

Constructor & Destructor Documentation

foedus::log::LogManager::LogManager ( Engine engine)
explicit

Definition at line 23 of file log_manager.cpp.

23  : pimpl_(nullptr) {
24  pimpl_ = new LogManagerPimpl(engine);
25 }
foedus::log::LogManager::~LogManager ( )

Definition at line 26 of file log_manager.cpp.

26  {
27  delete pimpl_;
28  pimpl_ = nullptr;
29 }
foedus::log::LogManager::LogManager ( )
delete
foedus::log::LogManager::LogManager ( const LogManager )
delete

Member Function Documentation

void foedus::log::LogManager::announce_new_durable_global_epoch ( Epoch  new_epoch)

Sets the new global durable epoch and also wakes up threads that were waiting for it.

Definition at line 42 of file log_manager.cpp.

References foedus::log::LogManagerPimpl::announce_new_durable_global_epoch().

Referenced by foedus::savepoint::SavepointManagerPimpl::savepoint_main().

42  {
43  pimpl_->announce_new_durable_global_epoch(new_epoch);
44 }
void announce_new_durable_global_epoch(Epoch new_epoch)

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::log::LogManager::copy_logger_states ( savepoint::Savepoint new_savepoint)

Fillup the given savepoint with the current information of the loggers.

This is called as a part of taking a savepoint.

Definition at line 57 of file log_manager.cpp.

References foedus::log::LogManagerPimpl::copy_logger_states().

Referenced by foedus::savepoint::SavepointManagerPimpl::savepoint_main().

57  {
58  pimpl_->copy_logger_states(new_savepoint);
59 }
void copy_logger_states(savepoint::Savepoint *new_savepoint)

Here is the call graph for this function:

Here is the caller graph for this function:

Epoch foedus::log::LogManager::get_durable_global_epoch ( ) const

Returns the durable epoch of the entire engine.

Invariant
current_global_epoch > durable_global_epoch (we need to advance current epoch to make sure the ex-current epoch is durable)

This value indicates upto what commit-groups we can return results to client programs. This value is advanced by checking the durable epoch of each logger.

Definition at line 36 of file log_manager.cpp.

References foedus::log::LogManagerPimpl::get_durable_global_epoch().

Referenced by foedus::Engine::get_durable_global_epoch(), foedus::snapshot::SnapshotManagerPimpl::handle_snapshot(), foedus::snapshot::SnapshotManagerPimpl::handle_snapshot_triggered(), foedus::restart::RestartManagerPimpl::recover(), and foedus::snapshot::SnapshotManagerPimpl::trigger_snapshot_immediate().

36  {
37  return pimpl_->get_durable_global_epoch();
38 }

Here is the call graph for this function:

Here is the caller graph for this function:

Epoch foedus::log::LogManager::get_durable_global_epoch_weak ( ) const

Non-atomic version of the method.

Definition at line 39 of file log_manager.cpp.

References foedus::log::LogManagerPimpl::get_durable_global_epoch_weak().

Referenced by foedus::xct::XctManagerPimpl::precommit_xct_verify_readonly().

39  {
40  return pimpl_->get_durable_global_epoch_weak();
41 }
Epoch get_durable_global_epoch_weak() const

Here is the call graph for this function:

Here is the caller graph for this function:

LoggerRef foedus::log::LogManager::get_logger ( LoggerId  logger_id)

Returns a reference to the logger of the given ID.

Definition at line 49 of file log_manager.cpp.

References ASSERT_ND, and foedus::log::LogManagerPimpl::logger_refs_.

Referenced by foedus::log::EpochMarkerLogType::apply_engine(), and foedus::snapshot::LogMapper::handle_process().

49  {
50  ASSERT_ND(logger_id < pimpl_->logger_refs_.size());
51  return pimpl_->logger_refs_[logger_id];
52 }
std::vector< LoggerRef > logger_refs_
All log writers.
#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

Here is the caller graph for this function:

MetaLogBuffer * foedus::log::LogManager::get_meta_buffer ( )
MetaLogger * foedus::log::LogManager::get_meta_logger ( )

Definition at line 65 of file log_manager.cpp.

References foedus::log::LogManagerPimpl::meta_logger_.

65  {
66  return pimpl_->meta_logger_;
67 }
MetaLogger * meta_logger_
Metadata log writer.
ErrorStack foedus::log::LogManager::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 31 of file log_manager.cpp.

References foedus::DefaultInitializable::initialize().

31 { 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::log::LogManager::is_initialized ( ) const
overridevirtual

Returns whether the object has been already initialized or not.

Implements foedus::Initializable.

Definition at line 32 of file log_manager.cpp.

References foedus::DefaultInitializable::is_initialized().

Referenced by foedus::storage::StorageManagerPimpl::initialize_once(), foedus::snapshot::SnapshotManagerPimpl::initialize_once(), foedus::storage::StorageManagerPimpl::uninitialize_once(), and foedus::snapshot::SnapshotManagerPimpl::uninitialize_once().

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

LogManager& foedus::log::LogManager::operator= ( const LogManager )
delete
ErrorStack foedus::log::LogManager::refresh_global_durable_epoch ( )

Called whenever there is a chance that the global durable epoch advances.

Each logger calls this method when they advance their local durable epoch, which may or may not advance the global durable epoch. This method recalculates global durable epoch.

Definition at line 54 of file log_manager.cpp.

References foedus::log::LogManagerPimpl::refresh_global_durable_epoch().

54  {
55  return pimpl_->refresh_global_durable_epoch();
56 }

Here is the call graph for this function:

ErrorStack foedus::log::LogManager::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 33 of file log_manager.cpp.

References foedus::DefaultInitializable::uninitialize().

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

ErrorCode foedus::log::LogManager::wait_until_durable ( Epoch  commit_epoch,
int64_t  wait_microseconds = -1 
)

Synchronously blocks until the durable global epoch reaches the given commit epoch or the given duration elapses.

Parameters
[in]commit_epochReturns kRetOk iff the durable global epoch reaches this value.
[in]wait_microsecondsOr, returns a TIMEOUT error when this duration elapses, whichever comes first. Negative value means waiting forever. 0 means conditional, immediately returning without blocking, which is useful to quickly check the committed-ness.

Client programs can either call this method for each transaction right after precommit_xct() or call this method after a bunch of precommit_xct() calls (group-commit). In either case, remember that both read-only and read-write transactions must not return results to clients until the durable global epoch reaches the given commit epoch. Otherwise, you violate serializability (which might be okay depending on your desired isolation level).

Definition at line 46 of file log_manager.cpp.

References foedus::log::LogManagerPimpl::wait_until_durable().

Referenced by foedus::xct::XctManagerPimpl::wait_for_commit().

46  {
47  return pimpl_->wait_until_durable(commit_epoch, wait_microseconds);
48 }
ErrorCode wait_until_durable(Epoch commit_epoch, int64_t wait_microseconds)

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::log::LogManager::wakeup_loggers ( )

Wake up loggers if they are sleeping.

This method might be called from several places for various events to make sure loggers catch up. As far as you don't call this method too often, like tens of thousands times per second, it wouldn't hurt.

Definition at line 35 of file log_manager.cpp.

References foedus::log::LogManagerPimpl::wakeup_loggers().

Referenced by foedus::xct::XctManagerPimpl::handle_epoch_chime(), and foedus::log::ThreadLogBuffer::wait_for_space().

Here is the call graph for this function:

Here is the caller graph for this function:


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