use of org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetQueueStatisticsOutput 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.direct.statistics.rev160511.GetQueueStatisticsOutput 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.direct.statistics.rev160511.GetQueueStatisticsOutput 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.direct.statistics.rev160511.GetQueueStatisticsOutput in project openflowplugin by opendaylight.
the class QueueDirectStatisticsService method buildReply.
@Override
protected GetQueueStatisticsOutput buildReply(List<MultipartReply> input, boolean success) {
final List<QueueIdAndStatisticsMap> queueIdAndStatisticsMap = new ArrayList<>();
if (success) {
for (final MultipartReply mpReply : input) {
final MultipartReplyQueueCase caseBody = (MultipartReplyQueueCase) mpReply.getMultipartReplyBody();
final MultipartReplyQueue replyBody = caseBody.getMultipartReplyQueue();
for (final QueueStats queueStats : replyBody.getQueueStats()) {
final DurationBuilder durationBuilder = new DurationBuilder().setSecond(new Counter32(queueStats.getDurationSec())).setNanosecond(new Counter32(queueStats.getDurationNsec()));
final QueueId queueId = new QueueId(queueStats.getQueueId());
final NodeConnectorId nodeConnectorId = InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(getDatapathId(), queueStats.getPortNo(), getOfVersion());
final QueueIdAndStatisticsMapBuilder statsBuilder = new QueueIdAndStatisticsMapBuilder().setKey(new QueueIdAndStatisticsMapKey(nodeConnectorId, queueId)).setNodeConnectorId(nodeConnectorId).setTransmissionErrors(new Counter64(queueStats.getTxErrors())).setTransmittedBytes(new Counter64(queueStats.getTxBytes())).setTransmittedPackets(new Counter64(queueStats.getTxPackets())).setQueueId(queueId).setDuration(durationBuilder.build());
queueIdAndStatisticsMap.add(statsBuilder.build());
}
}
}
return new GetQueueStatisticsOutputBuilder().setQueueIdAndStatisticsMap(queueIdAndStatisticsMap).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetQueueStatisticsOutput in project openflowplugin by opendaylight.
the class OpendaylightDirectStatisticsServiceImplTest method testGetQueueStatisticsFail.
@Test
public void testGetQueueStatisticsFail() throws Exception {
RpcResult<GetQueueStatisticsOutput> result = emptyService.getQueueStatistics(getQueueStatisticsInput).get();
assertFalse(result.isSuccessful());
for (RpcError error : result.getErrors()) {
assertTrue(error.getMessage().contains(AbstractQueueDirectStatisticsService.class.getSimpleName()));
}
verify(queueDirectStatisticsService, times(0)).handleAndReply(getQueueStatisticsInput);
}
Aggregations