Search in sources :

Example 6 with Peer

use of org.opendaylight.protocol.bgp.rib.spi.Peer 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);
        }
    }
}
Also used : BGPRibRoutingPolicy(org.opendaylight.protocol.bgp.rib.spi.policy.BGPRibRoutingPolicy) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) RIBSupport(org.opendaylight.protocol.bgp.rib.spi.RIBSupport) Peer(org.opendaylight.protocol.bgp.rib.spi.Peer) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) BGPRouteEntryExportParametersImpl(org.opendaylight.protocol.bgp.mode.impl.BGPRouteEntryExportParametersImpl) BGPRouteEntryExportParameters(org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

Peer (org.opendaylight.protocol.bgp.rib.spi.Peer)6 RIBSupport (org.opendaylight.protocol.bgp.rib.spi.RIBSupport)5 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)5 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)5 KeyedInstanceIdentifier (org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)5 BGPRouteEntryExportParametersImpl (org.opendaylight.protocol.bgp.mode.impl.BGPRouteEntryExportParametersImpl)4 BGPRouteEntryExportParameters (org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters)4 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey)4 Route (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.Route)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 MoreObjects (com.google.common.base.MoreObjects)1 ToStringHelper (com.google.common.base.MoreObjects.ToStringHelper)1 Objects (com.google.common.base.Objects)1 CacheBuilder (com.google.common.cache.CacheBuilder)1 CacheLoader (com.google.common.cache.CacheLoader)1 LoadingCache (com.google.common.cache.LoadingCache)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 InetAddresses (com.google.common.net.InetAddresses)1 Futures (com.google.common.util.concurrent.Futures)1