Search in sources :

Example 1 with Counter

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

the class BgpCounters method parseBgpL2vpnEvpnAll.

private void parseBgpL2vpnEvpnAll() {
    File file = new File(BGP_EVPN_FILE);
    List<String> inputStrs = new ArrayList<>();
    try (Scanner scanner = new Scanner(file)) {
        while (scanner.hasNextLine()) {
            inputStrs.add(scanner.nextLine());
        }
    } catch (IOException e) {
        LOG.error("Could not process the file {}", file.getAbsolutePath());
        return;
    }
    for (int i = 0; i < inputStrs.size(); i++) {
        String instr = inputStrs.get(i);
        if (instr.contains("Route Distinguisher")) {
            String[] result = instr.split(":");
            String rd = result[1].trim() + "_" + result[2].trim();
            i = processRouteCount(rd + "_EVPN", i + 1, inputStrs);
        }
    }
    /*populate the "BgpTotalPrefixes" counter by combining
        the prefixes that are calculated per RD basis*/
    long bgpTotalPfxs = calculateBgpTotalPrefixes();
    LOG.trace("BGP Total Prefixes:{}", bgpTotalPfxs);
    Counter counter = getCounter(BgpConstants.BGP_COUNTER_TOTAL_PFX, null, null, null, null, null);
    updateCounter(counter, bgpTotalPfxs);
}
Also used : Scanner(java.util.Scanner) Counter(org.opendaylight.infrautils.metrics.Counter) ArrayList(java.util.ArrayList) IOException(java.io.IOException) File(java.io.File)

Example 2 with Counter

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

the class MetricProviderTest method testCounterWith5Labels.

@Test
public void testCounterWith5Labels() {
    Labeled<Labeled<Labeled<Labeled<Labeled<Counter>>>>> counterWithFiveLabels = metrics.newCounter(MetricDescriptor.builder().anchor(this).project("infrautils").module("metrics").id("test_counter2").build(), "label1", "label2", "label3", "label4", "label5");
    Counter counterA = counterWithFiveLabels.label("l1").label("l2").label("l3").label("l4").label("l5");
    counterA.increment(5);
    assertThat(counterA.get()).isEqualTo(5);
    Counter againCounterA = counterWithFiveLabels.label("l1").label("l2").label("l3").label("l4").label("l5");
    assertThat(againCounterA.get()).isEqualTo(5);
}
Also used : Counter(org.opendaylight.infrautils.metrics.Counter) Labeled(org.opendaylight.infrautils.metrics.Labeled) Test(org.junit.Test)

Example 3 with Counter

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

the class FlowNodeConnectorInventoryTranslatorImpl method remove.

@Override
public void remove(InstanceIdentifier<FlowCapableNodeConnector> identifier, FlowCapableNodeConnector del, InstanceIdentifier<FlowCapableNodeConnector> nodeConnIdent) {
    Counter counter;
    if (compareInstanceIdentifierTail(identifier, II_TO_FLOW_CAPABLE_NODE_CONNECTOR)) {
        String nodeConnectorIdentifier = getNodeConnectorId(String.valueOf(nodeConnIdent.firstKeyOf(NodeConnector.class).getId()));
        long dataPathId = getDpIdFromPortName(nodeConnectorIdentifier);
        if (dpnToPortMultiMap.containsKey(dataPathId)) {
            LOG.debug("Node Connector {} removed", nodeConnectorIdentifier);
            dpnToPortMultiMap.remove(dataPathId, nodeConnectorIdentifier);
            counter = packetInCounter.label("OFSwitch").label(String.valueOf(dataPathId)).label("portsperswitch");
            counter.decrement();
            PortNameMapping.updatePortMap("openflow:" + dataPathId + ":" + del.getName(), nodeConnectorIdentifier, "DELETE");
        }
    }
}
Also used : Counter(org.opendaylight.infrautils.metrics.Counter) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) NodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector)

Example 4 with Counter

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

the class FlowNodeConnectorInventoryTranslatorImpl method add.

@Override
public void add(InstanceIdentifier<FlowCapableNodeConnector> identifier, FlowCapableNodeConnector add, InstanceIdentifier<FlowCapableNodeConnector> nodeConnIdent) {
    Counter counter;
    if (compareInstanceIdentifierTail(identifier, II_TO_FLOW_CAPABLE_NODE_CONNECTOR)) {
        String nodeConnectorIdentifier = getNodeConnectorId(String.valueOf(nodeConnIdent.firstKeyOf(NodeConnector.class).getId()));
        long dataPathId = getDpIdFromPortName(nodeConnectorIdentifier);
        if (entityOwnershipUtils.isEntityOwner(FcapsConstants.SERVICE_ENTITY_TYPE, getNodeId(dataPathId))) {
            if (!dpnToPortMultiMap.containsEntry(dataPathId, nodeConnectorIdentifier)) {
                LOG.debug("Node Connector {} added", nodeConnectorIdentifier);
                dpnToPortMultiMap.put(dataPathId, nodeConnectorIdentifier);
                counter = packetInCounter.label("OFSwitch").label(String.valueOf(dataPathId)).label("portsperswitch");
                counter.increment();
                PortNameMapping.updatePortMap("openflow:" + dataPathId + ":" + add.getName(), nodeConnectorIdentifier, "ADD");
            } else {
                LOG.error("Duplicate Event.Node Connector already added");
            }
        }
    }
}
Also used : Counter(org.opendaylight.infrautils.metrics.Counter) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) NodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector)

Example 5 with Counter

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

the class NodeUpdateCounter method nodeRemovedNotification.

public void nodeRemovedNotification(String node, String hostName) {
    Counter counter;
    dpnList.remove(node);
    counter = packetInCounter.label("OFSwitch").label(hostName).label("switchespernode");
    counter.close();
}
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