<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint.core</artifactId>
+ </dependency>
<!-- Test dependencies -->
<dependency>
--- /dev/null
+/*
+ * Copyright (c) 2016 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.bgpcep.bgp.topology.provider;
+
+import com.google.common.collect.Maps;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.opendaylight.bgpcep.bgp.topology.provider.spi.BgpTopologyDeployer;
+import org.opendaylight.bgpcep.bgp.topology.provider.spi.BgpTopologyProvider;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.protocol.bgp.rib.DefaultRibReference;
+import org.opendaylight.protocol.bgp.rib.RibReference;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.BgpRib;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.Rib;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.RibKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.topology.config.rev160726.Topology1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.topology.types.rev160524.TopologyTypes1;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yangtools.concepts.AbstractRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class AbstractBgpTopologyProvider implements BgpTopologyProvider, AutoCloseable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractBgpTopologyProvider.class);
+
+ private final Map<TopologyId, Entry<TopologyReferenceAutoCloseable, AbstractRegistration>> topologyBuilders = new HashMap<>();
+ private final AbstractRegistration registration;
+ private final DataBroker dataBroker;
+ private final BgpTopologyDeployer deployer;
+
+ public AbstractBgpTopologyProvider(final BgpTopologyDeployer deployer) {
+ this.deployer = deployer;
+ this.registration = deployer.registerTopologyProvider(this);
+ this.dataBroker = deployer.getDataBroker();
+ }
+
+ @Override
+ public final void onTopologyBuilderCreated(final Topology topology) {
+ LOG.debug("Cretaing topology builder instance {}", topology);
+ final TopologyReferenceAutoCloseable topologyBuilder = createInstance(topology);
+ final AbstractRegistration serviceRegistration = this.deployer.registerTopologyReference(topologyBuilder);
+ this.topologyBuilders.put(getTopologyId(topologyBuilder), Maps.immutableEntry(topologyBuilder, serviceRegistration));
+ LOG.debug("Topology builder instance created {}", topologyBuilder);
+ }
+
+ @Override
+ public final void onTopologyBuilderRemoved(final Topology topology) {
+ LOG.debug("Removing topology builder instance {}", topology);
+ final Entry<TopologyReferenceAutoCloseable, AbstractRegistration> topologyBuilder = this.topologyBuilders.remove(topology.getTopologyId());
+ if (topologyBuilder != null) {
+ topologyBuilder.getValue().close();
+ topologyBuilder.getKey().close();
+ LOG.debug("Topology builder instance removed {}", topologyBuilder);
+ }
+ }
+
+ @Override
+ public final void close() {
+ this.registration.close();
+ }
+
+ @Override
+ public final boolean topologyTypeFilter(final Topology topology) {
+ final TopologyTypes1 topologyTypes = topology.getTopologyTypes().getAugmentation(TopologyTypes1.class);
+ if (topologyTypes == null) {
+ return false;
+ }
+ return topologyTypeFilter(topologyTypes);
+ }
+
+ TopologyReferenceAutoCloseable createInstance(final Topology topology) {
+ final RibReference ribReference = new DefaultRibReference(InstanceIdentifier.create(BgpRib.class).child(Rib.class, new RibKey(topology.getAugmentation(Topology1.class).getRibId())));
+ return initiate(this.dataBroker, ribReference, topology.getTopologyId());
+ }
+
+ abstract TopologyReferenceAutoCloseable initiate(final DataBroker dataProvider, final RibReference locRibReference,
+ final TopologyId topologyId);
+
+ abstract boolean topologyTypeFilter(TopologyTypes1 topology);
+
+ private static TopologyId getTopologyId(final TopologyReferenceAutoCloseable topologyBuilder) {
+ return topologyBuilder.getInstanceIdentifier().firstKeyOf(Topology.class).getTopologyId();
+ }
+
+}
this.listenerResetLimitInMillsec = listenerResetLimitInMillsec;
this.listenerResetEnforceCounter = listenerResetEnforceCounter;
this.topology = InstanceIdentifier.builder(NetworkTopology.class).child(Topology.class, this.topologyKey).build();
-
- LOG.debug("Initiating topology builder from {} at {}. AFI={}, SAFI={}", locRibReference, this.topology, this.afi, this.safi);
- initTransactionChain();
- initOperationalTopology();
- registerDataChangeListener();
}
protected AbstractTopologyBuilder(final DataBroker dataProvider, final RibReference locRibReference,
this(dataProvider, locRibReference, topologyId, types, afi, safi, LISTENER_RESET_LIMIT_IN_MILLSEC, LISTENER_RESET_ENFORCE_COUNTER);
}
+ public final synchronized void start() {
+ LOG.debug("Initiating topology builder from {} at {}. AFI={}, SAFI={}", this.locRibReference, this.topology, this.afi, this.safi);
+ initTransactionChain();
+ initOperationalTopology();
+ registerDataChangeListener();
+ }
+
@Deprecated
public final InstanceIdentifier<Tables> tableInstanceIdentifier(final Class<? extends AddressFamily> afi,
final Class<? extends SubsequentAddressFamily> safi) {
}
@Override
- public final synchronized void close() throws TransactionCommitFailedException {
+ public final synchronized void close() {
if (this.closed) {
LOG.trace("Transaction chain was already closed.");
return;
trans.delete(LogicalDatastoreType.OPERATIONAL, getInstanceIdentifier());
try {
trans.submit().checkedGet();
- } catch (TransactionCommitFailedException e) {
+ } catch (final TransactionCommitFailedException e) {
LOG.error("Unable to reset operational topology {} (transaction {})", this.topology, trans.getIdentifier(), e);
}
}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.bgpcep.bgp.topology.provider;
+
+import com.google.common.reflect.AbstractInvocationHandler;
+import com.google.common.reflect.Reflection;
+import java.lang.reflect.Method;
+import org.opendaylight.bgpcep.topology.TopologyReference;
+import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.RibId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.Rib;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.RibKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.topology.config.rev160726.Topology1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.topology.config.rev160726.Topology1Builder;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.TopologyTypes;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
+import org.osgi.framework.BundleContext;
+
+public final class BackwardsCssTopologyProvider {
+
+ public static TopologyReferenceAutoCloseable createBackwardsCssInstance(final TopologyTypes topologyTypes, final TopologyId topologyId, final DataBroker dataBroker, final BundleContext bundleContext,
+ final KeyedInstanceIdentifier<Rib, RibKey> ribIId) {
+ //map configuration to topology
+ final Topology topology = createConfiguration(topologyTypes, topologyId, ribIId.getKey().getId());
+ //write to configuration DS
+ final KeyedInstanceIdentifier<Topology, TopologyKey> topologyIId = InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, topology.getKey());
+ writeConfiguration(dataBroker, topologyIId, topology);
+ //get topology service, use filter
+ final WaitingServiceTracker<TopologyReference> topologyTracker = WaitingServiceTracker.create(TopologyReference.class,
+ bundleContext, "(" + "topology-id" + "=" + topology.getTopologyId().getValue() + ")");
+ final TopologyReference topologyService = topologyTracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
+ return Reflection.newProxy(TopologyReferenceAutoCloseable.class, new AbstractInvocationHandler() {
+ @Override
+ protected Object handleInvocation(final Object proxy, final Method method, final Object[] args) throws Throwable {
+ if (method.getName().equals("close")) {
+ removeConfiguration(dataBroker, topologyIId);
+ topologyTracker.close();
+ return null;
+ } else {
+ return method.invoke(topologyService, args);
+ }
+ }
+ });
+ }
+
+ private static Topology createConfiguration(final TopologyTypes topologyTypes, final TopologyId topologyId, final RibId ribId) {
+ final TopologyBuilder topologyBuilder = new TopologyBuilder();
+ topologyBuilder.setTopologyId(topologyId);
+ topologyBuilder.setKey(new TopologyKey(topologyBuilder.getTopologyId()));
+ topologyBuilder.setTopologyTypes(topologyTypes);
+ topologyBuilder.addAugmentation(Topology1.class, new Topology1Builder().setRibId(ribId).build());
+ return topologyBuilder.build();
+ }
+
+ private static void writeConfiguration(final DataBroker dataBroker, final KeyedInstanceIdentifier<Topology, TopologyKey> topologyIId, final Topology topology) {
+ final WriteTransaction wTx = dataBroker.newWriteOnlyTransaction();
+ wTx.put(LogicalDatastoreType.CONFIGURATION, topologyIId, topology, true);
+ wTx.submit();
+ }
+
+ private static void removeConfiguration(final DataBroker dataBroker, final KeyedInstanceIdentifier<Topology, TopologyKey> topologyIId) throws TransactionCommitFailedException {
+ final WriteTransaction wTx = dataBroker.newWriteOnlyTransaction();
+ wTx.delete(LogicalDatastoreType.CONFIGURATION, topologyIId);
+ wTx.submit().checkedGet();
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.bgpcep.bgp.topology.provider;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Iterables;
+import java.util.Collection;
+import java.util.Dictionary;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Set;
+import javax.annotation.concurrent.GuardedBy;
+import org.opendaylight.bgpcep.bgp.topology.provider.spi.BgpTopologyDeployer;
+import org.opendaylight.bgpcep.bgp.topology.provider.spi.BgpTopologyProvider;
+import org.opendaylight.bgpcep.topology.TopologyReference;
+import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yangtools.concepts.AbstractRegistration;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class BgpTopologyDeployerImpl implements AutoCloseable, ClusteredDataTreeChangeListener<Topology>, BgpTopologyDeployer {
+
+ private static final Logger LOG = LoggerFactory.getLogger(BgpTopologyDeployerImpl.class);
+
+ @GuardedBy("this")
+ private final Set<BgpTopologyProvider> topologyProviders = new HashSet<>();
+ private final DataBroker dataBroker;
+ private final ListenerRegistration<BgpTopologyDeployerImpl> registration;
+ private final BundleContext context;
+ @GuardedBy("this")
+ private boolean closed;
+
+ public BgpTopologyDeployerImpl(final BundleContext context, final DataBroker dataBroker) {
+ this.context = Preconditions.checkNotNull(context);
+ this.dataBroker = Preconditions.checkNotNull(dataBroker);
+ this.registration =
+ this.dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier<Topology>(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(NetworkTopology.class).child(Topology.class)), this);
+ LOG.info("BGP topology deployer started.");
+ }
+
+ @Override
+ public synchronized void onDataTreeChanged(final Collection<DataTreeModification<Topology>> changes) {
+ if (this.closed) {
+ LOG.trace("BGP Topology Provider Deployer was already closed, skipping changes.");
+ return;
+ }
+ for (final DataTreeModification<Topology> change : changes) {
+ final DataObjectModification<Topology> rootNode = change.getRootNode();
+ final Topology dataBefore = rootNode.getDataBefore();
+ final Topology dataAfter = rootNode.getDataAfter();
+ LOG.trace("BGP topology deployer configuration changed: modification type: [{}], data before:[{}], data after: [{}]", rootNode.getModificationType(), dataBefore, dataAfter);
+ switch (rootNode.getModificationType()) {
+ case DELETE:
+ filterTopologyBuilders(dataBefore).forEach(provider -> provider.onTopologyBuilderRemoved(dataBefore));
+ break;
+ case SUBTREE_MODIFIED:
+ filterTopologyBuilders(dataBefore).forEach(provider -> provider.onTopologyBuilderRemoved(dataBefore));
+ filterTopologyBuilders(dataAfter).forEach(provider -> provider.onTopologyBuilderCreated(dataAfter));
+ break;
+ case WRITE:
+ filterTopologyBuilders(dataAfter).forEach(provider -> provider.onTopologyBuilderCreated(dataAfter));
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ @Override
+ public synchronized AbstractRegistration registerTopologyProvider(final BgpTopologyProvider topologyBuilder) {
+ this.topologyProviders.add(topologyBuilder);
+ return new AbstractRegistration() {
+ @Override
+ protected void removeRegistration() {
+ synchronized (BgpTopologyDeployerImpl.this) {
+ BgpTopologyDeployerImpl.this.topologyProviders.remove(topologyBuilder);
+ }
+ }
+ };
+ }
+
+ @Override
+ public synchronized void close() throws Exception {
+ this.registration.close();
+ LOG.info("BGP topology deployer stopped.");
+ this.closed = true;
+ }
+
+ @Override
+ public DataBroker getDataBroker() {
+ return this.dataBroker;
+ }
+
+ private synchronized Iterable<BgpTopologyProvider> filterTopologyBuilders(final Topology topology) {
+ return Iterables.filter(this.topologyProviders, input -> input.topologyTypeFilter(topology));
+ }
+
+ @Override
+ public AbstractRegistration registerTopologyReference(final TopologyReference topologyReference) {
+ final Dictionary<String, String> properties = new Hashtable<>();
+ properties.put("topology-id", topologyReference.getInstanceIdentifier().firstKeyOf(Topology.class).getTopologyId().getValue());
+ final ServiceRegistration<?> registerService = this.context.registerService(new String[] {TopologyReference.class.getName()}, topologyReference, properties);
+ return new AbstractRegistration() {
+ @Override
+ protected void removeRegistration() {
+ registerService.unregister();
+ }
+ };
+ }
+
+}
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public final class Ipv4ReachabilityTopologyBuilder extends AbstractReachabilityTopologyBuilder<Ipv4Route> {
- private static final TopologyTypes IPV4_TOPOLOGY_TYPE = new TopologyTypesBuilder()
- .addAugmentation(TopologyTypes1.class,
- new TopologyTypes1Builder()
- .setBgpIpv4ReachabilityTopology(new BgpIpv4ReachabilityTopologyBuilder().build()).build())
- .build();
+ public static final TopologyTypes IPV4_TOPOLOGY_TYPE = new TopologyTypesBuilder()
+ .addAugmentation(TopologyTypes1.class,
+ new TopologyTypes1Builder()
+ .setBgpIpv4ReachabilityTopology(new BgpIpv4ReachabilityTopologyBuilder().build()).build())
+ .build();
public Ipv4ReachabilityTopologyBuilder(final DataBroker dataProvider, final RibReference locRibReference,
final TopologyId topologyId) {
--- /dev/null
+/*
+ * Copyright (c) 2016 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.bgpcep.bgp.topology.provider;
+
+import org.opendaylight.bgpcep.bgp.topology.provider.spi.BgpTopologyDeployer;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.protocol.bgp.rib.RibReference;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.topology.types.rev160524.TopologyTypes1;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+
+public final class Ipv4TopologyProvider extends AbstractBgpTopologyProvider {
+
+ public Ipv4TopologyProvider(final BgpTopologyDeployer deployer) {
+ super(deployer);
+ }
+
+ @Override
+ TopologyReferenceAutoCloseable initiate(final DataBroker dataProvider, final RibReference locRibReference,
+ final TopologyId topologyId) {
+ final Ipv4ReachabilityTopologyBuilder builder = new Ipv4ReachabilityTopologyBuilder(dataProvider, locRibReference, topologyId);
+ builder.start();
+ return new TopologyReferenceAutoCloseable() {
+ @Override
+ public void close() {
+ builder.close();
+ }
+
+ @Override
+ public InstanceIdentifier<Topology> getInstanceIdentifier() {
+ return builder.getInstanceIdentifier();
+ }
+ };
+ }
+
+ @Override
+ boolean topologyTypeFilter(final TopologyTypes1 topology) {
+ return topology.getBgpIpv4ReachabilityTopology() != null;
+ }
+
+}
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public final class Ipv6ReachabilityTopologyBuilder extends AbstractReachabilityTopologyBuilder<Ipv6Route> {
- private static final TopologyTypes IPV6_TOPOLOGY_TYPE = new TopologyTypesBuilder()
- .addAugmentation(TopologyTypes1.class,
- new TopologyTypes1Builder()
- .setBgpIpv6ReachabilityTopology(new BgpIpv6ReachabilityTopologyBuilder().build()).build())
- .build();
+ public static final TopologyTypes IPV6_TOPOLOGY_TYPE = new TopologyTypesBuilder()
+ .addAugmentation(TopologyTypes1.class,
+ new TopologyTypes1Builder()
+ .setBgpIpv6ReachabilityTopology(new BgpIpv6ReachabilityTopologyBuilder().build()).build())
+ .build();
public Ipv6ReachabilityTopologyBuilder(final DataBroker dataProvider, final RibReference locRibReference,
final TopologyId topologyId) {
--- /dev/null
+/*
+ * Copyright (c) 2016 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.bgpcep.bgp.topology.provider;
+
+import org.opendaylight.bgpcep.bgp.topology.provider.spi.BgpTopologyDeployer;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.protocol.bgp.rib.RibReference;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.topology.types.rev160524.TopologyTypes1;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public final class Ipv6TopologyProvider extends AbstractBgpTopologyProvider {
+
+ public Ipv6TopologyProvider(final BgpTopologyDeployer deployer) {
+ super(deployer);
+ }
+
+ @Override
+ TopologyReferenceAutoCloseable initiate(final DataBroker dataProvider, final RibReference locRibReference,
+ final TopologyId topologyId) {
+ final Ipv6ReachabilityTopologyBuilder builder = new Ipv6ReachabilityTopologyBuilder(dataProvider, locRibReference, topologyId);
+ builder.start();
+ return new TopologyReferenceAutoCloseable() {
+ @Override
+ public void close() {
+ builder.close();
+ }
+
+ @Override
+ public InstanceIdentifier<Topology> getInstanceIdentifier() {
+ return builder.getInstanceIdentifier();
+ }
+ };
+ }
+
+ @Override
+ boolean topologyTypeFilter(final TopologyTypes1 topology) {
+ return topology.getBgpIpv6ReachabilityTopology() != null;
+ }
+
+}
*/
package org.opendaylight.bgpcep.bgp.topology.provider;
-import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import org.slf4j.LoggerFactory;
public class LinkstateTopologyBuilder extends AbstractTopologyBuilder<LinkstateRoute> {
- private static final TopologyTypes LINKSTATE_TOPOLOGY_TYPE = new TopologyTypesBuilder()
- .addAugmentation(TopologyTypes1.class,
- new TopologyTypes1Builder()
- .setBgpLinkstateTopology(new BgpLinkstateTopologyBuilder().build()).build())
- .build();
+ public static final TopologyTypes LINKSTATE_TOPOLOGY_TYPE = new TopologyTypesBuilder()
+ .addAugmentation(TopologyTypes1.class,
+ new TopologyTypes1Builder()
+ .setBgpLinkstateTopology(new BgpLinkstateTopologyBuilder().build()).build())
+ .build();
private static final String UNHANDLED_OBJECT_CLASS = "Unhandled object class {}";
}
// Re-generate termination points
- this.nb.setTerminationPoint(Lists.newArrayList(Collections2.transform(this.tps.values(), new Function<TpHolder, TerminationPoint>() {
- @Override
- public TerminationPoint apply(final TpHolder input) {
- return input.getTp();
- }
- })));
+ this.nb.setTerminationPoint(Lists.newArrayList(Collections2.transform(this.tps.values(), input -> input.getTp())));
// Re-generate prefixes
this.inab.setPrefix(Lists.newArrayList(this.prefixes.values()));
}
private static TpId buildTpId(final UriBuilder base, final TopologyIdentifier topologyIdentifier,
- final Ipv4InterfaceIdentifier ipv4InterfaceIdentifier, final Ipv6InterfaceIdentifier ipv6InterfaceIdentifier, final Long id) {
+ final Ipv4InterfaceIdentifier ipv4InterfaceIdentifier, final Ipv6InterfaceIdentifier ipv6InterfaceIdentifier, final Long id) {
final UriBuilder b = new UriBuilder(base, "tp");
if (topologyIdentifier != null) {
b.add("mt", topologyIdentifier.getValue());
private static TpId buildLocalTpId(final UriBuilder base, final LinkDescriptors linkDescriptors) {
return buildTpId(base, linkDescriptors.getMultiTopologyId(), linkDescriptors.getIpv4InterfaceAddress(),
- linkDescriptors.getIpv6InterfaceAddress(), linkDescriptors.getLinkLocalIdentifier());
+ linkDescriptors.getIpv6InterfaceAddress(), linkDescriptors.getLinkLocalIdentifier());
}
private static TerminationPoint buildTp(final TpId id, final TerminationPointType type) {
if (type != null) {
stpb.addAugmentation(TerminationPoint1.class, new TerminationPoint1Builder().setIgpTerminationPointAttributes(
- new IgpTerminationPointAttributesBuilder().setTerminationPointType(null).build()).build());
+ new IgpTerminationPointAttributesBuilder().setTerminationPointType(null).build()).build());
}
return stpb.build();
}
private static TerminationPointType getTpType(final Ipv4InterfaceIdentifier ipv4InterfaceIdentifier,
- final Ipv6InterfaceIdentifier ipv6InterfaceIdentifier, final Long id) {
+ final Ipv6InterfaceIdentifier ipv6InterfaceIdentifier, final Long id) {
// Order of preference: Unnumbered first, then IP
if (id != null) {
LOG.debug("Unnumbered termination point type: {}", id);
private static TerminationPoint buildLocalTp(final UriBuilder base, final LinkDescriptors linkDescriptors) {
final TpId id = buildLocalTpId(base, linkDescriptors);
final TerminationPointType t = getTpType(linkDescriptors.getIpv4InterfaceAddress(), linkDescriptors.getIpv6InterfaceAddress(),
- linkDescriptors.getLinkLocalIdentifier());
+ linkDescriptors.getLinkLocalIdentifier());
return buildTp(id, t);
}
private static TpId buildRemoteTpId(final UriBuilder base, final LinkDescriptors linkDescriptors) {
return buildTpId(base, linkDescriptors.getMultiTopologyId(), linkDescriptors.getIpv4NeighborAddress(),
- linkDescriptors.getIpv6NeighborAddress(), linkDescriptors.getLinkRemoteIdentifier());
+ linkDescriptors.getIpv6NeighborAddress(), linkDescriptors.getLinkRemoteIdentifier());
}
private static TerminationPoint buildRemoteTp(final UriBuilder base, final LinkDescriptors linkDescriptors) {
final TpId id = buildRemoteTpId(base, linkDescriptors);
final TerminationPointType t = getTpType(linkDescriptors.getIpv4NeighborAddress(), linkDescriptors.getIpv6NeighborAddress(),
- linkDescriptors.getLinkRemoteIdentifier());
+ linkDescriptors.getLinkRemoteIdentifier());
return buildTp(id, t);
}
private InstanceIdentifier<Link> buildLinkIdentifier(final LinkId id) {
return getInstanceIdentifier().child(
- org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link.class,
- new LinkKey(id));
+ org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link.class,
+ new LinkKey(id));
}
private static Float bandwidthToFloat(final Bandwidth bandwidth) {
}
private static List<UnreservedBandwidth> unreservedBandwidthList(
- final List<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.UnreservedBandwidth> input) {
+ final List<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.UnreservedBandwidth> input) {
final List<UnreservedBandwidth> ret = new ArrayList<>(input.size());
for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev150210.UnreservedBandwidth i : input) {
ret.add(new UnreservedBandwidthBuilder().setBandwidth(bandwidthToBigDecimal(i.getBandwidth())).setKey(
- new UnreservedBandwidthKey(i.getPriority())).build());
+ new UnreservedBandwidthKey(i.getPriority())).build());
}
return ret;
}
private static org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpLinkAttributes1 isisLinkAttributes(
- final TopologyIdentifier topologyIdentifier, final LinkAttributes la) {
+ final TopologyIdentifier topologyIdentifier, final LinkAttributes la) {
final org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.isis.link.attributes.isis.link.attributes.TedBuilder tb = new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.isis.link.attributes.isis.link.attributes.TedBuilder();
if (la != null) {
}
return new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpLinkAttributes1Builder().setIsisLinkAttributes(
- ilab.build()).build();
+ ilab.build()).build();
}
private static org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpLinkAttributes1 ospfLinkAttributes(
- final TopologyIdentifier topologyIdentifier, final LinkAttributes la) {
+ final TopologyIdentifier topologyIdentifier, final LinkAttributes la) {
final org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.ospf.link.attributes.ospf.link.attributes.TedBuilder tb = new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.ospf.link.attributes.ospf.link.attributes.TedBuilder();
if (la != null) {
}
return new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpLinkAttributes1Builder().setOspfLinkAttributes(
- ilab.build()).build();
+ ilab.build()).build();
}
private NodeHolder getNode(final NodeId id) {
case IsisLevel1:
case IsisLevel2:
ilab.addAugmentation(
- org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpLinkAttributes1.class,
- isisLinkAttributes(ld.getMultiTopologyId(), la));
+ org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpLinkAttributes1.class,
+ isisLinkAttributes(ld.getMultiTopologyId(), la));
break;
case OspfV3:
case Ospf:
ilab.addAugmentation(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpLinkAttributes1.class,
- ospfLinkAttributes(ld.getMultiTopologyId(), la));
+ ospfLinkAttributes(ld.getMultiTopologyId(), la));
break;
default:
break;
}
private void createLink(final WriteTransaction trans, final UriBuilder base,
- final LinkstateRoute value, final LinkCase l, final Attributes attributes) {
+ final LinkstateRoute value, final LinkCase l, final Attributes attributes) {
// defensive lookup
final LinkAttributes la;
final Attributes1 attr = attributes.getAugmentation(Attributes1.class);
}
private void removeTp(final WriteTransaction trans, final NodeId node, final TpId tp,
- final LinkId link, final boolean isRemote) {
+ final LinkId link, final boolean isRemote) {
final NodeHolder nh = this.nodes.get(node);
if (nh != null) {
final InstanceIdentifier<Node> nid = getNodeInstanceIdentifier(new NodeKey((NodeId) nh.getNodeId()));
}
private static org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpNodeAttributes1 isisNodeAttributes(
- final NodeIdentifier node, final NodeAttributes na) {
+ final NodeIdentifier node, final NodeAttributes na) {
final org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.isis.node.attributes.isis.node.attributes.TedBuilder tb = new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.isis.node.attributes.isis.node.attributes.TedBuilder();
final IsisNodeAttributesBuilder ab = new IsisNodeAttributesBuilder();
ab.setTed(tb.build());
return new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpNodeAttributes1Builder().setIsisNodeAttributes(
- ab.build()).build();
+ ab.build()).build();
}
private static List<IsoNetId> toIsoNetIds(final List<IsisAreaIdentifier> areaIds, final String systemId) {
- return Lists.transform(areaIds, new Function<IsisAreaIdentifier, IsoNetId>() {
- @Override
- public IsoNetId apply(final IsisAreaIdentifier input) {
- return new IsoNetId(UriBuilder.toIsoNetId(input, systemId));
- }
- });
+ return Lists.transform(areaIds, input -> new IsoNetId(UriBuilder.toIsoNetId(input, systemId)));
}
private static org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpNodeAttributes1 ospfNodeAttributes(
- final NodeIdentifier node, final NodeAttributes na) {
+ final NodeIdentifier node, final NodeAttributes na) {
final org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.ospf.node.attributes.ospf.node.attributes.TedBuilder tb = new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.ospf.node.attributes.ospf.node.attributes.TedBuilder();
final OspfNodeAttributesBuilder ab = new OspfNodeAttributesBuilder();
if (na != null) {
}
ab.setTed(tb.build());
return new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpNodeAttributes1Builder().setOspfNodeAttributes(
- ab.build()).build();
+ ab.build()).build();
}
private static void augmentProtocolId(final LinkstateRoute value, final IgpNodeAttributesBuilder inab,
case IsisLevel1:
case IsisLevel2:
inab.addAugmentation(
- org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpNodeAttributes1.class,
- isisNodeAttributes(nd, na));
+ org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpNodeAttributes1.class,
+ isisNodeAttributes(nd, na));
break;
case Ospf:
inab.addAugmentation(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpNodeAttributes1.class,
- ospfNodeAttributes(nd, na));
+ ospfNodeAttributes(nd, na));
break;
default:
break;
}
private void createNode(final WriteTransaction trans, final UriBuilder base,
- final LinkstateRoute value, final NodeCase n, final Attributes attributes) {
+ final LinkstateRoute value, final NodeCase n, final Attributes attributes) {
final NodeAttributes na;
//defensive lookup
final Attributes1 attr = attributes.getAugmentation(Attributes1.class);
case Ospf:
if (pa != null && pa.getOspfForwardingAddress() != null) {
pb.addAugmentation(
- Prefix1.class,
- new Prefix1Builder().setOspfPrefixAttributes(
- new OspfPrefixAttributesBuilder().setForwardingAddress(pa.getOspfForwardingAddress().getIpv4Address()).build()).build());
+ Prefix1.class,
+ new Prefix1Builder().setOspfPrefixAttributes(
+ new OspfPrefixAttributesBuilder().setForwardingAddress(pa.getOspfForwardingAddress().getIpv4Address()).build()).build());
}
break;
default:
}
private void createPrefix(final WriteTransaction trans, final UriBuilder base,
- final LinkstateRoute value, final PrefixCase p, final Attributes attributes) {
+ final LinkstateRoute value, final PrefixCase p, final Attributes attributes) {
final IpPrefix ippfx = p.getPrefixDescriptors().getIpReachabilityInformation();
if (ippfx == null) {
LOG.warn("IP reachability not present in prefix {} route {}, skipping it", p, value);
@Override
protected void createObject(final ReadWriteTransaction trans,
- final InstanceIdentifier<LinkstateRoute> id, final LinkstateRoute value) {
+ final InstanceIdentifier<LinkstateRoute> id, final LinkstateRoute value) {
final UriBuilder base = new UriBuilder(value);
final ObjectType t = value.getObjectType();
@Override
protected void removeObject(final ReadWriteTransaction trans,
- final InstanceIdentifier<LinkstateRoute> id, final LinkstateRoute value) {
+ final InstanceIdentifier<LinkstateRoute> id, final LinkstateRoute value) {
final UriBuilder base = new UriBuilder(value);
final ObjectType t = value.getObjectType();
--- /dev/null
+/*
+ * Copyright (c) 2016 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.bgpcep.bgp.topology.provider;
+
+import org.opendaylight.bgpcep.bgp.topology.provider.spi.BgpTopologyDeployer;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.protocol.bgp.rib.RibReference;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.topology.types.rev160524.TopologyTypes1;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public final class LinkstateTopologyProvider extends AbstractBgpTopologyProvider {
+
+ public LinkstateTopologyProvider(final BgpTopologyDeployer deployer) {
+ super(deployer);
+ }
+
+ @Override
+ TopologyReferenceAutoCloseable initiate(final DataBroker dataProvider, final RibReference locRibReference,
+ final TopologyId topologyId) {
+ final LinkstateTopologyBuilder builder = new LinkstateTopologyBuilder(dataProvider, locRibReference, topologyId);
+ builder.start();
+ return new TopologyReferenceAutoCloseable() {
+ @Override
+ public void close() {
+ builder.close();
+ }
+
+ @Override
+ public InstanceIdentifier<Topology> getInstanceIdentifier() {
+ return builder.getInstanceIdentifier();
+ }
+ };
+ }
+
+ @Override
+ boolean topologyTypeFilter(final TopologyTypes1 topology) {
+ return topology.getBgpLinkstateTopology() != null;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.bgpcep.bgp.topology.provider;
+
+import org.opendaylight.bgpcep.topology.TopologyReference;
+
+public interface TopologyReferenceAutoCloseable extends AutoCloseable, TopologyReference {
+
+ @Override
+ public void close();
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.bgpcep.bgp.topology.provider.spi;
+
+import org.opendaylight.bgpcep.topology.TopologyReference;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.yangtools.concepts.AbstractRegistration;
+
+public interface BgpTopologyDeployer {
+
+ AbstractRegistration registerTopologyProvider(BgpTopologyProvider topologyBuilder);
+
+ DataBroker getDataBroker();
+
+ AbstractRegistration registerTopologyReference(TopologyReference topologyReference);
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.bgpcep.bgp.topology.provider.spi;
+
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+
+
+public interface BgpTopologyProvider {
+
+ boolean topologyTypeFilter(Topology topology);
+
+ void onTopologyBuilderRemoved(Topology topology);
+
+ void onTopologyBuilderCreated(Topology topology);
+
+}
*/
package org.opendaylight.controller.config.yang.bgp.reachability.ipv4;
-import java.util.concurrent.ExecutionException;
+import org.opendaylight.bgpcep.bgp.topology.provider.BackwardsCssTopologyProvider;
import org.opendaylight.bgpcep.bgp.topology.provider.Ipv4ReachabilityTopologyBuilder;
-import org.opendaylight.bgpcep.topology.DefaultTopologyReference;
+import org.opendaylight.controller.config.api.DependencyResolver;
import org.opendaylight.controller.config.api.JmxAttributeValidationException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.osgi.framework.BundleContext;
/**
*
*/
-public final class Ipv4ReachabilityTopologyBuilderModule extends
- org.opendaylight.controller.config.yang.bgp.reachability.ipv4.AbstractIpv4ReachabilityTopologyBuilderModule {
- private static final Logger LOG = LoggerFactory.getLogger(Ipv4ReachabilityTopologyBuilderModule.class);
+public final class Ipv4ReachabilityTopologyBuilderModule extends AbstractIpv4ReachabilityTopologyBuilderModule {
- public Ipv4ReachabilityTopologyBuilderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
- final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ private BundleContext bundleContext;
+
+ public Ipv4ReachabilityTopologyBuilderModule(final ModuleIdentifier identifier, final DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
}
- public Ipv4ReachabilityTopologyBuilderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
- final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
- final Ipv4ReachabilityTopologyBuilderModule oldModule, final java.lang.AutoCloseable oldInstance) {
+ public Ipv4ReachabilityTopologyBuilderModule(final ModuleIdentifier identifier, final DependencyResolver dependencyResolver, final Ipv4ReachabilityTopologyBuilderModule oldModule,
+ final AutoCloseable oldInstance) {
super(identifier, dependencyResolver, oldModule, oldInstance);
}
@Override
public java.lang.AutoCloseable createInstance() {
- return new Ipv4ReachabilityTopologyBuilder(getDataProviderDependency(), getLocalRibDependency(), getTopologyId());
+ return BackwardsCssTopologyProvider.createBackwardsCssInstance(Ipv4ReachabilityTopologyBuilder.IPV4_TOPOLOGY_TYPE, getTopologyId(), getDataProviderDependency(), this.bundleContext,
+ getLocalRibDependency().getInstanceIdentifier());
+ }
+ public void setBundleContext(final BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
}
}
*/
package org.opendaylight.controller.config.yang.bgp.reachability.ipv4;
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
+import org.opendaylight.controller.config.spi.Module;
+import org.osgi.framework.BundleContext;
+
/**
*
*/
-public class Ipv4ReachabilityTopologyBuilderModuleFactory extends
- org.opendaylight.controller.config.yang.bgp.reachability.ipv4.AbstractIpv4ReachabilityTopologyBuilderModuleFactory {
+public class Ipv4ReachabilityTopologyBuilderModuleFactory extends AbstractIpv4ReachabilityTopologyBuilderModuleFactory {
+
+ @Override
+ public Module createModule(final String instanceName, final DependencyResolver dependencyResolver, final BundleContext bundleContext) {
+ final Ipv4ReachabilityTopologyBuilderModule module = (Ipv4ReachabilityTopologyBuilderModule) super.createModule(instanceName, dependencyResolver, bundleContext);
+ module.setBundleContext(bundleContext);
+ return module;
+ }
+
+ @Override
+ public Module createModule(final String instanceName, final DependencyResolver dependencyResolver,
+ final DynamicMBeanWithInstance old, final BundleContext bundleContext) throws Exception {
+ final Ipv4ReachabilityTopologyBuilderModule module = (Ipv4ReachabilityTopologyBuilderModule) super.createModule(instanceName, dependencyResolver, old, bundleContext);
+ module.setBundleContext(bundleContext);
+ return module;
+ }
}
*/
package org.opendaylight.controller.config.yang.bgp.reachability.ipv6;
-import java.util.concurrent.ExecutionException;
+import org.opendaylight.bgpcep.bgp.topology.provider.BackwardsCssTopologyProvider;
import org.opendaylight.bgpcep.bgp.topology.provider.Ipv6ReachabilityTopologyBuilder;
-import org.opendaylight.bgpcep.topology.DefaultTopologyReference;
+import org.opendaylight.controller.config.api.DependencyResolver;
import org.opendaylight.controller.config.api.JmxAttributeValidationException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
*/
-public final class Ipv6ReachabilityTopologyBuilderModule extends
- org.opendaylight.controller.config.yang.bgp.reachability.ipv6.AbstractIpv6ReachabilityTopologyBuilderModule {
+public final class Ipv6ReachabilityTopologyBuilderModule extends AbstractIpv6ReachabilityTopologyBuilderModule {
private static final Logger LOG = LoggerFactory.getLogger(Ipv6ReachabilityTopologyBuilderModule.class);
- public Ipv6ReachabilityTopologyBuilderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
- final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ private BundleContext bundleContext;
+
+ public Ipv6ReachabilityTopologyBuilderModule(final ModuleIdentifier identifier,
+ final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
}
- public Ipv6ReachabilityTopologyBuilderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
- final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+ public Ipv6ReachabilityTopologyBuilderModule(final ModuleIdentifier identifier, final DependencyResolver dependencyResolver,
final Ipv6ReachabilityTopologyBuilderModule oldModule, final AutoCloseable oldInstance) {
super(identifier, dependencyResolver, oldModule, oldInstance);
}
@Override
public AutoCloseable createInstance() {
- return new Ipv6ReachabilityTopologyBuilder(getDataProviderDependency(), getLocalRibDependency(), getTopologyId());
+ return BackwardsCssTopologyProvider.createBackwardsCssInstance(Ipv6ReachabilityTopologyBuilder.IPV6_TOPOLOGY_TYPE, getTopologyId(), getDataProviderDependency(), this.bundleContext,
+ getLocalRibDependency().getInstanceIdentifier());
+ }
+
+ public void setBundleContext(final BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
}
}
*/
package org.opendaylight.controller.config.yang.bgp.reachability.ipv6;
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
+import org.opendaylight.controller.config.spi.Module;
+import org.osgi.framework.BundleContext;
+
/**
*
*/
-public class Ipv6ReachabilityTopologyBuilderModuleFactory extends
- org.opendaylight.controller.config.yang.bgp.reachability.ipv6.AbstractIpv6ReachabilityTopologyBuilderModuleFactory {
+public class Ipv6ReachabilityTopologyBuilderModuleFactory extends AbstractIpv6ReachabilityTopologyBuilderModuleFactory {
+
+ @Override
+ public Module createModule(final String instanceName, final DependencyResolver dependencyResolver, final BundleContext bundleContext) {
+ final Ipv6ReachabilityTopologyBuilderModule module = (Ipv6ReachabilityTopologyBuilderModule) super.createModule(instanceName, dependencyResolver, bundleContext);
+ module.setBundleContext(bundleContext);
+ return module;
+ }
+ @Override
+ public Module createModule(final String instanceName, final DependencyResolver dependencyResolver,
+ final DynamicMBeanWithInstance old, final BundleContext bundleContext) throws Exception {
+ final Ipv6ReachabilityTopologyBuilderModule module = (Ipv6ReachabilityTopologyBuilderModule) super.createModule(instanceName, dependencyResolver, old, bundleContext);
+ module.setBundleContext(bundleContext);
+ return module;
+ }
}
*/
package org.opendaylight.controller.config.yang.bgp.topology.provider;
-import java.util.concurrent.ExecutionException;
+import org.opendaylight.bgpcep.bgp.topology.provider.BackwardsCssTopologyProvider;
import org.opendaylight.bgpcep.bgp.topology.provider.LinkstateTopologyBuilder;
-import org.opendaylight.bgpcep.topology.DefaultTopologyReference;
+import org.opendaylight.controller.config.api.DependencyResolver;
import org.opendaylight.controller.config.api.JmxAttributeValidationException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.osgi.framework.BundleContext;
/**
*
*/
-public final class LinkstateTopologyBuilderModule extends org.opendaylight.controller.config.yang.bgp.topology.provider.AbstractLinkstateTopologyBuilderModule {
- private static final Logger LOG = LoggerFactory.getLogger(LinkstateTopologyBuilderModule.class);
+public final class LinkstateTopologyBuilderModule extends AbstractLinkstateTopologyBuilderModule {
- public LinkstateTopologyBuilderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
- final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ private BundleContext bundleContext;
+
+ public LinkstateTopologyBuilderModule(final ModuleIdentifier identifier, final DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
}
- public LinkstateTopologyBuilderModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
- final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
- final LinkstateTopologyBuilderModule oldModule, final java.lang.AutoCloseable oldInstance) {
+ public LinkstateTopologyBuilderModule(final ModuleIdentifier identifier, final DependencyResolver dependencyResolver,
+ final LinkstateTopologyBuilderModule oldModule, final AutoCloseable oldInstance) {
super(identifier, dependencyResolver, oldModule, oldInstance);
}
@Override
public java.lang.AutoCloseable createInstance() {
- return new LinkstateTopologyBuilder(getDataProviderDependency(), getLocalRibDependency(), getTopologyId());
+ return BackwardsCssTopologyProvider.createBackwardsCssInstance(LinkstateTopologyBuilder.LINKSTATE_TOPOLOGY_TYPE, getTopologyId(), getDataProviderDependency(), this.bundleContext,
+ getLocalRibDependency().getInstanceIdentifier());
+ }
+ public void setBundleContext(final BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
}
}
*/
package org.opendaylight.controller.config.yang.bgp.topology.provider;
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
+import org.opendaylight.controller.config.spi.Module;
+import org.osgi.framework.BundleContext;
+
/**
*
*/
-public class LinkstateTopologyBuilderModuleFactory extends
- org.opendaylight.controller.config.yang.bgp.topology.provider.AbstractLinkstateTopologyBuilderModuleFactory {
+public class LinkstateTopologyBuilderModuleFactory extends AbstractLinkstateTopologyBuilderModuleFactory {
+
+ @Override
+ public Module createModule(final String instanceName, final DependencyResolver dependencyResolver, final BundleContext bundleContext) {
+ final LinkstateTopologyBuilderModule module = (LinkstateTopologyBuilderModule) super.createModule(instanceName, dependencyResolver, bundleContext);
+ module.setBundleContext(bundleContext);
+ return module;
+ }
+
+ @Override
+ public Module createModule(final String instanceName, final DependencyResolver dependencyResolver,
+ final DynamicMBeanWithInstance old, final BundleContext bundleContext) throws Exception {
+ final LinkstateTopologyBuilderModule module = (LinkstateTopologyBuilderModule) super.createModule(instanceName, dependencyResolver, old, bundleContext);
+ module.setBundleContext(bundleContext);
+ return module;
+ }
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
+
+ <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" odl:type="pingpong"/>
+
+ <bean id="bgpTopologyDeployer" class="org.opendaylight.bgpcep.bgp.topology.provider.BgpTopologyDeployerImpl" destroy-method="close">
+ <argument ref="blueprintBundleContext"/>
+ <argument ref="dataBroker"/>
+ </bean>
+
+ <service ref="bgpTopologyDeployer" interface="org.opendaylight.bgpcep.bgp.topology.provider.spi.BgpTopologyDeployer"/>
+
+ <bean id="ipv4TopologyProvider" class="org.opendaylight.bgpcep.bgp.topology.provider.Ipv4TopologyProvider" destroy-method="close">
+ <argument ref="bgpTopologyDeployer"/>
+ </bean>
+
+ <bean id="ipv6TopologyProvider" class="org.opendaylight.bgpcep.bgp.topology.provider.Ipv6TopologyProvider" destroy-method="close">
+ <argument ref="bgpTopologyDeployer"/>
+ </bean>
+
+ <bean id="linkstateTopologyProvider" class="org.opendaylight.bgpcep.bgp.topology.provider.LinkstateTopologyProvider" destroy-method="close">
+ <argument ref="bgpTopologyDeployer"/>
+ </bean>
+
+</blueprint>
\ No newline at end of file
--- /dev/null
+// vi: set smarttab et sw=4 tabstop=4:
+module odl-bgp-topology-config {
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:odl-bgp-topology-config";
+ prefix "bgp-topo-cfg";
+
+ import network-topology { prefix nt; revision-date 2013-10-21; }
+ import bgp-rib { prefix rib; revision-date 2013-09-25; }
+ import odl-bgp-topology-types { prefix topology-tpes; revision-date 2016-05-24; }
+
+ organization "Cisco Systems, Inc.";
+
+ contact "Milos Fabian <milfabia@cisco.com>";
+
+ description
+ "This module contains the base YANG definitions for
+ BGP topology provider configuration.
+
+ Copyright (c)2016 Cisco Systems, Inc. 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";
+
+ revision "2016-07-26" {
+ description
+ "Initial revision";
+ }
+
+ grouping bgp-topology-configuration {
+ leaf rib-id {
+ type rib:rib-id;
+ }
+ }
+
+ augment "/nt:network-topology/nt:topology" {
+ when "/nt:network-topology/nt:topology/nt:topology-types/topology-tpes:bgp-ipv4-reachability-topology or"
+ + "/nt:network-topology/nt:topology/nt:topology-types/topology-tpes:bgp-ipv6-reachability-topology or"
+ + "/nt:network-topology/nt:topology/nt:topology-types/topology-tpes:bgp-linkstate-topology";
+ uses bgp-topology-configuration;
+ }
+}
+
protected void setupWithDataBroker(final DataBroker dataBroker) {
super.setupWithDataBroker(dataBroker);
this.ipv4TopoBuilder = new Ipv4ReachabilityTopologyBuilder(dataBroker, LOC_RIB_REF, TEST_TOPOLOGY_ID);
+ this.ipv4TopoBuilder.start();
final InstanceIdentifier<Tables> path = this.ipv4TopoBuilder.tableInstanceIdentifier(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
this.ipv4RouteIID = path.builder().child((Class) Ipv4Routes.class).child(Ipv4Route.class, new Ipv4RouteKey(new PathId(PATH_ID),
new Ipv4Prefix(ROUTE_IP4PREFIX))).build();
protected void setupWithDataBroker(final DataBroker dataBroker) {
super.setupWithDataBroker(dataBroker);
this.ipv6TopoBuilder = new Ipv6ReachabilityTopologyBuilder(dataBroker, LOC_RIB_REF, TEST_TOPOLOGY_ID);
+ this.ipv6TopoBuilder.start();
final InstanceIdentifier<Tables> path = this.ipv6TopoBuilder.tableInstanceIdentifier(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class);
this.ipv6RouteIID = path.builder().child((Class) Ipv6Routes.class).child(Ipv6Route.class, new Ipv6RouteKey(new PathId(PATH_ID),
new Ipv6Prefix(ROUTE_IP6PREFIX))).build();
protected void setupWithDataBroker(final DataBroker dataBroker) {
super.setupWithDataBroker(dataBroker);
this.linkstateTopoBuilder = new LinkstateTopologyBuilder(dataBroker, LOC_RIB_REF, TEST_TOPOLOGY_ID, LISTENER_RESTART_TIME, LISTENER_ENFORCE_COUNTER);
+ this.linkstateTopoBuilder.start();
final InstanceIdentifier<Tables> path = this.linkstateTopoBuilder.tableInstanceIdentifier(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class);
this.linkstateRouteIID = path.builder().child((Class)LinkstateRoutes.class).child(LinkstateRoute.class, new LinkstateRouteKey(LINKSTATE_ROUTE_KEY)).build();
}
*/
@Test
public void testRouteChangedError() throws Exception {
- LinkstateTopologyBuilder spiedLinkstateTopologyBuilder = spy(this.linkstateTopoBuilder);
+ final LinkstateTopologyBuilder spiedLinkstateTopologyBuilder = spy(this.linkstateTopoBuilder);
doThrow(RuntimeException.class).when(spiedLinkstateTopologyBuilder).routeChanged(any(), any());
try {
spiedLinkstateTopologyBuilder.routeChanged(null, null);
fail("Mockito failed to spy routeChanged() method");
- } catch (Exception e) {
+ } catch (final Exception e) {
assertTrue(e instanceof RuntimeException);
}
assertEquals(0L, spiedLinkstateTopologyBuilder.listenerScheduledRestartTime);
assertEquals(0L, spiedLinkstateTopologyBuilder.listenerScheduledRestartTime);
assertEquals(0L, spiedLinkstateTopologyBuilder.listenerScheduledRestartEnforceCounter);
// now pass some invalid data to cause onDataTreeChanged fail
- DataTreeModification<LinkstateRoute> modification = (DataTreeModification<LinkstateRoute>) mock(DataTreeModification.class, RETURNS_SMART_NULLS);
+ final DataTreeModification<LinkstateRoute> modification = mock(DataTreeModification.class, RETURNS_SMART_NULLS);
final List<DataTreeModification<LinkstateRoute>> changes = new ArrayList<>();
changes.add(modification);
spiedLinkstateTopologyBuilder.onDataTreeChanged(changes);
import java.util.List;
import javax.management.ObjectName;
import org.junit.Test;
+import org.opendaylight.bgpcep.topology.TopologyReference;
import org.opendaylight.controller.config.api.ValidationException;
import org.opendaylight.controller.config.api.jmx.CommitStatus;
import org.opendaylight.controller.config.spi.ModuleFactory;
import org.opendaylight.controller.config.yang.bgp.reachability.ipv4.Ipv4ReachabilityTopologyBuilderModuleMXBean;
import org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractRIBImplModuleTest;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class Ipv4ReachabilityTopologyBuilderModuleTest extends AbstractRIBImplModuleTest {
private static final String FACTORY_NAME = Ipv4ReachabilityTopologyBuilderModuleFactory.NAME;
private static final String INSTANCE_NAME = "bgp-reachability-ipv4-instance";
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ setupMockService(TopologyReference.class, new TopologyReference() {
+ @Override
+ public InstanceIdentifier<Topology> getInstanceIdentifier() {
+ return null;
+ }
+ });
+ }
+
@Override
protected List<ModuleFactory> getModuleFactories() {
final List<ModuleFactory> moduleFactories = super.getModuleFactories();
paths.add("/META-INF/yang/bmp-message.yang");
paths.add("/META-INF/yang/ietf-yang-types@2013-07-15.yang");
paths.add("/META-INF/yang/odl-bgp-topology-types.yang");
+ paths.add("/META-INF/yang/odl-bgp-topology-config.yang");
return paths;
}
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+
import java.util.List;
import javax.management.ObjectName;
import org.junit.Test;
+import org.opendaylight.bgpcep.topology.TopologyReference;
import org.opendaylight.controller.config.api.ValidationException;
import org.opendaylight.controller.config.api.jmx.CommitStatus;
import org.opendaylight.controller.config.spi.ModuleFactory;
import org.opendaylight.controller.config.yang.bgp.reachability.ipv6.Ipv6ReachabilityTopologyBuilderModuleMXBean;
import org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractRIBImplModuleTest;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class Ipv6ReachabilityTopologyBuilderModuleTest extends AbstractRIBImplModuleTest {
private static final String FACTORY_NAME = Ipv6ReachabilityTopologyBuilderModuleFactory.NAME;
private static final String INSTANCE_NAME = "bgp-reachability-ipv6-instance";
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ setupMockService(TopologyReference.class, new TopologyReference() {
+ @Override
+ public InstanceIdentifier<Topology> getInstanceIdentifier() {
+ return null;
+ }
+ });
+ }
+
@Override
protected List<ModuleFactory> getModuleFactories() {
final List<ModuleFactory> moduleFactories = super.getModuleFactories();
paths.add("/META-INF/yang/bmp-message.yang");
paths.add("/META-INF/yang/ietf-yang-types@2013-07-15.yang");
paths.add("/META-INF/yang/odl-bgp-topology-types.yang");
+ paths.add("/META-INF/yang/odl-bgp-topology-config.yang");
return paths;
}
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+
import java.util.List;
import javax.management.ObjectName;
import org.junit.Test;
+import org.opendaylight.bgpcep.topology.TopologyReference;
import org.opendaylight.controller.config.api.ValidationException;
import org.opendaylight.controller.config.api.jmx.CommitStatus;
import org.opendaylight.controller.config.spi.ModuleFactory;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
import org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractRIBImplModuleTest;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class LinkstateTopologyBuilderModuleTest extends AbstractRIBImplModuleTest {
private static final String FACTORY_NAME = LinkstateTopologyBuilderModuleFactory.NAME;
private static final String INSTANCE_NAME = "bgp-linkstate-topology-instance";
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ setupMockService(TopologyReference.class, new TopologyReference() {
+ @Override
+ public InstanceIdentifier<Topology> getInstanceIdentifier() {
+ return null;
+ }
+ });
+ }
+
@Override
protected List<ModuleFactory> getModuleFactories() {
final List<ModuleFactory> moduleFactories = super.getModuleFactories();
paths.add("/META-INF/yang/bmp-message.yang");
paths.add("/META-INF/yang/ietf-yang-types@2013-07-15.yang");
paths.add("/META-INF/yang/odl-bgp-topology-types.yang");
+ paths.add("/META-INF/yang/odl-bgp-topology-config.yang");
return paths;
}