add forwarder node

This commit is contained in:
Zhenkai Zhu committed 2012-09-26 10:34:15 -07:00
1 parent 396473c568
commit a2e0b08f1d
4 files changed
+28 -6

No files matched your search

+7
View File
@@ -156,6 +156,13 @@ public:
*/
uint32_t getSeq () const
{ return m_seq; }
/**
* @brief Set sequence number
*/
void
setSeq(uint32_t seq)
{ m_seq = seq; }
private:
bool m_valid;
+1 -1
View File
@@ -43,7 +43,7 @@ namespace Sync {
* No corresponding data msg would be published and no attempt would be made to retrieve the
* data msg
*/
const string dummyPrefix = "/d0n0t18ak/t0ps8cr8t";
const std::string forwarderPrefix = "/d0n0t18ak/t0ps8cr8t";
class State;
typedef boost::shared_ptr<State> StatePtr;
+13 -2
View File
@@ -293,7 +293,7 @@ SyncLogic::processSyncData (const std::string &name, DigestConstPtr digest, cons
BOOST_ASSERT (diffLeaf != 0);
NameInfoConstPtr info = diffLeaf->getInfo();
if (diffLeaf->getOperation() == UPDATE)
if (diffLeaf->getOperation() == UPDATE && info->toString() != forwarderPrefix)
{
SeqNo seq = diffLeaf->getSeq();
@@ -328,7 +328,7 @@ SyncLogic::processSyncData (const std::string &name, DigestConstPtr digest, cons
}
else
{
BOOST_ASSERT (false); // just in case
BOOST_ASSERT (info->toString() == forwarderPrefix); // just in case
}
}
@@ -466,8 +466,19 @@ SyncLogic::remove(const string &prefix)
NameInfoConstPtr info = StdNameInfo::FindOrCreate(prefix);
m_state->remove(info);
// increment the sequence number for the forwarder node
NameInfoConstPtr forwarderInfo = StdNameInfo::FindOrCreate(forwarderPrefix);
bool inserted = false;
bool updated = false;
SeqNo oldSeq;
tie (inserted, updated, oldSeq) = m_state->update (forwarderInfo, oldSeq);
oldSeq.setSeq(oldSeq.getSeq() + 1);
m_state->update(info, oldSeq);
diff = make_shared<DiffState>();
diff->remove(info);
diff->update(forwarderInfo, oldSeq);
insertToDiffLog (diff);
}
+7 -3
View File
@@ -76,6 +76,9 @@ BOOST_AUTO_TEST_CASE (SyncLogicTest)
Handler h1 ("1");
SyncLogic l1 ("/bcast", bind (&Handler::wrapper, &h1, _1), bind (&Handler::onRemove, &h1, _1));
std::string oldDigest = l1.getRootDigest();
l1.addLocalNames ("/one", 1, 2);
BOOST_CHECK_EQUAL (h1.m_map.size (), 0);
@@ -89,8 +92,9 @@ BOOST_AUTO_TEST_CASE (SyncLogicTest)
BOOST_CHECK_EQUAL (h1.m_map.size (), 0);
BOOST_CHECK_EQUAL (h2.m_map.size (), 1);
// l1.remove ("/one");
l1.remove ("/one");
sleep(1);
std::string newDigest = l1.getRootDigest();
BOOST_CHECK(oldDigest != newDigest);
// sleep (10);
// l1.
}