libfoedus-core
FOEDUS Core Library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
foedus::log::LoggerControlBlock Struct Reference

Shared data of Logger. More...

Detailed Description

Shared data of Logger.

Definition at line 51 of file logger_impl.hpp.

#include <logger_impl.hpp>

Collaboration diagram for foedus::log::LoggerControlBlock:

Public Types

enum  Constants { kMaxEpochHistory = 1 << 16 }
 

Public Member Functions

 LoggerControlBlock ()=delete
 
 ~LoggerControlBlock ()=delete
 
void initialize ()
 
void uninitialize ()
 
bool is_epoch_history_empty () const
 
uint32_t get_tail_epoch_history () const
 

Static Public Member Functions

static uint32_t wrap_epoch_history_index (uint32_t index)
 

Public Attributes

std::atomic< Epoch::EpochIntegerdurable_epoch_
 Upto what epoch the logger flushed logs in all buffers assigned to it. More...
 
soc::SharedPolling wakeup_cond_
 The logger sleeps on this conditional. More...
 
Epoch marked_epoch_
 Upto what epoch the logger has put epoch marker in the log file. More...
 
std::atomic< LogFileOrdinaloldest_ordinal_
 Ordinal of the oldest active log file of this logger. More...
 
std::atomic< uint64_t > oldest_file_offset_begin_
 Inclusive beginning of active region in the oldest log file. More...
 
std::atomic< LogFileOrdinalcurrent_ordinal_
 Ordinal of the log file this logger is currently appending to. More...
 
std::atomic< uint64_t > current_file_durable_offset_
 We called fsync on current file up to this offset. More...
 
std::atomic< bool > stop_requested_
 Whether this logger should terminate. More...
 
soc::SharedMutex epoch_history_mutex_
 the followings are covered this mutex More...
 
uint32_t epoch_history_head_
 index of the oldest history in epoch_histories_ More...
 
uint32_t epoch_history_count_
 number of active entries in epoch_histories_ . More...
 
EpochHistory epoch_histories_ [kMaxEpochHistory]
 Remembers all epoch switching in this logger. More...
 

Member Enumeration Documentation

Enumerator
kMaxEpochHistory 

Max number of active epoch histories.

64k * 24b = 1536 kb. adjust kLoggerMemorySize according to this.

Definition at line 52 of file logger_impl.hpp.

52  {
57  kMaxEpochHistory = 1 << 16,
58  };
Max number of active epoch histories.
Definition: logger_impl.hpp:57

Constructor & Destructor Documentation

foedus::log::LoggerControlBlock::LoggerControlBlock ( )
delete
foedus::log::LoggerControlBlock::~LoggerControlBlock ( )
delete

Member Function Documentation

uint32_t foedus::log::LoggerControlBlock::get_tail_epoch_history ( ) const
inline

Definition at line 77 of file logger_impl.hpp.

References epoch_history_count_, epoch_history_head_, and wrap_epoch_history_index().

77  {
79  }
uint32_t epoch_history_head_
index of the oldest history in epoch_histories_
static uint32_t wrap_epoch_history_index(uint32_t index)
Definition: logger_impl.hpp:81
uint32_t epoch_history_count_
number of active entries in epoch_histories_ .

Here is the call graph for this function:

void foedus::log::LoggerControlBlock::initialize ( )
inline

Definition at line 64 of file logger_impl.hpp.

References epoch_history_count_, epoch_history_head_, epoch_history_mutex_, foedus::soc::SharedMutex::initialize(), foedus::soc::SharedPolling::initialize(), stop_requested_, and wakeup_cond_.

64  {
67  stop_requested_ = false;
70  }
soc::SharedPolling wakeup_cond_
The logger sleeps on this conditional.
void initialize(bool recursive=false)
std::atomic< bool > stop_requested_
Whether this logger should terminate.
soc::SharedMutex epoch_history_mutex_
the followings are covered this mutex
uint32_t epoch_history_head_
index of the oldest history in epoch_histories_
uint32_t epoch_history_count_
number of active entries in epoch_histories_ .

Here is the call graph for this function:

bool foedus::log::LoggerControlBlock::is_epoch_history_empty ( ) const
inline

Definition at line 76 of file logger_impl.hpp.

References epoch_history_count_.

76 { return epoch_history_count_ == 0; }
uint32_t epoch_history_count_
number of active entries in epoch_histories_ .
void foedus::log::LoggerControlBlock::uninitialize ( )
inline

Definition at line 71 of file logger_impl.hpp.

References epoch_history_mutex_, and foedus::soc::SharedMutex::uninitialize().

71  {
73  }
soc::SharedMutex epoch_history_mutex_
the followings are covered this mutex

Here is the call graph for this function:

