LogCabin
|
TODO(ongaro): docs. More...
#include <SimpleFileLog.h>
Classes | |
class | Sync |
Public Types | |
typedef Protocol::Raft::Entry | Entry |
The type of a log entry (the same format that's used in AppendEntries). | |
Public Member Functions | |
SimpleFileLog (const Storage::FilesystemUtil::File &parentDir) | |
~SimpleFileLog () | |
std::pair< uint64_t, uint64_t > | append (const std::vector< const Entry * > &entries) |
Start to append new entries to the log. | |
std::string | getName () const |
Return the name of the log implementation as it would be specified in the config file. | |
std::unique_ptr< Log::Sync > | takeSync () |
Get and remove the Log's Sync object in order to wait on it. | |
void | truncatePrefix (uint64_t firstEntryId) |
Delete the log entries before the given index. | |
void | truncateSuffix (uint64_t lastEntryId) |
Delete the log entries past the given index. | |
const Entry & | getEntry (uint64_t) const |
Look up an entry by its log index. | |
uint64_t | getLogStartIndex () const |
Get the index of the first entry in the log (whether or not this entry exists). | |
uint64_t | getLastLogIndex () const |
Get the index of the most recent entry in the log. | |
uint64_t | getSizeBytes () const |
Get the size of the entire log in bytes. | |
void | updateMetadata () |
Call this after changing metadata. | |
Protected Member Functions | |
Storage::FilesystemUtil::File | updateMetadataCallerSync () |
std::string | readMetadata (const std::string &filename, SimpleFileLogMetadata::Metadata &metadata) const |
std::vector< uint64_t > | getEntryIds () const |
Entry | read (const std::string &entryPath) const |
Protected Attributes | |
MemoryLog | memoryLog |
SimpleFileLogMetadata::Metadata | metadata |
Opaque metadata that the log keeps track of. | |
Storage::FilesystemUtil::File | dir |
Storage::FilesystemUtil::File | lostAndFound |
std::unique_ptr< Sync > | currentSync |
TODO(ongaro): docs.
Definition at line 37 of file SimpleFileLog.h.
typedef Protocol::Raft::Entry LogCabin::Storage::SimpleFileLog::Entry |
The type of a log entry (the same format that's used in AppendEntries).
Reimplemented from LogCabin::Storage::Log.
Definition at line 50 of file SimpleFileLog.h.
LogCabin::Storage::SimpleFileLog::SimpleFileLog | ( | const Storage::FilesystemUtil::File & | parentDir | ) | [explicit] |
Definition at line 146 of file SimpleFileLog.cc.
Definition at line 219 of file SimpleFileLog.cc.
std::pair< uint64_t, uint64_t > LogCabin::Storage::SimpleFileLog::append | ( | const std::vector< const Entry * > & | entries | ) | [virtual] |
Start to append new entries to the log.
The entries may not be on disk yet when this returns; see Sync.
entries | Entries to place at the end of the log. |
Implements LogCabin::Storage::Log.
Definition at line 226 of file SimpleFileLog.cc.
std::string LogCabin::Storage::SimpleFileLog::getName | ( | ) | const [virtual] |
Return the name of the log implementation as it would be specified in the config file.
Implements LogCabin::Storage::Log.
Definition at line 243 of file SimpleFileLog.cc.
std::unique_ptr< Log::Sync > LogCabin::Storage::SimpleFileLog::takeSync | ( | ) | [virtual] |
Get and remove the Log's Sync object in order to wait on it.
This Sync object must later be returned to the Log with syncComplete().
While takeSync() and syncComplete() may not be done concurrently with other Log operations, Sync::wait() may be done concurrently with all operations except truncateSuffix().
Implements LogCabin::Storage::Log.
Definition at line 249 of file SimpleFileLog.cc.
void LogCabin::Storage::SimpleFileLog::truncatePrefix | ( | uint64_t | firstIndex | ) | [virtual] |
Delete the log entries before the given index.
Once you truncate a prefix from the log, there's no way to undo this. The entries may still be on disk when this returns and file descriptors and other resources may remain open; see Sync.
firstIndex | After this call, the log will contain no entries indexed less than firstIndex. This can be any log index, including 0 and those past the end of the log. |
Implements LogCabin::Storage::Log.
Definition at line 257 of file SimpleFileLog.cc.
void LogCabin::Storage::SimpleFileLog::truncateSuffix | ( | uint64_t | lastIndex | ) | [virtual] |
Delete the log entries past the given index.
This will not affect the log start index.
lastIndex | After this call, the log will contain no entries indexed greater than lastIndex. This can be any log index, including 0 and those past the end of the log. |
Implements LogCabin::Storage::Log.
Definition at line 269 of file SimpleFileLog.cc.
const SimpleFileLog::Entry & LogCabin::Storage::SimpleFileLog::getEntry | ( | uint64_t | index | ) | const [virtual] |
Look up an entry by its log index.
index | Must be in the range [getLogStartIndex(), getLastLogIndex()]. Otherwise, this will crash the server. |
Implements LogCabin::Storage::Log.
Definition at line 281 of file SimpleFileLog.cc.
uint64_t LogCabin::Storage::SimpleFileLog::getLogStartIndex | ( | ) | const [virtual] |
Get the index of the first entry in the log (whether or not this entry exists).
Implements LogCabin::Storage::Log.
Definition at line 287 of file SimpleFileLog.cc.
uint64_t LogCabin::Storage::SimpleFileLog::getLastLogIndex | ( | ) | const [virtual] |
Get the index of the most recent entry in the log.
Implements LogCabin::Storage::Log.
Definition at line 293 of file SimpleFileLog.cc.
uint64_t LogCabin::Storage::SimpleFileLog::getSizeBytes | ( | ) | const [virtual] |
Get the size of the entire log in bytes.
Implements LogCabin::Storage::Log.
Definition at line 299 of file SimpleFileLog.cc.
void LogCabin::Storage::SimpleFileLog::updateMetadata | ( | ) | [virtual] |
Call this after changing metadata.
Implements LogCabin::Storage::Log.
Definition at line 305 of file SimpleFileLog.cc.
Definition at line 314 of file SimpleFileLog.cc.
std::string LogCabin::Storage::SimpleFileLog::readMetadata | ( | const std::string & | filename, |
SimpleFileLogMetadata::Metadata & | metadata | ||
) | const [protected] |
Definition at line 137 of file SimpleFileLog.cc.
std::vector< uint64_t > LogCabin::Storage::SimpleFileLog::getEntryIds | ( | ) | const [protected] |
Definition at line 328 of file SimpleFileLog.cc.
Log::Entry LogCabin::Storage::SimpleFileLog::read | ( | const std::string & | entryPath | ) | const [protected] |
Definition at line 355 of file SimpleFileLog.cc.
MemoryLog LogCabin::Storage::SimpleFileLog::memoryLog [protected] |
Definition at line 71 of file SimpleFileLog.h.
SimpleFileLogMetadata::Metadata LogCabin::Storage::SimpleFileLog::metadata [protected] |
Opaque metadata that the log keeps track of.
Reimplemented from LogCabin::Storage::Log.
Definition at line 72 of file SimpleFileLog.h.
Definition at line 73 of file SimpleFileLog.h.
Definition at line 74 of file SimpleFileLog.h.
std::unique_ptr<Sync> LogCabin::Storage::SimpleFileLog::currentSync [protected] |
Definition at line 75 of file SimpleFileLog.h.