Search in sources :

Example 1 with RouteKey

use of org.opendaylight.protocol.bgp.mode.impl.add.RouteKey in project bgpcep by opendaylight.

the class ComplexRouteEntry method addRoute.

@Override
public int addRoute(final UnsignedInteger routerId, final long remotePathId, final Route route) {
    final OffsetMap oldMap = getOffsets();
    final int offset = addRoute(new RouteKey(routerId, remotePathId), route.getAttributes());
    final OffsetMap newMap = getOffsets();
    if (!newMap.equals(oldMap)) {
        this.values = newMap.expand(oldMap, this.values, offset);
    }
    newMap.setValue(this.values, offset, route);
    return offset;
}
Also used : RouteKey(org.opendaylight.protocol.bgp.mode.impl.add.RouteKey) OffsetMap(org.opendaylight.protocol.bgp.mode.impl.add.OffsetMap)

Example 2 with RouteKey

use of org.opendaylight.protocol.bgp.mode.impl.add.RouteKey in project bgpcep by opendaylight.

the class AbstractAllPathsRouteEntry method selectBest.

@Override
public final boolean selectBest(final long localAs) {
    final List<AddPathBestPath> newBestPathList = new ArrayList<>();
    final List<RouteKey> keyList = this.offsets.getRouteKeysList();
    if (!keyList.isEmpty()) {
        /* we set the best path first on List for not supported Add path cases*/
        final AddPathBestPath newBest = selectBest(localAs, keyList);
        newBestPathList.add(newBest);
        keyList.remove(newBest.getRouteKey());
        /*we add the rest of path, regardless in what order they are, since this is all path case */
        for (final RouteKey key : keyList) {
            final int offset = this.offsets.offsetOf(key);
            final Attributes attributes = this.offsets.getValue(this.values, offset);
            requireNonNull(key.getRouteId(), "Router ID may not be null");
            if (attributes != null) {
                final BestPathState state = new BestPathStateImpl(attributes);
                final AddPathBestPath bestPath = new AddPathBestPath(state, key, offset, this.offsets.getValue(this.pathsId, offset));
                newBestPathList.add(bestPath);
            }
        }
    }
    return isBestPathNew(ImmutableList.copyOf(newBestPathList));
}
Also used : AddPathBestPath(org.opendaylight.protocol.bgp.mode.impl.add.AddPathBestPath) BestPathState(org.opendaylight.protocol.bgp.mode.api.BestPathState) BestPathStateImpl(org.opendaylight.protocol.bgp.mode.impl.BestPathStateImpl) ArrayList(java.util.ArrayList) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes) RouteKey(org.opendaylight.protocol.bgp.mode.impl.add.RouteKey)

Example 3 with RouteKey

use of org.opendaylight.protocol.bgp.mode.impl.add.RouteKey in project bgpcep by opendaylight.

the class ComplexRouteEntry method removeRoute.

@Override
public boolean removeRoute(final UnsignedInteger routerId, final long remotePathId) {
    final RouteKey key = new RouteKey(routerId, remotePathId);
    final OffsetMap map = getOffsets();
    final int offset = map.offsetOf(key);
    this.values = map.removeValue(this.values, offset);
    return removeRoute(key, offset);
}
Also used : RouteKey(org.opendaylight.protocol.bgp.mode.impl.add.RouteKey) OffsetMap(org.opendaylight.protocol.bgp.mode.impl.add.OffsetMap)

Example 4 with RouteKey

use of org.opendaylight.protocol.bgp.mode.impl.add.RouteKey in project bgpcep by opendaylight.

the class AbstractNPathsRouteEntry method selectBest.

@Override
public final boolean selectBest(final long localAs) {
    final List<AddPathBestPath> newBestPathList = new ArrayList<>();
    final List<RouteKey> keyList = this.offsets.getRouteKeysList();
    final long maxSearch = this.npaths < this.offsets.size() && this.npaths != 0 ? this.npaths : this.offsets.size();
    for (long i = 0; i < maxSearch; ++i) {
        final AddPathBestPath newBest = selectBest(localAs, keyList);
        newBestPathList.add(newBest);
        keyList.remove(newBest.getRouteKey());
    }
    return isBestPathNew(ImmutableList.copyOf(newBestPathList));
}
Also used : AddPathBestPath(org.opendaylight.protocol.bgp.mode.impl.add.AddPathBestPath) ArrayList(java.util.ArrayList) RouteKey(org.opendaylight.protocol.bgp.mode.impl.add.RouteKey)

Example 5 with RouteKey

use of org.opendaylight.protocol.bgp.mode.impl.add.RouteKey in project bgpcep by opendaylight.

the class ComplexRouteEntry method addRoute.

@Override
public int addRoute(final UnsignedInteger routerId, final long remotePathId, final Route route) {
    final OffsetMap oldMap = getOffsets();
    final int offset = addRoute(new RouteKey(routerId, remotePathId), route.getAttributes());
    final OffsetMap newMap = getOffsets();
    if (!newMap.equals(oldMap)) {
        this.values = newMap.expand(oldMap, this.values, offset);
    }
    newMap.setValue(this.values, offset, route);
    return offset;
}
Also used : RouteKey(org.opendaylight.protocol.bgp.mode.impl.add.RouteKey) OffsetMap(org.opendaylight.protocol.bgp.mode.impl.add.OffsetMap)

Aggregations

RouteKey (org.opendaylight.protocol.bgp.mode.impl.add.RouteKey)6 OffsetMap (org.opendaylight.protocol.bgp.mode.impl.add.OffsetMap)4 ArrayList (java.util.ArrayList)2 AddPathBestPath (org.opendaylight.protocol.bgp.mode.impl.add.AddPathBestPath)2 BestPathState (org.opendaylight.protocol.bgp.mode.api.BestPathState)1 BestPathStateImpl (org.opendaylight.protocol.bgp.mode.impl.BestPathStateImpl)1 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)1