private R createRoute(final RIBSupport<C, S, R, I> ribSup, final String routeKey, final AddPathBestPath path) {
final OffsetMap map = getOffsets();
final R route = map.getValue(this.values, map.offsetOf(path.getRouteKey()));
- return ribSup.createRoute(route, ribSup.createRouteListKey(pathIdObj(path.getPathId()), routeKey),
+ return ribSup.createRoute(route, ribSup.createRouteListKey(pathIdObj(path.getPathIdLong()), routeKey),
path.getAttributes());
}
private void selectBest(final RouteKey key, final AddPathSelector selector) {
final int offset = this.offsets.offsetOf(key);
final R route = this.offsets.getValue(this.values, offset);
- final long pathId = this.offsets.getValue(this.pathsId, offset);
+ final Long pathId = this.offsets.getValue(this.pathsId, offset);
LOG.trace("Processing router key {} route {}", key, route);
selector.processPath(route.getAttributes(), key, offset, pathId);
}
});
}
- private static PathId pathIdObj(final long pathId) {
+ private static PathId pathIdObj(final Long pathId) {
return pathId == NON_PATH_ID_VALUE ? NON_PATH_ID : new PathId(pathId);
}
}
public final class AddPathBestPath extends AbstractBestPath {
private final RouteKey routeKey;
- private final int offsetPosition;
- private final long pathId;
+ private final Long pathId;
+ private final int offset;
- public AddPathBestPath(@Nonnull final BestPathState state, @Nonnull final RouteKey key, final int offsetPosition,
- final long pathId) {
+ public AddPathBestPath(@Nonnull final BestPathState state, @Nonnull final RouteKey key, final @Nonnull Long pathId,
+ final int offset) {
super(state);
this.routeKey = requireNonNull(key);
- this.offsetPosition = offsetPosition;
- this.pathId = pathId;
+ this.pathId = requireNonNull(pathId);
+ this.offset = offset;
}
public RouteKey getRouteKey() {
return this.routeKey;
}
+ public int getOffset() {
+ return offset;
+ }
+
@Override
protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
- toStringHelper.add("routeKey", this.routeKey);
- toStringHelper.add("state", this.state);
- toStringHelper.add("offsetPosition", this.offsetPosition);
- toStringHelper.add("pathId", this.pathId);
- return toStringHelper;
+ return super.addToStringAttributes(toStringHelper.add("routeKey", this.routeKey)
+ .add("pathId", this.pathId)
+ .add("offset", offset));
}
@Override
return false;
}
- return this.pathId == other.pathId;
+ return this.pathId.equals(other.pathId);
}
@Override
public long getPathId() {
return this.pathId;
}
+
+ /**
+ * Return the boxed value equivalent of {@link #getPathId()}. This class uses boxed instances internally, hence
+ * this method exposes it.
+ *
+ * @return Path Id as a {@link Long}
+ */
+ public @Nonnull Long getPathIdLong() {
+ return this.pathId;
+ }
}
private static final Logger LOG = LoggerFactory.getLogger(AddPathSelector.class);
private RouteKey bestRouteKey;
- private int bestOffsetPosition;
- private long bestPathId;
+ private Long bestPathId;
+ private int bestOffset;
public AddPathSelector(final long ourAs) {
super(ourAs);
}
- void processPath(final Attributes attrs, final RouteKey key, final int offsetPosition, final long pathId) {
+ void processPath(final Attributes attrs, final RouteKey key, final int offsetPosition, final Long pathId) {
// Consider only non-null attributes
if (attrs != null) {
final UnsignedInteger routerId = key.getRouterId();
this.bestOriginatorId = originatorId;
this.bestState = state;
this.bestRouteKey = key;
- this.bestOffsetPosition = offsetPosition;
+ this.bestOffset = offsetPosition;
this.bestPathId = pathId;
}
}
public AddPathBestPath result() {
return this.bestRouteKey == null ? null : new AddPathBestPath(this.bestState, this.bestRouteKey,
- this.bestOffsetPosition, this.bestPathId);
+ this.bestPathId, this.bestOffset);
}
}
final Route route = this.offsets.getValue(this.values, offset);
if (route != null) {
final BestPathState state = new BestPathStateImpl(route.getAttributes());
- final AddPathBestPath bestPath = new AddPathBestPath(state, key, offset,
- this.offsets.getValue(this.pathsId, offset));
+ final AddPathBestPath bestPath = new AddPathBestPath(state, key,
+ this.offsets.getValue(this.pathsId, offset), offset);
newBestPathList.add(bestPath);
}
}
@Override
protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
- toStringHelper.add("routerId", this.routerId);
- toStringHelper.add("state", this.state);
- return toStringHelper;
+ return super.addToStringAttributes(toStringHelper.add("routerId", this.routerId));
}
@Override
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
import org.opendaylight.protocol.bgp.mode.api.BestPath;
import org.opendaylight.protocol.bgp.mode.api.BestPathState;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
this.state = requireNonNull(state);
}
- protected abstract MoreObjects.ToStringHelper addToStringAttributes(MoreObjects.ToStringHelper toStringHelper);
+ protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
+ return toStringHelper.add("state", state);
+ }
@VisibleForTesting
public final BestPathState getState() {