use of org.opendaylight.protocol.bgp.mode.impl.BestPathStateImpl 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;
}
}
}
use of org.opendaylight.protocol.bgp.mode.impl.BestPathStateImpl 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;
}
}
}
use of org.opendaylight.protocol.bgp.mode.impl.BestPathStateImpl 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));
}
Aggregations