Skip to content

Commit

Permalink
Change namespace of DummyClientFace, Signal, Segmenter, SegmentFetcher
Browse files Browse the repository at this point in the history
refs #3940

Change-Id: Ia3c9b4adcca9ff79a14be705ca9da525914f3dff
  • Loading branch information
yoursunny committed Aug 20, 2023
1 parent ecb0b71 commit 43f37a0
Show file tree
Hide file tree
Showing 35 changed files with 111 additions and 114 deletions.
4 changes: 2 additions & 2 deletions src/hello-protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class HelloProtocol
void
processInterest(const ndn::Name& name, const ndn::Interest& interest);

ndn::util::Signal<HelloProtocol, Statistics::PacketType> hpIncrementSignal;
ndn::signal::Signal<HelloProtocol, Statistics::PacketType> hpIncrementSignal;

private:
/*! \brief Try to contact a neighbor via Hello protocol again
Expand Down Expand Up @@ -126,7 +126,7 @@ class HelloProtocol
static inline const std::string INFO_COMPONENT{"INFO"};
static inline const std::string NLSR_COMPONENT{"nlsr"};

ndn::util::Signal<HelloProtocol, const ndn::Name&> onInitialHelloDataValidated;
ndn::signal::Signal<HelloProtocol, const ndn::Name&> onInitialHelloDataValidated;

private:
ndn::Face& m_face;
Expand Down
7 changes: 3 additions & 4 deletions src/lsdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,12 @@ Lsdb::expressInterest(const ndn::Name& interestName, uint32_t timeoutCount, uint
if (incomingFaceId != 0) {
interest.setTag(std::make_shared<ndn::lp::NextHopFaceIdTag>(incomingFaceId));
}
ndn::util::SegmentFetcher::Options options;
ndn::SegmentFetcher::Options options;
options.interestLifetime = m_confParam.getLsaInterestLifetime();
options.maxTimeout = m_confParam.getLsaInterestLifetime();

NLSR_LOG_DEBUG("Fetching Data for LSA: " << interestName << " Seq number: " << seqNo);
auto fetcher = ndn::util::SegmentFetcher::start(m_face, interest,
m_confParam.getValidator(), options);
auto fetcher = ndn::SegmentFetcher::start(m_face, interest, m_confParam.getValidator(), options);

auto it = m_fetchers.insert(fetcher).first;

Expand Down Expand Up @@ -493,7 +492,7 @@ Lsdb::onFetchLsaError(uint32_t errorCode, const std::string& msg, const ndn::Nam
// the potential for constant Interest flooding.
ndn::time::seconds delay = m_confParam.getLsaInterestLifetime();

if (errorCode == ndn::util::SegmentFetcher::ErrorCode::INTEREST_TIMEOUT) {
if (errorCode == ndn::SegmentFetcher::ErrorCode::INTEREST_TIMEOUT) {
delay = ndn::time::seconds(0);
}
m_scheduler.schedule(delay, std::bind(&Lsdb::expressInterest, this,
Expand Down
14 changes: 7 additions & 7 deletions src/lsdb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,10 @@ class Lsdb
}

public:
ndn::util::Signal<Lsdb, Statistics::PacketType> lsaIncrementSignal;
ndn::util::Signal<Lsdb, ndn::Data> afterSegmentValidatedSignal;
using AfterLsdbModified = ndn::util::Signal<Lsdb, std::shared_ptr<Lsa>, LsdbUpdate,
std::list<ndn::Name>, std::list<ndn::Name>>;
ndn::signal::Signal<Lsdb, Statistics::PacketType> lsaIncrementSignal;
ndn::signal::Signal<Lsdb, ndn::Data> afterSegmentValidatedSignal;
using AfterLsdbModified = ndn::signal::Signal<Lsdb, std::shared_ptr<Lsa>, LsdbUpdate,
std::list<ndn::Name>, std::list<ndn::Name>>;
AfterLsdbModified onLsdbModified;

PUBLIC_WITH_TESTS_ELSE_PRIVATE:
Expand All @@ -346,10 +346,10 @@ class Lsdb

SequencingManager m_sequencingManager;

ndn::util::signal::ScopedConnection m_onNewLsaConnection;
ndn::signal::ScopedConnection m_onNewLsaConnection;

std::set<std::shared_ptr<ndn::util::SegmentFetcher>> m_fetchers;
ndn::util::Segmenter m_segmenter;
std::set<std::shared_ptr<ndn::SegmentFetcher>> m_fetchers;
ndn::Segmenter m_segmenter;
ndn::InMemoryStorageFifo m_segmentFifo;

bool m_isBuildAdjLsaScheduled;
Expand Down
6 changes: 3 additions & 3 deletions src/nlsr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ class Nlsr
HelloProtocol m_helloProtocol;

private:
ndn::util::signal::ScopedConnection m_onNewLsaConnection;
ndn::util::signal::ScopedConnection m_onPrefixRegistrationSuccess;
ndn::util::signal::ScopedConnection m_onInitialHelloDataValidated;
ndn::signal::ScopedConnection m_onNewLsaConnection;
ndn::signal::ScopedConnection m_onPrefixRegistrationSuccess;
ndn::signal::ScopedConnection m_onInitialHelloDataValidated;

PUBLIC_WITH_TESTS_ELSE_PRIVATE:
ndn::mgmt::Dispatcher m_dispatcher;
Expand Down
4 changes: 2 additions & 2 deletions src/route/fib.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2022, The University of Memphis,
* Copyright (c) 2014-2023, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
Expand Down Expand Up @@ -222,7 +222,7 @@ class Fib
static inline const ndn::Name MULTICAST_STRATEGY{"/localhost/nfd/strategy/multicast"};
static inline const ndn::Name BEST_ROUTE_STRATEGY{"/localhost/nfd/strategy/best-route"};

ndn::util::Signal<Fib, ndn::Name> onPrefixRegistrationSuccess;
ndn::signal::Signal<Fib, ndn::Name> onPrefixRegistrationSuccess;

private:
ndn::Scheduler& m_scheduler;
Expand Down
6 changes: 3 additions & 3 deletions src/route/name-prefix-table.hpp
Original file line number Diff line number Diff line change
@@ -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-2023, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
Expand Down Expand Up @@ -141,8 +141,8 @@ class NamePrefixTable
const ndn::Name& m_ownRouterName;
Fib& m_fib;
RoutingTable& m_routingTable;
ndn::util::signal::Connection m_afterRoutingChangeConnection;
ndn::util::signal::Connection m_afterLsdbModified;
ndn::signal::Connection m_afterRoutingChangeConnection;
ndn::signal::Connection m_afterLsdbModified;
};

inline NamePrefixTable::const_iterator
Expand Down
4 changes: 2 additions & 2 deletions src/route/routing-table.hpp
Original file line number Diff line number Diff line change
@@ -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-2023, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
Expand Down Expand Up @@ -155,7 +155,7 @@ class RoutingTable : public RoutingTableStatus
bool m_isRouteCalculationScheduled;

ConfParameter& m_confParam;
ndn::util::signal::Connection m_afterLsdbModified;
ndn::signal::Connection m_afterLsdbModified;
int32_t m_hyperbolicState;
bool m_ownAdjLsaExist = false;
};
Expand Down
4 changes: 2 additions & 2 deletions src/security/certificate-store.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2022, The University of Memphis,
* Copyright (c) 2014-2023, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
Expand Down Expand Up @@ -104,7 +104,7 @@ class CertificateStore
ndn::Face& m_face;
ConfParameter& m_confParam;
ndn::security::ValidatorConfig& m_validator;
ndn::util::signal::ScopedConnection m_afterSegmentValidatedConnection;
ndn::signal::ScopedConnection m_afterSegmentValidatedConnection;
};

} // namespace security
Expand Down
6 changes: 3 additions & 3 deletions src/signals.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2022, The University of Memphis,
* Copyright (c) 2014-2023, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
Expand Down Expand Up @@ -32,8 +32,8 @@ class RoutingTable;
class RoutingTableEntry;
class SyncLogicHandler;

using AfterRoutingChange = ndn::util::Signal<RoutingTable, std::list<RoutingTableEntry>>;
using OnNewLsa = ndn::util::Signal<SyncLogicHandler, ndn::Name, uint64_t, ndn::Name, uint64_t>;
using AfterRoutingChange = ndn::signal::Signal<RoutingTable, std::list<RoutingTableEntry>>;
using OnNewLsa = ndn::signal::Signal<SyncLogicHandler, ndn::Name, uint64_t, ndn::Name, uint64_t>;

} // namespace nlsr

Expand Down
13 changes: 7 additions & 6 deletions src/stats-collector.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2017, The University of Memphis,
/*
* Copyright (c) 2014-2023, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
Expand Down Expand Up @@ -28,8 +28,9 @@

namespace nlsr {

// brief: a class designed to handle statistical signals in nlsr

/**
* \brief a class designed to handle statistical signals in nlsr
*/
class StatsCollector
{
public:
Expand Down Expand Up @@ -63,8 +64,8 @@ class StatsCollector
HelloProtocol& m_hp;
Statistics m_stats;

ndn::util::signal::ScopedConnection m_lsaIncrementConn;
ndn::util::signal::ScopedConnection m_helloIncrementConn;
ndn::signal::ScopedConnection m_lsaIncrementConn;
ndn::signal::ScopedConnection m_helloIncrementConn;
};

} // namespace nlsr
Expand Down
18 changes: 8 additions & 10 deletions tests/communication/test-sync-logic-handler.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2022, The University of Memphis,
* Copyright (c) 2014-2023, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
Expand Down Expand Up @@ -30,8 +30,6 @@
namespace nlsr {
namespace test {

using std::shared_ptr;

class SyncLogicFixture : public IoKeyChainFixture
{
public:
Expand All @@ -58,7 +56,7 @@ class SyncLogicFixture : public IoKeyChainFixture
}

public:
ndn::util::DummyClientFace face{m_io, m_keyChain};
ndn::DummyClientFace face{m_io, m_keyChain};
ConfParameter conf{face, m_keyChain};
DummyConfFileProcessor confProcessor{conf, SyncProtocol::PSYNC};
SyncLogicHandler::IsLsaNew testIsLsaNew;
Expand All @@ -84,7 +82,7 @@ BOOST_AUTO_TEST_CASE(UpdateForOtherLS)
for (auto lsaType : {Lsa::Type::NAME, Lsa::Type::ADJACENCY}) {
std::string updateName = this->updateNamePrefix + boost::lexical_cast<std::string>(lsaType);

ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
ndn::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
[&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) {
BOOST_CHECK_EQUAL(ndn::Name{updateName}, routerName);
BOOST_CHECK_EQUAL(sequenceNumber, syncSeqNo);
Expand All @@ -111,7 +109,7 @@ BOOST_AUTO_TEST_CASE(UpdateForOtherHR)
for (auto lsaType : {Lsa::Type::NAME, Lsa::Type::COORDINATE}) {
std::string updateName = this->updateNamePrefix + boost::lexical_cast<std::string>(lsaType);

ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
ndn::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
[&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) {
BOOST_CHECK_EQUAL(ndn::Name{updateName}, routerName);
BOOST_CHECK_EQUAL(sequenceNumber, syncSeqNo);
Expand All @@ -138,7 +136,7 @@ BOOST_AUTO_TEST_CASE(UpdateForOtherHRDry)
for (auto lsaType : this->lsaTypes) {
std::string updateName = this->updateNamePrefix + boost::lexical_cast<std::string>(lsaType);

ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
ndn::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
[&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) {
BOOST_CHECK_EQUAL(ndn::Name{updateName}, routerName);
BOOST_CHECK_EQUAL(sequenceNumber, syncSeqNo);
Expand Down Expand Up @@ -167,7 +165,7 @@ BOOST_AUTO_TEST_CASE(NoUpdateForSelf)
.append(this->conf.getRouterName())
.append(boost::lexical_cast<std::string>(lsaType));

ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
ndn::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
[&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) {
BOOST_FAIL("Updates for self should not be emitted!");
});
Expand All @@ -191,7 +189,7 @@ BOOST_AUTO_TEST_CASE(MalformedUpdate)
ndn::Name updateName{this->conf.getSiteName()};
updateName.append(this->conf.getRouterName()).append(boost::lexical_cast<std::string>(lsaType));

ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
ndn::signal::ScopedConnection connection = this->sync.onNewLsa.connect(
[&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) {
BOOST_FAIL("Malformed updates should not be emitted!");
});
Expand All @@ -216,7 +214,7 @@ BOOST_AUTO_TEST_CASE(LsaNotNew)

const uint64_t sequenceNumber = 1;
SyncLogicHandler sync{this->face, this->m_keyChain, testLsaAlwaysFalse, this->conf};
ndn::util::signal::ScopedConnection connection = sync.onNewLsa.connect(
ndn::signal::ScopedConnection connection = sync.onNewLsa.connect(
[&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter, uint64_t incomingFaceId) {
BOOST_FAIL("An update for an LSA with non-new sequence number should not emit!");
});
Expand Down
41 changes: 20 additions & 21 deletions tests/communication/test-sync-protocol-adapter.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2014-2022, The University of Memphis,
* Copyright (c) 2014-2023, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
Expand Down Expand Up @@ -29,15 +29,15 @@
namespace nlsr {
namespace test {

using namespace ndn;
using ndn::Name;

class SyncProtocolAdapterFixture : public IoKeyChainFixture
{
public:
SyncProtocolAdapterFixture()
: syncPrefix("/localhop/ndn/nlsr/sync")
, nameLsaUserPrefix("/localhop/ndn/nlsr/LSA/NAME")
, syncInterestLifetime(time::seconds(60))
, syncInterestLifetime(60_s)
{
syncPrefix.appendVersion(4);
}
Expand All @@ -46,29 +46,28 @@ class SyncProtocolAdapterFixture : public IoKeyChainFixture
addNodes()
{
for (int i = 0; i < 2; i++) {
faces[i] = std::make_shared<util::DummyClientFace>(m_io,
util::DummyClientFace::Options{true, true});
faces[i] = std::make_shared<ndn::DummyClientFace>(m_io, ndn::DummyClientFace::Options{true, true});
userPrefixes[i] = Name(nameLsaUserPrefix).appendNumber(i);
nodes[i] = std::make_shared<SyncProtocolAdapter>(*faces[i], m_keyChain, SyncProtocol::PSYNC,
syncPrefix, userPrefixes[i],
syncInterestLifetime,
[i, this] (const ndn::Name& updateName,
uint64_t highSeq, uint64_t incomingFaceId) {
prefixToSeq[i].emplace(updateName, highSeq);
});
nodes[i] = std::make_shared<SyncProtocolAdapter>(
*faces[i], m_keyChain, SyncProtocol::PSYNC, syncPrefix, userPrefixes[i],
syncInterestLifetime,
[i, this] (const Name& updateName, uint64_t highSeq, uint64_t incomingFaceId) {
prefixToSeq[i].emplace(updateName, highSeq);
});
}

faces[0]->linkTo(*faces[1]);
advanceClocks(ndn::time::milliseconds(10), 10);
advanceClocks(10_ms, 10);
}

public:
Name syncPrefix, nameLsaUserPrefix;
Name syncPrefix;
Name nameLsaUserPrefix;
Name userPrefixes[2];
time::milliseconds syncInterestLifetime;
std::shared_ptr<ndn::util::DummyClientFace> faces[2];
ndn::time::milliseconds syncInterestLifetime;
std::shared_ptr<ndn::DummyClientFace> faces[2];
std::shared_ptr<SyncProtocolAdapter> nodes[2];
std::map<ndn::Name, uint64_t> prefixToSeq[2];
std::map<Name, uint64_t> prefixToSeq[2];
};

BOOST_AUTO_TEST_SUITE(TestSyncProtocolAdapter)
Expand All @@ -78,15 +77,15 @@ BOOST_FIXTURE_TEST_CASE(Basic, SyncProtocolAdapterFixture)
addNodes();

nodes[0]->publishUpdate(userPrefixes[0], 10);
advanceClocks(ndn::time::milliseconds(1000), 100);
advanceClocks(1_s, 100);

auto it = prefixToSeq[1].find(userPrefixes[0]);
BOOST_CHECK(it != prefixToSeq[1].end());
BOOST_CHECK_EQUAL(it->first, userPrefixes[0]);
BOOST_CHECK_EQUAL(it->second, 10);

nodes[1]->publishUpdate(userPrefixes[1], 100);
advanceClocks(ndn::time::milliseconds(1000), 100);
advanceClocks(1_s, 100);

it = prefixToSeq[0].find(userPrefixes[1]);
BOOST_CHECK(it != prefixToSeq[0].end());
Expand All @@ -95,9 +94,9 @@ BOOST_FIXTURE_TEST_CASE(Basic, SyncProtocolAdapterFixture)

Name adjLsaUserPrefix("/localhop/ndn/nlsr/LSA/ADJACENCY");
nodes[0]->addUserNode(adjLsaUserPrefix);
advanceClocks(ndn::time::milliseconds(1000), 100);
advanceClocks(1_s, 100);
nodes[0]->publishUpdate(adjLsaUserPrefix, 10);
advanceClocks(ndn::time::milliseconds(1000), 100);
advanceClocks(1_s, 100);

it = prefixToSeq[1].find(adjLsaUserPrefix);
BOOST_CHECK(it != prefixToSeq[1].end());
Expand Down
Loading

0 comments on commit 43f37a0

Please sign in to comment.