Search in sources :

Example 11 with QueueStats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactoryTest method testQueueSerialize.

@Test
public void testQueueSerialize() throws Exception {
    MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setFlags(new MultipartRequestFlags(true));
    builder.setType(MultipartType.forValue(5));
    MultipartReplyQueueCaseBuilder queueCase = new MultipartReplyQueueCaseBuilder();
    MultipartReplyQueueBuilder queue = new MultipartReplyQueueBuilder();
    queue.setQueueStats(createQueueStats());
    queueCase.setMultipartReplyQueue(queue.build());
    builder.setMultipartReplyBody(queueCase.build());
    MultipartReplyMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 56);
    Assert.assertEquals("Wrong type", MultipartType.OFPMPQUEUE.getIntValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
    serializedBuffer.skipBytes(PADDING);
    MultipartReplyQueueCase body = (MultipartReplyQueueCase) message.getMultipartReplyBody();
    MultipartReplyQueue messageOutput = body.getMultipartReplyQueue();
    QueueStats queueStats = messageOutput.getQueueStats().get(0);
    Assert.assertEquals("Wrong PortNo", queueStats.getPortNo().intValue(), serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong queue id", queueStats.getQueueId().intValue(), serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong tx bytes", queueStats.getTxBytes().longValue(), serializedBuffer.readLong());
    Assert.assertEquals("Wrong tx packets", queueStats.getTxPackets().longValue(), serializedBuffer.readLong());
    Assert.assertEquals("Wrong tx errors", queueStats.getTxErrors().longValue(), serializedBuffer.readLong());
    Assert.assertEquals("Wrong duration sec", queueStats.getDurationSec().intValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong duration nsec", queueStats.getDurationNsec().intValue(), serializedBuffer.readInt());
}
Also used : MultipartReplyQueueCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCaseBuilder) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) MultipartReplyQueueCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) 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) ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyQueueBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueueBuilder) Test(org.junit.Test)

Example 12 with QueueStats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats 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 13 with QueueStats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats 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 QueueStats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats in project openflowplugin by opendaylight.

the class OF10StatsReplyMessageFactory method serializeQueueBody.

private void serializeQueueBody(MultipartReplyBody body, ByteBuf outBuffer) {
    MultipartReplyQueueCase queueCase = (MultipartReplyQueueCase) body;
    MultipartReplyQueue queue = queueCase.getMultipartReplyQueue();
    for (QueueStats queueStats : queue.getQueueStats()) {
        ByteBuf queueStatsBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
        queueStatsBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
        queueStatsBuff.writeZero(QUEUE_PADDING);
        queueStatsBuff.writeInt(queueStats.getQueueId().intValue());
        queueStatsBuff.writeLong(queueStats.getTxBytes().longValue());
        queueStatsBuff.writeLong(queueStats.getTxPackets().longValue());
        queueStatsBuff.writeLong(queueStats.getTxErrors().longValue());
        queueStatsBuff.setShort(QUEUE_STATS_LENGTH_INDEX, queueStatsBuff.readableBytes());
        outBuffer.writeBytes(queueStatsBuff);
    }
}
Also used : 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) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

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