Solving bugs in Fetcher and extending Fetcher test
diff --git a/ccnx/ccnx-selectors.h b/ccnx/ccnx-selectors.h
index 1275217..420f33e 100644
--- a/ccnx/ccnx-selectors.h
+++ b/ccnx/ccnx-selectors.h
@@ -62,7 +62,7 @@
answerOriginKind(AOK kind) {m_answerOriginKind = kind; return *this;}
inline Selectors &
- interestLifetime(int lifetime) {m_interestLifetime = lifetime; return *this;}
+ interestLifetime(double lifetime) {m_interestLifetime = lifetime; return *this;}
inline Selectors &
scope(int scope) {m_scope = scope; return *this;}
diff --git a/src/fetcher.cc b/src/fetcher.cc
index 876cab4..01a82a4 100644
--- a/src/fetcher.cc
+++ b/src/fetcher.cc
@@ -67,6 +67,7 @@
{
m_active = true;
m_minSendSeqNo = m_maxInOrderRecvSeqNo;
+ // cout << "Restart: " << m_minSendSeqNo << endl;
m_lastPositiveActivity = date_time::second_clock<boost::posix_time::ptime>::universal_time();
FillPipeline ();
@@ -83,9 +84,14 @@
{
for (; m_minSendSeqNo < m_maxSeqNo && m_activePipeline < m_pipeline; m_minSendSeqNo++)
{
+ if (m_outOfOrderRecvSeqNo.find (m_minSendSeqNo+1) != m_outOfOrderRecvSeqNo.end ())
+ continue;
+
+ // cout << ">>> " << m_minSendSeqNo+1 << endl;
m_ccnx->sendInterest (Name (m_name)(m_minSendSeqNo+1),
Closure (bind(&Fetcher::OnData, this, m_minSendSeqNo+1, _1, _2),
- bind(&Fetcher::OnTimeout, this, m_minSendSeqNo+1, _1)));
+ bind(&Fetcher::OnTimeout, this, m_minSendSeqNo+1, _1)),
+ Selectors().interestLifetime (1)); // Alex: this lifetime should be changed to RTO
m_activePipeline ++;
}
@@ -140,6 +146,7 @@
m_activePipeline --;
if (m_activePipeline == 0)
{
+ m_active = false;
m_onFetchFailed (*this);
// this is not valid anymore, but we still should be able finish work
}
diff --git a/test/test-fetch-manager.cc b/test/test-fetch-manager.cc
index d28570e..55c85df 100644
--- a/test/test-fetch-manager.cc
+++ b/test/test-fetch-manager.cc
@@ -61,7 +61,7 @@
recvContent.insert (*reinterpret_cast<const int*> (head(data)));
}
- // cout << basename << ", " << name << ", " << seqno << endl;
+ // cout << "<<< " << basename << ", " << name << ", " << seqno << endl;
}
void
@@ -89,14 +89,16 @@
// this will allow us to test our pipeline of 6
for (int i = 0; i < 10; i++)
{
- ccnx->publishData (Name (baseName)(i), reinterpret_cast<const unsigned char*> (&i), sizeof(int), 10);
+ ccnx->publishData (Name (baseName)(i), reinterpret_cast<const unsigned char*> (&i), sizeof(int), 30);
+ }
- int other = 10 + i+5;
- ccnx->publishData (Name (baseName)(other), reinterpret_cast<const unsigned char*> (&other), sizeof(int), 10);
+ for (int i = 15; i < 25; i++)
+ {
+ ccnx->publishData (Name (baseName)(i), reinterpret_cast<const unsigned char*> (&i), sizeof(int), 30);
}
int oneMore = 26;
- ccnx->publishData (Name (baseName)(oneMore), reinterpret_cast<const unsigned char*> (&oneMore), sizeof(int), 10);
+ ccnx->publishData (Name (baseName)(oneMore), reinterpret_cast<const unsigned char*> (&oneMore), sizeof(int), 30);
FetcherTestData data;
@@ -111,22 +113,57 @@
fetcher.RestartPipeline ();
BOOST_CHECK_EQUAL (fetcher.IsActive (), true);
- usleep(13000000);
+ usleep(7000000);
BOOST_CHECK_EQUAL (data.m_failed, true);
BOOST_CHECK_EQUAL (data.differentNames.size (), 1);
- BOOST_CHECK_EQUAL (data.segmentNames.size (), 10);
- BOOST_CHECK_EQUAL (data.recvData.size (), 10);
- BOOST_CHECK_EQUAL (data.recvContent.size (), 10);
+ BOOST_CHECK_EQUAL (data.segmentNames.size (), 20);
+ BOOST_CHECK_EQUAL (data.recvData.size (), 20);
+ BOOST_CHECK_EQUAL (data.recvContent.size (), 20);
- ostringstream recvData;
- for (set<uint32_t>::iterator i = data.recvData.begin (); i != data.recvData.end (); i++)
- recvData << *i << ", ";
+ {
+ ostringstream recvData;
+ for (set<uint32_t>::iterator i = data.recvData.begin (); i != data.recvData.end (); i++)
+ recvData << *i << ", ";
- ostringstream recvContent;
- for (set<uint32_t>::iterator i = data.recvContent.begin (); i != data.recvContent.end (); i++)
- recvContent << *i << ", ";
+ ostringstream recvContent;
+ for (set<uint32_t>::iterator i = data.recvContent.begin (); i != data.recvContent.end (); i++)
+ recvContent << *i << ", ";
- BOOST_CHECK_EQUAL (recvData.str (), recvContent.str ());
+ BOOST_CHECK_EQUAL (recvData.str (), "0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, ");
+ BOOST_CHECK_EQUAL (recvData.str (), recvContent.str ());
+ }
+
+ BOOST_CHECK_EQUAL (fetcher.IsActive (), false);
+ fetcher.RestartPipeline ();
+ BOOST_CHECK_EQUAL (fetcher.IsActive (), true);
+
+ usleep(7000000);
+ BOOST_CHECK_EQUAL (data.m_failed, true);
+
+ // publishing missing pieces
+ for (int i = 0; i < 27; i++)
+ {
+ ccnx->publishData (Name (baseName)(i), reinterpret_cast<const unsigned char*> (&i), sizeof(int), 1);
+ }
+ BOOST_CHECK_EQUAL (fetcher.IsActive (), false);
+ fetcher.RestartPipeline ();
+ BOOST_CHECK_EQUAL (fetcher.IsActive (), true);
+
+ usleep(1000000);
+ BOOST_CHECK_EQUAL (data.m_done, true);
+
+ {
+ ostringstream recvData;
+ for (set<uint32_t>::iterator i = data.recvData.begin (); i != data.recvData.end (); i++)
+ recvData << *i << ", ";
+
+ ostringstream recvContent;
+ for (set<uint32_t>::iterator i = data.recvContent.begin (); i != data.recvContent.end (); i++)
+ recvContent << *i << ", ";
+
+ BOOST_CHECK_EQUAL (recvData.str (), "0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, ");
+ BOOST_CHECK_EQUAL (recvData.str (), recvContent.str ());
+ }
}
// BOOST_AUTO_TEST_CASE (CcnxWrapperSelector)