diff options
author | Marek Gradzki <mgradzki@cisco.com> | 2017-06-19 08:30:19 +0200 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2017-06-19 13:23:52 +0200 |
commit | aaf712b80ac93d80e975014c235d7b8ba9db4747 (patch) | |
tree | 024a5844d00dbc467d93e00c0c7a546cd009af7d /infra/bgp-distribution | |
parent | 1ebe244eb98ca8c5c4728caaa767e76a777580d6 (diff) |
HONEYCOMB-356: API implementation
RibWriter registers DataTreeChangeListener for given route type.
RouteWriter recevies create/update/delete notifications for single route
modifications in LocRib DS.
Change-Id: I4832abfb25aa189ecd3964febd6071f9a25117b2
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'infra/bgp-distribution')
3 files changed, 57 insertions, 0 deletions
diff --git a/infra/bgp-distribution/pom.xml b/infra/bgp-distribution/pom.xml index c70d03017..62bc95752 100644 --- a/infra/bgp-distribution/pom.xml +++ b/infra/bgp-distribution/pom.xml @@ -57,6 +57,16 @@ <artifactId>minimal-distribution</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>io.fd.honeycomb</groupId> + <artifactId>bgp-translate-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>io.fd.honeycomb</groupId> + <artifactId>bgp-translate-impl</artifactId> + <version>${project.version}</version> + </dependency> <!-- ODL-BGP --> <dependency> diff --git a/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java index efef5a71f..a26b5c158 100644 --- a/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java +++ b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java @@ -25,6 +25,7 @@ import com.google.inject.name.Names; import io.fd.honeycomb.infra.distro.data.BindingDataBrokerProvider; import io.fd.honeycomb.infra.distro.data.DataStoreProvider; import io.fd.honeycomb.infra.distro.data.InmemoryDOMDataBrokerProvider; +import io.fd.honeycomb.translate.bgp.RibWriter; import io.netty.channel.EventLoopGroup; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; @@ -61,6 +62,10 @@ public final class BgpModule extends PrivateModule { // Initialize BgpNeighbours bind(BgpNeighbors.class).toProvider(BgpNeighboursProvider.class).in(Singleton.class); expose(BgpNeighbors.class); + + // Listens for local RIB modifications and passes routes to translation layer + bind(RibWriter.class).toProvider(LocRibWriterProvider.class).asEagerSingleton(); + expose(RibWriter.class); } private void configureRIB() { diff --git a/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/LocRibWriterProvider.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/LocRibWriterProvider.java new file mode 100644 index 000000000..1fc6b25ed --- /dev/null +++ b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/LocRibWriterProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.fd.honeycomb.infra.bgp; + +import com.google.inject.Inject; +import com.google.inject.name.Named; +import io.fd.honeycomb.bgp.translate.impl.LocRibWriter; +import io.fd.honeycomb.infra.distro.ProviderTrait; +import io.fd.honeycomb.translate.bgp.RouteWriterFactory; +import java.util.HashSet; +import java.util.Set; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; + +final class LocRibWriterProvider extends ProviderTrait<LocRibWriter> { + + @Inject + @Named(BgpModule.HONEYCOMB_BGP) + private DataBroker bgpDataBroker; + @Inject(optional = true) + private Set<RouteWriterFactory> writerFactories = new HashSet<>(); + + @Override + protected LocRibWriter create() { + final LocRibWriter registry = new LocRibWriter(bgpDataBroker); + writerFactories.stream().forEach(factory -> factory.init(registry)); + return registry; + } +} |