psync::FullProducer Class Reference

Full sync logic to synchronize with other nodes where all nodes wants to get all names prefixes synced. More...

#include <PSync/full-producer.hpp>

+ Inheritance diagram for psync::FullProducer:
+ Collaboration diagram for psync::FullProducer:

Classes

struct  Options
 Constructor options. More...
 

Public Member Functions

 FullProducer (ndn::Face &face, ndn::KeyChain &keyChain, const ndn::Name &syncPrefix, const Options &opts)
 Constructor. More...
 
 FullProducer (ndn::Face &face, ndn::KeyChain &keyChain, size_t expectedNumEntries, const ndn::Name &syncPrefix, const ndn::Name &userPrefix, UpdateCallback onUpdateCallBack, ndn::time::milliseconds syncInterestLifetime=SYNC_INTEREST_LIFETIME, ndn::time::milliseconds syncReplyFreshness=SYNC_REPLY_FRESHNESS, CompressionScheme ibltCompression=CompressionScheme::DEFAULT, CompressionScheme contentCompression=CompressionScheme::DEFAULT)
 
 ~FullProducer ()
 
bool addUserNode (const ndn::Name &prefix)
 Adds a user node for synchronization. More...
 
std::optional< uint64_t > getSeqNo (const ndn::Name &prefix) const
 Returns the current sequence number of the given prefix. More...
 
void publishName (const ndn::Name &prefix, std::optional< uint64_t > seq=std::nullopt)
 Publish name to let others know. More...
 
void removeUserNode (const ndn::Name &prefix)
 Remove the user node from synchronization. More...
 

Protected Types

using HashNameBiMap = bm::bimap< bm::unordered_set_of< uint32_t >, bm::unordered_set_of< ndn::Name, std::hash< ndn::Name > >>
 

Protected Member Functions

bool isUserNode (const ndn::Name &prefix) const
 
void sendApplicationNack (const ndn::Name &name)
 Sends a data packet with content type nack. More...
 
void updateSeqNo (const ndn::Name &prefix, uint64_t seq)
 Update m_prefixes and IBF with the given prefix and seq. More...
 

Static Protected Member Functions

static void onRegisterFailed (const ndn::Name &prefix, const std::string &msg)
 Logs a message and throws if setting an interest filter fails. More...
 

Protected Attributes

HashNameBiMap m_biMap
 
const CompressionScheme m_contentCompression
 
const size_t m_expectedNumEntries
 
ndn::Face & m_face
 
detail::IBLT m_iblt
 
const CompressionScheme m_ibltCompression
 
ndn::KeyChain & m_keyChain
 
uint64_t m_numOwnElements = 0
 
std::map< ndn::Name, uint64_t > m_prefixes
 
ndn::random::RandomNumberEngine & m_rng
 
ndn::Scheduler m_scheduler
 
SegmentPublisher m_segmentPublisher
 
const ndn::Name m_syncPrefix
 
const ndn::time::milliseconds m_syncReplyFreshness
 
const size_t m_threshold
 

Detailed Description

Full sync logic to synchronize with other nodes where all nodes wants to get all names prefixes synced.

Application should call publishName whenever it wants to let consumers know that new data is available for the userPrefix. Multiple userPrefixes can be added by using addUserNode. Currently, fetching and publishing of data needs to be handled by the application.

Definition at line 41 of file full-producer.hpp.

Member Typedef Documentation

◆ HashNameBiMap

using psync::ProducerBase::HashNameBiMap = bm::bimap<bm::unordered_set_of<uint32_t>, bm::unordered_set_of<ndn::Name, std::hash<ndn::Name> >>
protectedinherited

Definition at line 165 of file producer-base.hpp.

Constructor & Destructor Documentation

◆ FullProducer() [1/2]

psync::FullProducer::FullProducer ( ndn::Face &  face,
ndn::KeyChain &  keyChain,
const ndn::Name &  syncPrefix,
const Options opts 
)

Constructor.

Parameters
faceApplication face.
keyChainKeyChain instance to use for signing.
syncPrefixThe prefix of the sync group.
optsOptions.

Definition at line 34 of file full-producer.cpp.

◆ FullProducer() [2/2]

psync::FullProducer::FullProducer ( ndn::Face &  face,
ndn::KeyChain &  keyChain,
size_t  expectedNumEntries,
const ndn::Name &  syncPrefix,
const ndn::Name &  userPrefix,
UpdateCallback  onUpdateCallBack,
ndn::time::milliseconds  syncInterestLifetime = SYNC_INTEREST_LIFETIME,
ndn::time::milliseconds  syncReplyFreshness = SYNC_REPLY_FRESHNESS,
CompressionScheme  ibltCompression = CompressionScheme::DEFAULT,
CompressionScheme  contentCompression = CompressionScheme::DEFAULT 
)

Definition at line 52 of file full-producer.cpp.

◆ ~FullProducer()

psync::FullProducer::~FullProducer ( )

Definition at line 69 of file full-producer.cpp.

Member Function Documentation

◆ addUserNode()

bool psync::ProducerBase::addUserNode ( const ndn::Name &  prefix)
inherited

Adds a user node for synchronization.

Initializes m_prefixes[prefix] to zero Does not add zero-th sequence number to IBF because if a large number of user nodes are added then decoding of the difference between own IBF and other IBF will not be possible

Parameters
prefixthe user node to be added

Definition at line 53 of file producer-base.cpp.

◆ getSeqNo()

std::optional<uint64_t> psync::ProducerBase::getSeqNo ( const ndn::Name &  prefix) const
inlineinherited

Returns the current sequence number of the given prefix.

Parameters
prefixprefix to get the sequence number of

Definition at line 83 of file producer-base.hpp.

◆ isUserNode()

bool psync::ProducerBase::isUserNode ( const ndn::Name &  prefix) const
inlineprotectedinherited

Definition at line 132 of file producer-base.hpp.

◆ onRegisterFailed()

void psync::ProducerBase::onRegisterFailed ( const ndn::Name &  prefix,
const std::string &  msg 
)
staticprotectedinherited

Logs a message and throws if setting an interest filter fails.

Definition at line 140 of file producer-base.cpp.

◆ publishName()

void psync::FullProducer::publishName ( const ndn::Name &  prefix,
std::optional< uint64_t >  seq = std::nullopt 
)

Publish name to let others know.

addUserNode needs to be called before this to add the prefix if not already added via the constructor. If seq is null then the seq of prefix is incremented by 1 else the supplied sequence is set in the IBF.

Parameters
prefixthe prefix to be updated
seqthe sequence number of the prefix

Definition at line 77 of file full-producer.cpp.

◆ removeUserNode()

void psync::ProducerBase::removeUserNode ( const ndn::Name &  prefix)
inherited

Remove the user node from synchronization.

Erases prefix from IBF and other maps

Parameters
prefixthe user node to be removed

Definition at line 65 of file producer-base.cpp.

◆ sendApplicationNack()

void psync::ProducerBase::sendApplicationNack ( const ndn::Name &  name)
protectedinherited

Sends a data packet with content type nack.

Producer sends a nack to consumer if consumer has very old IBF whose differences with latest IBF can't be decoded successfully

Parameters
namesend application nack with this name

Definition at line 123 of file producer-base.cpp.

◆ updateSeqNo()

void psync::ProducerBase::updateSeqNo ( const ndn::Name &  prefix,
uint64_t  seq 
)
protectedinherited

Update m_prefixes and IBF with the given prefix and seq.

Whoever calls this needs to make sure that prefix is in m_prefixes We remove already existing prefix/seq from IBF (unless seq is zero because we don't insert zero seq into IBF) Then we update m_prefixes, m_biMap, and IBF

Parameters
prefixprefix of the update
seqsequence number of the update

Definition at line 82 of file producer-base.cpp.

Member Data Documentation

◆ m_biMap

HashNameBiMap psync::ProducerBase::m_biMap
protectedinherited

Definition at line 167 of file producer-base.hpp.

◆ m_contentCompression

const CompressionScheme psync::ProducerBase::m_contentCompression
protectedinherited

Definition at line 178 of file producer-base.hpp.

◆ m_expectedNumEntries

const size_t psync::ProducerBase::m_expectedNumEntries
protectedinherited

Definition at line 171 of file producer-base.hpp.

◆ m_face

ndn::Face& psync::ProducerBase::m_face
protectedinherited

Definition at line 155 of file producer-base.hpp.

◆ m_iblt

detail::IBLT psync::ProducerBase::m_iblt
protectedinherited

Definition at line 160 of file producer-base.hpp.

◆ m_ibltCompression

const CompressionScheme psync::ProducerBase::m_ibltCompression
protectedinherited

Definition at line 177 of file producer-base.hpp.

◆ m_keyChain

ndn::KeyChain& psync::ProducerBase::m_keyChain
protectedinherited

Definition at line 156 of file producer-base.hpp.

◆ m_numOwnElements

uint64_t psync::ProducerBase::m_numOwnElements = 0
protectedinherited

Definition at line 179 of file producer-base.hpp.

◆ m_prefixes

std::map<ndn::Name, uint64_t> psync::ProducerBase::m_prefixes
protectedinherited

Definition at line 163 of file producer-base.hpp.

◆ m_rng

ndn::random::RandomNumberEngine& psync::ProducerBase::m_rng
protectedinherited

Definition at line 158 of file producer-base.hpp.

◆ m_scheduler

ndn::Scheduler psync::ProducerBase::m_scheduler
protectedinherited

Definition at line 157 of file producer-base.hpp.

◆ m_segmentPublisher

SegmentPublisher psync::ProducerBase::m_segmentPublisher
protectedinherited

Definition at line 169 of file producer-base.hpp.

◆ m_syncPrefix

const ndn::Name psync::ProducerBase::m_syncPrefix
protectedinherited

Definition at line 175 of file producer-base.hpp.

◆ m_syncReplyFreshness

const ndn::time::milliseconds psync::ProducerBase::m_syncReplyFreshness
protectedinherited

Definition at line 176 of file producer-base.hpp.

◆ m_threshold

const size_t psync::ProducerBase::m_threshold
protectedinherited

Definition at line 174 of file producer-base.hpp.