use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.Attributes in project bgpcep by opendaylight.
the class AdjRibInWriter method updateRoutes.
void updateRoutes(final MpReachNlri nlri, final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes attributes) {
final TablesKey key = new TablesKey(nlri.getAfi(), nlri.getSafi());
final TableContext ctx = this.tables.get(key);
if (ctx == null) {
LOG.debug("No table for {}, not accepting NLRI {}", key, nlri);
return;
}
final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction();
ctx.writeRoutes(tx, nlri, attributes);
LOG.trace("Write routes {}", nlri);
Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
@Override
public void onSuccess(final Void result) {
LOG.trace("Write routes {}, succeed", nlri);
}
@Override
public void onFailure(final Throwable throwable) {
LOG.error("Write routes failed", throwable);
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.Attributes in project bgpcep by opendaylight.
the class AdjRibOutListener method buildUpdate.
private Update buildUpdate(@Nonnull final Collection<MapEntryNode> advertised, @Nonnull final Collection<MapEntryNode> withdrawn, @Nonnull final Attributes attr) {
final UpdateBuilder ub = new UpdateBuilder().setWithdrawnRoutes(extractWithdrawnRoutes(withdrawn)).setNlri(extractNlris(advertised));
ub.setAttributes(attr);
return ub.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.Attributes in project bgpcep by opendaylight.
the class BaseAbstractRouteEntry method addRoute.
@Override
public int addRoute(final UnsignedInteger routerId, final long remotePathId, final Route route) {
final Attributes advertisedAttrs = route.getAttributes();
int offset = this.offsets.offsetOf(routerId);
if (offset < 0) {
final OffsetMap newOffsets = this.offsets.with(routerId);
offset = newOffsets.offsetOf(routerId);
this.values = newOffsets.expand(this.offsets, this.values, offset);
this.offsets = newOffsets;
}
this.offsets.setValue(this.values, offset, advertisedAttrs);
LOG.trace("Added route from {} attributes {}", routerId, advertisedAttrs);
return offset;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.Attributes in project bgpcep by opendaylight.
the class BaseAbstractRouteEntry method initializeBestPaths.
@Override
@SuppressWarnings("unchecked")
public void initializeBestPaths(final RouteEntryDependenciesContainer entryDep, final RouteEntryInfo entryInfo, final WriteTransaction tx) {
if (this.bestPath == null) {
return;
}
final TablesKey localTK = entryDep.getLocalTablesKey();
final Peer toPeer = entryInfo.getToPeer();
if (!filterRoutes(this.bestPath.getPeerId(), toPeer, localTK)) {
return;
}
final Identifier oldRouteKey = entryInfo.getRouteKey();
final RIBSupport ribSupport = entryDep.getRibSupport();
Identifier newRouteKey = ribSupport.createNewRouteKey(this.bestPath.getPathId(), oldRouteKey);
if (newRouteKey == null) {
newRouteKey = oldRouteKey;
}
final BGPRouteEntryExportParameters routeEntry = new BGPRouteEntryExportParametersImpl(this.peerTracker.getPeer(this.bestPath.getPeerId()), toPeer);
final Optional<Attributes> effAttrib = entryDep.getRoutingPolicies().applyExportPolicies(routeEntry, this.bestPath.getAttributes());
final Route route = createRoute(ribSupport, newRouteKey, this.bestPath.getPathId(), this.bestPath);
InstanceIdentifier ribOutIId = ribSupport.createRouteIdentifier(toPeer.getRibOutIId(localTK), newRouteKey);
if (effAttrib.isPresent() && route != null) {
LOG.debug("Write route {} to peer AdjRibsOut {}", route, toPeer.getPeerId());
tx.put(LogicalDatastoreType.OPERATIONAL, ribOutIId, route);
tx.put(LogicalDatastoreType.OPERATIONAL, ribOutIId.child(Attributes.class), effAttrib.get());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.Attributes in project bgpcep by opendaylight.
the class BaseAbstractRouteEntry method selectBest.
@Override
public final boolean selectBest(final long localAs) {
/*
* FIXME: optimize flaps by making sure we consider stability of currently-selected route.
*/
final BasePathSelector selector = new BasePathSelector(localAs);
// Select the best route.
for (int i = 0; i < this.offsets.size(); ++i) {
final UnsignedInteger routerId = this.offsets.getRouterKey(i);
final Attributes attributes = this.offsets.getValue(this.values, i);
LOG.trace("Processing router id {} attributes {}", routerId, attributes);
selector.processPath(routerId, attributes);
}
// Get the newly-selected best path.
final BaseBestPath newBestPath = selector.result();
final boolean modified = newBestPath == null || !newBestPath.equals(this.bestPath);
if (modified) {
if (this.offsets.isEmpty()) {
this.removedBestPath = this.bestPath;
}
LOG.trace("Previous best {}, current best {}", this.bestPath, newBestPath);
this.bestPath = newBestPath;
}
return modified;
}
Aggregations