Search in sources :

Example 26 with OfHeader

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

the class GroupDescriptionService method buildRequest.

@Override
protected OfHeader buildRequest(final Xid xid, final GetGroupDescriptionInput input) throws ServiceException {
    final MultipartRequestInputBuilder mprInput = RequestInputUtils.createMultipartHeader(MultipartType.OFPMPGROUPDESC, xid.getValue(), getVersion());
    mprInput.setMultipartRequestBody(GROUP_DESC_CASE);
    return mprInput.build();
}
Also used : MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder)

Example 27 with OfHeader

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

the class StackedOutboundQueueNoBarrier method writeEntries.

@Override
int writeEntries(@Nonnull final Channel channel, final long now) {
    // Local cache
    StackedSegment segment = firstSegment;
    int entries = 0;
    while (channel.isWritable()) {
        final OutboundQueueEntry entry = segment.getEntry(flushOffset);
        if (!entry.isCommitted()) {
            LOG.debug("Queue {} XID {} segment {} offset {} not committed yet", this, segment.getBaseXid() + flushOffset, segment, flushOffset);
            break;
        }
        LOG.trace("Queue {} flushing entry at offset {}", this, flushOffset);
        final OfHeader message = entry.takeMessage();
        flushOffset++;
        entries++;
        if (message != null) {
            manager.writeMessage(message, now);
        } else {
            entry.complete(null);
        }
        if (flushOffset >= StackedSegment.SEGMENT_SIZE) {
            /*
                 * Slow path: purge the current segment unless it's the last one.
                 * If it is, we leave it for replacement when a new reservation
                 * is run on it.
                 * This costs us two slow paths, but hey, this should be very rare,
                 * so let's keep things simple.
                 */
            synchronized (unflushedSegments) {
                LOG.debug("Flush offset {} unflushed segments {}", flushOffset, unflushedSegments.size());
                // We may have raced ahead of reservation code and need to allocate a segment
                ensureSegment(segment, flushOffset);
                // Remove the segment, update the firstSegment and reset flushOffset
                final StackedSegment oldSegment = unflushedSegments.remove(0);
                oldSegment.completeAll();
                uncompletedSegments.remove(oldSegment);
                oldSegment.recycle();
                // Reset the first segment and add it to the uncompleted list
                segment = unflushedSegments.get(0);
                uncompletedSegments.add(segment);
                // Update the shutdown offset
                if (shutdownOffset != null) {
                    shutdownOffset -= StackedSegment.SEGMENT_SIZE;
                }
                // Allow reservations back on the fast path by publishing the new first segment
                firstSegment = segment;
                flushOffset = 0;
                LOG.debug("Queue {} flush moved to segment {}", this, segment);
            }
        }
    }
    return entries;
}
Also used : OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader)

Example 28 with OfHeader

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

the class AbstractStackedOutboundQueue method writeEntries.

/**
 * Write some entries from the queue to the channel. Guaranteed to run
 * in the corresponding EventLoop.
 *
 * @param channel Channel onto which we are writing
 * @param now time stamp
 * @return Number of entries written out
 */
int writeEntries(@Nonnull final Channel channel, final long now) {
    // Local cache
    StackedSegment segment = firstSegment;
    int entries = 0;
    while (channel.isWritable()) {
        final OutboundQueueEntry entry = segment.getEntry(flushOffset);
        if (!entry.isCommitted()) {
            LOG.debug("Queue {} XID {} segment {} offset {} not committed yet", this, segment.getBaseXid() + flushOffset, segment, flushOffset);
            break;
        }
        LOG.trace("Queue {} flushing entry at offset {}", this, flushOffset);
        final OfHeader message = entry.takeMessage();
        flushOffset++;
        entries++;
        if (message != null) {
            manager.writeMessage(message, now);
        } else {
            entry.complete(null);
        }
        if (flushOffset >= StackedSegment.SEGMENT_SIZE) {
            /*
                 * Slow path: purge the current segment unless it's the last one.
                 * If it is, we leave it for replacement when a new reservation
                 * is run on it.
                 *
                 * This costs us two slow paths, but hey, this should be very rare,
                 * so let's keep things simple.
                 */
            synchronized (unflushedSegments) {
                LOG.debug("Flush offset {} unflushed segments {}", flushOffset, unflushedSegments.size());
                // We may have raced ahead of reservation code and need to allocate a segment
                ensureSegment(segment, flushOffset);
                // Remove the segment, update the firstSegment and reset flushOffset
                final StackedSegment oldSegment = unflushedSegments.remove(0);
                if (oldSegment.isComplete()) {
                    uncompletedSegments.remove(oldSegment);
                    oldSegment.recycle();
                }
                // Reset the first segment and add it to the uncompleted list
                segment = unflushedSegments.get(0);
                uncompletedSegments.add(segment);
                // Update the shutdown offset
                if (shutdownOffset != null) {
                    shutdownOffset -= StackedSegment.SEGMENT_SIZE;
                }
                // Allow reservations back on the fast path by publishing the new first segment
                firstSegment = segment;
                flushOffset = 0;
                LOG.debug("Queue {} flush moved to segment {}", this, segment);
            }
        }
    }
    return entries;
}
Also used : OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader)

