Search in sources :

Example 16 with Segments

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.neutron.networks.network.Segments in project netvirt by opendaylight.

the class NeutronUtils method getSegmentationIdFromNeutronNetwork.

public static <T extends NetworkTypeBase> String getSegmentationIdFromNeutronNetwork(Network network, Class<T> networkType) {
    String segmentationId = null;
    NetworkProviderExtension providerExtension = network.getAugmentation(NetworkProviderExtension.class);
    if (providerExtension != null) {
        segmentationId = providerExtension.getSegmentationId();
        if (segmentationId == null) {
            List<Segments> providerSegments = providerExtension.getSegments();
            if (providerSegments != null && providerSegments.size() > 0) {
                for (Segments providerSegment : providerSegments) {
                    if (isNetworkSegmentType(providerSegment, networkType)) {
                        segmentationId = providerSegment.getSegmentationId();
                        break;
                    }
                }
            }
        }
    }
    return segmentationId;
}
Also used : Segments(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.neutron.networks.network.Segments) NetworkProviderExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.NetworkProviderExtension)

Example 17 with Segments

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.neutron.networks.network.Segments in project netvirt by opendaylight.

the class NeutronUtils method getSegmentationIdFromNeutronNetworkSegment.

public static String getSegmentationIdFromNeutronNetworkSegment(Network network, Long index) {
    String segmentationId = null;
    NetworkProviderExtension providerExtension = network.getAugmentation(NetworkProviderExtension.class);
    if (providerExtension != null) {
        List<Segments> providerSegments = providerExtension.getSegments();
        if (providerSegments != null && providerSegments.size() > 0) {
            for (Segments providerSegment : providerSegments) {
                if (Objects.equals(providerSegment.getSegmentationIndex(), index)) {
                    segmentationId = providerSegment.getSegmentationId();
                    break;
                }
            }
        }
    }
    return segmentationId;
}
Also used : Segments(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.neutron.networks.network.Segments) NetworkProviderExtension(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.NetworkProviderExtension)

Example 18 with Segments

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.neutron.networks.network.Segments 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 19 with Segments

use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.neutron.networks.network.Segments 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)

Aggregations

Segments (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.as.path.Segments)11 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)9 AsPathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.AsPathBuilder)8 SegmentsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.as.path.SegmentsBuilder)8 ArrayList (java.util.ArrayList)7 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)7 OriginBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.OriginBuilder)6 ByteBuf (io.netty.buffer.ByteBuf)5 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)5 UpdateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.UpdateBuilder)5 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)5 MultiExitDiscBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.MultiExitDiscBuilder)5 Test (org.junit.Test)4 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update)4 Ipv4NextHopCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv4NextHopCaseBuilder)4 Ipv4NextHopBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder)4 PeerSpecificParserConstraint (org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)3 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)3 NetworkProviderExtension (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.NetworkProviderExtension)3 Segments (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.provider.ext.rev150712.neutron.networks.network.Segments)3