use of org.onosproject.dhcprelay.store.DhcpRelayCountersStore in project onos by opennetworkinglab.
the class DhcpRelayAggCountersCommand method doExecute.
@Override
protected void doExecute() {
boolean toResetFlag;
if (reset != null) {
if (reset.equals("reset") || reset.equals("[reset]")) {
toResetFlag = true;
} else {
print("Last parameter is [reset]");
return;
}
} else {
toResetFlag = false;
}
print(HEADER);
DhcpRelayCountersStore counterStore = AbstractShellCommand.get(DhcpRelayCountersStore.class);
Optional<DhcpRelayCounters> perClassCounters = counterStore.getCounters(GCOUNT);
if (perClassCounters.isPresent()) {
Map<String, Integer> counters = perClassCounters.get().getCounters();
if (counters.size() > 0) {
counters.forEach((name, value) -> {
print("%-30s ............................ %-4d packets", name, value);
});
} else {
print("No counter for {}", GCOUNT);
}
if (toResetFlag) {
counterStore.resetCounters(GCOUNT);
}
}
}
use of org.onosproject.dhcprelay.store.DhcpRelayCountersStore in project onos by opennetworkinglab.
the class DhcpRelayWebResource method resetDhcpRelayAggCountersInternal.
/**
* To reset aggregate counters.
*
* @return counterPackets type ObjectNode.
*/
private void resetDhcpRelayAggCountersInternal() {
DhcpRelayCountersStore counterStore = get(DhcpRelayCountersStore.class);
Optional<DhcpRelayCounters> perClassCounters = counterStore.getCounters(GCOUNT_KEY);
if (perClassCounters.isPresent()) {
counterStore.resetCounters(GCOUNT_KEY);
}
}
use of org.onosproject.dhcprelay.store.DhcpRelayCountersStore in project onos by opennetworkinglab.
the class DhcpRelayWebResource method getDhcpRelayAggCountersJsonOutput.
/**
* To get dhcp relay aggregate counters.
*
* @return counterPackets type ObjectNode.
*/
private ObjectNode getDhcpRelayAggCountersJsonOutput() {
ObjectNode counterPackets = mapper().createObjectNode();
ObjectNode dhcpRelayAggCounterNode = mapper().createObjectNode();
DhcpRelayCountersStore counterStore = get(DhcpRelayCountersStore.class);
Optional<DhcpRelayCounters> perClassCounters = counterStore.getCounters(GCOUNT_KEY);
if (perClassCounters.isPresent()) {
Map<String, Integer> counters = perClassCounters.get().getCounters();
if (counters.size() > 0) {
counters.forEach((name, value) -> {
counterPackets.put(name, value);
});
}
}
dhcpRelayAggCounterNode.put(HEADER_A_COUNTERS, counterPackets);
return dhcpRelayAggCounterNode;
}
Aggregations