use of org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.reply.multipart.reply.body.MultipartReplyQueueStatsBuilder in project openflowplugin by opendaylight.
the class QueueDirectStatisticsServiceTest method testBuildReply.
@Override
public void testBuildReply() throws Exception {
final QueueIdAndStatisticsMap queueStats = new QueueIdAndStatisticsMapBuilder().setQueueId(new QueueId(QUEUE_NO)).setNodeConnectorId(new NodeConnectorId(PORT_NO.toString())).setTransmittedBytes(new Counter64(BigInteger.ONE)).setTransmissionErrors(new Counter64(BigInteger.ONE)).setTransmittedBytes(new Counter64(BigInteger.ONE)).build();
final MultipartReply reply = new MultipartReplyBuilder().setMultipartReplyBody(new MultipartReplyQueueStatsBuilder().setQueueIdAndStatisticsMap(Collections.singletonList(queueStats)).build()).build();
final List<MultipartReply> input = Collections.singletonList(reply);
final GetQueueStatisticsOutput output = service.buildReply(input, true);
assertTrue(output.getQueueIdAndStatisticsMap().size() > 0);
final QueueIdAndStatisticsMap map = output.getQueueIdAndStatisticsMap().get(0);
assertEquals(map.getQueueId().getValue(), QUEUE_NO);
assertEquals(map.getNodeConnectorId().getValue(), PORT_NO.toString());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.reply.multipart.reply.body.MultipartReplyQueueStatsBuilder 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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.reply.multipart.reply.body.MultipartReplyQueueStatsBuilder in project openflowplugin by opendaylight.
the class MultipartReplyQueueStatsDeserializer method deserialize.
@Override
public MultipartReplyBody deserialize(ByteBuf message) {
final MultipartReplyQueueStatsBuilder builder = new MultipartReplyQueueStatsBuilder();
final List<QueueIdAndStatisticsMap> items = new ArrayList<>();
while (message.readableBytes() > 0) {
final long port = message.readUnsignedInt();
final NodeConnectorId nodeConnectorId = new NodeConnectorId(OpenflowPortsUtil.getProtocolAgnosticPortUri(EncodeConstants.OF13_VERSION_ID, port));
final QueueId queueId = new QueueId(message.readUnsignedInt());
final byte[] txBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(txBytes);
final byte[] txPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(txPackets);
final byte[] txErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
message.readBytes(txErrors);
items.add(new QueueIdAndStatisticsMapBuilder().setKey(new QueueIdAndStatisticsMapKey(nodeConnectorId, queueId)).setNodeConnectorId(nodeConnectorId).setQueueId(queueId).setTransmittedBytes(new Counter64(new BigInteger(1, txBytes))).setTransmittedPackets(new Counter64(new BigInteger(1, txPackets))).setTransmissionErrors(new Counter64(new BigInteger(1, txErrors))).setDuration(new DurationBuilder().setSecond(new Counter32(message.readUnsignedInt())).setNanosecond(new Counter32(message.readUnsignedInt())).build()).build());
}
return builder.setQueueIdAndStatisticsMap(items).build();
}
Aggregations