Ring Daemon 16.0.0
Loading...
Searching...
No Matches
jami::Bucket Class Reference

#include <routing_table.h>

Collaboration diagram for jami::Bucket:
Collaboration graph

Public Member Functions

bool addConnectingNode (const NodeId &nodeId)
 Add NodeId to connecting_nodes if it doesn't exist in nodes.
 
bool addKnownNode (const NodeId &nodeId)
 Add NodeId to known_nodes if it doesn't exist in nodes.
 
bool addMobileNode (const NodeId &nodeId)
 Add NodeId to mobile_nodes if it doesn't exist in nodes.
 
bool addNode (const std::shared_ptr< dhtnet::ChannelSocketInterface > &socket)
 Add Node socket to bucket.
 
bool addNode (NodeInfo &&info)
 Add NodeInfo to bucket.
 
 Bucket ()=delete
 
 Bucket (const Bucket &)=delete
 
 Bucket (const NodeId &)
 
void changeMobility (const NodeId &nodeId, bool isMobile)
 Change mobility of specific node, mobile or not.
 
const std::set< NodeId > & getConnectingNodes () const
 Get NodeIds of connecting_nodes.
 
unsigned getConnectingNodesSize () const
 Returns number of mobile_nodes in bucket.
 
NodeId getKnownNode (unsigned index) const
 Returns NodeId from known_nodes at index.
 
const std::set< NodeId > & getKnownNodes () const
 Get NodeIds from known_nodes.
 
std::set< NodeIdgetKnownNodesRandom (unsigned numberNodes, std::mt19937_64 &rd) const
 Returns random numberNodes NodeId from known_nodes.
 
unsigned getKnownNodesSize () const
 Returns number of knwon_nodes in bucket.
 
NodeId getLowerLimit () const
 Returns bucket lower limit.
 
const std::set< NodeId > & getMobileNodes () const
 Get NodeIds from mobile_nodes.
 
std::set< NodeIdgetNodeIds () const
 Get NodeIds from bucket.
 
std::map< NodeId, NodeInfo > & getNodes ()
 Get connected nodes from bucket.
 
std::set< std::shared_ptr< dhtnet::ChannelSocketInterface > > getNodeSockets () const
 Get sockets from bucket.
 
unsigned getNodesSize () const
 Returns number of nodes in bucket.
 
asio::steady_timer & getNodeTimer (const std::shared_ptr< dhtnet::ChannelSocketInterface > &socket)
 Returns socket's timer.
 
bool hasConnectingNode (const NodeId &nodeId) const
 Test if NodeId exist in connecting_nodes.
 
bool hasKnownNode (const NodeId &nodeId) const
 Test if NodeId exist in known_nodes.
 
bool hasMobileNode (const NodeId &nodeId)
 Test if NodeId exist in mobile_nodes.
 
bool hasNode (const NodeId &nodeId) const
 Test if socket exists in nodes.
 
bool isEmpty () const
 
bool isFull () const
 Indicate if bucket is full.
 
void printBucket (unsigned number) const
 Prints bucket and bucket's number.
 
NodeId randomId (std::mt19937_64 &rd) const
 Returns random NodeId from known_nodes.
 
void removeConnectingNode (const NodeId &nodeId)
 Remove NodeId from connecting_nodes.
 
void removeKnownNode (const NodeId &nodeId)
 Remove NodeId from known_nodes.
 
void removeMobileNode (const NodeId &nodeId)
 Remove NodeId from mobile_nodes.
 
bool removeNode (const NodeId &nodeId)
 Remove NodeId socket from bucket and insert it in known_nodes or mobile_nodes depending on its type.
 
void setLowerLimit (const NodeId &nodeId)
 Set bucket's lower limit.
 
void shutdownAllNodes ()
 Shutdowns all sockets in nodes through shutdownNode.
 
bool shutdownNode (const NodeId &nodeId)
 Shutdowns socket and removes it from nodes.
 

Static Public Attributes

static constexpr int BUCKET_MAX_SIZE = 2
 

Detailed Description

Definition at line 56 of file routing_table.h.

Constructor & Destructor Documentation

◆ Bucket() [1/3]

jami::Bucket::Bucket ( )
delete

◆ Bucket() [2/3]

jami::Bucket::Bucket ( const Bucket )
delete

◆ Bucket() [3/3]

jami::Bucket::Bucket ( const NodeId id)

Definition at line 37 of file routing_table.cpp.

Member Function Documentation

◆ addConnectingNode()

bool jami::Bucket::addConnectingNode ( const NodeId nodeId)

Add NodeId to connecting_nodes if it doesn't exist in nodes.

Parameters
nodeId
nodeInfo
Returns
true if connecting node was added, false if not

Definition at line 128 of file routing_table.cpp.

