Search in sources :

Example 11 with NodeConnectorStatisticsAndPortNumberMap

use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap in project openflowplugin by opendaylight.

the class NodeConnectorDirectStatisticsServiceTest method testBuildReply.

@Override
public void testBuildReply() throws Exception {
    final MultipartReply reply = mock(MultipartReply.class);
    final MultipartReplyPortStatsCase nodeConnectorCase = mock(MultipartReplyPortStatsCase.class);
    final MultipartReplyPortStats nodeConnector = mock(MultipartReplyPortStats.class);
    final PortStats nodeConnectorStat = mock(PortStats.class);
    final List<PortStats> nodeConnectorStats = Collections.singletonList(nodeConnectorStat);
    final List<MultipartReply> input = Collections.singletonList(reply);
    when(nodeConnector.getPortStats()).thenReturn(nodeConnectorStats);
    when(nodeConnectorCase.getMultipartReplyPortStats()).thenReturn(nodeConnector);
    when(reply.getMultipartReplyBody()).thenReturn(nodeConnectorCase);
    when(nodeConnectorStat.getPortNo()).thenReturn(PORT_NO);
    when(nodeConnectorStat.getTxBytes()).thenReturn(BigInteger.ONE);
    when(nodeConnectorStat.getCollisions()).thenReturn(BigInteger.ONE);
    when(nodeConnectorStat.getRxBytes()).thenReturn(BigInteger.ONE);
    when(nodeConnectorStat.getRxCrcErr()).thenReturn(BigInteger.ONE);
    when(nodeConnectorStat.getRxDropped()).thenReturn(BigInteger.ONE);
    when(nodeConnectorStat.getRxErrors()).thenReturn(BigInteger.ONE);
    when(nodeConnectorStat.getRxFrameErr()).thenReturn(BigInteger.ONE);
    when(nodeConnectorStat.getRxOverErr()).thenReturn(BigInteger.ONE);
    when(nodeConnectorStat.getRxPackets()).thenReturn(BigInteger.ONE);
    when(nodeConnectorStat.getTxDropped()).thenReturn(BigInteger.ONE);
    when(nodeConnectorStat.getTxErrors()).thenReturn(BigInteger.ONE);
    final GetNodeConnectorStatisticsOutput output = service.buildReply(input, true);
    assertTrue(output.getNodeConnectorStatisticsAndPortNumberMap().size() > 0);
    final NodeConnectorStatisticsAndPortNumberMap stats = output.getNodeConnectorStatisticsAndPortNumberMap().get(0);
    assertEquals(stats.getNodeConnectorId(), nodeConnectorId);
}
Also used : MultipartReplyPortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) MultipartReplyPortStatsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase) GetNodeConnectorStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput) MultipartRequestPortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStats) MultipartReplyPortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats) PortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStats) NodeConnectorStatisticsAndPortNumberMap(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap)

Example 12 with NodeConnectorStatisticsAndPortNumberMap

use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap in project openflowplugin by opendaylight.

the class MultipartReplyTranslatorTest method testTranslatePortStats.

@Test
public void testTranslatePortStats() {
    DeviceContext mockedDeviceContext = mock(DeviceContext.class);
    MultipartReplyMessage multipartReplyMessage = prepareMocks(mockedDeviceContext, prepareMultipartReplyPortStats(), MultipartType.OFPMPPORTSTATS);
    DataContainer result = MultipartReplyTranslatorUtil.translate(multipartReplyMessage, mockedDeviceContext.getDeviceInfo(), CONVERTOR_MANAGER, mockedDeviceContext.oook()).get();
    DataContainer dataObject = validateOutput(result);
    assertTrue(dataObject instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsAndPortNumberMap);
    org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsAndPortNumberMap nodeConnectorStatisticsUpdate = (org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.NodeConnectorStatisticsAndPortNumberMap) dataObject;
    List<NodeConnectorStatisticsAndPortNumberMap> nodeConnectorStatisticsAndPortNumberMaps = nodeConnectorStatisticsUpdate.getNodeConnectorStatisticsAndPortNumberMap();
    assertEquals(1, nodeConnectorStatisticsAndPortNumberMaps.size());
    NodeConnectorStatisticsAndPortNumberMap nodeConnectorStatisticsAndPortNumberMap = nodeConnectorStatisticsAndPortNumberMaps.get(0);
    assertEquals("openflow:" + DUMMY_DATAPATH_ID + ":" + DUMMY_PORT_NO, nodeConnectorStatisticsAndPortNumberMap.getNodeConnectorId().getValue());
    assertEquals(DUMMY_RX_BYTES, nodeConnectorStatisticsAndPortNumberMap.getBytes().getReceived());
    assertEquals(DUMMY_TX_BYTES, nodeConnectorStatisticsAndPortNumberMap.getBytes().getTransmitted());
    assertEquals(DUMMY_RX_PACKETS, nodeConnectorStatisticsAndPortNumberMap.getPackets().getReceived());
    assertEquals(DUMMY_TX_PACKETS, nodeConnectorStatisticsAndPortNumberMap.getPackets().getTransmitted());
    assertEquals(DUMMY_COLLISIONS, nodeConnectorStatisticsAndPortNumberMap.getCollisionCount());
    assertEquals(DUMMY_RX_CRC_ERR, nodeConnectorStatisticsAndPortNumberMap.getReceiveCrcError());
    assertEquals(DUMMY_RX_DROPPED, nodeConnectorStatisticsAndPortNumberMap.getReceiveDrops());
    assertEquals(DUMMY_RX_ERRORS, nodeConnectorStatisticsAndPortNumberMap.getReceiveErrors());
    assertEquals(DUMMY_RX_FRAME_ERR, nodeConnectorStatisticsAndPortNumberMap.getReceiveFrameError());
    assertEquals(DUMMY_OVER_ERR, nodeConnectorStatisticsAndPortNumberMap.getReceiveOverRunError());
    assertEquals(DUMMY_TX_DROPPED, nodeConnectorStatisticsAndPortNumberMap.getTransmitDrops());
    assertEquals(DUMMY_TX_ERRORS, nodeConnectorStatisticsAndPortNumberMap.getTransmitErrors());
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) DeviceContext(org.opendaylight.openflowplugin.api.openflow.device.DeviceContext) DataContainer(org.opendaylight.yangtools.yang.binding.DataContainer) NodeConnectorStatisticsAndPortNumberMap(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap) Test(org.junit.Test)

