Search in sources :

Example 46 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.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();
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) RIBSupportContext(org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContext) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)

Example 47 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.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());
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo)

Example 48 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesKey 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);
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo)

Example 49 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesKey in project bgpcep by opendaylight.

the class AdjRibOutListener method onDataTreeChanged.

@Override
public void onDataTreeChanged(final Collection<DataTreeCandidate> changes) {
    LOG.debug("Data change received for AdjRibOut {}", changes);
    for (final DataTreeCandidate tc : changes) {
        LOG.trace("Change {} type {}", tc.getRootNode(), tc.getRootNode().getModificationType());
        for (final DataTreeCandidateNode child : tc.getRootNode().getChildNodes()) {
            for (final DataTreeCandidateNode route : support.changedRoutes(child)) {
                processRouteChange(route);
            }
        }
    }
    if (initalState) {
        final Update endOfRib = BgpPeerUtil.createEndOfRib(tablesKey);
        session.write(endOfRib);
        initalState = false;
    }
    session.flush();
}
Also used : DataTreeCandidate(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate) DataTreeCandidateNode(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode) Update(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update)

Example 50 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesKey in project bgpcep by opendaylight.

the class RibImpl method createRib.

private synchronized RIBImpl createRib(final Global global, final BGPTableTypeRegistryConsumer tableTypeRegistry) {
    afiSafi = getAfiSafiWithDefault(global.getAfiSafis(), true).values();
    final Config globalConfig = global.getConfig();
    asNumber = globalConfig.getAs();
    routerId = IetfInetUtil.INSTANCE.ipv4AddressNoZoneFor(globalConfig.getRouterId());
    clusterId = getGlobalClusterIdentifier(globalConfig);
    final Map<TablesKey, PathSelectionMode> pathSelectionModes = OpenConfigMappingUtil.toPathSelectionMode(afiSafi, tableTypeRegistry).entrySet().stream().collect(Collectors.toMap(entry -> new TablesKey(entry.getKey().getAfi(), entry.getKey().getSafi()), Map.Entry::getValue));
    final BGPRibRoutingPolicy ribPolicy = policyProvider.buildBGPRibPolicy(asNumber.getValue().toJava(), routerId, clusterId, RoutingPolicyUtil.getApplyPolicy(global.getApplyPolicy()));
    return new RIBImpl(tableTypeRegistry, ribId, asNumber, new BgpId(routerId), extensionProvider, dispatcher, codecsRegistry, domBroker, ribPolicy, toTableTypes(afiSafi, tableTypeRegistry), pathSelectionModes);
}
Also used : OpenConfigMappingUtil.getGlobalClusterIdentifier(org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.getGlobalClusterIdentifier) LoggerFactory(org.slf4j.LoggerFactory) BGPDispatcher(org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher) BGPStateProviderRegistry(org.opendaylight.protocol.bgp.rib.spi.state.BGPStateProviderRegistry) IetfInetUtil(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil) Ipv4AddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone) Map(java.util.Map) AfiSafi(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi) RIBImpl(org.opendaylight.protocol.bgp.rib.impl.RIBImpl) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) OpenConfigMappingUtil.toTableTypes(org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.toTableTypes) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Collection(java.util.Collection) Set(java.util.Set) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) PeerId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId) Collectors(java.util.stream.Collectors) Preconditions.checkState(com.google.common.base.Preconditions.checkState) DOMDataBroker(org.opendaylight.mdsal.dom.api.DOMDataBroker) GuardedBy(org.checkerframework.checker.lock.qual.GuardedBy) DOMTransactionChain(org.opendaylight.mdsal.dom.api.DOMTransactionChain) BGPRibRoutingPolicyFactory(org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.BGPRibRoutingPolicyFactory) Registration(org.opendaylight.yangtools.concepts.Registration) BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType) RIB(org.opendaylight.protocol.bgp.rib.impl.spi.RIB) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) DOMTransactionChainListener(org.opendaylight.mdsal.dom.api.DOMTransactionChainListener) Config(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.Config) ClusterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.ClusterIdentifier) BGPRibRoutingPolicy(org.opendaylight.protocol.bgp.rib.spi.policy.BGPRibRoutingPolicy) BgpId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.BgpId) Objects.requireNonNull(java.util.Objects.requireNonNull) RIBSupportContextRegistry(org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContextRegistry) CodecsRegistry(org.opendaylight.protocol.bgp.rib.impl.spi.CodecsRegistry) BGPPeerTracker(org.opendaylight.protocol.bgp.rib.spi.BGPPeerTracker) Global(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Global) Rib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.Rib) Logger(org.slf4j.Logger) BGPRibState(org.opendaylight.protocol.bgp.rib.spi.state.BGPRibState) PathSelectionMode(org.opendaylight.protocol.bgp.mode.api.PathSelectionMode) RibKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.RibKey) DOMDataTreeChangeService(org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService) Futures(com.google.common.util.concurrent.Futures) OpenConfigMappingUtil.getAfiSafiWithDefault(org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUtil.getAfiSafiWithDefault) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) KeyedInstanceIdentifier(org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier) BGPTableTypeRegistryConsumer(org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer) RibId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.RibId) RIBExtensionConsumerContext(org.opendaylight.protocol.bgp.rib.spi.RIBExtensionConsumerContext) BGPRibStateProvider(org.opendaylight.protocol.bgp.rib.spi.state.BGPRibStateProvider) FluentFuture(com.google.common.util.concurrent.FluentFuture) BGPRibRoutingPolicy(org.opendaylight.protocol.bgp.rib.spi.policy.BGPRibRoutingPolicy) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) BgpId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.BgpId) Config(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.Config) PathSelectionMode(org.opendaylight.protocol.bgp.mode.api.PathSelectionMode) Map(java.util.Map) RIBImpl(org.opendaylight.protocol.bgp.rib.impl.RIBImpl)

Aggregations

TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey)40 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey)15 RIBSupport (org.opendaylight.protocol.bgp.rib.spi.RIBSupport)11 KeyedInstanceIdentifier (org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)11 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)9 Before (org.junit.Before)8 Test (org.junit.Test)8 PathSelectionMode (org.opendaylight.protocol.bgp.mode.api.PathSelectionMode)8 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)8 ArrayList (java.util.ArrayList)7 CommitInfo (org.opendaylight.mdsal.common.api.CommitInfo)7 Peer (org.opendaylight.protocol.bgp.rib.spi.Peer)6 Identifier (org.opendaylight.yangtools.yang.binding.Identifier)6 DOMDataTreeWriteTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction)5 RibId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.RibId)5 ChannelFuture (io.netty.channel.ChannelFuture)4 InetSocketAddress (java.net.InetSocketAddress)4 HashMap (java.util.HashMap)4 BGPRouteEntryExportParametersImpl (org.opendaylight.protocol.bgp.mode.impl.BGPRouteEntryExportParametersImpl)4 BGPRouteEntryExportParameters (org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters)4