use of org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.reply.multipart.reply.body.MultipartReplyQueueStats in project openflowplugin by opendaylight.
the class MultipartReplyQueueStatsDeserializerTest method deserialize.
@Test
public void deserialize() throws Exception {
ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
buffer.writeInt(PORT);
buffer.writeInt(QUEUE_ID);
buffer.writeLong(TRANSMITTED_BYTES);
buffer.writeLong(TRANSMITTED_PACKETS);
buffer.writeLong(TRANSMISSON_ERRORS);
buffer.writeInt(SECOND);
buffer.writeInt(NANOSECOND);
final MultipartReplyQueueStats reply = (MultipartReplyQueueStats) deserializeMultipart(buffer);
final QueueIdAndStatisticsMap queueStats = reply.getQueueIdAndStatisticsMap().get(0);
assertEquals(QUEUE_ID, queueStats.getQueueId().getValue().intValue());
assertEquals(TRANSMITTED_BYTES, queueStats.getTransmittedBytes().getValue().longValue());
assertEquals(TRANSMITTED_PACKETS, queueStats.getTransmittedPackets().getValue().longValue());
assertEquals(TRANSMISSON_ERRORS, queueStats.getTransmissionErrors().getValue().longValue());
assertEquals(SECOND, queueStats.getDuration().getSecond().getValue().intValue());
assertEquals(NANOSECOND, queueStats.getDuration().getNanosecond().getValue().intValue());
assertEquals(0, buffer.readableBytes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.reply.multipart.reply.body.MultipartReplyQueueStats in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorUtil method translateQueue.
private static MultipartReplyQueueStats translateQueue(final MultipartReply msg, final OpenflowVersion ofVersion, final BigInteger datapathId) {
MultipartReplyQueueStatsBuilder message = new MultipartReplyQueueStatsBuilder();
MultipartReplyQueueCase caseBody = (MultipartReplyQueueCase) msg.getMultipartReplyBody();
MultipartReplyQueue replyBody = caseBody.getMultipartReplyQueue();
List<QueueIdAndStatisticsMap> statsMap = new ArrayList<>();
for (QueueStats queueStats : replyBody.getQueueStats()) {
QueueIdAndStatisticsMapBuilder statsBuilder = new QueueIdAndStatisticsMapBuilder();
statsBuilder.setNodeConnectorId(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(datapathId, queueStats.getPortNo(), ofVersion));
statsBuilder.setTransmissionErrors(new Counter64(queueStats.getTxErrors()));
statsBuilder.setTransmittedBytes(new Counter64(queueStats.getTxBytes()));
statsBuilder.setTransmittedPackets(new Counter64(queueStats.getTxPackets()));
DurationBuilder durationBuilder = new DurationBuilder();
durationBuilder.setSecond(new Counter32(queueStats.getDurationSec()));
durationBuilder.setNanosecond(new Counter32(queueStats.getDurationNsec()));
statsBuilder.setDuration(durationBuilder.build());
statsBuilder.setQueueId(new QueueId(queueStats.getQueueId()));
statsBuilder.setNodeConnectorId(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(datapathId, queueStats.getPortNo(), ofVersion));
statsMap.add(statsBuilder.build());
}
message.setQueueIdAndStatisticsMap(statsMap);
return message.build();
}
Aggregations