Derecho  0.9
Distributed systems toolkit for RDMA
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
persistent::PersistentRegistry Class Reference

PersistentRegistry is a book for all the Persistent<T> or Volatile<T> variables. More...

#include <Persistent.hpp>

Inheritance diagram for persistent::PersistentRegistry:
Inheritance graph
[legend]
Collaboration diagram for persistent::PersistentRegistry:
Collaboration graph
[legend]

Public Member Functions

 PersistentRegistry (ITemporalQueryFrontierProvider *tqfp, const std::type_index &subgroup_type, uint32_t subgroup_index, uint32_t shard_num)
 
virtual ~PersistentRegistry ()
 
void makeVersion (const int64_t &ver, const HLC &mhlc) noexcept(false)
 Make a new version capturing the current state of the object. More...
 
const int64_t persist () noexcept(false)
 (attempt to) Persist all existing versions More...
 
void trim (const int64_t &earliest_version) noexcept(false)
 Trims the log of all versions earlier than the argument. More...
 
const int64_t getMinimumLatestPersistedVersion () noexcept(false)
 Returns the minimum of the latest persisted versions among all Persistent fields. More...
 
void truncate (const int64_t &last_version)
 Truncates the log, deleting all versions newer than the provided argument. More...
 
void registerPersist (const char *obj_name, const VersionFunc &vf, const PersistFunc &pf, const TrimFunc &tf, const LatestPersistedGetterFunc &lpgf, const TruncateFunc &tcf) noexcept(false)
 set the latest version for serialization register a Persistent<T> along with its lambda More...
 
void unregisterPersist (const char *obj_name) noexcept(false)
 deregister More...
 
const HLC getFrontier ()
 get temporal query frontier More...
 
void updateTemporalFrontierProvider (ITemporalQueryFrontierProvider *tqfp)
 update temporal query frontier we didn't use a lock on this becuase we assume this is only updated object construction. More...
 
 PersistentRegistry (PersistentRegistry &&)=default
 Enable move constructor. More...
 
 PersistentRegistry (const PersistentRegistry &)=delete
 Disable copy constructor. More...
 
const char * get_subgroup_prefix ()
 Get prefix for subgroup, this will appear in the file name of Persistent<T> More...
 
- Public Member Functions inherited from mutils::RemoteDeserializationContext
 RemoteDeserializationContext (const RemoteDeserializationContext &)=delete
 
 RemoteDeserializationContext (const RemoteDeserializationContext &&)=delete
 
virtual ~RemoteDeserializationContext ()
 
 RemoteDeserializationContext ()
 

Static Public Member Functions

static void setEarliestVersionToSerialize (const int64_t &ver) noexcept(true)
 Set the earliest version for serialization, exclusive. More...
 
static void resetEarliestVersionToSerialize () noexcept(true)
 Reset the earliest version for serialization to an invalid "uninitialized" state. More...
 
static int64_t getEarliestVersionToSerialize () noexcept(true)
 Returns the earliest version for serialization. More...
 
static std::string generate_prefix (const std::type_index &subgroup_type, uint32_t subgroup_index, uint32_t shard_num) noexcept(true)
 prefix generator prefix format: [hex of subgroup_type]-[subgroup_index]-[shard_num] More...
 
static bool match_prefix (const std::string str, const std::type_index &subgroup_type, uint32_t subgroup_index, uint32_t shard_num) noexcept(true)
 match prefix More...
 

Protected Member Functions

template<int funcIdx, typename... Args>
void callFunc (Args... args)
 Helper function I. More...
 
template<int funcIdx, typename ReturnType , typename... Args>
ReturnType callFuncMin (Args... args)
 Helper function II. More...
 

Protected Attributes

const std::string _subgroup_prefix
 this appears in the first part of storage file for persistent<T> More...
 
ITemporalQueryFrontierProvider_temporal_query_frontier_provider
 Pointer to an entity providing TemporalQueryFrontier service. More...
 
