MADARA  3.4.1
madara::knowledge::CheckpointSettings Class Reference

Holds settings for checkpoints to load or save. More...

#include <CheckpointSettings.h>

Public Member Functions

 CheckpointSettings ()
 Constructor. More...
 
 CheckpointSettings (const CheckpointSettings &rhs)=default
 Copy constructor. More...
 
 CheckpointSettings (size_t t_buffer_size, bool t_clear_knowledge, std::string t_filename="", uint64_t t_initial_timestamp=0, uint64_t t_last_timestamp=0, uint64_t t_initial_lamport_clock=0, uint64_t t_last_lamport_clock=0, std::string t_originator="", const std::vector< std::string > &t_prefixes={}, uint64_t t_states=0, std::string t_version="", bool t_override_timestamp=false, bool t_override_lamport=false, bool t_keep_open=false, uint64_t t_initial_state=0, uint64_t t_last_state=(uint64_t) -1, bool t_reset_checkpoint=true, bool t_ignore_header_check=false, VariablesLister *t_variables_lister=nullptr, size_t t_max_buffer_size=2000000000)
 Constructor. More...
 
 ~CheckpointSettings ()=default
 Destructor. More...
 
int decode (char *source, int size, int max_size) const
 Calls decode on the the buffer filter chain. More...
 
int encode (char *source, int size, int max_size) const
 Calls encode on the the buffer filter chain. More...
 

Public Attributes

filters::BufferFilters buffer_filters
 buffer filters. More...
 
size_t buffer_size
 the size of the buffer needed for the checkpoint More...
 
bool clear_knowledge
 If true, during loads, clear the KnowledgeBase first. More...
 
std::string filename
 path to files More...
 
bool ignore_header_check
 If true, do not perform a header check. More...
 
uint64_t initial_lamport_clock
 initial lamport clock saved in the checkpoint More...
 
uint64_t initial_state
 the initial state number of interest (useful for loading ranges of checkpoint states). More...
 
uint64_t initial_timestamp
 initial wallclock time saved in the checkpoint More...
 
bool keep_open
 if true, keep the file open to avoid open/close overhead when programmatically iterating through checkpoints. More...
 
uint64_t last_lamport_clock
 final lamport clock saved in the checkpoint More...
 
