import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderActivator;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.EvpnSubsequentAddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.L2vpnAddressFamily;
import org.opendaylight.yangtools.concepts.Registration;
import org.osgi.service.component.annotations.Component;
@Override
public List<Registration> startRIBExtensionProvider(final RIBExtensionProviderContext context,
final BindingNormalizedNodeSerializer mappingService) {
- return List.of(context.registerRIBSupport(L2vpnAddressFamily.VALUE, EvpnSubsequentAddressFamily.VALUE,
- new EvpnRibSupport(mappingService)));
+ return List.of(context.registerRIBSupport(new EvpnRibSupport(mappingService)));
}
}
\ No newline at end of file
import org.opendaylight.protocol.bgp.flowspec.l3vpn.ipv6.FlowspecL3vpnIpv6RIBSupport;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderActivator;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.FlowspecL3vpnSubsequentAddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.FlowspecSubsequentAddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv6AddressFamily;
import org.opendaylight.yangtools.concepts.Registration;
import org.osgi.service.component.annotations.Component;
public List<Registration> startRIBExtensionProvider(final RIBExtensionProviderContext context,
final BindingNormalizedNodeSerializer mappingService) {
return List.of(
- context.registerRIBSupport(Ipv4AddressFamily.VALUE, FlowspecSubsequentAddressFamily.VALUE,
- new FlowspecIpv4RIBSupport(mappingService)),
- context.registerRIBSupport(Ipv6AddressFamily.VALUE, FlowspecSubsequentAddressFamily.VALUE,
- new FlowspecIpv6RIBSupport(mappingService)),
- context.registerRIBSupport(Ipv4AddressFamily.VALUE, FlowspecL3vpnSubsequentAddressFamily.VALUE,
- new FlowspecL3vpnIpv4RIBSupport(mappingService)),
- context.registerRIBSupport(Ipv6AddressFamily.VALUE, FlowspecL3vpnSubsequentAddressFamily.VALUE,
- new FlowspecL3vpnIpv6RIBSupport(mappingService)));
+ context.registerRIBSupport(new FlowspecIpv4RIBSupport(mappingService)),
+ context.registerRIBSupport(new FlowspecIpv6RIBSupport(mappingService)),
+ context.registerRIBSupport(new FlowspecL3vpnIpv4RIBSupport(mappingService)),
+ context.registerRIBSupport(new FlowspecL3vpnIpv6RIBSupport(mappingService)));
}
}
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderActivator;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv6AddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.UnicastSubsequentAddressFamily;
import org.opendaylight.yangtools.concepts.Registration;
import org.osgi.service.component.annotations.Component;
public List<Registration> startRIBExtensionProvider(final RIBExtensionProviderContext context,
final BindingNormalizedNodeSerializer mappingService) {
return List.of(
- context.registerRIBSupport(Ipv4AddressFamily.VALUE, UnicastSubsequentAddressFamily.VALUE,
- new IPv4RIBSupport(mappingService)),
- context.registerRIBSupport(Ipv6AddressFamily.VALUE, UnicastSubsequentAddressFamily.VALUE,
- new IPv6RIBSupport(mappingService)));
+ context.registerRIBSupport(new IPv4RIBSupport(mappingService)),
+ context.registerRIBSupport(new IPv6RIBSupport(mappingService)));
}
}
import org.opendaylight.protocol.bgp.l3vpn.unicast.ipv6.VpnIpv6RIBSupport;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderActivator;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.McastMplsLabeledVpnSubsequentAddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv6AddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.MplsLabeledVpnSubsequentAddressFamily;
import org.opendaylight.yangtools.concepts.Registration;
import org.osgi.service.component.annotations.Component;
public List<Registration> startRIBExtensionProvider(final RIBExtensionProviderContext context,
final BindingNormalizedNodeSerializer mappingService) {
return List.of(
- context.registerRIBSupport(Ipv4AddressFamily.VALUE, MplsLabeledVpnSubsequentAddressFamily.VALUE,
- new VpnIpv4RIBSupport(mappingService)),
- context.registerRIBSupport(Ipv6AddressFamily.VALUE, MplsLabeledVpnSubsequentAddressFamily.VALUE,
- new VpnIpv6RIBSupport(mappingService)),
- context.registerRIBSupport(Ipv4AddressFamily.VALUE, McastMplsLabeledVpnSubsequentAddressFamily.VALUE,
- new L3VpnMcastIpv4RIBSupport(mappingService)),
- context.registerRIBSupport(Ipv6AddressFamily.VALUE, McastMplsLabeledVpnSubsequentAddressFamily.VALUE,
- new L3VpnMcastIpv6RIBSupport(mappingService)));
+ context.registerRIBSupport(new VpnIpv4RIBSupport(mappingService)),
+ context.registerRIBSupport(new VpnIpv6RIBSupport(mappingService)),
+ context.registerRIBSupport(new L3VpnMcastIpv4RIBSupport(mappingService)),
+ context.registerRIBSupport(new L3VpnMcastIpv6RIBSupport(mappingService)));
}
}
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderActivator;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.LabeledUnicastSubsequentAddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv6AddressFamily;
import org.opendaylight.yangtools.concepts.Registration;
import org.osgi.service.component.annotations.Component;
public List<Registration> startRIBExtensionProvider(final RIBExtensionProviderContext context,
final BindingNormalizedNodeSerializer mappingService) {
return List.of(
- context.registerRIBSupport(Ipv4AddressFamily.VALUE, LabeledUnicastSubsequentAddressFamily.VALUE,
- new LabeledUnicastIpv4RIBSupport(mappingService)),
- context.registerRIBSupport(Ipv6AddressFamily.VALUE, LabeledUnicastSubsequentAddressFamily.VALUE,
- new LabeledUnicastIpv6RIBSupport(mappingService)));
+ context.registerRIBSupport(new LabeledUnicastIpv4RIBSupport(mappingService)),
+ context.registerRIBSupport(new LabeledUnicastIpv6RIBSupport(mappingService)));
}
}
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderActivator;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.LinkstateAddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.LinkstateSubsequentAddressFamily;
import org.opendaylight.yangtools.concepts.Registration;
import org.osgi.service.component.annotations.Component;
@Override
public List<Registration> startRIBExtensionProvider(final RIBExtensionProviderContext context,
final BindingNormalizedNodeSerializer mappingService) {
- return List.of(context.registerRIBSupport(LinkstateAddressFamily.VALUE,
- LinkstateSubsequentAddressFamily.VALUE, new LinkstateRIBSupport(mappingService)));
+ return List.of(context.registerRIBSupport(new LinkstateRIBSupport(mappingService)));
}
}
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderActivator;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.McastVpnSubsequentAddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv6AddressFamily;
import org.opendaylight.yangtools.concepts.Registration;
import org.osgi.service.component.annotations.Component;
public List<Registration> startRIBExtensionProvider(final RIBExtensionProviderContext context,
final BindingNormalizedNodeSerializer mappingService) {
return List.of(
- context.registerRIBSupport(Ipv4AddressFamily.VALUE, McastVpnSubsequentAddressFamily.VALUE,
- new MvpnIpv4RIBSupport(mappingService)),
- context.registerRIBSupport(Ipv6AddressFamily.VALUE, McastVpnSubsequentAddressFamily.VALUE,
- new MvpnIpv6RIBSupport(mappingService)));
+ context.registerRIBSupport(new MvpnIpv4RIBSupport(mappingService)),
+ context.registerRIBSupport(new MvpnIpv6RIBSupport(mappingService)));
}
}
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderActivator;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext;
import org.opendaylight.protocol.bgp.route.targetcontrain.impl.RouteTargetConstrainRIBSupport;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.RouteTargetConstrainSubsequentAddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily;
import org.opendaylight.yangtools.concepts.Registration;
import org.osgi.service.component.annotations.Component;
@Override
public List<Registration> startRIBExtensionProvider(final RIBExtensionProviderContext context,
final BindingNormalizedNodeSerializer mappingService) {
- return List.of(
- context.registerRIBSupport(Ipv4AddressFamily.VALUE, RouteTargetConstrainSubsequentAddressFamily.VALUE,
- new RouteTargetConstrainRIBSupport(mappingService)));
+ return List.of(context.registerRIBSupport(new RouteTargetConstrainRIBSupport(mappingService)));
}
}
\ No newline at end of file
private void onRoutesDeleted(final RIBSupport<?, ?> ribSupport, final YangInstanceIdentifier effectiveTablePath,
final Collection<MapEntryNode> deletedRoutes) {
- if (RouteTargetConstrainSubsequentAddressFamily.VALUE.equals(ribSupport.getSafi())) {
+ if (RouteTargetConstrainSubsequentAddressFamily.VALUE.equals(ribSupport.getTablesKey().getSafi())) {
final YangInstanceIdentifier routesPath = routeMapPath(ribSupport, effectiveTablePath);
for (final MapEntryNode routeBefore : deletedRoutes) {
deleteRouteTarget(ribSupport, routesPath.node(routeBefore.getIdentifier()), routeBefore);
private void handleRouteTarget(final ModificationType modificationType, final RIBSupport<?, ?> ribSupport,
final YangInstanceIdentifier routeIdPath, final NormalizedNode route) {
- if (RouteTargetConstrainSubsequentAddressFamily.VALUE.equals(ribSupport.getSafi())) {
+ if (RouteTargetConstrainSubsequentAddressFamily.VALUE.equals(ribSupport.getTablesKey().getSafi())) {
final var rtc = (RouteTargetConstrainRoute) ribSupport.fromNormalizedNode(routeIdPath, route);
if (ModificationType.DELETE == modificationType) {
deleteRouteTarget(rtc);
return routesListIdentifier;
}
- @Override
- public final AddressFamily getAfi() {
- return tk.getAfi();
- }
-
- @Override
- public final SubsequentAddressFamily getSafi() {
- return tk.getSafi();
- }
-
/**
* Build MpReachNlri object from DOM representation.
*
*/
private MpReachNlri buildReach(final Collection<MapEntryNode> routes, final CNextHop hop) {
return new MpReachNlriBuilder()
- .setAfi(getAfi())
- .setSafi(getSafi())
+ .setAfi(tk.getAfi())
+ .setSafi(tk.getSafi())
.setCNextHop(hop)
.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(buildDestination(routes)).build())
.build();
*/
private MpUnreachNlri buildUnreach(final Collection<MapEntryNode> routes) {
return new MpUnreachNlriBuilder()
- .setAfi(getAfi())
- .setSafi(getSafi())
+ .setAfi(tk.getAfi())
+ .setSafi(tk.getSafi())
.setWithdrawnRoutes(new WithdrawnRoutesBuilder()
.setDestinationType(buildWithdrawnDestination(routes))
.build())
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.bgp.rib.spi;
-
-import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
-
-public abstract class AbstractRIBSupportRegistration<T extends RIBSupport<?, ?>>
- extends AbstractObjectRegistration<T> implements RIBSupportRegistration<T> {
- protected AbstractRIBSupportRegistration(final T instance) {
- super(instance);
- }
-}
package org.opendaylight.protocol.bgp.rib.spi;
import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.AddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.SubsequentAddressFamily;
+import org.opendaylight.yangtools.concepts.Registration;
/**
* Interface for registering AdjRIBsIn factories. In order for a model-driven RIB implementation to work correctly, it
/**
* Register a RIBSupport instance for a particular AFI/SAFI combination.
*
- * @param afi Address Family identifier
- * @param safi Subsequent Address Family identifier
- * @param support T RIBSupport instance
- * @return Registration handle. Call {@link RIBSupportRegistration#close()} method to remove it.
- * @throws NullPointerException if any of the arguments is null
+ * @param support RIBSupport instance
+ * @return Registration handle. Call {@link Registration#close()} method to remove it.
+ * @throws NullPointerException if {@code support} is {@code null}
*/
- <T extends RIBSupport<?, ?>> RIBSupportRegistration<T> registerRIBSupport(
- @NonNull AddressFamily afi, @NonNull SubsequentAddressFamily safi, T support);
+ @NonNull Registration registerRIBSupport(RIBSupport<?, ?> support);
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.AddressFamily;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.SubsequentAddressFamily;
import org.opendaylight.yangtools.yang.binding.BindingObject;
import org.opendaylight.yangtools.yang.binding.ChildOf;
import org.opendaylight.yangtools.yang.binding.ChoiceIn;
@NonNull Update buildUpdate(@NonNull Collection<MapEntryNode> advertised,
@NonNull Collection<MapEntryNode> withdrawn, @NonNull Attributes attr);
- @NonNull AddressFamily getAfi();
-
- @NonNull SubsequentAddressFamily getSafi();
-
/**
* Creates Route table Peer InstanceIdentifier.
*
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.bgp.rib.spi;
-
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-
-/**
- * A registration of a {@link RIBSupport} instance.
- *
- * @param <T> {@link RIBSupport} type
- */
-public interface RIBSupportRegistration<T extends RIBSupport<?, ?>> extends ObjectRegistration<T> {
-
-}
}
/**
- * Creates Yang Instance Identifier path argument from supplied AFI and SAFI.
+ * Creates Yang Instance Identifier path argument from supplied {@link TablesKey}.
*
- * @param afi Class representing AFI
- * @param safi Class representing SAFI
+ * @param tablesKey Tables key representing table.
* @return NodeIdentifierWithPredicates of {@link Tables} for specified AFI, SAFI combination.
*/
- public static NodeIdentifierWithPredicates toYangTablesKey(final AddressFamily afi,
- final SubsequentAddressFamily safi) {
- return toYangKey(Tables.QNAME, afi, safi);
+ public static NodeIdentifierWithPredicates toYangTablesKey(final TablesKey tablesKey) {
+ return toYangKey(Tables.QNAME, tablesKey.getAfi(), tablesKey.getSafi());
}
/**
BindingReflections.getQName(afi), BindingReflections.getQName(safi)));
}
- /**
- * Creates Yang Instance Identifier path argument from supplied AFI and SAFI.
- *
- * @param id QNAME representing node
- * @param afi Class representing AFI
- * @param safi Class representing SAFI
- * @return NodeIdentifierWithPredicates of 'id' for specified AFI, SAFI combination.
- */
- public static NodeIdentifierWithPredicates toYangPathKey(final QName id, final AddressFamily afi,
- final SubsequentAddressFamily safi) {
- return NodeIdentifierWithPredicates.of(id, ADD_PATH_AFI_SAFI_TEMPLATE.instantiateWithValues(
- BindingReflections.getQName(afi), BindingReflections.getQName(safi)));
- }
-
/**
* Creates Yang Instance Identifier path argument from supplied {@link TablesKey}.
*
* @param tablesKey Tables key representing table.
* @return NodeIdentifierWithPredicates of 'id' for specified AFI, SAFI combination.
*/
- @SuppressWarnings("checkstyle:OverloadMethodsDeclarationOrder")
public static NodeIdentifierWithPredicates toYangKey(final QName id, final TablesKey tablesKey) {
return toYangKey(id, tablesKey.getAfi(), tablesKey.getSafi());
}
}
/**
- * Creates Yang Instance Identifier path argument from supplied {@link TablesKey}.
+ * Creates Yang Instance Identifier path argument from supplied AFI and SAFI.
*
- * @param tablesKey Tables key representing table.
- * @return NodeIdentifierWithPredicates of {@link Tables} for specified AFI, SAFI combination.
+ * @param id QNAME representing node
+ * @param afi Class representing AFI
+ * @param safi Class representing SAFI
+ * @return NodeIdentifierWithPredicates of 'id' for specified AFI, SAFI combination.
*/
- @SuppressWarnings("checkstyle:OverloadMethodsDeclarationOrder")
- public static NodeIdentifierWithPredicates toYangTablesKey(final TablesKey tablesKey) {
- return toYangTablesKey(tablesKey.getAfi(), tablesKey.getSafi());
+ public static NodeIdentifierWithPredicates toYangPathKey(final QName id, final AddressFamily afi,
+ final SubsequentAddressFamily safi) {
+ return NodeIdentifierWithPredicates.of(id, ADD_PATH_AFI_SAFI_TEMPLATE.instantiateWithValues(
+ BindingReflections.getQName(afi), BindingReflections.getQName(safi)));
}
}
*/
package org.opendaylight.protocol.bgp.rib.spi;
-import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
import java.util.concurrent.ConcurrentHashMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.SubsequentAddressFamily;
+import org.opendaylight.yangtools.concepts.AbstractRegistration;
+import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.ChildOf;
import org.opendaylight.yangtools.yang.binding.ChoiceIn;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class SimpleRIBExtensionProviderContext implements RIBExtensionProviderContext {
- private static final Logger LOG = LoggerFactory.getLogger(SimpleRIBExtensionProviderContext.class);
-
- private final ConcurrentMap<TablesKey, RIBSupport<?, ?>> supports = new ConcurrentHashMap<>();
private final ConcurrentMap<NodeIdentifierWithPredicates, RIBSupport<?, ?>> domSupports = new ConcurrentHashMap<>();
+ private final ConcurrentMap<TablesKey, RIBSupport<?, ?>> supports = new ConcurrentHashMap<>();
@Override
- public <T extends RIBSupport<?, ?>> RIBSupportRegistration<T> registerRIBSupport(
- final AddressFamily afi, final SubsequentAddressFamily safi, final T support) {
- final TablesKey key = new TablesKey(afi, safi);
- final RIBSupport<?, ?> prev = supports.putIfAbsent(key, support);
- checkArgument(prev == null, "AFI %s SAFI %s is already registered with %s", afi, safi, prev);
- domSupports.put(RibSupportUtils.toYangTablesKey(afi, safi), support);
- return new AbstractRIBSupportRegistration<>(support) {
+ public Registration registerRIBSupport(final RIBSupport<?, ?> support) {
+ final var bindingKey = support.getTablesKey();
+ final var prevBinding = supports.putIfAbsent(bindingKey, support);
+ if (prevBinding != null) {
+ throw new IllegalStateException(bindingKey + " is already registered with " + prevBinding);
+ }
+
+ final var domKey = support.tablesKey();
+ final var prevDom = domSupports.putIfAbsent(domKey, support);
+ if (prevDom != null) {
+ throw new IllegalStateException(domKey + " is already registered with " + prevDom);
+ }
+
+ return new AbstractRegistration() {
@Override
protected void removeRegistration() {
// FIXME: clean up registrations, too
- supports.remove(key);
+ supports.remove(bindingKey, support);
+ domSupports.remove(domKey, support);
}
};
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.rib.LocRib;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
import org.opendaylight.yangtools.yang.binding.ChildOf;
import org.opendaylight.yangtools.yang.binding.ChoiceIn;
}
protected final MapEntryNode createEmptyTable() {
- final Tables tables = new TablesBuilder().withKey(getTablesKey())
+ final Tables tables = new TablesBuilder().withKey(abstractRIBSupport.getTablesKey())
.setAttributes(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329
.rib.tables.AttributesBuilder().build()).build();
return (MapEntryNode) adapter.currentSerializer().toNormalizedNode(tablesIId(), tables).getValue();
}
protected final ChoiceNode createRoutes(final Routes routes) {
- final Tables tables = new TablesBuilder().withKey(getTablesKey()).setRoutes(routes).build();
+ final Tables tables = new TablesBuilder().withKey(abstractRIBSupport.getTablesKey()).setRoutes(routes).build();
return (ChoiceNode) verifyNotNull(((MapEntryNode) adapter.currentSerializer()
.toNormalizedNode(tablesIId(), tables).getValue())
.childByArg(new NodeIdentifier(BindingReflections.findQName(Routes.class))));
return ((MapNode) container.getChildByArg(routeNid)).body();
}
- private TablesKey getTablesKey() {
- return new TablesKey(abstractRIBSupport.getAfi(), abstractRIBSupport.getSafi());
- }
-
private InstanceIdentifier<Tables> tablesIId() {
- return RIB.child(Tables.class, getTablesKey());
+ return RIB.child(Tables.class, abstractRIBSupport.getTablesKey());
}
private InstanceIdentifier<S> routesIId() {
}
@Test
- public void getAfi() {
- assertEquals(Ipv4AddressFamily.VALUE, ribSupportTestImp.getAfi());
- }
-
- @Test
- public void getSafi() {
- assertEquals(UnicastSubsequentAddressFamily.VALUE, ribSupportTestImp.getSafi());
+ public void getTablesKey() {
+ assertEquals(new TablesKey(Ipv4AddressFamily.VALUE, UnicastSubsequentAddressFamily.VALUE),
+ ribSupportTestImp.getTablesKey());
}
@Test
public void routesContainerIdentifier() {
- assertEquals(IPV4_ROUTES_IDENTIFIER,ribSupportTestImp.routesContainerIdentifier());
-
+ assertEquals(IPV4_ROUTES_IDENTIFIER, ribSupportTestImp.routesContainerIdentifier());
}
@Test
UnicastSubsequentAddressFamily.VALUE);
static {
- final QName afi = QName.create("urn:opendaylight:params:xml:ns:yang:bgp-rib?revision=2018-03-29",
- "afi");
- final QName safi = QName.create("urn:opendaylight:params:xml:ns:yang:bgp-rib?revision=2018-03-29",
- "safi");
+ final QName afi = QName.create("urn:opendaylight:params:xml:ns:yang:bgp-rib?revision=2018-03-29", "afi");
+ final QName safi = QName.create("urn:opendaylight:params:xml:ns:yang:bgp-rib?revision=2018-03-29", "safi");
NII = NodeIdentifierWithPredicates.of(SupportedTables.QNAME, ImmutableMap.of(afi, Ipv4AddressFamily.QNAME,
safi, UnicastSubsequentAddressFamily.QNAME));
NII_PATH = NodeIdentifierWithPredicates.of(SupportedTables.QNAME, ImmutableMap.of(
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.opendaylight.protocol.bgp.rib.spi.RIBQNames.AFI_QNAME;
+import static org.opendaylight.protocol.bgp.rib.spi.RIBQNames.SAFI_QNAME;
import java.util.List;
+import java.util.Map;
import org.junit.Test;
-import org.mockito.Mockito;
import org.opendaylight.mdsal.binding.dom.adapter.AdapterContext;
import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest;
import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTestCustomizer;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.UnicastSubsequentAddressFamily;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
public class SimpleRIBExtensionTest extends AbstractConcurrentDataBrokerTest {
private AdapterContext adapter;
@Test
public void testExtensionProvider() {
- final BindingNormalizedNodeSerializer codec = adapter.currentSerializer();
+ final var codec = adapter.currentSerializer();
var ctx = new DefaultRIBExtensionConsumerContext(codec);
assertNull(ctx.getRIBSupport(Ipv4AddressFamily.VALUE, UnicastSubsequentAddressFamily.VALUE));
@Override
public List<Registration> startRIBExtensionProvider(final RIBExtensionProviderContext context,
final BindingNormalizedNodeSerializer mappingService) {
- final RIBSupport<?, ?> support = Mockito.mock(RIBSupport.class);
+ final var support = mock(RIBSupport.class);
doReturn(Route.class).when(support).routesListClass();
doReturn(DataObject.class).when(support).routesContainerClass();
doReturn(DataObject.class).when(support).routesCaseClass();
- return List.of(context.registerRIBSupport(Ipv4AddressFamily.VALUE,
- UnicastSubsequentAddressFamily.VALUE, support));
+ doReturn(new TablesKey(Ipv4AddressFamily.VALUE, UnicastSubsequentAddressFamily.VALUE)).when(support)
+ .getTablesKey();
+ doReturn(NodeIdentifierWithPredicates.of(Tables.QNAME,
+ Map.of(AFI_QNAME, Ipv4AddressFamily.QNAME, SAFI_QNAME, UnicastSubsequentAddressFamily.QNAME)))
+ .when(support).tablesKey();
+ return List.of(context.registerRIBSupport(support));
}
}
}