Search in sources :

Example 1 with DhcpL2RelayEvent

use of org.opencord.dhcpl2relay.DhcpL2RelayEvent in project dhcpl2relay by opencord.

the class SimpleDhcpL2RelayCountersStore method publishStats.

private void publishStats() {
    // Only publish events if we are the cluster leader for DHCP L2 relay stats
    if (!Objects.equals(leadershipService.getLeader(DHCP_STATISTICS_LEADERSHIP), clusterService.getLocalNode().id())) {
        return;
    }
    aggregate().counters().forEach((counterKey, counterValue) -> {
        // Subscriber-specific counters have the subscriber ID set
        String subscriberId = null;
        if (!counterKey.counterClassKey.equals(DhcpL2RelayEvent.GLOBAL_COUNTER)) {
            subscriberId = counterKey.counterClassKey;
        }
        notifyDelegate(new DhcpL2RelayEvent(DhcpL2RelayEvent.Type.STATS_UPDATE, null, null, new AbstractMap.SimpleEntry<>(counterKey.counterTypeKey.toString(), new AtomicLong(counterValue)), subscriberId));
    });
}
Also used : DhcpL2RelayEvent(org.opencord.dhcpl2relay.DhcpL2RelayEvent) AtomicLong(java.util.concurrent.atomic.AtomicLong)

Aggregations

AtomicLong (java.util.concurrent.atomic.AtomicLong)1 DhcpL2RelayEvent (org.opencord.dhcpl2relay.DhcpL2RelayEvent)1