Search in sources :

Example 11 with Metric

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.metric.object.Metric in project bgpcep by opendaylight.

the class LinkAttributesParser method serializeLinkAttributes.

static void serializeLinkAttributes(final LinkAttributesCase linkAttributesCase, final ByteBuf output) {
    final LinkAttributes linkAttributes = linkAttributesCase.getLinkAttributes();
    LOG.trace("Started serializing Link Attributes");
    ifPresentApply(linkAttributes.getLocalIpv4RouterId(), value -> TlvUtil.writeTLV(TlvUtil.LOCAL_IPV4_ROUTER_ID, Ipv4Util.byteBufForAddress((Ipv4Address) value), output));
    ifPresentApply(linkAttributes.getLocalIpv6RouterId(), value -> TlvUtil.writeTLV(TlvUtil.LOCAL_IPV6_ROUTER_ID, Ipv6Util.byteBufForAddress((Ipv6Address) value), output));
    ifPresentApply(linkAttributes.getRemoteIpv4RouterId(), value -> TlvUtil.writeTLV(REMOTE_IPV4_ROUTER_ID, Ipv4Util.byteBufForAddress((Ipv4Address) value), output));
    ifPresentApply(linkAttributes.getRemoteIpv6RouterId(), value -> TlvUtil.writeTLV(REMOTE_IPV6_ROUTER_ID, Ipv6Util.byteBufForAddress((Ipv6Address) value), output));
    ifPresentApply(linkAttributes.getAdminGroup(), value -> TlvUtil.writeTLV(ADMIN_GROUP, Unpooled.copyInt((((AdministrativeGroup) value).getValue()).intValue()), output));
    ifPresentApply(linkAttributes.getMaxLinkBandwidth(), value -> TlvUtil.writeTLV(MAX_BANDWIDTH, Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
    ifPresentApply(linkAttributes.getMaxReservableBandwidth(), value -> TlvUtil.writeTLV(MAX_RESERVABLE_BANDWIDTH, Unpooled.wrappedBuffer(((Bandwidth) value).getValue()), output));
    serializeUnreservedBw(linkAttributes.getUnreservedBandwidth(), output);
    ifPresentApply(linkAttributes.getTeMetric(), value -> TlvUtil.writeTLV(TE_METRIC, Unpooled.copyLong(((TeMetric) value).getValue()), output));
    ifPresentApply(linkAttributes.getLinkProtection(), value -> TlvUtil.writeTLV(LINK_PROTECTION_TYPE, Unpooled.copyShort(((LinkProtectionType) value).getIntValue()), output));
    serializeMplsProtocolMask(linkAttributes.getMplsProtocol(), output);
    ifPresentApply(linkAttributes.getMetric(), value -> TlvUtil.writeTLV(METRIC, Unpooled.copyMedium(((Metric) value).getValue().intValue()), output));
    serializeSrlg(linkAttributes.getSharedRiskLinkGroups(), output);
    ifPresentApply(linkAttributes.getLinkName(), value -> TlvUtil.writeTLV(LINK_NAME, Unpooled.wrappedBuffer(StandardCharsets.UTF_8.encode((String) value)), output));
    ifPresentApply(linkAttributes.getSrAdjIds(), value -> SrLinkAttributesParser.serializeAdjacencySegmentIdentifiers((List<SrAdjIds>) value, SR_ADJ_ID, output));
    ifPresentApply(linkAttributes.getSrLanAdjIds(), value -> SrLinkAttributesParser.serializeLanAdjacencySegmentIdentifiers((List<SrLanAdjIds>) value, output));
    ifPresentApply(linkAttributes.getPeerNodeSid(), value -> TlvUtil.writeTLV(PEER_NODE_SID_CODE, SrLinkAttributesParser.serializeAdjacencySegmentIdentifier((PeerNodeSid) value), output));
    ifPresentApply(linkAttributes.getPeerAdjSid(), value -> TlvUtil.writeTLV(PEER_ADJ_SID_CODE, SrLinkAttributesParser.serializeAdjacencySegmentIdentifier((PeerAdjSid) value), output));
    ifPresentApply(linkAttributes.getPeerSetSids(), value -> SrLinkAttributesParser.serializeAdjacencySegmentIdentifiers((List<PeerSetSids>) value, PEER_SET_SID_CODE, output));
    LOG.trace("Finished serializing Link Attributes");
}
Also used : LinkAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.link.attributes._case.LinkAttributes) Metric(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Metric) TeMetric(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.TeMetric) ArrayList(java.util.ArrayList) List(java.util.List)

Example 12 with Metric

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.metric.object.Metric in project genius by opendaylight.

the class NodeConnectorStatsImpl method processNodeConnectorStatistics.

/**
 * This method processes NodeConnectorStatistics RPC result.
 * It performs:
 * - fetches various OF Port counters values
 * - creates/updates new OF Port counters using Infrautils metrics API
 * - set counter with values fetched from NodeConnectorStatistics
 */
private void processNodeConnectorStatistics(GetNodeConnectorStatisticsOutput nodeConnectorStatisticsOutput, BigInteger dpid) {
    String port = "";
    String portUuid = "";
    List<NodeConnectorStatisticsAndPortNumberMap> ncStatsAndPortMapList = nodeConnectorStatisticsOutput.getNodeConnectorStatisticsAndPortNumberMap();
    // Parse NodeConnectorStatistics and create/update counters for them
    for (NodeConnectorStatisticsAndPortNumberMap ncStatsAndPortMap : ncStatsAndPortMapList) {
        NodeConnectorId nodeConnector = ncStatsAndPortMap.getNodeConnectorId();
        LOG.trace("Create/update metric counter for NodeConnector: {} of node: {}", nodeConnector, dpid.toString());
        port = nodeConnector.getValue();
        // update port name as per port name maintained in portNameCache
        String portNameInCache = "openflow" + ":" + dpid.toString() + ":" + port;
        java.util.Optional<String> portName = portNameCache.get(portNameInCache);
        if (portName.isPresent()) {
            Optional<List<InterfaceChildEntry>> interfaceChildEntries = interfaceChildCache.getInterfaceChildEntries(portName.get());
            if (interfaceChildEntries.isPresent()) {
                if (!interfaceChildEntries.get().isEmpty()) {
                    portUuid = interfaceChildEntries.get().get(0).getChildInterface();
                    LOG.trace("Retrieved portUuid {} for portname {}", portUuid, portName.get());
                } else {
                    LOG.trace("PortUuid is not found for portname {}. Skipping IFM counters publish for this port.", portName.get());
                    continue;
                }
            } else {
                LOG.trace("PortUuid is not found for portname {}. Skipping IFM counters publish for this port.", portName.get());
                continue;
            }
        }
        Counter counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_DURATION, dpid, port, portUuid, null);
        long ofPortDuration = ncStatsAndPortMap.getDuration().getSecond().getValue();
        updateCounter(counter, ofPortDuration);
        counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_PKT_RECVDROP, dpid, port, portUuid, null);
        long packetsPerOFPortReceiveDrop = ncStatsAndPortMap.getReceiveDrops().longValue();
        updateCounter(counter, packetsPerOFPortReceiveDrop);
        counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_PKT_RECVERROR, dpid, port, portUuid, null);
        long packetsPerOFPortReceiveError = ncStatsAndPortMap.getReceiveErrors().longValue();
        updateCounter(counter, packetsPerOFPortReceiveError);
        counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_PKT_SENT, dpid, port, portUuid, null);
        long packetsPerOFPortSent = ncStatsAndPortMap.getPackets().getTransmitted().longValue();
        updateCounter(counter, packetsPerOFPortSent);
        counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_PKT_RECV, dpid, port, portUuid, null);
        long packetsPerOFPortReceive = ncStatsAndPortMap.getPackets().getReceived().longValue();
        updateCounter(counter, packetsPerOFPortReceive);
        counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_BYTE_SENT, dpid, port, portUuid, null);
        long bytesPerOFPortSent = ncStatsAndPortMap.getBytes().getTransmitted().longValue();
        updateCounter(counter, bytesPerOFPortSent);
        counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_BYTE_RECV, dpid, port, portUuid, null);
        long bytesPerOFPortReceive = ncStatsAndPortMap.getBytes().getReceived().longValue();
        updateCounter(counter, bytesPerOFPortReceive);
    }
}
Also used : Counter(org.opendaylight.infrautils.metrics.Counter) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) List(java.util.List) FlowAndStatisticsMapList(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList) NodeConnectorStatisticsAndPortNumberMap(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)5 BitArray (org.opendaylight.protocol.util.BitArray)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 Metric (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Metric)3 List (java.util.List)2 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)2 LinkAttributesCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.LinkAttributesCaseBuilder)2 LinkAttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.link.attributes._case.LinkAttributesBuilder)2 SrRange (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.prefix.state.SrRange)2 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)2 Preconditions (com.google.common.base.Preconditions)1 Collections (java.util.Collections)1 Counter (org.opendaylight.infrautils.metrics.Counter)1 BGPExtensionProviderContext (org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext)1 ServiceLoaderBGPExtensionProviderContext (org.opendaylight.protocol.bgp.parser.spi.pojo.ServiceLoaderBGPExtensionProviderContext)1 ByteBufWriteUtil.writeFloat32 (org.opendaylight.protocol.util.ByteBufWriteUtil.writeFloat32)1 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)1