Search in sources :

Example 1 with QueueId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId in project openflowplugin by opendaylight.

the class QueueStatisticsToNotificationTransformer method transformToNotification.

/**
 * Transform statistics to notification.
 *
 * @param mpReplyList   raw multipart response from device
 * @param deviceInfo    device state
 * @param ofVersion     device version
 * @param emulatedTxId  emulated transaction Id
 * @return notification containing flow stats
 */
public static QueueStatisticsUpdate transformToNotification(final List<MultipartReply> mpReplyList, final DeviceInfo deviceInfo, final OpenflowVersion ofVersion, final TransactionId emulatedTxId) {
    QueueStatisticsUpdateBuilder notification = new QueueStatisticsUpdateBuilder();
    notification.setId(deviceInfo.getNodeId());
    notification.setMoreReplies(Boolean.FALSE);
    notification.setTransactionId(emulatedTxId);
    notification.setQueueIdAndStatisticsMap(new ArrayList<>());
    for (MultipartReply mpReply : mpReplyList) {
        MultipartReplyQueueCase caseBody = (MultipartReplyQueueCase) mpReply.getMultipartReplyBody();
        MultipartReplyQueue replyBody = caseBody.getMultipartReplyQueue();
        for (QueueStats queueStats : replyBody.getQueueStats()) {
            QueueIdAndStatisticsMapBuilder statsBuilder = new QueueIdAndStatisticsMapBuilder();
            statsBuilder.setNodeConnectorId(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(deviceInfo.getDatapathId(), 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()));
            notification.getQueueIdAndStatisticsMap().add(statsBuilder.build());
        }
    }
    return notification.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) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) 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) QueueId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId) 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) QueueStatisticsUpdateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.QueueStatisticsUpdateBuilder) DurationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder)

Example 2 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 testStoreStatistics.

@Override
public void testStoreStatistics() throws Exception {
    final QueueIdAndStatisticsMap map = mock(QueueIdAndStatisticsMap.class);
    when(map.getQueueId()).thenReturn(new QueueId(QUEUE_NO));
    final List<QueueIdAndStatisticsMap> maps = Collections.singletonList(map);
    final GetQueueStatisticsOutput output = mock(GetQueueStatisticsOutput.class);
    when(output.getQueueIdAndStatisticsMap()).thenReturn(maps);
    multipartWriterProvider.lookup(MultipartType.OFPMPQUEUE).get().write(output, true);
    verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
}
Also used : QueueIdAndStatisticsMap(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap) GetQueueStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetQueueStatisticsOutput) QueueId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId)

Example 3 with QueueId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId 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 4 with QueueId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId in project openflowplugin by opendaylight.

the class OF10EnqueueActionDeserializer method deserialize.

@Override
public Action deserialize(ByteBuf input) {
    final ActionBuilder builder = new ActionBuilder();
    input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    final EnqueueCaseBuilder caseBuilder = new EnqueueCaseBuilder();
    EnqueueActionBuilder actionBuilder = new EnqueueActionBuilder();
    actionBuilder.setPort(new PortNumber((long) input.readUnsignedShort()));
    input.skipBytes(ActionConstants.PADDING_IN_ENQUEUE_ACTION);
    actionBuilder.setQueueId(new QueueId(input.readUnsignedInt()));
    caseBuilder.setEnqueueAction(actionBuilder.build());
    builder.setActionChoice(caseBuilder.build());
    return builder.build();
}
Also used : EnqueueCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.EnqueueCaseBuilder) EnqueueActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.enqueue._case.EnqueueActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) QueueId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) EnqueueActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.enqueue._case.EnqueueActionBuilder)

Example 5 with QueueId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId in project openflowplugin by opendaylight.

the class QueueGetConfigReplyMessageFactoryTest method createQueuesList.

private static List<Queues> createQueuesList() {
    final List<Queues> queuesList = new ArrayList<>();
    QueuesBuilder qb = new QueuesBuilder();
    qb.setQueueId(new QueueId(1L));
    qb.setPort(new PortNumber(3L));
    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)

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