ndnputchunks: display some output by default.

Will display some messages without the need of the '-v' parameter.
'-v' still adds the additional output per incoming Interest.

Also adds '-q' flag to disable all output except errors.

refs: #4286

Change-Id: I81116182403cd3f3e9d9bd63be64c1ff3a4552ee
This commit is contained in:
Klaus Schneider committed 2017-09-15 22:21:02 -07:00
1 parent 0ebecab714
commit 59ec95a15e
4 files changed
+31 -18

No files matched your search

+5 -5
View File
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
/*
* Copyright (c) 2016-2017, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
@@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE(InputData)
for (size_t i = 0; i < testStrings.size(); ++i) {
std::istringstream str(testStrings[i]);
Producer prod(prefix, face, m_keyChain, signingInfo, time::seconds(4), maxSegmentSize, false,
false, str);
false, false, str);
size_t expectedSize = std::ceil(static_cast<double>(testStrings[i].size()) / maxSegmentSize);
if (testStrings[i].size() == 0)
@@ -103,7 +103,7 @@ BOOST_AUTO_TEST_CASE(InputData)
BOOST_AUTO_TEST_CASE(RequestSegmentUnspecifiedVersion)
{
Producer producer(prefix, face, m_keyChain, signingInfo, freshnessPeriod, maxSegmentSize,
false, false, testString);
false, false, false, testString);
io.poll();
size_t nSegments = std::ceil(static_cast<double>(testString.str().size()) / maxSegmentSize);
@@ -140,7 +140,7 @@ BOOST_AUTO_TEST_CASE(RequestSegmentUnspecifiedVersion)
BOOST_AUTO_TEST_CASE(RequestSegmentSpecifiedVersion)
{
Producer producer(prefix.appendVersion(version), face, m_keyChain, signingInfo, freshnessPeriod,
maxSegmentSize, false, false, testString);
maxSegmentSize, false, false, false, testString);
io.poll();
size_t nSegments = std::ceil(static_cast<double>(testString.str().size()) / maxSegmentSize);
@@ -178,7 +178,7 @@ BOOST_AUTO_TEST_CASE(RequestSegmentSpecifiedVersion)
BOOST_AUTO_TEST_CASE(RequestNotExistingSegment)
{
Producer producer(prefix, face, m_keyChain, signingInfo, freshnessPeriod, maxSegmentSize,
false, false, testString);
false, false, false, testString);
io.poll();
size_t nSegments = std::ceil(static_cast<double>(testString.str().size()) / maxSegmentSize);
+12 -4
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2016, Regents of the University of California,
/*
* Copyright (c) 2016-2017, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -23,6 +23,7 @@
* @author Wentao Shang
* @author Steve DiBenedetto
* @author Andrea Tosatto
* @author Klaus Schneider
*/
#include "core/version.hpp"
@@ -50,6 +51,7 @@ main(int argc, char** argv)
size_t maxChunkSize = MAX_NDN_PACKET_SIZE >> 1;
std::string signingStr;
bool isVerbose = false;
bool isQuiet = false;
std::string prefix;
po::options_description visibleDesc("Options");
@@ -62,7 +64,8 @@ main(int argc, char** argv)
"maximum chunk size, in bytes")
("signing-info,S", po::value<std::string>(&signingStr)->default_value(signingStr),
"set signing information")
("verbose,v", po::bool_switch(&isVerbose), "turn on verbose output")
("quiet,q", po::bool_switch(&isQuiet), "turn off all non-error output")
("verbose,v", po::bool_switch(&isVerbose), "turn on verbose output (per Interest information)")
("version,V", "print program version and exit")
;
@@ -110,6 +113,11 @@ main(int argc, char** argv)
return 2;
}
if (isQuiet && isVerbose) {
std::cerr << "ERROR: Cannot use flags -q and -v at the same time\n";
return 2;
}
security::SigningInfo signingInfo;
try {
signingInfo = security::SigningInfo(signingStr);
@@ -123,7 +131,7 @@ main(int argc, char** argv)
Face face;
KeyChain keyChain;
Producer producer(prefix, face, keyChain, signingInfo, time::milliseconds(freshnessPeriod),
maxChunkSize, isVerbose, printVersion, std::cin);
maxChunkSize, isQuiet, isVerbose, printVersion, std::cin);
producer.run();
}
catch (const std::exception& e) {
+8 -5
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2016, Regents of the University of California,
/*
* Copyright (c) 2016-2017, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -23,6 +23,7 @@
* @author Wentao Shang
* @author Steve DiBenedetto
* @author Andrea Tosatto
* @author Klaus Schneider
*/
#include "producer.hpp"
@@ -36,6 +37,7 @@ Producer::Producer(const Name& prefix,
const security::SigningInfo& signingInfo,
time::milliseconds freshnessPeriod,
size_t maxSegmentSize,
bool isQuiet,
bool isVerbose,
bool needToPrintVersion,
std::istream& is)
@@ -44,6 +46,7 @@ Producer::Producer(const Name& prefix,
, m_signingInfo(signingInfo)
, m_freshnessPeriod(freshnessPeriod)
, m_maxSegmentSize(maxSegmentSize)
, m_isQuiet(isQuiet)
, m_isVerbose(isVerbose)
{
if (prefix.size() > 0 && prefix[-1].isVersion()) {
@@ -65,7 +68,7 @@ Producer::Producer(const Name& prefix,
RegisterPrefixSuccessCallback(),
bind(&Producer::onRegisterFailed, this, _1, _2));
if (m_isVerbose)
if (!m_isQuiet)
std::cerr << "Data published with name: " << m_versionedPrefix << std::endl;
}
@@ -113,7 +116,7 @@ Producer::populateStore(std::istream& is)
{
BOOST_ASSERT(m_store.size() == 0);
if (m_isVerbose)
if (!m_isQuiet)
std::cerr << "Loading input ..." << std::endl;
std::vector<uint8_t> buffer(m_maxSegmentSize);
@@ -141,7 +144,7 @@ Producer::populateStore(std::istream& is)
m_keyChain.sign(*data, m_signingInfo);
}
if (m_isVerbose)
if (!m_isQuiet)
std::cerr << "Created " << m_store.size() << " chunks for prefix " << m_prefix << std::endl;
}
+6 -4
View File
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2016, Regents of the University of California,
/*
* Copyright (c) 2016-2017, Regents of the University of California,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University.
*
@@ -23,6 +23,7 @@
* @author Wentao Shang
* @author Steve DiBenedetto
* @author Andrea Tosatto
* @author Klaus Schneider
*/
#ifndef NDN_TOOLS_CHUNKS_PUTCHUNKS_PRODUCER_HPP
@@ -51,8 +52,8 @@ public:
*/
Producer(const Name& prefix, Face& face, KeyChain& keyChain,
const security::SigningInfo& signingInfo, time::milliseconds freshnessPeriod,
size_t maxSegmentSize, bool isVerbose = false, bool needToPrintVersion = false,
std::istream& is = std::cin);
size_t maxSegmentSize, bool isQuiet = false, bool isVerbose = false,
bool needToPrintVersion = false, std::istream& is = std::cin);
/**
* @brief Run the Producer
@@ -91,6 +92,7 @@ private:
security::SigningInfo m_signingInfo;
time::milliseconds m_freshnessPeriod;
size_t m_maxSegmentSize;
bool m_isQuiet;
bool m_isVerbose;
};