23 #include <ndn-cxx/util/exception.hpp> 24 #include <ndn-cxx/util/logger.hpp> 35 const ndn::Name& syncPrefix,
36 const ndn::Name& userPrefix,
37 ndn::time::milliseconds syncReplyFreshness,
40 : m_iblt(expectedNumEntries, ibltCompression)
41 , m_expectedNumEntries(expectedNumEntries)
42 , m_threshold(expectedNumEntries / 2)
44 , m_scheduler(m_face.getIoService())
45 , m_syncPrefix(syncPrefix)
46 , m_userPrefix(userPrefix)
47 , m_syncReplyFreshness(syncReplyFreshness)
48 , m_segmentPublisher(m_face, m_keyChain)
49 , m_rng(ndn::random::getRandomNumberEngine())
50 , m_ibltCompression(ibltCompression)
51 , m_contentCompression(contentCompression)
73 uint64_t seqNo = it->second;
76 ndn::Name prefixWithSeq = ndn::Name(prefix).appendNumber(seqNo);
77 auto hashIt =
m_biMap.right.find(prefixWithSeq);
78 if (hashIt !=
m_biMap.right.end()) {
88 NDN_LOG_DEBUG(
"UpdateSeq: " << prefix <<
" " << seq);
96 NDN_LOG_WARN(
"Prefix not found in m_prefixes");
101 NDN_LOG_WARN(
"Update has lower/equal seq no for prefix, doing nothing!");
108 ndn::Name prefixWithSeq = ndn::Name(prefix).appendNumber(oldSeq);
109 auto hashIt =
m_biMap.right.find(prefixWithSeq);
110 if (hashIt !=
m_biMap.right.end()) {
118 ndn::Name prefixWithSeq = ndn::Name(prefix).appendNumber(seq);
120 m_biMap.insert({newHash, prefixWithSeq});
127 NDN_LOG_DEBUG(
"Sending application nack");
128 ndn::Name dataName(name);
131 dataName.appendSegment(0);
132 ndn::Data data(dataName);
134 data.setContentType(ndn::tlv::ContentType_Nack);
135 data.setFinalBlock(dataName[-1]);
143 NDN_LOG_ERROR(
"ProducerBase::onRegisterFailed(" << prefix <<
"): " << msg);
144 NDN_THROW(
Error(msg));
void appendToName(ndn::Name &name) const
Appends self to name.
void sendApplicationNack(const ndn::Name &name)
Sends a data packet with content type nack.
void updateSeqNo(const ndn::Name &prefix, uint64_t seq)
Update m_prefixes and IBF with the given prefix and seq.
NDN_LOG_INIT(psync.Consumer)
void insert(uint32_t key)
ProducerBase(size_t expectedNumEntries, ndn::Face &face, const ndn::Name &syncPrefix, const ndn::Name &userPrefix, ndn::time::milliseconds syncReplyFreshness=SYNC_REPLY_FRESHNESS, CompressionScheme ibltCompression=CompressionScheme::NONE, CompressionScheme contentCompression=CompressionScheme::NONE)
constructor
bool addUserNode(const ndn::Name &prefix)
Adds a user node for synchronization.
void removeUserNode(const ndn::Name &prefix)
Remove the user node from synchronization.
void onRegisterFailed(const ndn::Name &prefix, const std::string &msg) const
Logs a message if setting an interest filter fails.
ndn::time::milliseconds m_syncReplyFreshness
Base class for PartialProducer and FullProducer.
uint32_t murmurHash3(const void *key, size_t len, uint32_t seed)
std::map< ndn::Name, uint64_t > m_prefixes