Derecho  0.9
Distributed systems toolkit for RDMA
Classes | Namespaces | Macros | Typedefs | Functions
FilePersistLog.hpp File Reference
#include "PersistLog.hpp"
#include "util.hpp"
#include <derecho/utils/logger.hpp>
#include <pthread.h>
#include <string>
Include dependency graph for FilePersistLog.hpp:
This graph shows which files directly or indirectly include this file:

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 &)
 

Class Documentation

◆ persistent::log_entry

union persistent::log_entry

Definition at line 33 of file FilePersistLog.hpp.

Class Members
uint8_t bytes[64]
struct log_entry fields

◆ persistent::meta_header.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

◆ persistent::log_entry.fields

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

Macro Definition Documentation

◆ ALIGN_TO_PAGE

#define ALIGN_TO_PAGE (   x)    ((void*)(((uint64_t)(x)) - ((uint64_t)(x)) % PAGE_SIZE))

Definition at line 81 of file FilePersistLog.hpp.

◆ CURR_LOG_IDX

#define CURR_LOG_IDX   ((NUM_USED_SLOTS == 0) ? -1 : META_HEADER->fields.tail - 1)

Definition at line 70 of file FilePersistLog.hpp.

◆ DATA_FILE_SUFFIX

#define DATA_FILE_SUFFIX   "data"

Definition at line 14 of file FilePersistLog.hpp.

◆ FPL_PERS_LOCK

#define FPL_PERS_LOCK
Value:
do { \
if(pthread_mutex_lock(&this->m_perslock) != 0) { \
throw PERSIST_EXP_MUTEX_LOCK(errno); \
} \
} while(0)
#define PERSIST_EXP_MUTEX_LOCK(x)

Definition at line 143 of file FilePersistLog.hpp.

◆ FPL_PERS_UNLOCK

#define FPL_PERS_UNLOCK
Value:
do { \
if(pthread_mutex_unlock(&this->m_perslock) != 0) { \
throw PERSIST_EXP_MUTEX_UNLOCK(errno); \
} \
} while(0)
#define PERSIST_EXP_MUTEX_UNLOCK(x)

Definition at line 150 of file FilePersistLog.hpp.

◆ FPL_RDLOCK

#define FPL_RDLOCK
Value:
do { \
if(pthread_rwlock_rdlock(&this->m_rwlock) != 0) { \
throw PERSIST_EXP_RWLOCK_WRLOCK(errno); \
} \
} while(0)
#define PERSIST_EXP_RWLOCK_WRLOCK(x)

Definition at line 129 of file FilePersistLog.hpp.

◆ FPL_UNLOCK

#define FPL_UNLOCK
Value:
do { \
if(pthread_rwlock_unlock(&this->m_rwlock) != 0) { \
throw PERSIST_EXP_RWLOCK_UNLOCK(errno); \
} \
} while(0)
#define PERSIST_EXP_RWLOCK_UNLOCK(x)

Definition at line 136 of file FilePersistLog.hpp.

◆ FPL_WRLOCK

#define FPL_WRLOCK
Value:
do { \
if(pthread_rwlock_wrlock(&this->m_rwlock) != 0) { \
throw PERSIST_EXP_RWLOCK_WRLOCK(errno); \
} \
} while(0)
#define PERSIST_EXP_RWLOCK_WRLOCK(x)

Definition at line 122 of file FilePersistLog.hpp.

◆ LOG_ENTRY_ARRAY

#define LOG_ENTRY_ARRAY   ((LogEntry*)(this->m_pLog))

Definition at line 59 of file FilePersistLog.hpp.

◆ LOG_ENTRY_AT

#define LOG_ENTRY_AT (   idx)    (LOG_ENTRY_ARRAY + (int)((idx) % MAX_LOG_ENTRY))

Definition at line 66 of file FilePersistLog.hpp.

◆ LOG_ENTRY_DATA

#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.

◆ LOG_FILE_SUFFIX

#define LOG_FILE_SUFFIX   "log"

Definition at line 13 of file FilePersistLog.hpp.

◆ MAX_DATA_SIZE

#define MAX_DATA_SIZE   (this->m_iMaxDataSize)

Definition at line 52 of file FilePersistLog.hpp.

◆ MAX_LOG_ENTRY

#define MAX_LOG_ENTRY   (this->m_iMaxLogEntry)

Definition at line 50 of file FilePersistLog.hpp.

◆ MAX_LOG_SIZE

#define MAX_LOG_SIZE   (sizeof(LogEntry) * MAX_LOG_ENTRY)

Definition at line 51 of file FilePersistLog.hpp.

◆ META_FILE_SUFFIX

#define META_FILE_SUFFIX   "meta"

Definition at line 12 of file FilePersistLog.hpp.

◆ META_HEADER

#define META_HEADER   ((MetaHeader*)(&(this->m_currMetaHeader)))

Definition at line 57 of file FilePersistLog.hpp.

◆ META_HEADER_PERS

#define META_HEADER_PERS   ((MetaHeader*)(&(this->m_persMetaHeader)))

Definition at line 58 of file FilePersistLog.hpp.

◆ META_SIZE

#define META_SIZE   (sizeof(MetaHeader))

Definition at line 53 of file FilePersistLog.hpp.

◆ NEXT_DATA

#define NEXT_DATA   ((void*)((uint64_t) this->m_pData + NEXT_DATA_OFST % MAX_DATA_SIZE))

Definition at line 74 of file FilePersistLog.hpp.

◆ NEXT_DATA_OFST

#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.

◆ NEXT_DATA_PERS

#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.

◆ NEXT_LOG_ENTRY

#define NEXT_LOG_ENTRY   LOG_ENTRY_AT(META_HEADER->fields.tail)

Definition at line 67 of file FilePersistLog.hpp.

◆ NEXT_LOG_ENTRY_PERS

#define NEXT_LOG_ENTRY_PERS
Value:
MAX(META_HEADER_PERS->fields.tail, META_HEADER->fields.head))
#define LOG_ENTRY_AT(idx)
#define META_HEADER
#define META_HEADER_PERS
#define MAX(a, b)
Definition: util.hpp:13

Definition at line 68 of file FilePersistLog.hpp.

◆ NUM_FREE_BYTES

#define NUM_FREE_BYTES   (MAX_DATA_SIZE - NUM_USED_BYTES)

Definition at line 78 of file FilePersistLog.hpp.

◆ NUM_FREE_SLOTS

#define NUM_FREE_SLOTS   (MAX_LOG_ENTRY - 1 - NUM_USED_SLOTS)

Definition at line 63 of file FilePersistLog.hpp.

◆ NUM_USED_BYTES

#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.

◆ NUM_USED_SLOTS

#define NUM_USED_SLOTS   (META_HEADER->fields.tail - META_HEADER->fields.head)

Definition at line 61 of file FilePersistLog.hpp.

◆ PAGE_SIZE

#define PAGE_SIZE   (getpagesize())

Definition at line 80 of file FilePersistLog.hpp.

◆ SWAP_FILE_SUFFIX

#define SWAP_FILE_SUFFIX   "swp"

Definition at line 15 of file FilePersistLog.hpp.