Add advisory "incomingFaceId" to missing data notifications
Change-Id: Ida1acdc7c86d1110a8586d4a396301b89c37229b Refs: #3626
This commit is contained in:
+2
-1
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, The University of Memphis
|
||||
* Copyright (c) 2014-2022, The University of Memphis
|
||||
*
|
||||
* This file is part of PSync.
|
||||
* See AUTHORS.md for complete list of PSync authors and contributors.
|
||||
@@ -65,6 +65,7 @@ struct MissingDataInfo
|
||||
ndn::Name prefix;
|
||||
uint64_t lowSeq;
|
||||
uint64_t highSeq;
|
||||
uint64_t incomingFace;
|
||||
};
|
||||
|
||||
using UpdateCallback = std::function<void(const std::vector<MissingDataInfo>&)>;
|
||||
|
||||
+3
-3
@@ -63,7 +63,7 @@ Consumer::addSubscription(const ndn::Name& prefix, uint64_t seqNo, bool callSync
|
||||
m_bloomFilter.insert(prefix);
|
||||
|
||||
if (callSyncDataCb && seqNo != 0) {
|
||||
m_onUpdate({{prefix, seqNo, seqNo}});
|
||||
m_onUpdate({{prefix, seqNo, seqNo, 0}});
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -145,7 +145,7 @@ Consumer::onHelloData(const ndn::ConstBufferPtr& bufferPtr)
|
||||
// m_prefixes (see addSubscription). So [] operator is safe to use.
|
||||
if (isSubscribed(prefix) && seq > m_prefixes[prefix]) {
|
||||
// In case we are behind on this prefix and consumer is subscribed to it
|
||||
updates.push_back({prefix, m_prefixes[prefix] + 1, seq});
|
||||
updates.push_back({prefix, m_prefixes[prefix] + 1, seq, 0});
|
||||
m_prefixes[prefix] = seq;
|
||||
}
|
||||
availableSubscriptions.emplace(prefix, seq);
|
||||
@@ -240,7 +240,7 @@ Consumer::onSyncData(const ndn::ConstBufferPtr& bufferPtr)
|
||||
if (m_prefixes.find(prefix) == m_prefixes.end() || seq > m_prefixes[prefix]) {
|
||||
// If this is just the next seq number then we had already informed the consumer about
|
||||
// the previous sequence number and hence seq low and seq high should be equal to current seq
|
||||
updates.push_back({prefix, m_prefixes[prefix] + 1, seq});
|
||||
updates.push_back({prefix, m_prefixes[prefix] + 1, seq, 0});
|
||||
m_prefixes[prefix] = seq;
|
||||
}
|
||||
// Else updates will be empty and consumer will not be notified.
|
||||
|
||||
+12
-1
@@ -24,6 +24,7 @@
|
||||
#include <ndn-cxx/security/validator-null.hpp>
|
||||
#include <ndn-cxx/util/logger.hpp>
|
||||
#include <ndn-cxx/util/segment-fetcher.hpp>
|
||||
#include <ndn-cxx/lp/tags.hpp>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
@@ -117,6 +118,16 @@ FullProducer::sendSyncInterest()
|
||||
onSyncData(syncInterest, bufferPtr);
|
||||
});
|
||||
|
||||
m_fetcher->afterSegmentValidated.connect([this] (const ndn::Data& data) {
|
||||
auto tag = data.getTag<ndn::lp::IncomingFaceIdTag>();
|
||||
if (tag) {
|
||||
m_incomingFace = *tag;
|
||||
}
|
||||
else {
|
||||
m_incomingFace = 0;
|
||||
}
|
||||
});
|
||||
|
||||
m_fetcher->onError.connect([this] (uint32_t errorCode, const std::string& msg) {
|
||||
NDN_LOG_ERROR("Cannot fetch sync data, error: " << errorCode << ", message: " << msg);
|
||||
// We would like to recover from errors like NoRoute NACK quicker than sync Interest timeout.
|
||||
@@ -295,7 +306,7 @@ FullProducer::onSyncData(const ndn::Interest& interest, const ndn::ConstBufferPt
|
||||
uint64_t seq = content.get(content.size() - 1).toNumber();
|
||||
|
||||
if (m_prefixes.find(prefix) == m_prefixes.end() || m_prefixes[prefix] < seq) {
|
||||
updates.push_back({prefix, m_prefixes[prefix] + 1, seq});
|
||||
updates.push_back({prefix, m_prefixes[prefix] + 1, seq, m_incomingFace});
|
||||
updateSeqNo(prefix, seq);
|
||||
// We should not call satisfyPendingSyncInterests here because we just
|
||||
// got data and deleted pending interest by calling deletePendingFullSyncInterests
|
||||
|
||||
@@ -188,6 +188,7 @@ private:
|
||||
ndn::Name m_outstandingInterestName;
|
||||
ndn::ScopedRegisteredPrefixHandle m_registeredPrefix;
|
||||
std::shared_ptr<ndn::util::SegmentFetcher> m_fetcher;
|
||||
uint64_t m_incomingFace = 0;
|
||||
};
|
||||
|
||||
} // namespace psync
|
||||
|
||||
Reference in New Issue
Block a user