static uint32_t foedus::log::LoggerControlBlock::wrap_epoch_history_index ( uint32_t  index)
inlinestatic

Definition at line 81 of file logger_impl.hpp.

References kMaxEpochHistory.

Referenced by get_tail_epoch_history().

81 { return index % kMaxEpochHistory; }
Max number of active epoch histories.
Definition: logger_impl.hpp:57

Here is the caller graph for this function:

Member Data Documentation

std::atomic< uint64_t > foedus::log::LoggerControlBlock::current_file_durable_offset_

We called fsync on current file up to this offset.

Invariant
current_file_durable_offset_ <= current_file->get_current_offset()
current_file_durable_offset_ % kLogWriteUnitSize == 0 (because we pad)

Definition at line 140 of file logger_impl.hpp.

std::atomic< LogFileOrdinal > foedus::log::LoggerControlBlock::current_ordinal_

Ordinal of the log file this logger is currently appending to.

Definition at line 133 of file logger_impl.hpp.

Referenced by foedus::log::operator<<().

std::atomic< Epoch::EpochInteger > foedus::log::LoggerControlBlock::durable_epoch_

Upto what epoch the logger flushed logs in all buffers assigned to it.

Invariant
durable_epoch_.is_valid()
global durable epoch <= durable_epoch_ < global current epoch - 1

The logger advances this value when it writes out all logs in all buffers in an epoch. The global durable epoch is an aggregate (min) of this value from all loggers. Even when some thread is idle, this value could be advanced upto "global current epoch - 2" because of the way the epoch-chime starts a new epoch. It is guaranteed that no thread will emit any log in that epoch or older.

Definition at line 94 of file logger_impl.hpp.

EpochHistory foedus::log::LoggerControlBlock::epoch_histories_[kMaxEpochHistory]

Remembers all epoch switching in this logger.

This forms a circular buffer starting from epoch_history_head_. After log gleaning, we can move head forward and reduce epoch_history_count_.

Definition at line 158 of file logger_impl.hpp.

uint32_t foedus::log::LoggerControlBlock::epoch_history_count_

number of active entries in epoch_histories_ .

Definition at line 151 of file logger_impl.hpp.

Referenced by get_tail_epoch_history(), initialize(), is_epoch_history_empty(), and foedus::log::operator<<().

uint32_t foedus::log::LoggerControlBlock::epoch_history_head_

index of the oldest history in epoch_histories_

Definition at line 149 of file logger_impl.hpp.

Referenced by get_tail_epoch_history(), initialize(), and foedus::log::operator<<().

soc::SharedMutex foedus::log::LoggerControlBlock::epoch_history_mutex_

the followings are covered this mutex

Definition at line 146 of file logger_impl.hpp.

Referenced by initialize(), and uninitialize().

Epoch foedus::log::LoggerControlBlock::marked_epoch_

Upto what epoch the logger has put epoch marker in the log file.

Invariant
marked_epoch_.is_valid()
marked_epoch_ <= durable_epoch_.one_more()

Usually, this value is always same as durable_epoch_.one_more(). This value becomes smaller than that if the logger had no log to write out when it advanced durable_epoch_. In that case, writing out an epoch marker is a waste (eg when the system is idle for long time, there will be tons of empty epochs), so we do not write out the epoch marker and let this value remain same. When the logger later writes out a log, it checks this value and writes out an epoch mark.

Definition at line 116 of file logger_impl.hpp.

Referenced by foedus::log::operator<<().

std::atomic< uint64_t > foedus::log::LoggerControlBlock::oldest_file_offset_begin_

Inclusive beginning of active region in the oldest log file.

Invariant
oldest_file_offset_begin_ % kLogWriteUnitSize == 0 (because we pad)

Definition at line 129 of file logger_impl.hpp.

Referenced by foedus::log::operator<<().

std::atomic< LogFileOrdinal > foedus::log::LoggerControlBlock::oldest_ordinal_

Ordinal of the oldest active log file of this logger.

Invariant
oldest_ordinal_ <= current_ordinal_

Definition at line 124 of file logger_impl.hpp.

Referenced by foedus::log::operator<<().

std::atomic<bool> foedus::log::LoggerControlBlock::stop_requested_

Whether this logger should terminate.

Definition at line 143 of file logger_impl.hpp.

Referenced by initialize().

soc::SharedPolling foedus::log::LoggerControlBlock::wakeup_cond_

The logger sleeps on this conditional.

When someone else (whether in same SOC or other SOC) wants to wake up this logger, they fire this. There is no 'real' condition variable as this is not about correctness. The logger simply wakes on this cond and resumes as far as it wakes up. It might be a spurrious wakeup, but doesn't matter.

Definition at line 102 of file logger_impl.hpp.

Referenced by initialize().


The documentation for this struct was generated from the following file: