psync::FullProducer Class Reference

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

#include <full-producer.hpp>

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

Public Member Functions

 FullProducer (size_t expectedNumEntries, ndn::Face &face, const ndn::Name &syncPrefix, const ndn::Name &userPrefix, const UpdateCallback &onUpdateCallBack, ndn::time::milliseconds syncInterestLifetime=SYNC_INTEREST_LIFTIME, ndn::time::milliseconds syncReplyFreshness=SYNC_REPLY_FRESHNESS)
 constructor More...
 
 ~FullProducer ()
 
bool addUserNode (const ndn::Name &prefix)
 Adds a user node for synchronization. More...
 
ndn::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, ndn::optional< uint64_t > seq=ndn::nullopt)
 Publish name to let others know. More...
 
void removeUserNode (const ndn::Name &prefix)
 Remove the user node from synchronization. More...
 

Protected Member Functions

bool isUserNode (const ndn::Name &prefix)
 
void onRegisterFailed (const ndn::Name &prefix, const std::string &msg) const
 Logs a message if setting an interest filter fails. More...
 
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...
 

Protected Attributes

uint32_t m_expectedNumEntries
 
ndn::Face & m_face
 
std::map< uint32_t, ndn::Name > m_hash2prefix
 
ndn::time::milliseconds m_helloReplyFreshness
 
IBLT m_iblt
 
ndn::KeyChain m_keyChain
 
std::map< ndn::Name, uint32_t > m_prefix2hash
 
std::map< ndn::Name, uint64_t > m_prefixes
 
ndn::random::RandomNumberEngine & m_rng
 
ndn::Scheduler m_scheduler
 
SegmentPublisher m_segmentPublisher
 
ndn::Name m_syncPrefix
 
ndn::time::milliseconds m_syncReplyFreshness
 
uint32_t m_threshold
 
ndn::Name m_userPrefix
 

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 60 of file full-producer.hpp.

Constructor & Destructor Documentation

psync::FullProducer::FullProducer ( size_t  expectedNumEntries,
ndn::Face &  face,
const ndn::Name &  syncPrefix,
const ndn::Name &  userPrefix,
const UpdateCallback onUpdateCallBack,
ndn::time::milliseconds  syncInterestLifetime = SYNC_INTEREST_LIFTIME,
ndn::time::milliseconds  syncReplyFreshness = SYNC_REPLY_FRESHNESS 
)

constructor

Registers syncPrefix in NFD and sends a sync interest

Parameters
expectedNumEntriesexpected entries in IBF
faceapplication's face
syncPrefixThe prefix of the sync group
userPrefixThe prefix of the first user in the group
onUpdateCallBackThe call back to be called when there is new data
syncInterestLifetimelifetime of the sync interest
syncReplyFreshnessfreshness of sync data

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

psync::FullProducer::~FullProducer ( )

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

Member Function Documentation

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 55 of file producer-base.cpp.

ndn::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.

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

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

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

Logs a message if setting an interest filter fails.

Parameters
prefix
msg

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

void psync::FullProducer::publishName ( const ndn::Name &  prefix,
ndn::optional< uint64_t >  seq = ndn::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 66 of file full-producer.cpp.

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 67 of file producer-base.cpp.

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 128 of file producer-base.cpp.

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_prefix, m_prefix2hash, m_hash2prefix, and IBF

Parameters
prefixprefix of the update
seqsequence number of the update

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

Member Data Documentation

uint32_t psync::ProducerBase::m_expectedNumEntries
protectedinherited

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

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

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

std::map<uint32_t, ndn::Name> psync::ProducerBase::m_hash2prefix
protectedinherited

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

ndn::time::milliseconds psync::ProducerBase::m_helloReplyFreshness
protectedinherited

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

IBLT psync::ProducerBase::m_iblt
protectedinherited

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

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

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

std::map<ndn::Name, uint32_t> psync::ProducerBase::m_prefix2hash
protectedinherited

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

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

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

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

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

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

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

SegmentPublisher psync::ProducerBase::m_segmentPublisher
protectedinherited

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

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

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

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

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

uint32_t psync::ProducerBase::m_threshold
protectedinherited

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

ndn::Name psync::ProducerBase::m_userPrefix
protectedinherited

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