Search in sources :

Example 6 with GetQueueConfigOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput in project openflowplugin by opendaylight.

the class OF10QueueGetConfigReplyMessageFactory method deserialize.

@Override
public GetQueueConfigOutput deserialize(ByteBuf rawMessage) {
    GetQueueConfigOutputBuilder builder = new GetQueueConfigOutputBuilder();
    builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setPort(new PortNumber((long) rawMessage.readUnsignedShort()));
    rawMessage.skipBytes(PADDING_IN_QUEUE_GET_CONFIG_REPLY_HEADER);
    builder.setQueues(createQueuesList(rawMessage));
    return builder.build();
}
Also used : GetQueueConfigOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutputBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)

Example 7 with GetQueueConfigOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput 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 8 with GetQueueConfigOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput 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)

Example 9 with GetQueueConfigOutput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput in project openflowplugin by opendaylight.

the class OF10QueueGetConfigReplyMessageFactoryTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    GetQueueConfigOutputBuilder builder = new GetQueueConfigOutputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    builder.setPort(new PortNumber(1L));
    builder.setQueues(createQueues());
    GetQueueConfigOutput message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 40);
    Assert.assertEquals("Wrong port", message.getPort().getValue().longValue(), serializedBuffer.readShort());
    serializedBuffer.skipBytes(6);
    Assert.assertEquals("Wrong queue Id", message.getQueues().get(0).getQueueId().getValue().longValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong length", 24, serializedBuffer.readShort());
    serializedBuffer.skipBytes(2);
    List<QueueProperty> properties = message.getQueues().get(0).getQueueProperty();
    Assert.assertEquals("Wrong property", properties.get(0).getProperty().getIntValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong property length", 16, serializedBuffer.readShort());
    serializedBuffer.skipBytes(4);
    RateQueueProperty rateQueueProperty = properties.get(0).getAugmentation(RateQueueProperty.class);
    Assert.assertEquals("Wrong rate", rateQueueProperty.getRate().intValue(), serializedBuffer.readShort());
    serializedBuffer.skipBytes(6);
}
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) GetQueueConfigOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutputBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) ByteBuf(io.netty.buffer.ByteBuf) QueueProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty) RateQueueProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)7 Test (org.junit.Test)5 RateQueueProperty (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty)5 GetQueueConfigOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput)5 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)4 GetQueueConfigOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutputBuilder)4 QueueProperty (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty)4 Queues (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues)3 ExperimenterIdQueueProperty (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdQueueProperty)1