Search in sources :

Example 16 with PathId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.PathId in project bgpcep by opendaylight.

the class LocRibWriter method updateRoutesEntries.

@SuppressWarnings("unchecked")
private void updateRoutesEntries(final Collection<DataObjectModification<? extends DataObject>> routeChanges, final UnsignedInteger routerId, final Map<RouteUpdateKey, RouteEntry> routes) {
    for (final DataObjectModification<? extends DataObject> route : routeChanges) {
        final Identifier routeKey = ((InstanceIdentifier.IdentifiableItem) route.getIdentifier()).getKey();
        RouteEntry entry = this.routeEntries.get(routeKey);
        final Route newRoute = (Route) route.getDataAfter();
        final Route oldRoute = (Route) route.getDataBefore();
        if (newRoute != null) {
            if (entry == null) {
                entry = createEntry(routeKey);
            }
            final long pathId = this.ribSupport.extractPathId(newRoute);
            entry.addRoute(routerId, pathId, newRoute);
            this.totalPathsCounter.increment();
        } else if (oldRoute != null && entry != null) {
            this.totalPathsCounter.decrement();
            final long pathId = this.ribSupport.extractPathId(oldRoute);
            if (entry.removeRoute(routerId, pathId)) {
                this.routeEntries.remove(routeKey);
                this.totalPrefixesCounter.decrement();
                LOG.trace("Removed route from {}", routerId);
            }
        }
        final RouteUpdateKey routeUpdateKey = new RouteUpdateKey(routerId, routeKey);
        LOG.debug("Updated route {} entry {}", routeKey, entry);
        routes.put(routeUpdateKey, entry);
    }
}
Also used : RouteEntry(org.opendaylight.protocol.bgp.mode.api.RouteEntry) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) Identifier(org.opendaylight.yangtools.yang.binding.Identifier) DataTreeIdentifier(org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier) Route(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route)

Example 17 with PathId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.PathId in project bgpcep by opendaylight.

the class PathIdUtilTest method testReadPathId.

@Test
public void testReadPathId() {
    final long expected = 10L;
    ByteBufWriteUtil.writeUnsignedInt(expected, this.buffer);
    final PathId pathId = PathIdUtil.readPathId(this.buffer);
    Assert.assertEquals(expected, pathId.getValue().longValue());
}
Also used : PathId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.PathId) Test(org.junit.Test)

Example 18 with PathId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.PathId in project bgpcep by opendaylight.

the class PathIdUtilTest method testWritePathId.

@Test
public void testWritePathId() {
    PathIdUtil.writePathId(new PathId(10L), this.buffer);
    Assert.assertEquals(Integer.BYTES, this.buffer.readableBytes());
}
Also used : PathId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.PathId) Test(org.junit.Test)

Example 19 with PathId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.PathId in project bgpcep by opendaylight.

the class ComplexRouteEntry method createRoute.

@Override
public Route createRoute(final RIBSupport ribSup, final Identifier routeKey, final long pathId, final AddPathBestPath path) {
    final OffsetMap map = getOffsets();
    final Route route = map.getValue(this.values, map.offsetOf(path.getRouteKey()));
    return ribSup.createRoute(route, routeKey, pathId, path.getAttributes());
}
Also used : OffsetMap(org.opendaylight.protocol.bgp.mode.impl.add.OffsetMap) Route(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route)

Example 20 with PathId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.PathId in project bgpcep by opendaylight.

the class ComplexRouteEntry method createRoute.

@Override
public Route createRoute(final RIBSupport ribSup, Identifier routeKey, final long pathId, final BaseBestPath path) {
    final OffsetMap map = getOffsets();
    final Route route = map.getValue(this.values, map.offsetOf(path.getRouterId()));
    return ribSup.createRoute(route, routeKey, pathId, path.getAttributes());
}
Also used : Route(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route)

Aggregations

PathId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.PathId)21 Test (org.junit.Test)12 AbstractRIBSupportTest (org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest)8 RouteDistinguisher (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisher)6 List (java.util.List)4 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)4 Flowspec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.Flowspec)4 Route (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route)4 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)4 Nonnull (javax.annotation.Nonnull)3 UpdateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.UpdateBuilder)3 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)3 AdvertizedRoutesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.reach.nlri.AdvertizedRoutesBuilder)3 ByteBuf (io.netty.buffer.ByteBuf)2 Before (org.junit.Before)2 RouteDistinguisherUtil.extractRouteDistinguisher (org.opendaylight.bgp.concepts.RouteDistinguisherUtil.extractRouteDistinguisher)2 OffsetMap (org.opendaylight.protocol.bgp.mode.impl.add.OffsetMap)2 PeerSpecificParserConstraint (org.opendaylight.protocol.bgp.parser.spi.PeerSpecificParserConstraint)2 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)2 DestinationFlowspecL3vpnIpv4Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.l3vpn.destination.ipv4.DestinationFlowspecL3vpnIpv4Builder)2