use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.
the class BGPPeer method onUpdateMessage.
/**
* Process Update message received.
* Calls {@link #checkMandatoryAttributesPresence(Update)} to check for presence of mandatory attributes.
*
* @param message Update message
*/
private synchronized void onUpdateMessage(final Update message) throws BGPDocumentedException {
checkMandatoryAttributesPresence(message);
// update AdjRibs
final Attributes attrs = message.getAttributes();
MpReachNlri mpReach;
final boolean isAnyNlriAnnounced = message.getNlri() != null;
if (isAnyNlriAnnounced) {
mpReach = prefixesToMpReach(message);
} else {
mpReach = MessageUtil.getMpReachNlri(attrs);
}
if (mpReach != null) {
this.ribWriter.updateRoutes(mpReach, nextHopToAttribute(attrs, mpReach));
}
final MpUnreachNlri mpUnreach;
if (message.getWithdrawnRoutes() != null) {
mpUnreach = prefixesToMpUnreach(message, isAnyNlriAnnounced);
} else {
mpUnreach = MessageUtil.getMpUnreachNlri(attrs);
}
final boolean endOfRib = BgpPeerUtil.isEndOfRib(message);
if (mpUnreach != null) {
if (endOfRib) {
final TablesKey tablesKey = new TablesKey(mpUnreach.getAfi(), mpUnreach.getSafi());
this.ribWriter.removeStaleRoutes(tablesKey);
this.missingEOT.remove(tablesKey);
handleGracefulEndOfRib();
} else {
this.ribWriter.removeRoutes(mpUnreach);
}
} else if (endOfRib) {
this.ribWriter.removeStaleRoutes(IPV4_UCAST_TABLE_KEY);
this.missingEOT.remove(IPV4_UCAST_TABLE_KEY);
handleGracefulEndOfRib();
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.
the class BGPPeer method handleGracefulEndOfRib.
@Holding("this")
private void handleGracefulEndOfRib() {
if (isLocalRestarting()) {
if (this.missingEOT.isEmpty()) {
createEffRibInWriter();
this.effRibInWriter.init();
registerPrefixesCounters(this.effRibInWriter, this.effRibInWriter);
for (final TablesKey key : getAfiSafisAdvertized()) {
createAdjRibOutListener(key, true);
}
setLocalRestartingState(false);
setGracefulPreferences(false, Collections.emptySet());
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.
the class BGPPeer method onRouteRefreshMessage.
private void onRouteRefreshMessage(final RouteRefresh message) {
final Class<? extends AddressFamily> rrAfi = message.getAfi();
final Class<? extends SubsequentAddressFamily> rrSafi = message.getSafi();
final TablesKey key = new TablesKey(rrAfi, rrSafi);
synchronized (this) {
final AdjRibOutListener listener = this.adjRibOutListenerSet.remove(key);
if (listener != null) {
listener.close();
createAdjRibOutListener(key, listener.isMpSupported());
} else {
LOG.info("Ignoring RouteRefresh message. Afi/Safi is not supported: {}, {}.", rrAfi, rrSafi);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.
the class AdjRibInWriter method createNewTableInstances.
/**
* Create new table instances, potentially creating their empty entries.
*/
private static ImmutableMap<TablesKey, TableContext> createNewTableInstances(final YangInstanceIdentifier newPeerPath, final RIBSupportContextRegistry registry, final Set<TablesKey> tableTypes, final Map<TablesKey, SendReceive> addPathTablesType, final DOMDataTreeWriteTransaction tx) {
final Builder<TablesKey, TableContext> tb = ImmutableMap.builder();
for (final TablesKey tableKey : tableTypes) {
final RIBSupportContext rs = registry.getRIBSupportContext(tableKey);
// TODO: Use returned value once Instance Identifier builder allows for it.
final NodeIdentifierWithPredicates instanceIdentifierKey = RibSupportUtils.toYangTablesKey(tableKey);
if (rs == null) {
LOG.warn("No support for table type {}, skipping it", tableKey);
continue;
}
installAdjRibsOutTables(newPeerPath, rs, instanceIdentifierKey, tableKey, addPathTablesType.get(tableKey), tx);
installAdjRibInTables(newPeerPath, tableKey, rs, instanceIdentifierKey, tx, tb);
}
return tb.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.
the class AdjRibInWriter method removeRoutes.
void removeRoutes(final MpUnreachNlri nlri) {
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;
}
LOG.trace("Removing routes {}", nlri);
final DOMDataTreeWriteTransaction tx = this.chain.getDomChain().newWriteOnlyTransaction();
ctx.removeRoutes(tx, nlri);
final FluentFuture<? extends CommitInfo> future = tx.commit();
this.submitted = future;
future.addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.trace("Removing routes {}, succeed", nlri);
}
@Override
public void onFailure(final Throwable throwable) {
LOG.error("Removing routes failed", throwable);
}
}, MoreExecutors.directExecutor());
}
Aggregations