use of org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap 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.queue.id.and.statistics.map.QueueIdAndStatisticsMap in project openflowplugin by opendaylight.
the class QueueDirectStatisticsServiceTest method testBuildReply.
@Override
public void testBuildReply() throws Exception {
final MultipartReply reply = mock(MultipartReply.class);
final MultipartReplyQueueCase queueCase = mock(MultipartReplyQueueCase.class);
final MultipartReplyQueue queue = mock(MultipartReplyQueue.class);
final QueueStats queueStat = mock(QueueStats.class);
final List<QueueStats> queueStats = Collections.singletonList(queueStat);
final List<MultipartReply> input = Collections.singletonList(reply);
when(queue.getQueueStats()).thenReturn(queueStats);
when(queueCase.getMultipartReplyQueue()).thenReturn(queue);
when(reply.getMultipartReplyBody()).thenReturn(queueCase);
when(queueStat.getPortNo()).thenReturn(PORT_NO);
when(queueStat.getQueueId()).thenReturn(QUEUE_NO);
when(queueStat.getTxBytes()).thenReturn(BigInteger.ONE);
when(queueStat.getTxErrors()).thenReturn(BigInteger.ONE);
when(queueStat.getTxPackets()).thenReturn(BigInteger.ONE);
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(), nodeConnectorId);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap in project openflowplugin by opendaylight.
the class QueueDirectStatisticsServiceTest method testStoreStatistics.
@Override
public void testStoreStatistics() throws Exception {
final QueueIdAndStatisticsMap map = mock(QueueIdAndStatisticsMap.class);
when(map.getQueueId()).thenReturn(new QueueId(QUEUE_NO));
final List<QueueIdAndStatisticsMap> maps = Collections.singletonList(map);
final GetQueueStatisticsOutput output = mock(GetQueueStatisticsOutput.class);
when(output.getQueueIdAndStatisticsMap()).thenReturn(maps);
multipartWriterProvider.lookup(MultipartType.OFPMPQUEUE).get().write(output, true);
verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap 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.queue.id.and.statistics.map.QueueIdAndStatisticsMap 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