package org.opendaylight.protocol.bgp.rib.impl;
import com.google.common.primitives.UnsignedInteger;
-import java.util.Objects;
import javax.annotation.concurrent.NotThreadSafe;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
// Get the newly-selected best path.
final BestPath newBestPath = selector.result();
- // FIXME: run deeper comparison
- final boolean ret = !Objects.equals(this.bestPath, newBestPath);
+ final boolean ret = !newBestPath.equals(this.bestPath);
LOG.trace("Previous best {}, current best {}, result {}", this.bestPath, newBestPath, ret);
this.bestPath = newBestPath;
return ret;
*/
package org.opendaylight.protocol.bgp.rib.impl;
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedInteger;
import javax.annotation.Nonnull;
}
UnsignedInteger getRouterId() {
- return routerId;
+ return this.routerId;
}
BestPathState getState() {
- return state;
+ return this.state;
+ }
+
+ private ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
+ toStringHelper.add("routerId", this.routerId);
+ toStringHelper.add("state", this.state);
+ return toStringHelper;
+ }
+
+ @Override
+ public String toString() {
+ return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + this.routerId.hashCode();
+ result = prime * result + this.state.hashCode();
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof BestPath)) {
+ return false;
+ }
+ final BestPath other = (BestPath) obj;
+ if (!this.routerId.equals(other.routerId)) {
+ return false;
+ }
+ if (!this.state.equals(other.state)) {
+ return false;
+ }
+ return true;
}
}
*/
final BestPathState state = new BestPathState(attrs);
if (this.bestOriginatorId == null || !selectPath(originatorId, state)) {
- LOG.trace("Selecting path from router {} state {}", routerId, state);
+ LOG.trace("Selecting path from router {}", routerId);
this.bestOriginatorId = originatorId;
this.bestRouterId = routerId;
this.bestState = state;
*/
package org.opendaylight.protocol.bgp.rib.impl;
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
case "incomplete":
return BgpOrigin.Incomplete;
default:
- throw new IllegalArgumentException("Unhandleed origin value " + originStr);
+ throw new IllegalArgumentException("Unhandled origin value " + originStr);
}
}
ContainerNode getAttributes() {
return this.attributes;
}
+
+ private ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
+ toStringHelper.add("attributes", this.attributes);
+ toStringHelper.add("localPref", this.localPref);
+ toStringHelper.add("multiExitDisc", this.multiExitDisc);
+ toStringHelper.add("origin", this.origin);
+ toStringHelper.add("resolved", this.resolved);
+ return toStringHelper;
+ }
+
+ @Override
+ public String toString() {
+ return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + this.attributes.hashCode();
+ result = prime * result + ((this.localPref == null) ? 0 : this.localPref.hashCode());
+ result = prime * result + ((this.multiExitDisc == null) ? 0 : this.multiExitDisc.hashCode());
+ result = prime * result + ((this.origin == null) ? 0 : this.origin.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof BestPathState)) {
+ return false;
+ }
+ final BestPathState other = (BestPathState) obj;
+ if (!this.attributes.equals(other.attributes)) {
+ return false;
+ }
+ if (this.localPref == null) {
+ if (other.localPref != null) {
+ return false;
+ }
+ } else if (!this.localPref.equals(other.localPref)) {
+ return false;
+ }
+ if (this.multiExitDisc == null) {
+ if (other.multiExitDisc != null) {
+ return false;
+ }
+ } else if (!this.multiExitDisc.equals(other.multiExitDisc)) {
+ return false;
+ }
+ if (this.origin != other.origin) {
+ return false;
+ }
+ return true;
+ }
}
@Override
public final Collection<DataTreeCandidateNode> changedRoutes(final DataTreeCandidateNode routes) {
- LOG.trace("Changed routes called with {} identifier {}", routes, routes.getIdentifier());
final DataTreeCandidateNode myRoutes = routes.getModifiedChild(this.routesContainerIdentifier);
if (myRoutes == null) {
return Collections.emptySet();
}
- LOG.trace("MyRoutes {} identifier {}", myRoutes, myRoutes.getIdentifier());
final DataTreeCandidateNode routesMap = myRoutes.getModifiedChild(this.routesListIdentifier);
if (routesMap == null) {
return Collections.emptySet();
}
- LOG.trace("RoutesMap {} identifier {}", routesMap, routesMap.getIdentifier());
// Well, given the remote possibility of augmentation, we should perform a filter here,
// to make sure the type matches what routeType() reports.
- LOG.trace("Returning children {}", routesMap.getChildNodes());
return routesMap.getChildNodes();
}
ab.setCNextHop(null);
if (!advertised.isEmpty()) {
- MpReachNlri mb = buildReach(advertised, hop);
+ final MpReachNlri mb = buildReach(advertised, hop);
ab.addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mb).build());
}
if (!withdrawn.isEmpty()) {
- MpUnreachNlri mb = buildUnreach(withdrawn);
+ final MpUnreachNlri mb = buildUnreach(withdrawn);
ab.addAugmentation(Attributes2.class, new Attributes2Builder().setMpUnreachNlri(mb).build());
}