use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId in project bgpcep by opendaylight.
the class BmpRouterImpl method onPeerUp.
private synchronized void onPeerUp(final PeerUpNotification peerUp) {
final PeerId peerId = getPeerIdFromOpen(peerUp.getReceivedOpen());
if (!getPeer(peerId).isPresent()) {
final BmpRouterPeer peer = BmpRouterPeerImpl.createRouterPeer(this.domTxChain, this.peersYangIId, peerUp, this.extensions, this.tree, peerId);
this.peers.put(peerId, peer);
LOG.debug("Router {}: Peer {} goes up.", this.routerIp, peerId.getValue());
} else {
LOG.debug("Peer: {} for Router: {} already exists.", peerId.getValue(), this.routerIp);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId in project bgpcep by opendaylight.
the class MatchBgpNeighborSetHandler method loadRoleSets.
private List<PeerId> loadRoleSets(final String key) throws ExecutionException, InterruptedException {
final ReadOnlyTransaction tr = this.dataBroker.newReadOnlyTransaction();
final Optional<NeighborSet> result = tr.read(LogicalDatastoreType.CONFIGURATION, NEIGHBOR_SET_IID.child(NeighborSet.class, new NeighborSetKey(key))).get();
if (!result.isPresent()) {
return Collections.emptyList();
}
return result.get().getNeighbor().stream().map(nei -> RouterIds.createPeerId(nei.getAddress())).collect(Collectors.toList());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId in project bgpcep by opendaylight.
the class BaseAbstractRouteEntry method fillAdjRibsOut.
@VisibleForTesting
@SuppressWarnings("unchecked")
private void fillAdjRibsOut(@Nullable final Attributes attributes, @Nullable final Route route, final Identifier routeKey, final PeerId fromPeerId, final RouteEntryDependenciesContainer routeEntryDep, final WriteTransaction tx) {
/*
* We need to keep track of routers and populate adj-ribs-out, too. If we do not, we need to
* expose from which client a particular route was learned from in the local RIB, and have
* the listener perform filtering.
*
* We walk the policy set in order to minimize the amount of work we do for multiple peers:
* if we have two eBGP peers, for example, there is no reason why we should perform the translation
* multiple times.
*/
final TablesKey localTK = routeEntryDep.getLocalTablesKey();
final BGPRibRoutingPolicy routingPolicies = routeEntryDep.getRoutingPolicies();
final RIBSupport ribSupport = routeEntryDep.getRibSupport();
for (final Peer toPeer : this.peerTracker.getPeers()) {
if (!filterRoutes(fromPeerId, toPeer, localTK)) {
continue;
}
Optional<Attributes> effAttr = Optional.empty();
final Peer fromPeer = this.peerTracker.getPeer(fromPeerId);
if (fromPeer != null && attributes != null) {
final BGPRouteEntryExportParameters routeEntry = new BGPRouteEntryExportParametersImpl(fromPeer, toPeer);
effAttr = routingPolicies.applyExportPolicies(routeEntry, attributes);
}
final InstanceIdentifier ribOutTarget = ribSupport.createRouteIdentifier(toPeer.getRibOutIId(localTK), routeKey);
if (effAttr.isPresent() && route != null) {
LOG.debug("Write route {} to peer AdjRibsOut {}", route, toPeer.getPeerId());
tx.put(LogicalDatastoreType.OPERATIONAL, ribOutTarget, route);
tx.put(LogicalDatastoreType.OPERATIONAL, ribOutTarget.child(Attributes.class), effAttr.get());
} else {
LOG.trace("Removing {} from transaction for peer {}", ribOutTarget, toPeer.getPeerId());
tx.delete(LogicalDatastoreType.OPERATIONAL, ribOutTarget);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId in project bgpcep by opendaylight.
the class AdjRibInWriter method transform.
AdjRibInWriter transform(final PeerId newPeerId, final YangInstanceIdentifier peerPath, final RIBSupportContextRegistry registry, final Set<TablesKey> tableTypes, final Map<TablesKey, SendReceive> addPathTablesType, @Nullable final RegisterAppPeerListener registerAppPeerListener) {
final DOMDataTreeWriteTransaction tx = this.chain.getDomChain().newWriteOnlyTransaction();
createEmptyPeerStructure(newPeerId, peerPath, tx);
final ImmutableMap<TablesKey, TableContext> tb = createNewTableInstances(peerPath, registry, tableTypes, addPathTablesType, tx);
tx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
if (registerAppPeerListener != null) {
LOG.trace("Application Peer Listener registered");
registerAppPeerListener.register();
}
}
@Override
public void onFailure(final Throwable throwable) {
if (registerAppPeerListener != null) {
LOG.error("Failed to create Empty Structure, Application Peer Listener won't be registered", throwable);
} else {
LOG.error("Failed to create Empty Structure", throwable);
}
}
}, MoreExecutors.directExecutor());
return new AdjRibInWriter(this.ribPath, this.chain, this.role, tb);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId in project bgpcep by opendaylight.
the class AbstractPeer method initializeRibOut.
@Override
public final synchronized <C extends Routes & DataObject & ChoiceIn<Tables>, S extends ChildOf<? super C>> void initializeRibOut(final RouteEntryDependenciesContainer entryDep, final List<ActualBestPathRoutes<C, S>> routesToStore) {
if (ribOutChain == null) {
LOG.debug("Session closed, skip changes to peer AdjRibsOut {}", getPeerId());
return;
}
final RIBSupport<C, S> ribSupport = entryDep.getRIBSupport();
final YangInstanceIdentifier tableRibout = getRibOutIId(ribSupport.tablesKey());
final boolean addPathSupported = supportsAddPathSupported(ribSupport.getTablesKey());
final DOMDataTreeWriteTransaction tx = ribOutChain.newWriteOnlyTransaction();
for (final ActualBestPathRoutes<C, S> initRoute : routesToStore) {
if (!supportsLLGR() && initRoute.isDepreferenced()) {
// Stale Long-lived Graceful Restart routes should not be propagated
continue;
}
final PeerId fromPeerId = initRoute.getFromPeerId();
if (!filterRoutes(fromPeerId, ribSupport.getTablesKey())) {
continue;
}
final MapEntryNode route = initRoute.getRoute();
final Peer fromPeer = entryDep.getPeerTracker().getPeer(fromPeerId);
if (fromPeer == null) {
LOG.debug("Failed to acquire peer structure for {}, ignoring route {}", fromPeerId, initRoute);
continue;
}
final YangInstanceIdentifier routePath = createRoutePath(ribSupport, tableRibout, initRoute, addPathSupported);
applyExportPolicy(entryDep, fromPeerId, route, routePath, initRoute.getAttributes()).ifPresent(attributes -> storeRoute(ribSupport, initRoute, route, routePath, attributes, tx));
}
final FluentFuture<? extends CommitInfo> future = tx.commit();
submitted = future;
future.addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.trace("Successful update commit");
}
@Override
public void onFailure(final Throwable trw) {
LOG.error("Failed update commit", trw);
}
}, MoreExecutors.directExecutor());
}
Aggregations