uint64_t last_state
 the last state number of interest (useful for loading ranges of checkpoint states. More...
 
uint64_t last_timestamp
 final wallclock time saved in the checkpoint More...
 
size_t max_buffer_size = 2000000000
 the max size the buffer can grow to More...
 
std::string originator
 the originator id of the checkpoint More...
 
bool override_lamport
 use the lamport clocks in this class instead of KB clock when writing context or checkpoints More...
 
bool override_timestamp
 use the timestamps in this class instead of current wallclock time when writing context or checkpoints More...
 
bool playback_simtime = false
 If true, update simtime during playback to match recorded TOI. More...
 
std::vector< std::string > prefixes
 A list of prefixes to save/load. More...
 
bool reset_checkpoint
 If true, resets the checkpoint to start a new diff from this point forward. More...
 
uint64_t states
 the number of states checkpointed in the file stream More...
 
friend ThreadSafeContext
 Allow for ThreadSafeContext to update private data members. More...
 
VariablesListervariables_lister = nullptr
 Object which will be used to extract variables for checkpoint saving. More...
 
std::string version
 the MADARA version More...
 

Private Attributes

std::shared_ptr< FILE > checkpoint_file
 a thread-safe ref-counted file handle for quick access to an open checkpoint binary file More...
 

Detailed Description

Holds settings for checkpoints to load or save.

Most of the data members are "smart" data members. For loads, many of the fields are essentially pass-by-reference and fill with the related data.

Definition at line 35 of file CheckpointSettings.h.

Constructor & Destructor Documentation

◆ CheckpointSettings() [1/3]

madara::knowledge::CheckpointSettings::CheckpointSettings ( )
inline

Constructor.

Definition at line 46 of file CheckpointSettings.h.

◆ CheckpointSettings() [2/3]

madara::knowledge::CheckpointSettings::CheckpointSettings ( size_t  t_buffer_size,
bool  t_clear_knowledge,
std::string  t_filename = "",
uint64_t  t_initial_timestamp = 0,
uint64_t  t_last_timestamp = 0,
uint64_t  t_initial_lamport_clock = 0,
uint64_t  t_last_lamport_clock = 0,
std::string  t_originator = "",
const std::vector< std::string > &  t_prefixes = {},
uint64_t  t_states = 0,
std::string  t_version = "",
bool  t_override_timestamp = false,
bool  t_override_lamport = false,
bool  t_keep_open = false,
uint64_t  t_initial_state = 0,
uint64_t  t_last_state = (uint64_t)-1,
bool  t_reset_checkpoint = true,
bool  t_ignore_header_check = false,
VariablesLister t_variables_lister = nullptr,
size_t  t_max_buffer_size = 2000000000 
)
inline

Constructor.

Parameters
t_buffer_sizesize in bytes to allocate for a buffer
t_clear_knowledgeif true, during loads, clear knowledge
t_filenamethe filename, including path to load/save
t_originatorthe originator id
t_initial_timestampthe wallclock time the checkpoint started
t_last_timestampthe wallclock time the checkpoint ended
t_initial_lamport_clockthe clock when checkpoint started
t_last_lamport_clockthe clock when checkpoint ended
t_prefixesthe prefixes to save or load (empty = all)
t_statesnumber of states in checkpoint
t_versionthe version of the checkpoint
t_override_timestampoverride the timestamps
t_override_lamportoverride the lamport clocks
t_keep_openattempt to keep the file open for later
t_initial_statethe initial state to query/save
t_last_statethe last state to query/save
t_reset_checkpointreset the checkpoint modifieds
t_ignore_header_checkif true, ignore header checks
t_max_buffer_sizethe max size in bytes for buffer growth
t_variables_listera custom list of variables to print

Definition at line 89 of file CheckpointSettings.h.

◆ CheckpointSettings() [3/3]

madara::knowledge::CheckpointSettings::CheckpointSettings ( const CheckpointSettings rhs)
default

Copy constructor.

Parameters
rhssettings instance to copy

◆ ~CheckpointSettings()

madara::knowledge::CheckpointSettings::~CheckpointSettings ( )
default

Destructor.

Member Function Documentation

◆ decode()

int madara::knowledge::CheckpointSettings::decode ( char *  source,
int  size,
int  max_size 
) const
inline

Calls decode on the the buffer filter chain.

Parameters
sourcethe source and destination buffer
sizethe amount of data in the buffer in bytes
max_sizethe amount of bytes the buffer can hold
Returns
the new size after encoding

Definition at line 223 of file CheckpointSettings.h.

◆ encode()

int madara::knowledge::CheckpointSettings::encode ( char *  source,
int  size,
int  max_size 
) const
inline

Calls encode on the the buffer filter chain.

Parameters
sourcethe source and destination buffer
sizethe amount of data in the buffer in bytes
max_sizethe amount of bytes the buffer can hold
Returns
the new size after encoding

Definition at line 164 of file CheckpointSettings.h.

Member Data Documentation

◆ buffer_filters

filters::BufferFilters madara::knowledge::CheckpointSettings::buffer_filters

buffer filters.

Note that the user must clean up memory of all filters

Definition at line 419 of file CheckpointSettings.h.

◆ buffer_size

size_t madara::knowledge::CheckpointSettings::buffer_size

the size of the buffer needed for the checkpoint

Definition at line 352 of file CheckpointSettings.h.

◆ checkpoint_file

std::shared_ptr<FILE> madara::knowledge::CheckpointSettings::checkpoint_file
private

a thread-safe ref-counted file handle for quick access to an open checkpoint binary file

Definition at line 480 of file CheckpointSettings.h.

◆ clear_knowledge

bool madara::knowledge::CheckpointSettings::clear_knowledge

If true, during loads, clear the KnowledgeBase first.

Definition at line 357 of file CheckpointSettings.h.

◆ filename

std::string madara::knowledge::CheckpointSettings::filename

path to files

Definition at line 362 of file CheckpointSettings.h.

◆ ignore_header_check

bool madara::knowledge::CheckpointSettings::ignore_header_check

If true, do not perform a header check.

This is useful if you are loading an arbitrary text file with no buffer filters

Definition at line 452 of file CheckpointSettings.h.

◆ initial_lamport_clock

uint64_t madara::knowledge::CheckpointSettings::initial_lamport_clock

initial lamport clock saved in the checkpoint

Definition at line 377 of file CheckpointSettings.h.

◆ initial_state

uint64_t madara::knowledge::CheckpointSettings::initial_state

the initial state number of interest (useful for loading ranges of checkpoint states).

This is an inclusive identifier, so 0 means to load from initial context/checkpoint save

Definition at line 433 of file CheckpointSettings.h.

◆ initial_timestamp

uint64_t madara::knowledge::CheckpointSettings::initial_timestamp

initial wallclock time saved in the checkpoint

Definition at line 367 of file CheckpointSettings.h.

◆ keep_open

bool madara::knowledge::CheckpointSettings::keep_open

if true, keep the file open to avoid open/close overhead when programmatically iterating through checkpoints.

This is sort of useful with save_checkpoint

Definition at line 426 of file CheckpointSettings.h.

◆ last_lamport_clock

uint64_t madara::knowledge::CheckpointSettings::last_lamport_clock

final lamport clock saved in the checkpoint

Definition at line 382 of file CheckpointSettings.h.

◆ last_state

uint64_t madara::knowledge::CheckpointSettings::last_state

the last state number of interest (useful for loading ranges of checkpoint states.

This is an inclusive identifier. If last_state >= states, it will essentially indicate the last valid state.

Definition at line 440 of file CheckpointSettings.h.

◆ last_timestamp

uint64_t madara::knowledge::CheckpointSettings::last_timestamp

final wallclock time saved in the checkpoint

Definition at line 372 of file CheckpointSettings.h.

◆ max_buffer_size

size_t madara::knowledge::CheckpointSettings::max_buffer_size = 2000000000

the max size the buffer can grow to

Definition at line 473 of file CheckpointSettings.h.

◆ originator

std::string madara::knowledge::CheckpointSettings::originator

the originator id of the checkpoint

Definition at line 387 of file CheckpointSettings.h.

◆ override_lamport

bool madara::knowledge::CheckpointSettings::override_lamport

use the lamport clocks in this class instead of KB clock when writing context or checkpoints

Definition at line 414 of file CheckpointSettings.h.

◆ override_timestamp

bool madara::knowledge::CheckpointSettings::override_timestamp

use the timestamps in this class instead of current wallclock time when writing context or checkpoints

Definition at line 408 of file CheckpointSettings.h.

◆ playback_simtime

bool madara::knowledge::CheckpointSettings::playback_simtime = false

If true, update simtime during playback to match recorded TOI.

Only operable if MADARA_FEATURE_SIMTIME macro is defined.

Definition at line 458 of file CheckpointSettings.h.

◆ prefixes

std::vector<std::string> madara::knowledge::CheckpointSettings::prefixes

A list of prefixes to save/load.

If empty, all prefixes are valid.

Definition at line 392 of file CheckpointSettings.h.

◆ reset_checkpoint

bool madara::knowledge::CheckpointSettings::reset_checkpoint

If true, resets the checkpoint to start a new diff from this point forward.

Definition at line 446 of file CheckpointSettings.h.

◆ states

uint64_t madara::knowledge::CheckpointSettings::states

the number of states checkpointed in the file stream

Definition at line 397 of file CheckpointSettings.h.

◆ ThreadSafeContext

friend madara::knowledge::CheckpointSettings::ThreadSafeContext

Allow for ThreadSafeContext to update private data members.

Definition at line 41 of file CheckpointSettings.h.

◆ variables_lister

VariablesLister* madara::knowledge::CheckpointSettings::variables_lister = nullptr

Object which will be used to extract variables for checkpoint saving.

By default (if left nullptr), use a default implementation which uses ThreadSaveContext::get_local_modified

This object is not owned, so must exist as long as this settings obejct exists

Definition at line 468 of file CheckpointSettings.h.

◆ version

std::string madara::knowledge::CheckpointSettings::version

the MADARA version

Definition at line 402 of file CheckpointSettings.h.


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