32 #include <boost/range/adaptor/map.hpp>
33 #include <boost/range/algorithm/copy.hpp>
41 Strategy::getRegistry()
43 static Registry registry;
47 Strategy::Registry::const_iterator
48 Strategy::find(
const Name& instanceName)
50 const Registry& registry = getRegistry();
56 auto found = registry.lower_bound(parsed.strategyName);
57 if (found != registry.end()) {
58 if (parsed.strategyName.getPrefix(-1).isPrefixOf(found->first)) {
59 NFD_LOG_TRACE(
"find " << instanceName <<
" versioned found=" << found->first);
64 NFD_LOG_TRACE(
"find " << instanceName <<
" versioned not-found");
65 return registry.end();
70 if (!parsed.strategyName.empty()) {
71 auto found = registry.lower_bound(parsed.strategyName.getSuccessor());
72 if (found != registry.begin()) {
74 if (parsed.strategyName.isPrefixOf(found->first)) {
75 NFD_LOG_TRACE(
"find " << instanceName <<
" unversioned found=" << found->first);
81 NFD_LOG_TRACE(
"find " << instanceName <<
" unversioned not-found");
82 return registry.end();
88 return Strategy::find(instanceName) != getRegistry().end();
94 auto found = Strategy::find(instanceName);
95 if (found == getRegistry().end()) {
100 unique_ptr<Strategy> instance = found->second(forwarder, instanceName);
101 NFD_LOG_DEBUG(
"create " << instanceName <<
" found=" << found->first
102 <<
" created=" << instance->getInstanceName());
103 BOOST_ASSERT(!instance->getInstanceName().empty());
110 return Strategy::find(instanceNameA) == Strategy::find(instanceNameB);
116 std::set<Name> strategyNames;
117 boost::copy(getRegistry() | boost::adaptors::map_keys,
118 std::inserter(strategyNames, strategyNames.end()));
119 return strategyNames;
125 for (ssize_t i = input.
size() - 1; i > 0; --i) {
126 if (input[i].isVersion()) {
138 bool hasVersion = std::any_of(input.
rbegin(), input.
rend(),
140 return hasVersion ? input :
Name(input).append(strategyName.
at(-1));
144 : afterAddFace(forwarder.m_faceTable.afterAdd)
145 , beforeRemoveFace(forwarder.m_faceTable.beforeRemove)
146 , m_forwarder(forwarder)
147 , m_measurements(m_forwarder.getMeasurements(), m_forwarder.getStrategyChoice(), *this)
159 <<
" in=" << ingress);
166 NFD_LOG_DEBUG(
"beforeSatisfyInterest pitEntry=" << pitEntry->getName()
167 <<
" in=" << ingress <<
" data=" << data.
getName());
174 NFD_LOG_DEBUG(
"afterContentStoreHit pitEntry=" << pitEntry->getName()
175 <<
" in=" << ingress <<
" data=" << data.
getName());
177 this->
sendData(pitEntry, data, ingress);
184 NFD_LOG_DEBUG(
"afterReceiveData pitEntry=" << pitEntry->getName()
185 <<
" in=" << ingress <<
" data=" << data.
getName());
194 const shared_ptr<pit::Entry>& pitEntry)
196 NFD_LOG_DEBUG(
"afterReceiveNack in=" << ingress <<
" pitEntry=" << pitEntry->getName());
212 m_forwarder.onOutgoingInterest(pitEntry, egress, interest2);
215 m_forwarder.onOutgoingInterest(pitEntry, egress, interest);
221 NFD_LOG_DEBUG(
"afterNewNextHop pitEntry=" << pitEntry->getName()
229 BOOST_ASSERT(pitEntry->getInterest().matchesData(data));
231 shared_ptr<lp::PitToken> pitToken;
232 auto inRecord = pitEntry->getInRecord(egress.
face);
233 if (inRecord != pitEntry->in_end()) {
234 pitToken = inRecord->getInterest().getTag<
lp::PitToken>();
239 pitEntry->deleteInRecord(egress.
face);
241 if (pitToken !=
nullptr) {
244 m_forwarder.onOutgoingData(data2, egress);
247 m_forwarder.onOutgoingData(data, egress);
254 std::set<Face*> pendingDownstreams;
258 for (
const pit::InRecord& inRecord : pitEntry->getInRecords()) {
259 if (inRecord.getExpiry() > now) {
260 if (inRecord.getFace().getId() == ingress.
face.
getId() &&
264 pendingDownstreams.emplace(&inRecord.getFace());
268 for (
const auto& pendingDownstream : pendingDownstreams) {
275 std::initializer_list<FaceEndpoint> exceptFaceEndpoints)
278 std::set<Face*> downstreams;
279 std::transform(pitEntry->in_begin(), pitEntry->in_end(), std::inserter(downstreams, downstreams.end()),
281 return &inR.getFace();
285 for (
const auto& exceptFaceEndpoint : exceptFaceEndpoints) {
286 downstreams.erase(&exceptFaceEndpoint.face);
290 for (
const auto& downstream : downstreams) {
330 BOOST_ASSERT(fibEntry !=
nullptr && fibEntry->
getPrefix().
size() == 0);