Example 29 with OfHeader

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

the class OutboundQueueEntry method takeMessage.

OfHeader takeMessage() {
    final OfHeader ret = message;
    if (!barrier) {
        checkCompletionNeed();
    }
    message = null;
    return ret;
}
Also used : OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader)

Example 30 with OfHeader

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

the class MessageSerializerInjector method injectSerializers.

/**
 * Injects message serializers into provided
 * {@link org.opendaylight.openflowjava.protocol.api.extensibility.SerializerExtensionProvider}.
 * @param provider OpenflowJava serializer extension provider
 * @param isGroupAddModEnabled config to enale/disable GroupAddMod Message
 */
static void injectSerializers(final SerializerExtensionProvider provider, final boolean isGroupAddModEnabled) {
    // Inject new message serializers here using injector created by createInjector method
    final Function<Class<?>, Consumer<OFSerializer<? extends OfHeader>>> injector = createInjector(provider, EncodeConstants.OF13_VERSION_ID);
    injector.apply(FlowMessage.class).accept(new FlowMessageSerializer());
    injector.apply(MeterMessage.class).accept(new MeterMessageSerializer());
    injector.apply(PortMessage.class).accept(new PortMessageSerializer());
    injector.apply(GroupMessage.class).accept(new GroupMessageSerializer(isGroupAddModEnabled));
    injector.apply(MultipartRequest.class).accept(new MultipartRequestMessageSerializer());
    injector.apply(AsyncConfigMessage.class).accept(new AsyncConfigMessageSerializer());
}
Also used : MeterMessageSerializer(org.opendaylight.openflowplugin.impl.protocol.serialization.messages.MeterMessageSerializer) MeterMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterMessage) PortMessageSerializer(org.opendaylight.openflowplugin.impl.protocol.serialization.messages.PortMessageSerializer) GroupMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupMessage) FlowMessageSerializer(org.opendaylight.openflowplugin.impl.protocol.serialization.messages.FlowMessageSerializer) MultipartRequestMessageSerializer(org.opendaylight.openflowplugin.impl.protocol.serialization.multipart.MultipartRequestMessageSerializer) PortMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortMessage) Consumer(java.util.function.Consumer) GroupMessageSerializer(org.opendaylight.openflowplugin.impl.protocol.serialization.messages.GroupMessageSerializer) AsyncConfigMessageSerializer(org.opendaylight.openflowplugin.impl.protocol.serialization.messages.AsyncConfigMessageSerializer) AsyncConfigMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.async.config.service.rev170619.AsyncConfigMessage) FlowMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowMessage) MultipartRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartRequest)

Aggregations

OfHeader (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader)30 Test (org.junit.Test)23 MultipartRequestInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder)17 Xid (org.opendaylight.openflowplugin.api.openflow.device.Xid)10 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)5 ExecutionException (java.util.concurrent.ExecutionException)3 ServiceException (org.opendaylight.openflowplugin.impl.services.util.ServiceException)3 GroupMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupMessage)3 MultipartType (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType)3 FutureCallback (com.google.common.util.concurrent.FutureCallback)2 List (java.util.List)2 Future (java.util.concurrent.Future)2 Function (java.util.function.Function)2 OFDeserializer (org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer)2 TypeVersionKey (org.opendaylight.openflowplugin.extension.api.TypeVersionKey)2 ConversionException (org.opendaylight.openflowplugin.extension.api.exception.ConversionException)2 ConverterNotFoundException (org.opendaylight.openflowplugin.extension.api.exception.ConverterNotFoundException)2 ConvertorExecutor (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor)2 PortMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortMessage)2 FlowMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowMessage)2