chunks: print summary by default
Introduce -q/--quiet option to suppress all output. Change-Id: Ib529849cb1ca8975d11ce6689e2d88708291d1c4 Refs: #4421
This commit is contained in:
1 parent
3dae1090cf
commit
f6991e1a61
9 files changed
+43
-41
No files matched your search
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2016-2017, Regents of the University of California,
|
||||
* Copyright (c) 2016-2018, Regents of the University of California,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University.
|
||||
*
|
||||
@@ -66,7 +66,7 @@ BOOST_AUTO_TEST_CASE(OutputDataSequential)
|
||||
|
||||
util::DummyClientFace face;
|
||||
output_test_stream output("");
|
||||
Consumer cons(security::v2::getAcceptAllValidator(), false, output);
|
||||
Consumer cons(security::v2::getAcceptAllValidator(), output);
|
||||
|
||||
auto interest = makeInterest(name);
|
||||
|
||||
@@ -105,7 +105,7 @@ BOOST_AUTO_TEST_CASE(OutputDataUnordered)
|
||||
|
||||
util::DummyClientFace face;
|
||||
output_test_stream output("");
|
||||
Consumer cons(security::v2::getAcceptAllValidator(), false, output);
|
||||
Consumer cons(security::v2::getAcceptAllValidator(), output);
|
||||
|
||||
auto interest = makeInterest(name);
|
||||
std::vector<shared_ptr<Data>> dataStore;
|
||||
@@ -197,7 +197,7 @@ BOOST_FIXTURE_TEST_CASE(RunBasic, UnitTestTimeFixture)
|
||||
{
|
||||
boost::asio::io_service io;
|
||||
util::DummyClientFace face(io);
|
||||
Consumer consumer(security::v2::getAcceptAllValidator(), false);
|
||||
Consumer consumer(security::v2::getAcceptAllValidator());
|
||||
|
||||
Name prefix("/ndn/chunks/test");
|
||||
auto discover = make_unique<DiscoverVersionDummy>(prefix, face, Options());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2016-2017, Regents of the University of California,
|
||||
* Copyright (c) 2016-2018, Regents of the University of California,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University.
|
||||
*
|
||||
@@ -36,12 +36,11 @@ namespace tests {
|
||||
|
||||
using namespace ndn::tests;
|
||||
|
||||
class PipelineInterestAimdFixture : public ndn::chunks::tests::PipelineInterestsFixture
|
||||
class PipelineInterestAimdFixture : public chunks::tests::PipelineInterestsFixture
|
||||
{
|
||||
public:
|
||||
PipelineInterestAimdFixture()
|
||||
: PipelineInterestsFixture()
|
||||
, opt(makePipelineOptions())
|
||||
: opt(makePipelineOptions())
|
||||
, rttEstimator(makeRttEstimatorOptions())
|
||||
{
|
||||
createPipeline();
|
||||
@@ -56,10 +55,12 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
static PipelineInterestsAimdOptions
|
||||
static PipelineInterestsAimd::Options
|
||||
makePipelineOptions()
|
||||
{
|
||||
PipelineInterestsAimdOptions pipelineOptions;
|
||||
PipelineInterestsAimd::Options pipelineOptions;
|
||||
pipelineOptions.isQuiet = true;
|
||||
pipelineOptions.isVerbose = false;
|
||||
pipelineOptions.disableCwa = false;
|
||||
pipelineOptions.ignoreCongMarks = false;
|
||||
pipelineOptions.resetCwndToInit = false;
|
||||
@@ -83,7 +84,7 @@ private:
|
||||
}
|
||||
|
||||
protected:
|
||||
PipelineInterestsAimdOptions opt;
|
||||
PipelineInterestsAimd::Options opt;
|
||||
RttEstimator rttEstimator;
|
||||
PipelineInterestsAimd* aimdPipeline;
|
||||
static constexpr double MARGIN = 0.01;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2016-2017, Regents of the University of California,
|
||||
* Copyright (c) 2016-2018, Regents of the University of California,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University.
|
||||
*
|
||||
@@ -34,31 +34,28 @@ namespace tests {
|
||||
|
||||
class PipelineInterestFixedWindowFixture : public PipelineInterestsFixture
|
||||
{
|
||||
public:
|
||||
typedef PipelineInterestsFixedWindowOptions Options;
|
||||
|
||||
public:
|
||||
PipelineInterestFixedWindowFixture()
|
||||
: PipelineInterestsFixture()
|
||||
, opt(makeOptions())
|
||||
: opt(makeOptions())
|
||||
{
|
||||
setPipeline(make_unique<PipelineInterestsFixedWindow>(face, PipelineInterestsFixedWindow::Options(opt)));
|
||||
}
|
||||
|
||||
protected:
|
||||
Options opt;
|
||||
|
||||
private:
|
||||
static Options
|
||||
static PipelineInterestsFixedWindow::Options
|
||||
makeOptions()
|
||||
{
|
||||
Options options;
|
||||
PipelineInterestsFixedWindow::Options options;
|
||||
options.isQuiet = true;
|
||||
options.isVerbose = false;
|
||||
options.interestLifetime = time::seconds(1);
|
||||
options.maxRetriesOnTimeoutOrNack = 3;
|
||||
options.maxPipelineSize = 5;
|
||||
return options;
|
||||
}
|
||||
|
||||
protected:
|
||||
PipelineInterestsFixedWindow::Options opt;
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(Chunks)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2016-2017, Regents of the University of California,
|
||||
* Copyright (c) 2016-2018, Regents of the University of California,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University.
|
||||
*
|
||||
@@ -30,11 +30,10 @@
|
||||
namespace ndn {
|
||||
namespace chunks {
|
||||
|
||||
Consumer::Consumer(security::v2::Validator& validator, bool isVerbose, std::ostream& os)
|
||||
Consumer::Consumer(security::v2::Validator& validator, std::ostream& os)
|
||||
: m_validator(validator)
|
||||
, m_outputStream(os)
|
||||
, m_nextToPrint(0)
|
||||
, m_isVerbose(isVerbose)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -65,10 +64,6 @@ Consumer::handleData(const Data& data)
|
||||
m_validator.validate(data,
|
||||
[this, dataPtr] (const Data& data) {
|
||||
if (data.getContentType() == ndn::tlv::ContentType_Nack) {
|
||||
if (m_isVerbose) {
|
||||
std::cerr << "Application level NACK: " << data << std::endl;
|
||||
}
|
||||
m_pipeline->cancel();
|
||||
BOOST_THROW_EXCEPTION(ApplicationNackError(data));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2016-2017, Regents of the University of California,
|
||||
* Copyright (c) 2016-2018, Regents of the University of California,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University.
|
||||
*
|
||||
@@ -70,7 +70,8 @@ public:
|
||||
/**
|
||||
* @brief Create the consumer
|
||||
*/
|
||||
Consumer(security::v2::Validator& validator, bool isVerbose, std::ostream& os = std::cout);
|
||||
explicit
|
||||
Consumer(security::v2::Validator& validator, std::ostream& os = std::cout);
|
||||
|
||||
/**
|
||||
* @brief Run the consumer
|
||||
@@ -92,7 +93,6 @@ private:
|
||||
unique_ptr<DiscoverVersion> m_discover;
|
||||
unique_ptr<PipelineInterests> m_pipeline;
|
||||
uint64_t m_nextToPrint;
|
||||
bool m_isVerbose;
|
||||
|
||||
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
|
||||
std::map<uint64_t, shared_ptr<const Data>> m_bufferedData;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2016-2017, Regents of the University of California,
|
||||
* Copyright (c) 2016-2018, Regents of the University of California,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University.
|
||||
*
|
||||
@@ -78,7 +78,8 @@ main(int argc, char** argv)
|
||||
"lifetime of expressed Interests, in milliseconds")
|
||||
("retries,r", po::value<int>(&options.maxRetriesOnTimeoutOrNack)->default_value(options.maxRetriesOnTimeoutOrNack),
|
||||
"maximum number of retries in case of Nack or timeout (-1 = no limit)")
|
||||
("verbose,v", po::bool_switch(&options.isVerbose), "turn on verbose output")
|
||||
("quiet,q", po::bool_switch(&options.isQuiet), "suppress all diagnostic output, except fatal errors")
|
||||
("verbose,v", po::bool_switch(&options.isVerbose), "turn on verbose output (per segment information")
|
||||
("version,V", "print program version and exit")
|
||||
;
|
||||
|
||||
@@ -208,9 +209,13 @@ main(int argc, char** argv)
|
||||
std::cerr << "ERROR: lifetime cannot be negative" << std::endl;
|
||||
return 2;
|
||||
}
|
||||
|
||||
options.interestLifetime = time::milliseconds(vm["lifetime"].as<int64_t>());
|
||||
|
||||
if (options.isQuiet && options.isVerbose) {
|
||||
std::cerr << "ERROR: cannot be quiet and verbose at the same time" << std::endl;
|
||||
return 2;
|
||||
}
|
||||
|
||||
try {
|
||||
Face face;
|
||||
|
||||
@@ -288,8 +293,7 @@ main(int argc, char** argv)
|
||||
return 2;
|
||||
}
|
||||
|
||||
Consumer consumer(security::v2::getAcceptAllValidator(), options.isVerbose);
|
||||
|
||||
Consumer consumer(security::v2::getAcceptAllValidator());
|
||||
BOOST_ASSERT(discover != nullptr);
|
||||
BOOST_ASSERT(pipeline != nullptr);
|
||||
consumer.run(std::move(discover), std::move(pipeline));
|
||||
@@ -299,6 +303,10 @@ main(int argc, char** argv)
|
||||
std::cerr << "ERROR: " << e.what() << std::endl;
|
||||
return 3;
|
||||
}
|
||||
catch (const Consumer::DataValidationError& e) {
|
||||
std::cerr << "ERROR: " << e.what() << std::endl;
|
||||
return 5;
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
std::cerr << "ERROR: " << e.what() << std::endl;
|
||||
return 1;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2016-2017, Regents of the University of California,
|
||||
* Copyright (c) 2016-2018, Regents of the University of California,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University.
|
||||
*
|
||||
@@ -38,6 +38,7 @@ struct Options
|
||||
time::milliseconds interestLifetime = ndn::DEFAULT_INTEREST_LIFETIME;
|
||||
int maxRetriesOnTimeoutOrNack = 3;
|
||||
bool mustBeFresh = false;
|
||||
bool isQuiet = false;
|
||||
bool isVerbose = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -292,7 +292,7 @@ PipelineInterestsAimd::handleData(const Interest& interest, const Data& data)
|
||||
if (m_hasFinalBlockId &&
|
||||
static_cast<uint64_t>(m_nReceived - 1) >= m_lastSegmentNo) { // all segments have been received
|
||||
cancel();
|
||||
if (m_options.isVerbose) {
|
||||
if (!m_options.isQuiet) {
|
||||
printSummary();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2016-2017, Regents of the University of California,
|
||||
* Copyright (c) 2016-2018, Regents of the University of California,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University.
|
||||
*
|
||||
@@ -143,7 +143,7 @@ PipelineInterestsFixedWindow::handleData(const Interest& interest, const Data& d
|
||||
BOOST_ASSERT(m_nReceived > 0);
|
||||
if (m_hasFinalBlockId &&
|
||||
static_cast<uint64_t>(m_nReceived - 1) >= m_lastSegmentNo) { // all segments have been received
|
||||
if (m_options.isVerbose) {
|
||||
if (!m_options.isQuiet) {
|
||||
printSummary();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user