std::map< std::size_t, std::tuple< VersionFunc, PersistFunc, TrimFunc, LatestPersistedGetterFunc, TruncateFunc > > _registry
 Callback registry. More...
 

Static Protected Attributes

static thread_local int64_t earliest_version_to_serialize = INVALID_VERSION
 Set the earliest version to serialize for recovery. More...
 

Detailed Description

PersistentRegistry is a book for all the Persistent<T> or Volatile<T> variables.

Replicated<T> class should maintain such a registry to perform the following operations:

Definition at line 81 of file Persistent.hpp.

Constructor & Destructor Documentation

◆ PersistentRegistry() [1/3]

persistent::PersistentRegistry::PersistentRegistry ( ITemporalQueryFrontierProvider tqfp,
const std::type_index &  subgroup_type,
uint32_t  subgroup_index,
uint32_t  shard_num 
)

Definition at line 13 of file Persistent.cpp.

◆ ~PersistentRegistry()

persistent::PersistentRegistry::~PersistentRegistry ( )
virtual

Definition at line 22 of file Persistent.cpp.

◆ PersistentRegistry() [2/3]

persistent::PersistentRegistry::PersistentRegistry ( PersistentRegistry &&  )
default

Enable move constructor.

◆ PersistentRegistry() [3/3]

persistent::PersistentRegistry::PersistentRegistry ( const PersistentRegistry )
delete

Disable copy constructor.

Member Function Documentation

◆ callFunc()

template<int funcIdx, typename... Args>
void persistent::PersistentRegistry::callFunc ( Args...  args)
protected

Helper function I.

Definition at line 21 of file Persistent_impl.hpp.

◆ callFuncMin()

template<int funcIdx, typename ReturnType , typename... Args>
ReturnType persistent::PersistentRegistry::callFuncMin ( Args...  args)
protected

Helper function II.

Definition at line 29 of file Persistent_impl.hpp.

◆ generate_prefix()

std::string persistent::PersistentRegistry::generate_prefix ( const std::type_index &  subgroup_type,
uint32_t  subgroup_index,
uint32_t  shard_num 
)
staticnoexcept

prefix generator prefix format: [hex of subgroup_type]-[subgroup_index]-[shard_num]

Parameters
subgroup_type,thetype information of a subgroup
subgroup_index,theindex of a subgroup
shard_num,theshard number of a subgroup
Returns
a std::string representation of the prefix

Definition at line 88 of file Persistent.cpp.

◆ get_subgroup_prefix()

const char * persistent::PersistentRegistry::get_subgroup_prefix ( )

Get prefix for subgroup, this will appear in the file name of Persistent<T>

Definition at line 84 of file Persistent.cpp.

◆ getEarliestVersionToSerialize()

int64_t persistent::PersistentRegistry::getEarliestVersionToSerialize ( )
staticnoexcept

Returns the earliest version for serialization.

Definition at line 50 of file Persistent.cpp.

◆ getFrontier()

const HLC persistent::PersistentRegistry::getFrontier ( )
inline

get temporal query frontier

Definition at line 146 of file Persistent.hpp.

◆ getMinimumLatestPersistedVersion()

const int64_t persistent::PersistentRegistry::getMinimumLatestPersistedVersion ( )
noexcept

Returns the minimum of the latest persisted versions among all Persistent fields.

Definition at line 38 of file Persistent.cpp.

◆ makeVersion()

void persistent::PersistentRegistry::makeVersion ( const int64_t &  ver,
const HLC mhlc 
)
noexcept

Make a new version capturing the current state of the object.

Definition at line 26 of file Persistent.cpp.

◆ match_prefix()

bool persistent::PersistentRegistry::match_prefix ( const std::string  str,
const std::type_index &  subgroup_type,
uint32_t  subgroup_index,
uint32_t  shard_num 
)
staticnoexcept

