29 #include <ndn-cxx/util/indented-stream.hpp>
55 using boost::logic::indeterminate;
63 p.setCapacity(*capacity);
65 if (!indeterminate(enableAdmit)) {
66 p.setFlagBit(ndn::nfd::BIT_CS_ENABLE_ADMIT,
bool(enableAdmit));
68 if (!indeterminate(enableServe)) {
69 p.setFlagBit(ndn::nfd::BIT_CS_ENABLE_SERVE,
bool(enableServe));
72 ctx.
controller.start<ndn::nfd::CsConfigCommand>(p,
73 [&] (
const ControlParameters& resp) {
75 ctx.
out <<
"cs-config-updated "
76 << ia(
"capacity") << resp.getCapacity()
77 << ia(
"admit") <<
text::OnOff{resp.getFlagBit(ndn::nfd::BIT_CS_ENABLE_ADMIT)}
78 << ia(
"serve") <<
text::OnOff{resp.getFlagBit(ndn::nfd::BIT_CS_ENABLE_SERVE)}
84 ctx.
face.processEvents();
90 auto prefix = ctx.
args.
get<Name>(
"prefix");
93 uint64_t numErased = 0;
94 bool wasLimited =
false;
95 bool wasSuccessful =
true;
97 ControlParameters params;
98 params.setName(prefix);
104 params.setCount(*count - numErased);
107 wasSuccessful =
false;
109 ctx.
controller.start<ndn::nfd::CsEraseCommand>(
111 [&] (
const ControlParameters& resp) {
112 wasSuccessful =
true;
113 numErased += resp.getCount();
114 wasLimited = resp.hasCapacity();
119 ctx.
face.processEvents();
120 }
while (wasSuccessful && wasLimited);
124 ctx.
out <<
"cs-erased "
125 << ia(
"prefix") << prefix
126 << ia(
"count") << numErased
133 const std::function<
void()>& onSuccess,
134 const Controller::DatasetFailCallback& onFailure,
135 const CommandOptions& options)
137 controller.fetch<ndn::nfd::CsInfoDataset>(
138 [
this, onSuccess] (
const CsInfo& result) {
155 os <<
"<capacity>" << item.getCapacity() <<
"</capacity>";
156 os <<
xml::Flag{
"admitEnabled", item.getEnableAdmit()};
157 os <<
xml::Flag{
"serveEnabled", item.getEnableServe()};
158 os <<
"<nEntries>" << item.getNEntries() <<
"</nEntries>";
159 os <<
"<nHits>" << item.getNHits() <<
"</nHits>";
160 os <<
"<nMisses>" << item.getNMisses() <<
"</nMisses>";
167 os <<
"CS information:\n";
168 ndn::util::IndentedStream indented(os,
" ");
176 os << ia(
"capacity") << item.getCapacity()
177 << ia(
"admit") <<
text::OnOff{item.getEnableAdmit()}
178 << ia(
"serve") <<
text::OnOff{item.getEnableServe()}
179 << ia(
"nEntries") << item.getNEntries()
180 << ia(
"nHits") << item.getNHits()
181 << ia(
"nMisses") << item.getNMisses()
Context for command execution.
std::ostream & out
output stream
const CommandArguments & args
Controller::CommandFailCallback makeCommandFailureHandler(const std::string &commandName)
ndn::nfd::CommandOptions makeCommandOptions() const
Print attributes of an item.
Print boolean as 'on' or 'off'.