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);
}
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);
}
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");
}
}
}
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");
}
}
}
}
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();
}
Aggregations