match prefix

Parameters
str,astring begin with a prefix like [hex64 of subgroup_type]-[subgroup_index]-[shard_num]-
subgroup_type,thetype information of a subgroup
subgroup_index,theindex of a subgroup
shard_num,theshard number of a subgroup
Returns
true if the prefix match the subgroup type,index, and shard_num; otherwise, false.

Definition at line 102 of file Persistent.cpp.

◆ persist()

const int64_t persistent::PersistentRegistry::persist ( )
noexcept

(attempt to) Persist all existing versions

Returns
The newest version number that was actually persisted.

Definition at line 30 of file Persistent.cpp.

◆ registerPersist()

void persistent::PersistentRegistry::registerPersist ( const char *  obj_name,
const VersionFunc vf,
const PersistFunc pf,
const TrimFunc tf,
const LatestPersistedGetterFunc lpgf,
const TruncateFunc tcf 
)
noexcept

set the latest version for serialization register a Persistent<T> along with its lambda

Definition at line 58 of file Persistent.cpp.

◆ resetEarliestVersionToSerialize()

void persistent::PersistentRegistry::resetEarliestVersionToSerialize ( )
staticnoexcept

Reset the earliest version for serialization to an invalid "uninitialized" state.

Definition at line 46 of file Persistent.cpp.

◆ setEarliestVersionToSerialize()

void persistent::PersistentRegistry::setEarliestVersionToSerialize ( const int64_t &  ver)
staticnoexcept

Set the earliest version for serialization, exclusive.

This version will be stored in a thread-local variable. When to_bytes() is next called on Persistent<T>, it will serialize the logs starting after that version (so the serialized logs exclude version ver).

Parameters
verThe version after which to begin serializing logs

Definition at line 42 of file Persistent.cpp.

◆ trim()

void persistent::PersistentRegistry::trim ( const int64_t &  earliest_version)
noexcept

Trims the log of all versions earlier than the argument.

Definition at line 34 of file Persistent.cpp.

◆ truncate()

void persistent::PersistentRegistry::truncate ( const int64_t &  last_version)

Truncates the log, deleting all versions newer than the provided argument.

Since this throws away recently-used data, it should only be used during failure recovery when those versions must be rolled back.

Definition at line 54 of file Persistent.cpp.

◆ unregisterPersist()

void persistent::PersistentRegistry::unregisterPersist ( const char *  obj_name)
noexcept

deregister

Definition at line 75 of file Persistent.cpp.

◆ updateTemporalFrontierProvider()

void persistent::PersistentRegistry::updateTemporalFrontierProvider ( ITemporalQueryFrontierProvider tqfp)

update temporal query frontier we didn't use a lock on this becuase we assume this is only updated object construction.

please use this when you are sure there is no concurrent threads relying on it.

Definition at line 80 of file Persistent.cpp.

Member Data Documentation

◆ _registry

std::map<std::size_t, std::tuple<VersionFunc, PersistFunc, TrimFunc, LatestPersistedGetterFunc, TruncateFunc> > persistent::PersistentRegistry::_registry
protected

Callback registry.

Definition at line 217 of file Persistent.hpp.

◆ _subgroup_prefix

const std::string persistent::PersistentRegistry::_subgroup_prefix
protected

this appears in the first part of storage file for persistent<T>

Definition at line 207 of file Persistent.hpp.

◆ _temporal_query_frontier_provider

ITemporalQueryFrontierProvider* persistent::PersistentRegistry::_temporal_query_frontier_provider
protected

Pointer to an entity providing TemporalQueryFrontier service.

Definition at line 212 of file Persistent.hpp.

◆ earliest_version_to_serialize

thread_local int64_t persistent::PersistentRegistry::earliest_version_to_serialize = INVALID_VERSION
staticprotected

Set the earliest version to serialize for recovery.

Definition at line 234 of file Persistent.hpp.


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