35#include "src/jazz_elements/volatile.h"
38#ifndef INCLUDED_JAZZ_CATCH2
39#define INCLUDED_JAZZ_CATCH2
41#include "src/catch2/catch.hpp"
47#ifndef INCLUDED_JAZZ_ELEMENTS_PERSISTED
48#define INCLUDED_JAZZ_ELEMENTS_PERSISTED
50#include "src/lmdb/lmdb.h"
56#define MAX_POSSIBLE_SOURCES 32
57#define MAX_LMDB_HOME_LEN 128
58#define LMDB_UNIX_FILE_PERMISSIONS 0664
59#define INVALID_MDB_DBI 0xefefEFEF
65 char path[MAX_LMDB_HOME_LEN];
74typedef std::map <std::string, MDB_dbi>
DBImap;
130 int mode = WRITE_AS_FULL_BLOCK);
167 void log_lmdb_err(
int loglevel,
int lmdb_err,
const char *msg);
A configuration file as a key/value store.
Definition utils.h:217
Container: A Service to manage Jazz blocks. All Jazz blocks are managed by this or a descendant of th...
Definition container.h:282
virtual StatusCode put(pChar p_where, pBlock p_block, int mode=WRITE_AS_BASE_DEFAULT)
Definition container.cpp:1903
virtual StatusCode remove(pChar p_where)
Definition container.cpp:1941
virtual StatusCode new_entity(pChar p_where)
Definition container.cpp:1922
virtual StatusCode copy(pChar p_where, pChar p_what)
Definition container.cpp:1963
virtual StatusCode get(pTransaction &p_txn, pChar p_what)
Definition container.cpp:1760
virtual StatusCode header(StaticBlockHeader &hea, pChar p_what)
Definition container.cpp:1854
A simple logger.
Definition utils.h:245
Persisted: A Service to manage data objects in LMDB.
Definition persisted.h:93
void base_names(BaseNames &base_names)
Definition persisted.cpp:643
void done_pointer_to_block(pMDB_txn &p_txn)
Completes the transaction started by lock_pointer_to_block() doing a mdb_txn_commit() which invalidat...
Definition persisted.cpp:726
StatusCode shut_down()
Shuts down the Persisted Service.
Definition persisted.cpp:203
StatusCode remove_database(pChar name)
Definition persisted.cpp:919
virtual StatusCode copy(Locator &where, Locator &what)
Definition persisted.cpp:615
bool dbi_exists(Name dbi_name)
Check the internal std::map to see if a (dbi) database name exists.
Definition persisted.cpp:655
virtual StatusCode remove(Locator &where)
Definition persisted.cpp:546
DBImap source_dbi
The lmdb MDB_dbi handles for each source.
Definition persisted.h:169
bool open_all_databases()
Definition persisted.cpp:742
void close_all_databases()
Definition persisted.cpp:807
virtual pChar const id()
Definition persisted.cpp:62
StatusCode new_database(pChar name)
Definition persisted.cpp:829
MDB_env * lmdb_env
The LMDB environment.
Definition persisted.h:171
virtual StatusCode new_entity(Locator &where)
Definition persisted.cpp:531
virtual StatusCode put(Locator &where, pBlock p_block, int mode=WRITE_AS_FULL_BLOCK)
Definition persisted.cpp:444
virtual StatusCode get(pTransaction &p_txn, Locator &what)
Definition persisted.cpp:236
bool is_running()
Check if the service is running.
Definition persisted.h:145
StatusCode start()
Starts the service, checking the environment and building the databases.
Definition persisted.cpp:74
void log_lmdb_err(int loglevel, int lmdb_err, const char *msg)
A nicer presentation for LMDB error messages.
Definition persisted.cpp:985
JazzLmdbOptions lmdb_opt
The LMDB options.
Definition persisted.h:170
virtual StatusCode header(StaticBlockHeader &hea, Locator &what)
Definition persisted.cpp:352
pBlock lock_pointer_to_block(Locator &what, pMDB_txn &p_txn)
Locates a block doing an mdb_get() leaving the transaction open.
Definition persisted.cpp:671
The namespace for Jazz Utils, Blocks, Kinds, Tuples, Containers, etc.
Definition block.cpp:39
std::map< std::string, MDB_dbi > DBImap
The lmdb MDB_dbi handles for each source.
Definition persisted.h:74
MDB_txn * pMDB_txn
A pointer to a MDB_txn structure which is what mdb_txn_begin() returns.
Definition persisted.h:75
char * pChar
A pointer to a char buffer.
Definition types.h:185
class Block * pBlock
A (forward defined) pointer to a Block.
Definition block.h:66
Persisted * pPersisted
A pointer to a Persisted object.
Definition persisted.h:173
char Name[NAME_SIZE]
A short identifier used in Blocks, Containers and API.
Definition types.h:183
std::map< std::string, pContainer > BaseNames
A map of names for the containers (or structure engines like "map" or "tree" inside Volatile).
Definition container.h:152
int StatusCode
Type returned by the Service API.
Definition utils.h:141
All the necessary LMDB options (a binary representation of the values in the config file)
Definition persisted.h:64
char path[MAX_LMDB_HOME_LEN]
The path to the LMDB home directory.
Definition persisted.h:65
int env_set_maxdbs
The maximum number of databases as defined in configuration key MDB_ENV_SET_MAXDBS.
Definition persisted.h:69
int flags
The flags as defined in many configuration keys MDB_FIXEDMAP, .. MDB_NOMEMINIT.
Definition persisted.h:70
int env_set_mapsize
The size of the memory map as defined in configuration key MDB_ENV_SET_MAPSIZE.
Definition persisted.h:67
int env_set_maxreaders
The maximum number of reader slots as defined in configuration key MDB_ENV_SET_MAXREADERS.
Definition persisted.h:68
Locator: A minimal structure to define the location of resources inside a Container.
Definition container.h:184
Transaction: A wrapper over a Block that defines the communication of a block with a Container.
Definition container.h:162