Example 13 with NodeConnectorStatisticsAndPortNumberMap

use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap in project openflowplugin by opendaylight.

the class MultipartReplyPortStatsDeserializerTest method deserialize.

@Test
public void deserialize() throws Exception {
    ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    buffer.writeInt(PORT);
    buffer.writeZero(PADDING_IN_PORT_STATS_HEADER);
    buffer.writeLong(PACKETS_RECEIVED);
    buffer.writeLong(PACKETS_TRANSMITTED);
    buffer.writeLong(BYTES_RECEIVED);
    buffer.writeLong(BYTES_TRANSMITTED);
    buffer.writeLong(RECEIVE_DROPS);
    buffer.writeLong(TRANSMIT_DROPS);
    buffer.writeLong(RECEIVE_ERRORS);
    buffer.writeLong(TRANSMIT_ERRORS);
    buffer.writeLong(RECEIVE_FRAME_ERROR);
    buffer.writeLong(RECEIVE_OVER_RUN_ERROR);
    buffer.writeLong(RECEIVE_CRC_ERROR);
    buffer.writeLong(COLLIESION_COUNT);
    buffer.writeInt(SECOND);
    buffer.writeInt(NANOSECOND);
    final MultipartReplyPortStats reply = (MultipartReplyPortStats) deserializeMultipart(buffer);
    final NodeConnectorStatisticsAndPortNumberMap portStats = reply.getNodeConnectorStatisticsAndPortNumberMap().get(0);
    assertEquals(PACKETS_RECEIVED, portStats.getPackets().getReceived().longValue());
    assertEquals(PACKETS_TRANSMITTED, portStats.getPackets().getTransmitted().longValue());
    assertEquals(BYTES_RECEIVED, portStats.getBytes().getReceived().longValue());
    assertEquals(BYTES_TRANSMITTED, portStats.getBytes().getTransmitted().longValue());
    assertEquals(RECEIVE_DROPS, portStats.getReceiveDrops().longValue());
    assertEquals(TRANSMIT_DROPS, portStats.getTransmitDrops().longValue());
    assertEquals(RECEIVE_ERRORS, portStats.getReceiveErrors().longValue());
    assertEquals(TRANSMIT_ERRORS, portStats.getTransmitErrors().longValue());
    assertEquals(RECEIVE_FRAME_ERROR, portStats.getReceiveFrameError().longValue());
    assertEquals(RECEIVE_OVER_RUN_ERROR, portStats.getReceiveOverRunError().longValue());
    assertEquals(RECEIVE_CRC_ERROR, portStats.getReceiveCrcError().longValue());
    assertEquals(COLLIESION_COUNT, portStats.getCollisionCount().longValue());
    assertEquals(SECOND, portStats.getDuration().getSecond().getValue().intValue());
    assertEquals(NANOSECOND, portStats.getDuration().getNanosecond().getValue().intValue());
    assertEquals(0, buffer.readableBytes());
}
Also used : MultipartReplyPortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.reply.multipart.reply.body.MultipartReplyPortStats) ByteBuf(io.netty.buffer.ByteBuf) NodeConnectorStatisticsAndPortNumberMap(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap) Test(org.junit.Test)

Example 14 with NodeConnectorStatisticsAndPortNumberMap

use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap 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

NodeConnectorStatisticsAndPortNumberMap (org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap)12 GetNodeConnectorStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput)5 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)4 NodeConnectorStatisticsAndPortNumberMapBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder)4 BigInteger (java.math.BigInteger)3 ArrayList (java.util.ArrayList)3 Counter32 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32)3 DurationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder)3 BytesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.node.connector.statistics.BytesBuilder)3 PacketsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.node.connector.statistics.PacketsBuilder)3 MultipartReplyPortStatsCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase)3 MultipartReplyPortStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats)3 PortStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStats)3 MultipartReplyPortStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.reply.multipart.reply.body.MultipartReplyPortStatsBuilder)3 NodeConnectorStatisticsAndPortNumberMapKey (org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapKey)3 Test (org.junit.Test)2 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)2 ByteBuf (io.netty.buffer.ByteBuf)1 List (java.util.List)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1