Search in sources :

Example 1 with MultipartReplyQueueCaseBuilder

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

the class StatisticsGatheringUtilsTest method testGatherStatistics_queue.

@Test
public void testGatherStatistics_queue() throws Exception {
    final MultipartType type = MultipartType.OFPMPQUEUE;
    final long queueIdValue = 4L;
    final QueueStatsBuilder queueStatsBld = new QueueStatsBuilder().setPortNo(11L).setTxBytes(BigInteger.valueOf(44L)).setTxErrors(BigInteger.valueOf(45L)).setTxPackets(BigInteger.valueOf(46L)).setDurationSec(47L).setDurationNsec(48L).setQueueId(queueIdValue);
    final MultipartReplyQueueBuilder mpReplyQueueBld = new MultipartReplyQueueBuilder();
    mpReplyQueueBld.setQueueStats(Lists.newArrayList(queueStatsBld.build()));
    final MultipartReplyQueueCaseBuilder mpReplyQueueCaseBld = new MultipartReplyQueueCaseBuilder();
    mpReplyQueueCaseBld.setMultipartReplyQueue(mpReplyQueueBld.build());
    final MultipartReply meterStatsUpdated = assembleMPReplyMessage(type, mpReplyQueueCaseBld.build());
    final List<MultipartReply> statsData = Collections.singletonList(meterStatsUpdated);
    fireAndCheck(type, statsData);
    final KeyedInstanceIdentifier<Queue, QueueKey> queuePath = dummyNodePath.child(NodeConnector.class, new NodeConnectorKey(new NodeConnectorId("openflow:" + DUMMY_NODE_ID_VALUE + ":11"))).augmentation(FlowCapableNodeConnector.class).child(Queue.class, new QueueKey(new QueueId(queueIdValue)));
    verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(queuePath), Matchers.any(Queue.class));
}
Also used : MultipartType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) QueueId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId) MultipartReplyQueueBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueueBuilder) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) MultipartReplyQueueCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCaseBuilder) QueueStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStatsBuilder) Queue(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue) NodeConnectorKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey) QueueKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.QueueKey) Test(org.junit.Test)

Example 2 with MultipartReplyQueueCaseBuilder

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

the class OF10StatsReplyMessageFactoryTest method testQueueBodySerialize.

@Test
public void testQueueBodySerialize() throws Exception {
    MultipartReplyMessageBuilder builder;
    builder = new MultipartReplyMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_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.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 44);
    Assert.assertEquals("Wrong type", MultipartType.OFPMPQUEUE.getIntValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
    MultipartReplyQueueCase body = (MultipartReplyQueueCase) message.getMultipartReplyBody();
    MultipartReplyQueue messageOutput = body.getMultipartReplyQueue();
    QueueStats queueStats = messageOutput.getQueueStats().get(0);
    Assert.assertEquals("Wrong length", 32, serializedBuffer.readUnsignedShort());
    serializedBuffer.skipBytes(2);
    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());
}
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 3 with MultipartReplyQueueCaseBuilder

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

the class MultipartReplyMessageFactory method setQueue.

private static MultipartReplyQueueCase setQueue(final ByteBuf input) {
    MultipartReplyQueueCaseBuilder caseBuilder = new MultipartReplyQueueCaseBuilder();
    MultipartReplyQueueBuilder builder = new MultipartReplyQueueBuilder();
    List<QueueStats> queueStatsList = new ArrayList<>();
    while (input.readableBytes() > 0) {
        QueueStatsBuilder queueStatsBuilder = new QueueStatsBuilder();
        queueStatsBuilder.setPortNo(input.readUnsignedInt());
        queueStatsBuilder.setQueueId(input.readUnsignedInt());
        byte[] txBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(txBytes);
        queueStatsBuilder.setTxBytes(new BigInteger(1, txBytes));
        byte[] txPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(txPackets);
        queueStatsBuilder.setTxPackets(new BigInteger(1, txPackets));
        byte[] txErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(txErrors);
        queueStatsBuilder.setTxErrors(new BigInteger(1, txErrors));
        queueStatsBuilder.setDurationSec(input.readUnsignedInt());
        queueStatsBuilder.setDurationNsec(input.readUnsignedInt());
        queueStatsList.add(queueStatsBuilder.build());
    }
    builder.setQueueStats(queueStatsList);
    caseBuilder.setMultipartReplyQueue(builder.build());
    return caseBuilder.build();
}
Also used : MultipartReplyQueueCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCaseBuilder) QueueStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStatsBuilder) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) QueueStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats) MultipartReplyQueueBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueueBuilder)

Example 4 with MultipartReplyQueueCaseBuilder

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

the class OF10StatsReplyMessageFactory method setQueue.

private static MultipartReplyQueueCase setQueue(ByteBuf input) {
    MultipartReplyQueueCaseBuilder caseBuilder = new MultipartReplyQueueCaseBuilder();
    MultipartReplyQueueBuilder builder = new MultipartReplyQueueBuilder();
    List<QueueStats> queueStatsList = new ArrayList<>();
    while (input.readableBytes() > 0) {
        QueueStatsBuilder queueStatsBuilder = new QueueStatsBuilder();
        queueStatsBuilder.setPortNo((long) input.readUnsignedShort());
        input.skipBytes(PADDING_IN_QUEUE_HEADER);
        queueStatsBuilder.setQueueId(input.readUnsignedInt());
        byte[] txBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(txBytes);
        queueStatsBuilder.setTxBytes(new BigInteger(1, txBytes));
        byte[] txPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(txPackets);
        queueStatsBuilder.setTxPackets(new BigInteger(1, txPackets));
        byte[] txErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(txErrors);
        queueStatsBuilder.setTxErrors(new BigInteger(1, txErrors));
        queueStatsList.add(queueStatsBuilder.build());
    }
    builder.setQueueStats(queueStatsList);
    caseBuilder.setMultipartReplyQueue(builder.build());
    return caseBuilder.build();
}
Also used : MultipartReplyQueueCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCaseBuilder) QueueStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStatsBuilder) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) QueueStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats) MultipartReplyQueueBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueueBuilder)

Example 5 with MultipartReplyQueueCaseBuilder

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

Aggregations

MultipartReplyQueueCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCaseBuilder)6 MultipartReplyQueueBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueueBuilder)6 Test (org.junit.Test)4 QueueStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.multipart.reply.queue.QueueStats)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 ByteBuf (io.netty.buffer.ByteBuf)2 BigInteger (java.math.BigInteger)2 ArrayList (java.util.ArrayList)2 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)2 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)2 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)2 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)2 MultipartReplyQueueCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase)2 MultipartReplyQueue (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue)2 FlowCapableNodeConnector (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector)1 Queue (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue)1 QueueKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.QueueKey)1 QueueId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId)1 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)1 NodeConnectorKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey)1