Search in sources :

Example 6 with Counter

use of org.opendaylight.infrautils.metrics.Counter in project genius by opendaylight.

the class PacketInCounterHandler method onPacketReceived.

@Override
public void onPacketReceived(PacketReceived notification) {
    Counter counter;
    LOG.debug("Ingress packet notification received");
    if (notification.getIngress() == null) {
        if (LOG.isWarnEnabled()) {
            LOG.warn("invalid PacketReceived notification");
        }
        return;
    }
    String dpnId = getDpnId(notification.getIngress().getValue().toString());
    counter = packetInCounter.label("OFSwitch").label(dpnId).label("packetin");
    counter.increment();
}
Also used : Counter(org.opendaylight.infrautils.metrics.Counter)

Example 7 with Counter

use of org.opendaylight.infrautils.metrics.Counter in project netvirt by opendaylight.

the class BgpCounters method processRouteCount.

private int processRouteCount(String rd, int startIndex, List<String> inputStrs) {
    int num = startIndex;
    long routeCount = 0;
    String bgpRdRouteCountKey = BgpConstants.BGP_COUNTER_RD_ROUTE_COUNT + rd;
    Counter counter = getCounter(BgpConstants.BGP_COUNTER_RD_ROUTE_COUNT, null, null, null, null, rd);
    for (String str = inputStrs.get(num); str != null && !str.trim().equals("") && num < inputStrs.size(); str = inputStrs.get(num)) {
        if (str.contains("Route Distinguisher")) {
            totalPfxMap.put(bgpRdRouteCountKey, Long.toString(routeCount));
            updateCounter(counter, routeCount);
            return num - 1;
        }
        routeCount++;
        num++;
        if (num == inputStrs.size()) {
            break;
        }
    }
    if (routeCount == 0) {
        // by sending a big number back.
        return Integer.MAX_VALUE;
    }
    updateCounter(counter, routeCount);
    return num - 1;
}
Also used : Counter(org.opendaylight.infrautils.metrics.Counter)

Example 8 with Counter

use of org.opendaylight.infrautils.metrics.Counter in project netvirt by opendaylight.

the class BgpCounters method getCounter.

/**
 * Returns the counter.
 * This method returns counter and also creates counter if does not exist.
 *
 * @param counterName name of the counter.
 * @param asValue as value.
 * @param rxValue rx value.
 * @param txValue tx value.
 * @param neighborIp neighbor Ipaddress.
 * @param rdValue rd value.
 * @return counter object.
 */
