Search in sources :

Example 1 with DhcpRelayCountersStore

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);
        }
    }
}
Also used : DhcpRelayCounters(org.onosproject.dhcprelay.store.DhcpRelayCounters) DhcpRelayCountersStore(org.onosproject.dhcprelay.store.DhcpRelayCountersStore)

Example 2 with DhcpRelayCountersStore

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);
    }
}
Also used : DhcpRelayCounters(org.onosproject.dhcprelay.store.DhcpRelayCounters) DhcpRelayCountersStore(org.onosproject.dhcprelay.store.DhcpRelayCountersStore)

Example 3 with DhcpRelayCountersStore

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;
}
Also used : DhcpRelayCounters(org.onosproject.dhcprelay.store.DhcpRelayCounters) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DhcpRelayCountersStore(org.onosproject.dhcprelay.store.DhcpRelayCountersStore)

Aggregations

DhcpRelayCounters (org.onosproject.dhcprelay.store.DhcpRelayCounters)3 DhcpRelayCountersStore (org.onosproject.dhcprelay.store.DhcpRelayCountersStore)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1