rippled
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
ripple::NodeStore::DeterministicShard Class Reference

DeterministicShard class. More...

Collaboration diagram for ripple::NodeStore::DeterministicShard:
Collaboration graph
[legend]

Public Member Functions

 ~DeterministicShard ()
 
void close ()
 Finalizes and closes the shard. More...
 
boost::filesystem::path const & getDir () const
 
bool store (std::shared_ptr< NodeObject > const &nodeObject)
 Store a node object in memory. More...
 

Private Member Functions

 DeterministicShard (DeterministicShard const &)=delete
 
DeterministicShardoperator= (DeterministicShard const &)=delete
 
 DeterministicShard (Application &app, boost::filesystem::path const &dir, std::uint32_t index, beast::Journal j)
 Creates the object for shard database. More...
 
bool init (Serializer const &finalKey)
 Initializes the deterministic shard. More...
 
void close (bool cancel)
 Finalizes and closes the shard. More...
 

Private Attributes

Applicationapp_
 
const std::uint32_t index_
 
const boost::filesystem::path dir_
 
DummyScheduler scheduler_
 
std::unique_ptr< nudb::context > ctx_
 
std::shared_ptr< Backendbackend_
 
const beast::Journal j_
 
std::uint32_t curMemObjs_
 
const std::uint32_t maxMemObjs_
 

Static Private Attributes

constexpr static std::uint32_t maxMemObjsDefault = 16384u
 
constexpr static std::uint32_t maxMemObjsTest = 16u
 
constexpr static std::uint64_t deterministicType = 0x5348524400000000ll
 

Friends

std::shared_ptr< DeterministicShardmake_DeterministicShard (Application &app, boost::filesystem::path const &shardDir, std::uint32_t shardIndex, Serializer const &finalKey, beast::Journal j)
 Creates shared pointer to deterministic shard and initializes it. More...
 

Detailed Description

DeterministicShard class.

  1. The init() method creates temporary folder dir_, and the deterministic shard is initialized in that folder.
  2. The store() method adds object to memory pool.
  3. The flush() method stores all objects from memory pool to the shard located in dir_ in sorted order.
  4. The close(true) method closes the backend and removes the directory.

Definition at line 40 of file DeterministicShard.h.

Constructor & Destructor Documentation

◆ DeterministicShard() [1/2]

ripple::NodeStore::DeterministicShard::DeterministicShard ( DeterministicShard const &  )
privatedelete

◆ DeterministicShard() [2/2]

ripple::NodeStore::DeterministicShard::DeterministicShard ( Application app,
boost::filesystem::path const &  dir,
std::uint32_t  index,
beast::Journal  j 
)
private

Creates the object for shard database.

Parameters
appApplication object
dirDirectory where shard is located
indexIndex of the shard
jJournal to logging

Definition at line 35 of file DeterministicShard.cpp.

◆ ~DeterministicShard()

ripple::NodeStore::DeterministicShard::~DeterministicShard ( )

Definition at line 52 of file DeterministicShard.cpp.

Member Function Documentation

◆ operator=()

DeterministicShard& ripple::NodeStore::DeterministicShard::operator= ( DeterministicShard const &  )
privatedelete

◆ init()

bool ripple::NodeStore::DeterministicShard::init ( Serializer const &  finalKey)
private

Initializes the deterministic shard.

Parameters
finalKeySerializer of shard's final key which consists of: shard version (32 bit) first ledger sequence in the shard (32 bit) last ledger sequence in the shard (32 bit) hash of last ledger (256 bits)
Returns
true if no error, false if error

Definition at line 58 of file DeterministicShard.cpp.

◆ close() [1/2]

void ripple::NodeStore::DeterministicShard::close ( )

Finalizes and closes the shard.

Definition at line 84 of file DeterministicShard.h.

◆ getDir()

boost::filesystem::path const& ripple::NodeStore::DeterministicShard::getDir ( ) const

Definition at line 90 of file DeterministicShard.h.

◆ store()

bool ripple::NodeStore::DeterministicShard::store ( std::shared_ptr< NodeObject > const &  nodeObject)

Store a node object in memory.

Parameters
nodeObjectThe node object to store
Returns
true on success.
Note
Flushes all objects in memory to the backend when the number of node objects held in memory exceed a threshold

Definition at line 191 of file DeterministicShard.cpp.

◆ close() [2/2]

void ripple::NodeStore::DeterministicShard::close ( bool  cancel)
private

Finalizes and closes the shard.

Parameters
cancelTrue if reject the shard and delete all files, false if finalize the shard and store them

Definition at line 166 of file DeterministicShard.cpp.

Friends And Related Function Documentation

◆ make_DeterministicShard

std::shared_ptr<DeterministicShard> make_DeterministicShard ( Application app,
boost::filesystem::path const &  shardDir,
std::uint32_t  shardIndex,
Serializer const &  finalKey,
beast::Journal  j 
)
friend

Creates shared pointer to deterministic shard and initializes it.

Parameters
appApplication object
shardDirDirectory where shard is located
shardIndexIndex of the shard
finalKeySerializer of shard's ginal key which consists of: shard version (32 bit) first ledger sequence in the shard (32 bit) last ledger sequence in the shard (32 bit) hash of last ledger (256 bits)
jJournal to logging
Returns
Shared pointer to deterministic shard or {} in case of error.

Definition at line 151 of file DeterministicShard.cpp.

Member Data Documentation

◆ maxMemObjsDefault

constexpr static std::uint32_t ripple::NodeStore::DeterministicShard::maxMemObjsDefault = 16384u
staticconstexprprivate

Definition at line 42 of file DeterministicShard.h.

◆ maxMemObjsTest

constexpr static std::uint32_t ripple::NodeStore::DeterministicShard::maxMemObjsTest = 16u
staticconstexprprivate

Definition at line 43 of file DeterministicShard.h.

◆ deterministicType

constexpr static std::uint64_t ripple::NodeStore::DeterministicShard::deterministicType = 0x5348524400000000ll
staticconstexprprivate

Definition at line 46 of file DeterministicShard.h.

◆ app_

Application& ripple::NodeStore::DeterministicShard::app_
private

Definition at line 115 of file DeterministicShard.h.

◆ index_

const std::uint32_t ripple::NodeStore::DeterministicShard::index_
private

Definition at line 118 of file DeterministicShard.h.

◆ dir_

const boost::filesystem::path ripple::NodeStore::DeterministicShard::dir_
private

Definition at line 121 of file DeterministicShard.h.

◆ scheduler_

DummyScheduler ripple::NodeStore::DeterministicShard::scheduler_
private

Definition at line 124 of file DeterministicShard.h.

◆ ctx_

std::unique_ptr<nudb::context> ripple::NodeStore::DeterministicShard::ctx_
private

Definition at line 127 of file DeterministicShard.h.

◆ backend_

std::shared_ptr<Backend> ripple::NodeStore::DeterministicShard::backend_
private

Definition at line 130 of file DeterministicShard.h.

◆ j_

const beast::Journal ripple::NodeStore::DeterministicShard::j_
private

Definition at line 133 of file DeterministicShard.h.

◆ curMemObjs_

std::uint32_t ripple::NodeStore::DeterministicShard::curMemObjs_
private

Definition at line 136 of file DeterministicShard.h.

◆ maxMemObjs_

const std::uint32_t ripple::NodeStore::DeterministicShard::maxMemObjs_
private

Definition at line 139 of file DeterministicShard.h.