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