References hasNode().

Here is the call graph for this function:

◆ addKnownNode()

bool jami::Bucket::addKnownNode ( const NodeId nodeId)

Add NodeId to known_nodes if it doesn't exist in nodes.

Parameters
nodeId
Returns
true if known node was added, false if not

Definition at line 93 of file routing_table.cpp.

References hasNode().

Referenced by removeNode().

Here is the call graph for this function:

◆ addMobileNode()

bool jami::Bucket::addMobileNode ( const NodeId nodeId)

Add NodeId to mobile_nodes if it doesn't exist in nodes.

Parameters
nodeId
Returns
true if mobile node was added, false if not

Definition at line 116 of file routing_table.cpp.

References hasNode().

Referenced by removeNode().

Here is the call graph for this function:

◆ addNode() [1/2]

bool jami::Bucket::addNode ( const std::shared_ptr< dhtnet::ChannelSocketInterface > &  socket)

Add Node socket to bucket.

Parameters
socket
Returns
true if node was added, false if not

Definition at line 42 of file routing_table.cpp.

References addNode().

Referenced by addNode().

Here is the call graph for this function:

◆ addNode() [2/2]

bool jami::Bucket::addNode ( NodeInfo &&  info)

Add NodeInfo to bucket.

Parameters
nodeInfo
Returns
true if node was added, false if not

Definition at line 48 of file routing_table.cpp.

◆ changeMobility()

void jami::Bucket::changeMobility ( const NodeId nodeId,
bool  isMobile 
)

Change mobility of specific node, mobile or not.

Definition at line 226 of file routing_table.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ getConnectingNodes()

const std::set< NodeId > & jami::Bucket::getConnectingNodes ( ) const
inline

Get NodeIds of connecting_nodes.

Returns
set of connecting NodeIds

Definition at line 189 of file routing_table.h.

◆ getConnectingNodesSize()

unsigned jami::Bucket::getConnectingNodesSize ( ) const
inline

Returns number of mobile_nodes in bucket.

Returns
size of mobile_nodes

Definition at line 274 of file routing_table.h.

◆ getKnownNode()

NodeId jami::Bucket::getKnownNode ( unsigned  index) const

Returns NodeId from known_nodes at index.

Parameters
index
Returns
NodeId

Definition at line 104 of file routing_table.cpp.

References jami::emitSignal().

Referenced by getKnownNodesRandom().

Here is the call graph for this function:

◆ getKnownNodes()

const std::set< NodeId > & jami::Bucket::getKnownNodes ( ) const
inline

Get NodeIds from known_nodes.

Returns
set of known NodeIds

Definition at line 124 of file routing_table.h.

Referenced by getKnownNodesRandom().

◆ getKnownNodesRandom()

std::set< NodeId > jami::Bucket::getKnownNodesRandom ( unsigned  numberNodes,
std::mt19937_64 &  rd 
) const

Returns random numberNodes NodeId from known_nodes.

Parameters
numberNodes
rd
Returns
set of numberNodes random known NodeIds

Definition at line 141 of file routing_table.cpp.

References jami::emitSignal(), getKnownNode(), getKnownNodes(), and getKnownNodesSize().

Referenced by randomId().

Here is the call graph for this function:

◆ getKnownNodesSize()

unsigned jami::Bucket::getKnownNodesSize ( ) const
inline

Returns number of knwon_nodes in bucket.

Returns
size of knwon_nodes

Definition at line 268 of file routing_table.h.

Referenced by getKnownNodesRandom().

◆ getLowerLimit()

NodeId jami::Bucket::getLowerLimit ( ) const
inline

Returns bucket lower limit.

Returns
NodeId lower limit

Definition at line 280 of file routing_table.h.

◆ getMobileNodes()

const std::set< NodeId > & jami::Bucket::getMobileNodes ( ) const
inline

Get NodeIds from mobile_nodes.

Returns
set of mobile NodeIds

Definition at line 170 of file routing_table.h.

◆ getNodeIds()

std::set< NodeId > jami::Bucket::getNodeIds ( ) const

Get NodeIds from bucket.

Returns
set of NodeIds

Definition at line 78 of file routing_table.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ getNodes()

std::map< NodeId, NodeInfo > & jami::Bucket::getNodes ( )
inline

Get connected nodes from bucket.

Returns
map of NodeId and NodeInfo

Definition at line 92 of file routing_table.h.

◆ getNodeSockets()

std::set< std::shared_ptr< dhtnet::ChannelSocketInterface > > jami::Bucket::getNodeSockets ( ) const

Get sockets from bucket.

Returns
set of sockets

Definition at line 237 of file routing_table.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ getNodesSize()

unsigned jami::Bucket::getNodesSize ( ) const
inline

