use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId 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.flow.types.queue.rev130925.QueueId 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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId 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.flow.types.queue.rev130925.QueueId in project openflowplugin by opendaylight.
the class QueueDirectStatisticsServiceTest method testBuildRequestBody.
@Override
public void testBuildRequestBody() throws Exception {
final GetQueueStatisticsInput input = mock(GetQueueStatisticsInput.class);
when(input.getNode()).thenReturn(createNodeRef(NODE_ID));
when(input.getQueueId()).thenReturn(new QueueId(QUEUE_NO));
when(input.getNodeConnectorId()).thenReturn(new NodeConnectorId(NODE_ID + ":" + PORT_NO));
final MultipartRequestQueueCase body = (MultipartRequestQueueCase) ((MultipartRequestInput) service.buildRequest(new Xid(42L), input)).getMultipartRequestBody();
final MultipartRequestQueue queue = body.getMultipartRequestQueue();
assertEquals(PORT_NO, queue.getPortNo());
assertEquals(QUEUE_NO, queue.getQueueId());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId in project openflowplugin by opendaylight.
the class OpendaylightQueueStatisticsServiceImplTest method testGetQueueStatisticsFromGivenPort.
@Test
public void testGetQueueStatisticsFromGivenPort() throws Exception {
Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider).commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
GetQueueStatisticsFromGivenPortInputBuilder input = new GetQueueStatisticsFromGivenPortInputBuilder().setNode(createNodeRef("unitProt:123")).setNodeConnectorId(new NodeConnectorId("unitProt:123:321")).setQueueId(new QueueId(21L));
rpcResult = buildQueueStatsReply();
final Future<RpcResult<GetQueueStatisticsFromGivenPortOutput>> resultFuture = queueStatisticsService.getQueueStatisticsFromGivenPort(input.build());
Assert.assertTrue(resultFuture.isDone());
final RpcResult<GetQueueStatisticsFromGivenPortOutput> rpcResult = resultFuture.get();
Assert.assertTrue(rpcResult.isSuccessful());
Assert.assertEquals(MultipartType.OFPMPQUEUE, requestInput.getValue().getType());
}
Aggregations