Search in sources :

Example 16 with QueueId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId in project openflowplugin by opendaylight.

the class OF10QueueGetConfigReplyMessageFactory method createQueuesList.

private static List<Queues> createQueuesList(ByteBuf input) {
    List<Queues> queuesList = new ArrayList<>();
    while (input.readableBytes() > 0) {
        QueuesBuilder queueBuilder = new QueuesBuilder();
        queueBuilder.setQueueId(new QueueId(input.readUnsignedInt()));
        int length = input.readUnsignedShort();
        input.skipBytes(PADDING_IN_PACKET_QUEUE_HEADER);
        queueBuilder.setQueueProperty(createPropertiesList(input, length - PACKET_QUEUE_HEADER_LENGTH));
        queuesList.add(queueBuilder.build());
    }
    return queuesList;
}
Also used : ArrayList(java.util.ArrayList) QueueId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId) Queues(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues) QueuesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.QueuesBuilder)

Example 17 with QueueId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactoryTest method testMultipartReplyQueueBody.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testMultipartReplyQueueBody() {
    ByteBuf bb = BufferHelper.buildBuffer("00 05 00 01 00 00 00 00 " + // portNo
    "00 00 00 FF " + // queueId
    "00 00 00 10 " + // txBytes
    "FF 02 03 02 03 02 03 02 " + // txPackets
    "FF 02 02 02 02 02 02 02 " + // txErrors
    "FF 02 03 02 03 02 03 02 " + // durationSec
    "00 00 00 02 " + // durationNsec
    "00 00 00 04");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyQueueCase messageCase = (MultipartReplyQueueCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyQueue message = messageCase.getMultipartReplyQueue();
    Assert.assertEquals("Wrong portNo", 255, message.getQueueStats().get(0).getPortNo().intValue());
    Assert.assertEquals("Wrong queueId", 16, message.getQueueStats().get(0).getQueueId().intValue());
    Assert.assertEquals("Wrong txBytes", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02 }), message.getQueueStats().get(0).getTxBytes());
    Assert.assertEquals("Wrong txPackets", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getQueueStats().get(0).getTxPackets());
    Assert.assertEquals("Wrong txErrors", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02 }), message.getQueueStats().get(0).getTxErrors());
    Assert.assertEquals("Wrong durationSec", 2, message.getQueueStats().get(0).getDurationSec().intValue());
    Assert.assertEquals("Wrong durationNsec", 4, message.getQueueStats().get(0).getDurationNsec().intValue());
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyQueueCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase) BigInteger(java.math.BigInteger) 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) Test(org.junit.Test)

Example 18 with QueueId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId in project openflowplugin by opendaylight.

the class QueueGetConfigReplyMessageFactoryMultiTest method test.

/**
 * Testing of {@link QueueGetConfigReplyMessageFactory} for correct
 * translation into POJO.
 */
@Test
public void test() {
    ByteBuf bb = BufferHelper.buildBuffer(// port
    "00 01 02 03 " + // padding
    "00 00 00 00 " + // queueId
    "00 00 00 01 " + // port
    "00 00 00 01 " + // length
    "00 20 " + // pad
    "00 00 00 00 00 00 " + // property
    "00 02 " + // length
    "00 10 " + // pad
    "00 00 00 00 " + // rate
    "00 05 " + // pad
    "00 00 00 00 00 00 " + // queueId
    "00 00 00 02 " + // port
    "00 00 00 02 " + // length
    "00 20 " + // pad
    "00 00 00 00 00 00 " + // property
    "00 02 " + // length
    "00 10 " + // pad
    "00 00 00 00 " + // rate
    "00 05 " + // pad
    "00 00 00 00 00 00");
    GetQueueConfigOutput builtByFactory = BufferHelper.deserialize(queueFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong port", 66051L, builtByFactory.getPort().getValue().longValue());
    Assert.assertEquals("Wrong queues", createQueuesList(), builtByFactory.getQueues());
}
Also used : GetQueueConfigOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 19 with QueueId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId in project openflowplugin by opendaylight.

the class QueueGetConfigReplyMessageFactoryMultiTest method createQueuesList.

private static List<Queues> createQueuesList() {
    List<Queues> queuesList = new ArrayList<>();
    for (int i = 1; i < 3; i++) {
        QueuesBuilder qb = new QueuesBuilder();
        qb.setQueueId(new QueueId((long) i));
        qb.setPort(new PortNumber((long) i));
        qb.setQueueProperty(createPropertiesList());
        queuesList.add(qb.build());
    }
    return queuesList;
}
Also used : ArrayList(java.util.ArrayList) QueueId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId) Queues(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) QueuesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.QueuesBuilder)

Example 20 with QueueId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId in project openflowplugin by opendaylight.

the class OF10QueueGetConfigReplyMessageFactoryTest method test.

/**
 * Testing of {@link OF10QueueGetConfigReplyMessageFactory} for correct
 * translation into POJO.
 */
@Test
public void test() {
    ByteBuf bb = BufferHelper.buildBuffer("00 01 00 00 00 00 00 00 " + "00 00 00 08 00 10 00 00 00 00 00 08 00 00 00 00 " + "00 00 00 02 00 28 00 00 00 01 00 10 00 00 00 00 00 20 00 00 00 00 00 00 " + "00 01 00 10 00 00 00 00 00 30 00 00 00 00 00 00");
    GetQueueConfigOutput builtByFactory = BufferHelper.deserialize(queueFactory, bb);
    BufferHelper.checkHeaderV10(builtByFactory);
    Assert.assertEquals("Wrong port", 1, builtByFactory.getPort().getValue().intValue());
    Assert.assertEquals("Wrong queues size", 2, builtByFactory.getQueues().size());
    Queues queue1 = builtByFactory.getQueues().get(0);
    Queues queue2 = builtByFactory.getQueues().get(1);
    Assert.assertEquals("Wrong queueId", 8, queue1.getQueueId().getValue().intValue());
    Assert.assertEquals("Wrong queue - # properties", 1, queue1.getQueueProperty().size());
    Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTNONE, queue1.getQueueProperty().get(0).getProperty());
    Assert.assertEquals("Wrong queueId", 2, queue2.getQueueId().getValue().intValue());
    Assert.assertEquals("Wrong queue - # properties", 2, queue2.getQueueProperty().size());
    Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTMINRATE, queue2.getQueueProperty().get(0).getProperty());
    Assert.assertEquals("Wrong queue - wrong property", QueueProperties.OFPQTMINRATE, queue2.getQueueProperty().get(1).getProperty());
    RateQueueProperty rate1 = queue2.getQueueProperty().get(0).getAugmentation(RateQueueProperty.class);
    RateQueueProperty rate2 = queue2.getQueueProperty().get(1).getAugmentation(RateQueueProperty.class);
    Assert.assertEquals("Wrong queue - wrong property rate", 32, rate1.getRate().intValue());
    Assert.assertEquals("Wrong queue - wrong property rate", 48, rate2.getRate().intValue());
}
Also used : GetQueueConfigOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput) RateQueueProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty) Queues(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues) ByteBuf(io.netty.buffer.ByteBuf) 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