Returns number of nodes in bucket.

Returns
size of nodes

Definition at line 262 of file routing_table.h.

◆ getNodeTimer()

asio::steady_timer & jami::Bucket::getNodeTimer ( const std::shared_ptr< dhtnet::ChannelSocketInterface > &  socket)

Returns socket's timer.

Parameters
socket
Returns
timer

Definition at line 158 of file routing_table.cpp.

◆ hasConnectingNode()

bool jami::Bucket::hasConnectingNode ( const NodeId nodeId) const
inline

Test if NodeId exist in connecting_nodes.

Parameters
nodeId
Returns
true if connecting node exists, false if not

Definition at line 196 of file routing_table.h.

◆ hasKnownNode()

bool jami::Bucket::hasKnownNode ( const NodeId nodeId) const
inline

Test if NodeId exist in known_nodes.

Parameters
nodeId
Returns
true if known node exists, false if not

Definition at line 138 of file routing_table.h.

◆ hasMobileNode()

bool jami::Bucket::hasMobileNode ( const NodeId nodeId)
inline

Test if NodeId exist in mobile_nodes.

Parameters
nodeId
Returns
true if mobile node exists, false if not

Definition at line 161 of file routing_table.h.

◆ hasNode()

bool jami::Bucket::hasNode ( const NodeId nodeId) const

Test if socket exists in nodes.

Parameters
nodeId
Returns
true if node exists, false if not

Definition at line 87 of file routing_table.cpp.

Referenced by addConnectingNode(), addKnownNode(), and addMobileNode().

◆ isEmpty()

bool jami::Bucket::isEmpty ( ) const
inline

Definition at line 201 of file routing_table.h.

◆ isFull()

bool jami::Bucket::isFull ( ) const
inline

Indicate if bucket is full.

Returns
true if bucket is full, false if not

Definition at line 207 of file routing_table.h.

References BUCKET_MAX_SIZE.

◆ printBucket()

void jami::Bucket::printBucket ( unsigned  number) const

Prints bucket and bucket's number.

Definition at line 195 of file routing_table.cpp.

References jami::emitSignal(), JAMI_DEBUG, and JAMI_ERROR.

Here is the call graph for this function:

◆ randomId()

NodeId jami::Bucket::randomId ( std::mt19937_64 &  rd) const
inline

Returns random NodeId from known_nodes.

Parameters
rd
Returns
random known NodeId

Definition at line 222 of file routing_table.h.

References getKnownNodesRandom().

Here is the call graph for this function:

◆ removeConnectingNode()

void jami::Bucket::removeConnectingNode ( const NodeId nodeId)
inline

Remove NodeId from connecting_nodes.

Parameters
nodeId

Definition at line 184 of file routing_table.h.

◆ removeKnownNode()

void jami::Bucket::removeKnownNode ( const NodeId nodeId)
inline

Remove NodeId from known_nodes.

Parameters
nodeId

Definition at line 118 of file routing_table.h.

◆ removeMobileNode()

void jami::Bucket::removeMobileNode ( const NodeId nodeId)
inline

Remove NodeId from mobile_nodes.

Parameters
nodeId

Definition at line 154 of file routing_table.h.

◆ removeNode()

bool jami::Bucket::removeNode ( const NodeId nodeId)

Remove NodeId socket from bucket and insert it in known_nodes or mobile_nodes depending on its type.

Parameters
nodeId
Returns
true if node was removed, false if not

Definition at line 61 of file routing_table.cpp.

References addKnownNode(), and addMobileNode().

Referenced by shutdownAllNodes(), and shutdownNode().

Here is the call graph for this function:

◆ setLowerLimit()

void jami::Bucket::setLowerLimit ( const NodeId nodeId)
inline

Set bucket's lower limit.

Parameters
nodeId

Definition at line 286 of file routing_table.h.

◆ shutdownAllNodes()

void jami::Bucket::shutdownAllNodes ( )

Shutdowns all sockets in nodes through shutdownNode.

Definition at line 183 of file routing_table.cpp.

References jami::emitSignal(), and removeNode().

Here is the call graph for this function:

◆ shutdownNode()

bool jami::Bucket::shutdownNode ( const NodeId nodeId)

Shutdowns socket and removes it from nodes.

The corresponding node is moved to known_nodes or mobile_nodes

Parameters
socket
Returns
true if node was shutdown, false if not found

Definition at line 168 of file routing_table.cpp.

References removeNode().

Here is the call graph for this function:

Member Data Documentation

◆ BUCKET_MAX_SIZE

constexpr int jami::Bucket::BUCKET_MAX_SIZE = 2
staticconstexpr

Definition at line 60 of file routing_table.h.

Referenced by isFull(), and jami::SwarmManager::maintainBuckets().


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