From aaf712b80ac93d80e975014c235d7b8ba9db4747 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Mon, 19 Jun 2017 08:30:19 +0200 Subject: 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 --- infra/bgp-distribution/pom.xml | 10 ++++++ .../java/io/fd/honeycomb/infra/bgp/BgpModule.java | 5 +++ .../honeycomb/infra/bgp/LocRibWriterProvider.java | 42 ++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/LocRibWriterProvider.java (limited to 'infra/bgp-distribution') 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 @@ minimal-distribution ${project.version} + + io.fd.honeycomb + bgp-translate-api + ${project.version} + + + io.fd.honeycomb + bgp-translate-impl + ${project.version} + 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 { + + @Inject + @Named(BgpModule.HONEYCOMB_BGP) + private DataBroker bgpDataBroker; + @Inject(optional = true) + private Set writerFactories = new HashSet<>(); + + @Override + protected LocRibWriter create() { + final LocRibWriter registry = new LocRibWriter(bgpDataBroker); + writerFactories.stream().forEach(factory -> factory.init(registry)); + return registry; + } +} -- cgit 1.2.3-korg