private Counter getCounter(String counterName, String asValue, String rxValue, String txValue, String neighborIp, String rdValue) {
    String counterTypeEntityCounter = "entitycounter";
    String labelKeyEntityType = "entitytype";
    String labelValEntityTypeBgpPeer = "bgp-peer";
    String labelKeyAsId = "asid";
    String labelKeyNeighborIp = "neighborip";
    String labelValEntityTypeBgpRd = "bgp-rd";
    String labelKeyRd = "rd";
    String counterTypeAggregateCounter = "aggregatecounter";
    String labelKeyCounterName = "name";
    Counter counter = null;
    if (rxValue != null) {
        /*
             * Following is the key pattern for Counter BgpNeighborPacketsReceived
             * netvirt.bgpmanager.entitycounter{entitytype=bgp-peer, asid=value, neighborip=value, name=countername}
             * */
        Labeled<Labeled<Labeled<Labeled<Counter>>>> labeledCounter = metricProvider.newCounter(MetricDescriptor.builder().anchor(this).project("netvirt").module("bgpmanager").id(counterTypeEntityCounter).build(), labelKeyEntityType, labelKeyAsId, labelKeyNeighborIp, labelKeyCounterName);
        counter = labeledCounter.label(labelValEntityTypeBgpPeer).label(asValue).label(neighborIp).label(counterName);
    } else if (txValue != null) {
        /*
             * Following is the key pattern for Counter BgpNeighborPacketsSent
             * netvirt.bgpmanager.entitycounter{entitytype=bgp-peer, asid=value, neighborip=value, name=countername}
             * */
        Labeled<Labeled<Labeled<Labeled<Counter>>>> labeledCounter = metricProvider.newCounter(MetricDescriptor.builder().anchor(this).project("netvirt").module("bgpmanager").id(counterTypeEntityCounter).build(), labelKeyEntityType, labelKeyAsId, labelKeyNeighborIp, labelKeyCounterName);
        counter = labeledCounter.label(labelValEntityTypeBgpPeer).label(asValue).label(neighborIp).label(counterName);
    } else if (rdValue != null) {
        /*
             * Following is the key pattern for Counter BgpRdRouteCount
             * netvirt.bgpmanager.entitycounter{entitytype=bgp-rd, rd=value, name=countername}
             * */
        Labeled<Labeled<Labeled<Counter>>> labeledCounter = metricProvider.newCounter(MetricDescriptor.builder().anchor(this).project("netvirt").module("bgpmanager").id(counterTypeEntityCounter).build(), labelKeyEntityType, labelKeyRd, labelKeyCounterName);
        counter = labeledCounter.label(labelValEntityTypeBgpRd).label(rdValue).label(counterName);
    } else {
        /*
             * Following is the key pattern for Counter BgpTotalPrefixes:Bgp_Total_Prefixes
             * netvirt.bgpmanager.aggregatecounter{name=countername}
             * */
        Labeled<Counter> labeledCounter = metricProvider.newCounter(MetricDescriptor.builder().anchor(this).project("netvirt").module("bgpmanager").id(counterTypeAggregateCounter).build(), labelKeyCounterName);
        counter = labeledCounter.label(counterName);
    }
    return counter;
}
Also used : Counter(org.opendaylight.infrautils.metrics.Counter) Labeled(org.opendaylight.infrautils.metrics.Labeled)

Example 9 with Counter

use of org.opendaylight.infrautils.metrics.Counter in project genius by opendaylight.

the class NodeUpdateCounter method nodeAddedNotification.

public void nodeAddedNotification(String node, String hostName) {
    Counter counter;
    dpnList.add(node);
    counter = packetInCounter.label("OFSwitch").label(hostName).label("switchespernode");
    counter.increment();
}
Also used : Counter(org.opendaylight.infrautils.metrics.Counter)

Example 10 with Counter

use of org.opendaylight.infrautils.metrics.Counter in project genius by opendaylight.

the class PacketInCounterHandler method nodeRemovedNotification.

public void nodeRemovedNotification(String dpnId) {
    Counter counter;
    if (dpnId != null) {
        dpnId = dpnId.split(":")[1];
        LOG.debug("Dpnvalue Id {}", dpnId);
        counter = packetInCounter.label("OFSwitch").label(dpnId).label("packetin");
        counter.close();
    } else {
        LOG.error("DpnId is null upon nodeRemovedNotification");
    }
}
Also used : Counter(org.opendaylight.infrautils.metrics.Counter)

Aggregations

Counter (org.opendaylight.infrautils.metrics.Counter)19 Labeled (org.opendaylight.infrautils.metrics.Labeled)7 Test (org.junit.Test)5 BigInteger (java.math.BigInteger)3 List (java.util.List)3 UncheckedCloseable (org.opendaylight.infrautils.utils.UncheckedCloseable)3 FlowAndStatisticsMapList (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList)3 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)3 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)3 NodeConnectorStatisticsAndPortNumberMap (org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap)3 Optional (com.google.common.base.Optional)2 FutureCallback (com.google.common.util.concurrent.FutureCallback)2 Futures (com.google.common.util.concurrent.Futures)2 JdkFutureAdapters (com.google.common.util.concurrent.JdkFutureAdapters)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)2 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Set (java.util.Set)2