29 #include <ndn-cxx/mgmt/nfd/status-dataset.hpp>
30 #include <ndn-cxx/util/indented-stream.hpp>
56 using boost::logic::indeterminate;
64 p.setCapacity(*capacity);
66 if (!indeterminate(enableAdmit)) {
67 p.setFlagBit(ndn::nfd::BIT_CS_ENABLE_ADMIT,
bool(enableAdmit));
69 if (!indeterminate(enableServe)) {
70 p.setFlagBit(ndn::nfd::BIT_CS_ENABLE_SERVE,
bool(enableServe));
73 ctx.
controller.start<ndn::nfd::CsConfigCommand>(p,
74 [&] (
const ControlParameters& resp) {
76 ctx.
out <<
"cs-config-updated "
77 << ia(
"capacity") << resp.getCapacity()
78 << ia(
"admit") <<
text::OnOff{resp.getFlagBit(ndn::nfd::BIT_CS_ENABLE_ADMIT)}
79 << ia(
"serve") <<
text::OnOff{resp.getFlagBit(ndn::nfd::BIT_CS_ENABLE_SERVE)}
85 ctx.
face.processEvents();
91 auto prefix = ctx.
args.
get<Name>(
"prefix");
94 uint64_t numErased = 0;
95 bool wasLimited =
false;
96 bool wasSuccessful =
true;
98 ControlParameters params;
99 params.setName(prefix);
105 params.setCount(*count - numErased);
108 wasSuccessful =
false;
110 ctx.
controller.start<ndn::nfd::CsEraseCommand>(
112 [&] (
const ControlParameters& resp) {
113 wasSuccessful =
true;
114 numErased += resp.getCount();
115 wasLimited = resp.hasCapacity();
120 ctx.
face.processEvents();
121 }
while (wasSuccessful && wasLimited);
125 ctx.
out <<
"cs-erased "
126 << ia(
"prefix") << prefix
127 << ia(
"count") << numErased
134 const std::function<
void()>& onSuccess,
135 const ndn::nfd::DatasetFailureCallback& onFailure,
136 const CommandOptions& options)
138 controller.fetch<ndn::nfd::CsInfoDataset>(
139 [
this, onSuccess] (
const CsInfo& result) {
156 os <<
"<capacity>" << item.getCapacity() <<
"</capacity>";
157 os <<
xml::Flag{
"admitEnabled", item.getEnableAdmit()};
158 os <<
xml::Flag{
"serveEnabled", item.getEnableServe()};
159 os <<
"<nEntries>" << item.getNEntries() <<
"</nEntries>";
160 os <<
"<nHits>" << item.getNHits() <<
"</nHits>";
161 os <<
"<nMisses>" << item.getNMisses() <<
"</nMisses>";
168 os <<
"CS information:\n";
169 ndn::util::IndentedStream indented(os,
" ");
177 os << ia(
"capacity") << item.getCapacity()
178 << ia(
"admit") <<
text::OnOff{item.getEnableAdmit()}
179 << ia(
"serve") <<
text::OnOff{item.getEnableServe()}
180 << ia(
"nEntries") << item.getNEntries()
181 << ia(
"nHits") << item.getNHits()
182 << ia(
"nMisses") << item.getNMisses()
Context for command execution.
std::ostream & out
output stream
ndn::nfd::Controller & controller
const CommandArguments & args
ndn::nfd::CommandFailureCallback makeCommandFailureHandler(const std::string &commandName)
ndn::nfd::CommandOptions makeCommandOptions() const
Print attributes of an item.
Print boolean as 'on' or 'off'.