[Ndn-lib] PSync PartialProducer on multiple nodes

Lan Wang (lanwang) lanwang at memphis.edu
Tue Jan 29 12:32:19 PST 2019


Just to add a bit of explanation of PartialSync: if you have multiple producers hosting the *same* set of data, then they should share the same sync prefix and each of them may handle some of the consumers/subscribers (with the best-route strategy, the subscribers’ interests may go to different producers if they are spread out in the network)

Lan

On Jan 29, 2019, at 2:26 PM, Lan Wang (lanwang) <lanwang at memphis.edu<mailto:lanwang at memphis.edu>> wrote:

Maybe use separate sync prefix for different producers (/sync/user-0 and /sync/user-1)?  If they share the same prefix, because of the best route strategy, the hello interests from A-D may be routed to the same producer.

Lan

On Jan 29, 2019, at 12:05 PM, Junxiao Shi <shijunxiao at email.arizona.edu<mailto:shijunxiao at email.arizona.edu>> wrote:

Hi Ashlesh

I'm learning to use PSync's PartialProducer class.
I constructed the following topology:

producers   subscribers
         /---A
0--\    / /--B
    router---C
1--/      \--D

"router" is a local NFD instance using default configuration, i.e. best-route strategy.
All producers and subscribers use sync prefix /sync.
Producer 0 has user prefix /user-0. Producer 1 has user prefix /user-1.
Subscriber A and B want to subscribe to /user-0 only. Subscriber C and D want to subscribe to /user-1 only.

My code is pasted at end of this message. All producers and subscribers are in the same program, but they use separate faces, logically equivalent to different nodes.
However, in the HelloData of all four subscribers, they only learn about /user-0 but not /user-1. Consequently, subscriber C and D cannot find their subscriptions.
Am I missing something?

Yours, Junxiao



// g++ -std=c++14 -o psyncdemo psyncdemo.cpp $(pkg-config --cflags --libs libndn-cxx) $(pkg-config --cflags --libs PSync)

#include <ndn-cxx/face.hpp>
#include <ndn-cxx/name.hpp>
#include <ndn-cxx/util/scheduler.hpp>
#include <ndn-cxx/util/time.hpp>

#include <PSync/consumer.hpp>
#include <PSync/partial-producer.hpp>

#include <cstdlib>
#include <ctime>
#include <iostream>
#include <string>

static const ndn::Name SYNC_PREFIX = "/sync";
static const std::string USER_PREFIX = "/user-";

class Publisher
{
public:
explicit
Publisher(const std::string& tag, ndn::Face& face)
: m_tag(tag)
, m_user(USER_PREFIX + tag)
, m_sched(face.getIoService())
, m_producer(40, face, SYNC_PREFIX, m_user)
{
schedule();
}

private:
void
schedule()
{
m_sched.scheduleEvent(ndn::time::milliseconds(std::rand() % 1000 + 3000),
std::bind(&Publisher::publish, this));
}

void
publish()
{
m_producer.publishName(m_user);
std::cout << "P " << m_tag << " " << m_producer.getSeqNo(m_user).value_or(0) << std::endl;
schedule();
}

private:
std::string m_tag;
ndn::Name m_user;
ndn::Scheduler m_sched;
psync::PartialProducer m_producer;
};

class Subscriber
{
public:
explicit
Subscriber(const std::string& tag, const std::string& sub, ndn::Face& face)
: m_tag(tag)
, m_user(USER_PREFIX + sub)
, m_consumer(SYNC_PREFIX, face,
std::bind(&Subscriber::processHello, this, _1),
std::bind(&Subscriber::processUpdate, this, _1),
1, 0.001)
{
m_consumer.sendHelloInterest();
}

private:
void
processHello(const std::vector<ndn::Name>& availSubs)
{
std::cout << "H " << m_tag << " (" << availSubs.size() << ")" << std::endl;
for (const auto& sub : availSubs) {
if (sub == m_user) {
m_consumer.addSubscription(sub);
std::cout << "S " << m_tag << " " << sub << std::endl;
}
}
m_consumer.sendSyncInterest();
}

void
processUpdate(const std::vector<psync::MissingDataInfo>& updates)
{
std::cout << "R " << m_tag << " (" << updates.size() << ")" << std::endl;
for (const auto& update : updates) {
for (uint64_t seq = update.lowSeq; seq <= update.highSeq; ++seq) {
std::cout << "U " << m_tag << " " << update.prefix << " " << seq << std::endl;
}
}
}

private:
std::string m_tag;
ndn::Name m_user;
psync::Consumer m_consumer;
};

int
main()
{
std::srand(std::time(nullptr));

ndn::Face faceP0;
ndn::Face faceP1(faceP0.getIoService());
ndn::Face faceSA(faceP0.getIoService());
ndn::Face faceSB(faceP0.getIoService());
ndn::Face faceSC(faceP0.getIoService());
ndn::Face faceSD(faceP0.getIoService());

Publisher p0("0", faceP0);
Publisher p1("1", faceP1);
Subscriber sA("A", "0", faceSA);
Subscriber sB("B", "0", faceSB);
Subscriber sC("C", "1", faceSC);
Subscriber sD("D", "1", faceSD);

faceP0.processEvents();
return 0;
}

_______________________________________________
Ndn-lib mailing list
Ndn-lib at lists.cs.ucla.edu<mailto:Ndn-lib at lists.cs.ucla.edu>
http://www.lists.cs.ucla.edu/mailman/listinfo/ndn-lib

_______________________________________________
Ndn-lib mailing list
Ndn-lib at lists.cs.ucla.edu<mailto:Ndn-lib at lists.cs.ucla.edu>
http://www.lists.cs.ucla.edu/mailman/listinfo/ndn-lib

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndn-lib/attachments/20190129/09565c54/attachment-0001.html>


More information about the Ndn-lib mailing list