29 #include <ndn-cxx/util/indented-stream.hpp> 57 using boost::logic::indeterminate;
65 p.setCapacity(*capacity);
67 if (!indeterminate(enableAdmit)) {
68 p.setFlagBit(ndn::nfd::BIT_CS_ENABLE_ADMIT,
bool(enableAdmit));
70 if (!indeterminate(enableServe)) {
71 p.setFlagBit(ndn::nfd::BIT_CS_ENABLE_SERVE,
bool(enableServe));
74 ctx.
controller.start<ndn::nfd::CsConfigCommand>(p,
75 [&] (
const ControlParameters& resp) {
77 ctx.
out <<
"cs-config-updated " 78 << ia(
"capacity") << resp.getCapacity()
79 << ia(
"admit") <<
text::OnOff{resp.getFlagBit(ndn::nfd::BIT_CS_ENABLE_ADMIT)}
80 << ia(
"serve") <<
text::OnOff{resp.getFlagBit(ndn::nfd::BIT_CS_ENABLE_SERVE)}
86 ctx.
face.processEvents();
92 auto prefix = ctx.
args.
get<Name>(
"prefix");
95 uint64_t numErased = 0;
96 bool wasLimited =
false;
97 bool wasSuccessful =
true;
99 ControlParameters params;
100 params.setName(prefix);
106 params.setCount(*count - numErased);
109 wasSuccessful =
false;
111 ctx.
controller.start<ndn::nfd::CsEraseCommand>(
113 [&] (
const ControlParameters& resp) {
114 wasSuccessful =
true;
115 numErased += resp.getCount();
116 wasLimited = resp.hasCapacity();
121 ctx.
face.processEvents();
122 }
while (wasSuccessful && wasLimited);
126 ctx.
out <<
"cs-erased " 127 << ia(
"prefix") << prefix
128 << ia(
"count") << numErased
135 const std::function<
void()>& onSuccess,
136 const Controller::DatasetFailCallback& onFailure,
137 const CommandOptions& options)
139 controller.fetch<ndn::nfd::CsInfoDataset>(
140 [
this, onSuccess] (
const CsInfo& result) {
157 os <<
"<capacity>" << item.getCapacity() <<
"</capacity>";
158 os <<
xml::Flag{
"admitEnabled", item.getEnableAdmit()};
159 os <<
xml::Flag{
"serveEnabled", item.getEnableServe()};
160 os <<
"<nEntries>" << item.getNEntries() <<
"</nEntries>";
161 os <<
"<nHits>" << item.getNHits() <<
"</nHits>";
162 os <<
"<nMisses>" << item.getNMisses() <<
"</nMisses>";
169 os <<
"CS information:\n";
170 ndn::util::IndentedStream indented(os,
" ");
178 os << ia(
"capacity") << item.getCapacity()
179 << ia(
"admit") <<
text::OnOff{item.getEnableAdmit()}
180 << ia(
"serve") <<
text::OnOff{item.getEnableServe()}
181 << ia(
"nEntries") << item.getNEntries()
182 << ia(
"nHits") << item.getNHits()
183 << ia(
"nMisses") << item.getNMisses()
const CommandArguments & args
Controller::CommandFailCallback makeCommandFailureHandler(const std::string &commandName)
std::ostream & out
output stream
context for command execution
ndn::nfd::CommandOptions makeCommandOptions() const
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
print attributes of an item
print boolean as 'on' or 'off'