#include "PersistLog.hpp"
#include "util.hpp"
#include <derecho/utils/logger.hpp>
#include <pthread.h>
#include <string>
Go to the source code of this file.
Classes | |
union | persistent::meta_header |
union | persistent::log_entry |
class | persistent::FilePersistLog |
struct | persistent::meta_header.fields |
struct | persistent::log_entry.fields |
Namespaces | |
persistent | |
This file include all common types internal to derecho and not necessarily being known by a client program. | |
Macros | |
#define | META_FILE_SUFFIX "meta" |
#define | LOG_FILE_SUFFIX "log" |
#define | DATA_FILE_SUFFIX "data" |
#define | SWAP_FILE_SUFFIX "swp" |
#define | MAX_LOG_ENTRY (this->m_iMaxLogEntry) |
#define | MAX_LOG_SIZE (sizeof(LogEntry) * MAX_LOG_ENTRY) |
#define | MAX_DATA_SIZE (this->m_iMaxDataSize) |
#define | META_SIZE (sizeof(MetaHeader)) |
#define | META_HEADER ((MetaHeader*)(&(this->m_currMetaHeader))) |
#define | META_HEADER_PERS ((MetaHeader*)(&(this->m_persMetaHeader))) |
#define | LOG_ENTRY_ARRAY ((LogEntry*)(this->m_pLog)) |
#define | NUM_USED_SLOTS (META_HEADER->fields.tail - META_HEADER->fields.head) |
#define | NUM_FREE_SLOTS (MAX_LOG_ENTRY - 1 - NUM_USED_SLOTS) |
#define | LOG_ENTRY_AT(idx) (LOG_ENTRY_ARRAY + (int)((idx) % MAX_LOG_ENTRY)) |
#define | NEXT_LOG_ENTRY LOG_ENTRY_AT(META_HEADER->fields.tail) |
#define | NEXT_LOG_ENTRY_PERS |
#define | CURR_LOG_IDX ((NUM_USED_SLOTS == 0) ? -1 : META_HEADER->fields.tail - 1) |
#define | LOG_ENTRY_DATA(e) ((void*)((uint8_t*)this->m_pData + (e)->fields.ofst % MAX_DATA_SIZE)) |
#define | NEXT_DATA_OFST ((CURR_LOG_IDX == -1) ? 0 : (LOG_ENTRY_AT(CURR_LOG_IDX)->fields.ofst + LOG_ENTRY_AT(CURR_LOG_IDX)->fields.dlen)) |
#define | NEXT_DATA ((void*)((uint64_t) this->m_pData + NEXT_DATA_OFST % MAX_DATA_SIZE)) |
#define | NEXT_DATA_PERS ((NEXT_LOG_ENTRY > NEXT_LOG_ENTRY_PERS) ? LOG_ENTRY_DATA(NEXT_LOG_ENTRY_PERS) : NULL) |
#define | NUM_USED_BYTES ((NUM_USED_SLOTS == 0) ? 0 : (LOG_ENTRY_AT(CURR_LOG_IDX)->fields.ofst + LOG_ENTRY_AT(CURR_LOG_IDX)->fields.dlen - LOG_ENTRY_AT(META_HEADER->fields.head)->fields.ofst)) |
#define | NUM_FREE_BYTES (MAX_DATA_SIZE - NUM_USED_BYTES) |
#define | PAGE_SIZE (getpagesize()) |
#define | ALIGN_TO_PAGE(x) ((void*)(((uint64_t)(x)) - ((uint64_t)(x)) % PAGE_SIZE)) |
#define | FPL_WRLOCK |
#define | FPL_RDLOCK |
#define | FPL_UNLOCK |
#define | FPL_PERS_LOCK |
#define | FPL_PERS_UNLOCK |
Typedefs | |
typedef union persistent::meta_header | persistent::MetaHeader |
typedef union persistent::log_entry | persistent::LogEntry |
Functions | |
template<typename TKey , typename KeyGetter > | |
int64_t | persistent::binarySearch (const KeyGetter &, const TKey &, const int64_t &, const int64_t &) |
union persistent::log_entry |
Definition at line 33 of file FilePersistLog.hpp.
Class Members | ||
---|---|---|
uint8_t | bytes[64] | |
struct log_entry | fields |
struct persistent::meta_header.fields |
Definition at line 19 of file FilePersistLog.hpp.
Class Members | ||
---|---|---|
int64_t | head | |
int64_t | tail | |
int64_t | ver |
struct persistent::log_entry.fields |
Definition at line 34 of file FilePersistLog.hpp.
Class Members | ||
---|---|---|
uint64_t | dlen | |
uint64_t | hlc_l | |
uint64_t | hlc_r | |
uint64_t | ofst | |
int64_t | ver |
#define ALIGN_TO_PAGE | ( | x | ) | ((void*)(((uint64_t)(x)) - ((uint64_t)(x)) % PAGE_SIZE)) |
Definition at line 81 of file FilePersistLog.hpp.
#define CURR_LOG_IDX ((NUM_USED_SLOTS == 0) ? -1 : META_HEADER->fields.tail - 1) |
Definition at line 70 of file FilePersistLog.hpp.
#define DATA_FILE_SUFFIX "data" |
Definition at line 14 of file FilePersistLog.hpp.
#define FPL_PERS_LOCK |
Definition at line 143 of file FilePersistLog.hpp.
#define FPL_PERS_UNLOCK |
Definition at line 150 of file FilePersistLog.hpp.
#define FPL_RDLOCK |
Definition at line 129 of file FilePersistLog.hpp.
#define FPL_UNLOCK |
Definition at line 136 of file FilePersistLog.hpp.
#define FPL_WRLOCK |
Definition at line 122 of file FilePersistLog.hpp.
#define LOG_ENTRY_ARRAY ((LogEntry*)(this->m_pLog)) |
Definition at line 59 of file FilePersistLog.hpp.
#define LOG_ENTRY_AT | ( | idx | ) | (LOG_ENTRY_ARRAY + (int)((idx) % MAX_LOG_ENTRY)) |
Definition at line 66 of file FilePersistLog.hpp.
#define LOG_ENTRY_DATA | ( | e | ) | ((void*)((uint8_t*)this->m_pData + (e)->fields.ofst % MAX_DATA_SIZE)) |
Definition at line 71 of file FilePersistLog.hpp.
#define LOG_FILE_SUFFIX "log" |
Definition at line 13 of file FilePersistLog.hpp.
#define MAX_DATA_SIZE (this->m_iMaxDataSize) |
Definition at line 52 of file FilePersistLog.hpp.
#define MAX_LOG_ENTRY (this->m_iMaxLogEntry) |
Definition at line 50 of file FilePersistLog.hpp.
#define MAX_LOG_SIZE (sizeof(LogEntry) * MAX_LOG_ENTRY) |
Definition at line 51 of file FilePersistLog.hpp.
#define META_FILE_SUFFIX "meta" |
Definition at line 12 of file FilePersistLog.hpp.
#define META_HEADER ((MetaHeader*)(&(this->m_currMetaHeader))) |
Definition at line 57 of file FilePersistLog.hpp.
#define META_HEADER_PERS ((MetaHeader*)(&(this->m_persMetaHeader))) |
Definition at line 58 of file FilePersistLog.hpp.
#define META_SIZE (sizeof(MetaHeader)) |
Definition at line 53 of file FilePersistLog.hpp.
#define NEXT_DATA ((void*)((uint64_t) this->m_pData + NEXT_DATA_OFST % MAX_DATA_SIZE)) |
Definition at line 74 of file FilePersistLog.hpp.
#define NEXT_DATA_OFST ((CURR_LOG_IDX == -1) ? 0 : (LOG_ENTRY_AT(CURR_LOG_IDX)->fields.ofst + LOG_ENTRY_AT(CURR_LOG_IDX)->fields.dlen)) |
Definition at line 73 of file FilePersistLog.hpp.
#define NEXT_DATA_PERS ((NEXT_LOG_ENTRY > NEXT_LOG_ENTRY_PERS) ? LOG_ENTRY_DATA(NEXT_LOG_ENTRY_PERS) : NULL) |
Definition at line 75 of file FilePersistLog.hpp.
#define NEXT_LOG_ENTRY LOG_ENTRY_AT(META_HEADER->fields.tail) |
Definition at line 67 of file FilePersistLog.hpp.
#define NEXT_LOG_ENTRY_PERS |
Definition at line 68 of file FilePersistLog.hpp.
#define NUM_FREE_BYTES (MAX_DATA_SIZE - NUM_USED_BYTES) |
Definition at line 78 of file FilePersistLog.hpp.
#define NUM_FREE_SLOTS (MAX_LOG_ENTRY - 1 - NUM_USED_SLOTS) |
Definition at line 63 of file FilePersistLog.hpp.
#define NUM_USED_BYTES ((NUM_USED_SLOTS == 0) ? 0 : (LOG_ENTRY_AT(CURR_LOG_IDX)->fields.ofst + LOG_ENTRY_AT(CURR_LOG_IDX)->fields.dlen - LOG_ENTRY_AT(META_HEADER->fields.head)->fields.ofst)) |
Definition at line 77 of file FilePersistLog.hpp.
#define NUM_USED_SLOTS (META_HEADER->fields.tail - META_HEADER->fields.head) |
Definition at line 61 of file FilePersistLog.hpp.
#define PAGE_SIZE (getpagesize()) |
Definition at line 80 of file FilePersistLog.hpp.
#define SWAP_FILE_SUFFIX "swp" |
Definition at line 15 of file FilePersistLog.hpp.