Search in sources :

Example 1 with BestPathState

use of org.opendaylight.protocol.bgp.mode.api.BestPathState in project bgpcep by opendaylight.

the class BasePathSelector method processPath.

void processPath(final UnsignedInteger routerId, final Attributes attrs) {
    requireNonNull(routerId, "Router ID may not be null");
    // Consider only non-null attributes
    if (attrs != null) {
        final UnsignedInteger originatorId = replaceOriginator(routerId, attrs.getOriginatorId());
        /*
             * Store the new details if we have nothing stored or when the selection algorithm indicates new details
             * are better.
             */
        final BestPathState state = new BestPathStateImpl(attrs);
        if (this.bestOriginatorId == null || !isExistingPathBetter(state)) {
            LOG.trace("Selecting path from router {}", routerId);
            this.bestOriginatorId = originatorId;
            this.bestRouterId = routerId;
            this.bestState = state;
        }
    }
}
Also used : BestPathState(org.opendaylight.protocol.bgp.mode.api.BestPathState) BestPathStateImpl(org.opendaylight.protocol.bgp.mode.impl.BestPathStateImpl) UnsignedInteger(com.google.common.primitives.UnsignedInteger)

Example 2 with BestPathState

use of org.opendaylight.protocol.bgp.mode.api.BestPathState in project bgpcep by opendaylight.

the class AddPathSelector method processPath.

void processPath(final Attributes attrs, final RouteKey key, final int offsetPosition, final long pathId) {
    requireNonNull(key.getRouteId(), "Router ID may not be null");
    // Consider only non-null attributes
    if (attrs != null) {
        final UnsignedInteger originatorId = replaceOriginator(key.getRouteId(), attrs.getOriginatorId());
        /*
             * Store the new details if we have nothing stored or when the selection algorithm indicates new details
             * are better.
             */
        final BestPathState state = new BestPathStateImpl(attrs);
        if (this.bestOriginatorId == null || !isExistingPathBetter(state)) {
            LOG.trace("Selecting path from router {}", key);
            this.bestOriginatorId = originatorId;
            this.bestState = state;
            this.bestRouteKey = key;
            this.bestOffsetPosition = offsetPosition;
            this.bestPathId = pathId;
        }
    }
}
Also used : BestPathState(org.opendaylight.protocol.bgp.mode.api.BestPathState) BestPathStateImpl(org.opendaylight.protocol.bgp.mode.impl.BestPathStateImpl) UnsignedInteger(com.google.common.primitives.UnsignedInteger)

Example 3 with BestPathState

use of org.opendaylight.protocol.bgp.mode.api.BestPathState 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)

Aggregations

BestPathState (org.opendaylight.protocol.bgp.mode.api.BestPathState)3 BestPathStateImpl (org.opendaylight.protocol.bgp.mode.impl.BestPathStateImpl)3 UnsignedInteger (com.google.common.primitives.UnsignedInteger)2 ArrayList (java.util.ArrayList)1 AddPathBestPath (org.opendaylight.protocol.bgp.mode.impl.add.AddPathBestPath)1 RouteKey (org.opendaylight.protocol.bgp.mode.impl.add.RouteKey)1 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)1