Search in sources :

Example 11 with QueueId

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();
}
Also used : Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) QueueIdAndStatisticsMap(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap) QueueIdAndStatisticsMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder) MultipartReplyQueueCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase) ArrayList(java.util.ArrayList) QueueId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId) MultipartReplyQueueStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.reply.multipart.reply.body.MultipartReplyQueueStatsBuilder) QueueStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats) MultipartReplyQueueStats(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.reply.multipart.reply.body.MultipartReplyQueueStats) MultipartReplyQueue(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue) DurationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder)

Example 12 with QueueId

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();
}
Also used : QueueIdAndStatisticsMap(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) ArrayList(java.util.ArrayList) QueueId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId) Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) QueueIdAndStatisticsMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder) QueueIdAndStatisticsMapKey(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapKey) BigInteger(java.math.BigInteger) MultipartReplyQueueStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.reply.multipart.reply.body.MultipartReplyQueueStatsBuilder) DurationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder)

Example 13 with QueueId

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();
}
Also used : QueueIdAndStatisticsMap(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap) GetQueueStatisticsOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetQueueStatisticsOutputBuilder) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) ArrayList(java.util.ArrayList) QueueId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId) Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) QueueIdAndStatisticsMapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder) QueueIdAndStatisticsMapKey(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapKey) MultipartReplyQueueCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase) QueueStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats) MultipartReplyQueue(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue) DurationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder)

Example 14 with QueueId

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());
}
Also used : Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) MultipartRequestQueue(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueue) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) QueueId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId) MultipartRequestQueueCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCase) GetQueueStatisticsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetQueueStatisticsInput)

Example 15 with QueueId

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());
}
Also used : GetQueueStatisticsFromGivenPortOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutput) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) QueueId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId) FutureCallback(com.google.common.util.concurrent.FutureCallback) GetQueueStatisticsFromGivenPortInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortInputBuilder) Test(org.junit.Test)

Aggregations

QueueId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId)11 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)8 QueueId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId)8 Queues (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues)7 ByteBuf (io.netty.buffer.ByteBuf)6 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)6 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)6 QueuesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.QueuesBuilder)6 QueueIdAndStatisticsMap (org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap)6 Counter64 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64)5 MultipartReplyQueueCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase)5 MultipartReplyQueue (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue)5 QueueIdAndStatisticsMapBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder)5 Counter32 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32)4 DurationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder)4 BigInteger (java.math.BigInteger)3 GetQueueStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetQueueStatisticsOutput)3 QueueStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats)3 MultipartReplyQueueStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.reply.multipart.reply.body.MultipartReplyQueueStatsBuilder)3