Search in sources :

Example 16 with PortStats

use of 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 in project openflowplugin by opendaylight.

the class OF10StatsReplyMessageFactory method serializePortStatsBody.

private void serializePortStatsBody(MultipartReplyBody body, ByteBuf outBuffer) {
    MultipartReplyPortStatsCase portStatsCase = (MultipartReplyPortStatsCase) body;
    MultipartReplyPortStats portStats = portStatsCase.getMultipartReplyPortStats();
    for (PortStats portStat : portStats.getPortStats()) {
        outBuffer.writeInt(portStat.getPortNo().intValue());
        outBuffer.writeZero(PORT_STATS_PADDING);
        outBuffer.writeLong(portStat.getRxPackets().longValue());
        outBuffer.writeLong(portStat.getTxPackets().longValue());
        outBuffer.writeLong(portStat.getRxBytes().longValue());
        outBuffer.writeLong(portStat.getTxBytes().longValue());
        outBuffer.writeLong(portStat.getRxDropped().longValue());
        outBuffer.writeLong(portStat.getTxDropped().longValue());
        outBuffer.writeLong(portStat.getRxErrors().longValue());
        outBuffer.writeLong(portStat.getTxErrors().longValue());
        outBuffer.writeLong(portStat.getRxFrameErr().longValue());
        outBuffer.writeLong(portStat.getRxOverErr().longValue());
        outBuffer.writeLong(portStat.getRxCrcErr().longValue());
        outBuffer.writeLong(portStat.getCollisions().longValue());
    }
}
Also used : MultipartReplyPortStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats) MultipartReplyPortStatsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase) 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)

Example 17 with PortStats

use of 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 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)

Aggregations

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)12 MultipartReplyPortStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats)10 MultipartReplyPortStatsCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase)8 ArrayList (java.util.ArrayList)6 MultipartReplyPortStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStatsBuilder)6 MultipartReplyPortStatsCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCaseBuilder)4 PortStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.multipart.reply.port.stats.PortStatsBuilder)4 NodeConnectorStatisticsAndPortNumberMap (org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap)4 NodeConnectorStatisticsAndPortNumberMapBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder)4 ByteBuf (io.netty.buffer.ByteBuf)3 Test (org.junit.Test)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 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)3 MultipartRequestPortStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStats)3 NodeConnectorStatisticsAndPortNumberMapKey (org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapKey)3 BigInteger (java.math.BigInteger)2 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)2