HONEYCOMB-374: move BGP to minimal-distribution 63/7363/5
authorMarek Gradzki <mgradzki@cisco.com>
Fri, 30 Jun 2017 11:11:22 +0000 (13:11 +0200)
committerJan Srnicek <jsrnicek@cisco.com>
Mon, 3 Jul 2017 10:29:22 +0000 (12:29 +0200)
Separate BGP distribution was temporary workaround
for HONEYCOMB-358 and (partially) HONEYCOMB-360.

BGP northbound interface is disabled by default.

Change-Id: I72a0f83f40ea96bee478be7d6560f2112611d80f
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
29 files changed:
infra/bgp-distribution-test/pom.xml
infra/bgp-distribution-test/src/test/java/io/fd/honeycomb/infra/bgp/distro/BgpDistributionTest.java
infra/bgp-distribution/asciidoc/Readme.adoc [deleted file]
infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/distro/Main.java [deleted file]
infra/minimal-distribution/pom.xml
infra/northbound/bgp/asciidoc/Readme.adoc [new file with mode: 0644]
infra/northbound/bgp/bgp_postman_collection.json [moved from infra/bgp-distribution/bgp_postman_collection.json with 100% similarity]
infra/northbound/bgp/pom.xml [moved from infra/bgp-distribution/pom.xml with 59% similarity]
infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BGPDispatcherImplProvider.java [moved from infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BGPDispatcherImplProvider.java with 100% similarity]
infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BGPExtensionConsumerContextProvider.java [moved from infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BGPExtensionConsumerContextProvider.java with 100% similarity]
infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfiguration.java [moved from infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfiguration.java with 100% similarity]
infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfigurationModule.java [moved from infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfigurationModule.java with 100% similarity]
infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpExtensionsModule.java [moved from infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpExtensionsModule.java with 85% similarity]
infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java [moved from infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java with 82% similarity]
infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpNeighboursProvider.java [moved from infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpNeighboursProvider.java with 99% similarity]
infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpNettyThreadGroupProvider.java [moved from infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpNettyThreadGroupProvider.java with 100% similarity]
infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpRIBProvider.java [moved from infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpRIBProvider.java with 100% similarity]
infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpReaderFactoryProvider.java [moved from infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpReaderFactoryProvider.java with 100% similarity]
infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpReadersModule.java [moved from infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpReadersModule.java with 68% similarity]
infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpServerProvider.java [moved from infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpServerProvider.java with 98% similarity]
infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpWriterFactoryProvider.java [moved from infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpWriterFactoryProvider.java with 100% similarity]
infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpWritersModule.java [moved from infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpWritersModule.java with 68% similarity]
infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/LocRibWriterProvider.java [moved from infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/LocRibWriterProvider.java with 100% similarity]
infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/RIBExtensionConsumerContextProvider.java [moved from infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/RIBExtensionConsumerContextProvider.java with 100% similarity]
infra/northbound/bgp/src/main/resources/honeycomb-minimal-resources/config/activation.json [moved from infra/bgp-distribution/src/main/resources/honeycomb-minimal-resources/config/activation.json with 100% similarity]
infra/northbound/bgp/src/main/resources/honeycomb-minimal-resources/config/bgp-peers.json [moved from infra/bgp-distribution/src/main/resources/honeycomb-minimal-resources/config/bgp-peers.json with 100% similarity]
infra/northbound/bgp/src/main/resources/honeycomb-minimal-resources/config/bgp.json [moved from infra/bgp-distribution/src/main/resources/honeycomb-minimal-resources/config/bgp.json with 86% similarity]
infra/northbound/pom.xml
infra/pom.xml

index 34eeda3..858f21e 100644 (file)
@@ -32,7 +32,7 @@
     <dependencies>
         <dependency>
             <groupId>io.fd.honeycomb</groupId>
-            <artifactId>bgp-distribution</artifactId>
+            <artifactId>minimal-distribution</artifactId>
             <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
index be927a6..d6f03f9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Cisco and/or its affiliates.
+ * 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.
@@ -18,6 +18,7 @@ package io.fd.honeycomb.infra.bgp.distro;
 
 import com.google.common.io.ByteStreams;
 import com.mashape.unirest.http.Unirest;
+import io.fd.honeycomb.infra.distro.Main;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.InetAddress;
@@ -60,7 +61,7 @@ public class BgpDistributionTest {
 
     @Test(timeout = 120000)
     public void test() throws Exception {
-        io.fd.honeycomb.infra.bgp.distro.Main.init();
+        Main.init();
         LOG.info("Testing Honeycomb BGP distribution");
         assertBgp();
     }
diff --git a/infra/bgp-distribution/asciidoc/Readme.adoc b/infra/bgp-distribution/asciidoc/Readme.adoc
deleted file mode 100644 (file)
index f6222d4..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-= bgp-distribution
-
-Honeycomb distribution that adds BGP to NETCONF and RESTCONF northbound intrerfaces provided by minimal-distribution.
\ No newline at end of file
diff --git a/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/distro/Main.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/distro/Main.java
deleted file mode 100644 (file)
index 8994f04..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.distro;
-
-import com.google.inject.ConfigurationException;
-import com.google.inject.CreationException;
-import com.google.inject.Injector;
-import com.google.inject.ProvisionException;
-import io.fd.honeycomb.infra.bgp.BgpConfiguration;
-import io.fd.honeycomb.infra.bgp.BgpServerProvider;
-import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.BgpNeighbors;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class Main {
-
-    private static final Logger LOG = LoggerFactory.getLogger(Main.class);
-
-    private Main() {
-    }
-
-    public static void main(String[] args) {
-        init();
-    }
-
-    /**
-     * Initialize the Honeycomb with provided modules
-     */
-    public static Injector init() {
-        try {
-            Injector injector = io.fd.honeycomb.infra.distro.Main.init();
-            final BgpConfiguration bgpAttributes = injector.getInstance(BgpConfiguration.class);
-
-            if (bgpAttributes.isBgpEnabled()) {
-                LOG.info("Starting BGP");
-                injector.getInstance(BgpServerProvider.BgpServer.class);
-                LOG.info("Initializing BgpNeighbours");
-                injector.getInstance(BgpNeighbors.class);
-                LOG.info("BGP started successfully!");
-            }
-
-            return injector;
-        } catch (CreationException | ProvisionException | ConfigurationException e) {
-            LOG.error("Failed to initialize Honeycomb components", e);
-            throw e;
-        } catch (RuntimeException e) {
-            LOG.error("Unexpected initialization failure", e);
-            throw e;
-        } finally {
-            // Trigger gc to force collect initial garbage + dedicated classloader
-            System.gc();
-        }
-    }
-
-}
index 66f15f7..37c010f 100644 (file)
             io.fd.honeycomb.infra.distro.netconf.NetconfModule,
             io.fd.honeycomb.infra.distro.netconf.NetconfReadersModule,
             io.fd.honeycomb.infra.distro.restconf.RestconfModule,
-            io.fd.honeycomb.infra.distro.cfgattrs.CfgAttrsModule
+            io.fd.honeycomb.infra.distro.cfgattrs.CfgAttrsModule,
+            // io.fd.honeycomb.infra.bgp.BgpModule,
+            // io.fd.honeycomb.infra.bgp.BgpExtensionsModule,
+            // io.fd.honeycomb.infra.bgp.BgpReadersModule,
+            // io.fd.honeycomb.infra.bgp.BgpWritersModule
         </distribution.modules>
     </properties>
 
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-server</artifactId>
         </dependency>
+        <dependency>
+            <groupId>io.fd.honeycomb.northbound</groupId>
+            <artifactId>bgp</artifactId>
+            <version>${project.version}</version>
+        </dependency>
     </dependencies>
 </project>
diff --git a/infra/northbound/bgp/asciidoc/Readme.adoc b/infra/northbound/bgp/asciidoc/Readme.adoc
new file mode 100644 (file)
index 0000000..d125fb6
--- /dev/null
@@ -0,0 +1,4 @@
+= bgp
+
+Adds BGP support to Honeycomb's northbound interfaces.
+Depends on ODL's BGP implementation.
\ No newline at end of file
similarity index 59%
rename from infra/bgp-distribution/pom.xml
rename to infra/northbound/bgp/pom.xml
index 5458859..60860a5 100644 (file)
@@ -1,62 +1,62 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 
     <parent>
+        <artifactId>impl-parent</artifactId>
         <groupId>io.fd.honeycomb.common</groupId>
-        <artifactId>minimal-distribution-parent</artifactId>
         <version>1.17.07-SNAPSHOT</version>
-        <relativePath>../../common/minimal-distribution-parent</relativePath>
+        <relativePath>../../../common/impl-parent</relativePath>
     </parent>
 
     <modelVersion>4.0.0</modelVersion>
-    <groupId>io.fd.honeycomb</groupId>
-    <artifactId>bgp-distribution</artifactId>
-    <name>${project.artifactId}</name>
-    <version>1.17.07-SNAPSHOT</version>
-
-    <properties>
-        <main.class>io.fd.honeycomb.infra.bgp.distro.Main</main.class>
-        <sonar.skip>true</sonar.skip>
-        <distribution.modules>
-            io.fd.honeycomb.infra.bgp.BgpModule,
-            io.fd.honeycomb.infra.bgp.BgpExtensionsModule,
-            io.fd.honeycomb.infra.bgp.BgpReadersModule,
-            io.fd.honeycomb.infra.bgp.BgpWritersModule,
-            io.fd.honeycomb.infra.bgp.BgpConfigurationModule
-        </distribution.modules>
-    </properties>
 
-    <build>
-        <plugins>
-            <plugin>
-                <artifactId>maven-compiler-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.gmaven</groupId>
-                <artifactId>groovy-maven-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-jar-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-dependency-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <artifactId>maven-assembly-plugin</artifactId>
-            </plugin>
-        </plugins>
-    </build>
+    <groupId>io.fd.honeycomb.northbound</groupId>
+    <artifactId>bgp</artifactId>
+    <version>1.17.07-SNAPSHOT</version>
 
     <dependencies>
+        <!-- Common northbound configuration -->
+        <dependency>
+            <groupId>io.fd.honeycomb.northbound</groupId>
+            <artifactId>common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <!-- Common HC infra utils -->
         <dependency>
             <groupId>io.fd.honeycomb</groupId>
-            <artifactId>minimal-distribution</artifactId>
+            <artifactId>minimal-distribution-core</artifactId>
             <version>${project.version}</version>
         </dependency>
+
+        <!-- DI-->
+        <dependency>
+            <groupId>com.google.inject</groupId>
+            <artifactId>guice</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>net.jmob</groupId>
+            <artifactId>guice.conf</artifactId>
+        </dependency>
+
+        <!-- BGP translation layer -->
         <dependency>
             <groupId>io.fd.honeycomb</groupId>
             <artifactId>bgp-translate-api</artifactId>
@@ -68,7 +68,7 @@
             <version>${project.version}</version>
         </dependency>
 
-        <!-- ODL-BGP -->
+        <!-- ODL BGP -->
         <dependency>
             <groupId>org.opendaylight.bgpcep</groupId>
             <artifactId>bgp-rib-impl</artifactId>
@@ -84,7 +84,8 @@
             <groupId>org.opendaylight.bgpcep</groupId>
             <artifactId>bgp-openconfig-impl</artifactId>
         </dependency>
-        <!-- BGP extensions -->
+
+        <!-- ODL BGP extensions -->
         <dependency>
             <groupId>org.opendaylight.bgpcep</groupId>
             <artifactId>bgp-evpn</artifactId>
             <artifactId>bgp-l3vpn</artifactId>
         </dependency>
     </dependencies>
+
 </project>
\ No newline at end of file
 
 package io.fd.honeycomb.infra.bgp;
 
-import com.google.inject.AbstractModule;
 import com.google.inject.Singleton;
 import com.google.inject.multibindings.Multibinder;
+import io.fd.honeycomb.northbound.NorthboundAbstractModule;
 import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionConsumerContext;
 import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderActivator;
 import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionConsumerContext;
 import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderActivator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Registers BGP extensions provided by ODL implementation.
  * TODO add support for flowspec (requires some special initialization)
  */
-public final class BgpExtensionsModule extends AbstractModule {
+public final class BgpExtensionsModule extends NorthboundAbstractModule<BgpConfiguration> {
+    private static final Logger LOG = LoggerFactory.getLogger(BgpExtensionsModule.class);
+
+    public BgpExtensionsModule() {
+        super(new BgpConfigurationModule(), BgpConfiguration.class);
+    }
 
     protected void configure() {
+        if (!getConfiguration().isBgpEnabled()) {
+            LOG.debug("BGP disabled. Skipping initialization");
+            return;
+        }
+        LOG.debug("Initializing BgpExtensionsModule");
         // This should be part of BgpModule, but that one is Private and Multibinders + private BASE_MODULES
         // do not work together, that's why there's a dedicated module here
         // https://github.com/google/guice/issues/906
@@ -19,12 +19,12 @@ package io.fd.honeycomb.infra.bgp;
 import static io.fd.honeycomb.infra.distro.data.InmemoryDOMDataBrokerProvider.CONFIG;
 import static io.fd.honeycomb.infra.distro.data.InmemoryDOMDataBrokerProvider.OPERATIONAL;
 
-import com.google.inject.PrivateModule;
 import com.google.inject.Singleton;
 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.northbound.NorthboundPrivateModule;
 import io.fd.honeycomb.translate.bgp.RibWriter;
 import io.netty.channel.EventLoopGroup;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
@@ -38,12 +38,25 @@ import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
 import org.opendaylight.protocol.bgp.rib.impl.spi.RIB;
 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.BgpNeighbors;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-public final class BgpModule extends PrivateModule {
+public final class BgpModule extends NorthboundPrivateModule<BgpConfiguration> {
+    private static final Logger LOG = LoggerFactory.getLogger(BgpModule.class);
 
     static final String HONEYCOMB_BGP = "honeycomb-bgp";
 
+    public BgpModule() {
+        super(new BgpConfigurationModule(), BgpConfiguration.class);
+    }
+
     protected void configure() {
+        if (!getConfiguration().isBgpEnabled()) {
+            LOG.debug("BGP disabled. Skipping initialization");
+            return;
+        }
+        LOG.debug("Initializing BgpModule");
+        install(getConfigurationModule());
         // Create BGPDispatcher BGPDispatcher for creating BGP clients
         bind(EventLoopGroup.class).toProvider(BgpNettyThreadGroupProvider.class).in(Singleton.class);
         bind(BGPDispatcher.class).toProvider(BGPDispatcherImplProvider.class).in(Singleton.class);
@@ -54,16 +67,14 @@ public final class BgpModule extends PrivateModule {
         bind(BGPOpenConfigMappingService.class).toInstance(new BGPOpenConfigMappingServiceImpl());
         bind(BGPPeerRegistry.class).toInstance(StrictBGPPeerRegistry.instance());
 
+        // Create BGP server instance (initialize eagerly to start BGP)
+        bind(BgpServerProvider.BgpServer.class).toProvider(BgpServerProvider.class).asEagerSingleton();
 
-        // Create BGP server instance
-        bind(BgpServerProvider.BgpServer.class).toProvider(BgpServerProvider.class).in(Singleton.class);
-        expose(BgpServerProvider.BgpServer.class);
-
-        // Initialize BgpNeighbours
-        bind(BgpNeighbors.class).toProvider(BgpNeighboursProvider.class).in(Singleton.class);
-        expose(BgpNeighbors.class);
+        // Initialize BgpNeighbours (initialize eagerly to start BGP neighbours)
+        bind(BgpNeighbors.class).toProvider(BgpNeighboursProvider.class).asEagerSingleton();
 
         // Listens for local RIB modifications and passes routes to translation layer
+        // (initialize eagerly to configure RouteWriters)
         bind(RibWriter.class).toProvider(LocRibWriterProvider.class).asEagerSingleton();
         expose(RibWriter.class);
     }
@@ -31,7 +31,6 @@ import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
 import org.opendaylight.controller.sal.core.api.model.SchemaService;
 import org.opendaylight.protocol.bgp.openconfig.spi.BGPOpenConfigMappingService;
-import org.opendaylight.protocol.bgp.rib.impl.StrictBGPPeerRegistry;
 import org.opendaylight.protocol.bgp.rib.impl.config.AppPeer;
 import org.opendaylight.protocol.bgp.rib.impl.config.BgpPeer;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry;
@@ -77,6 +76,7 @@ final class BgpNeighboursProvider extends ProviderTrait<BgpNeighbors> {
 
     @Override
     protected BgpNeighbors create() {
+        LOG.info("Initializing BgpNeighbours");
         final BgpNeighbors neighbors = readNeighbours();
         for (final Neighbor neighbor : neighbors.getNeighbor()) {
             if (isApplicationPeer(neighbor)) {
 
 package io.fd.honeycomb.infra.bgp;
 
-import com.google.inject.AbstractModule;
 import com.google.inject.Singleton;
 import com.google.inject.multibindings.Multibinder;
+import io.fd.honeycomb.northbound.NorthboundAbstractModule;
 import io.fd.honeycomb.translate.read.ReaderFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-public class BgpReadersModule extends AbstractModule {
+public class BgpReadersModule extends NorthboundAbstractModule<BgpConfiguration> {
+    private static final Logger LOG = LoggerFactory.getLogger(BgpReadersModule.class);
+
+    public BgpReadersModule() {
+        super(new BgpConfigurationModule(), BgpConfiguration.class);
+    }
 
     protected void configure() {
+        if (!getConfiguration().isBgpEnabled()) {
+            LOG.debug("BGP disabled. Skipping initialization");
+            return;
+        }
+        LOG.debug("Initializing BgpReadersModule");
         // This should be part of BgpModule, but that one is Private and Multibinders + private BASE_MODULES
         // do not work together, that's why there's a dedicated module here
         // https://github.com/google/guice/issues/906
@@ -66,7 +66,7 @@ public final class BgpServerProvider  extends ProviderTrait<BgpServerProvider.Bg
             }
         });
         final BgpServer server = new BgpServer(localServer);
-        LOG.debug("BgpServer successfully created.");
+        LOG.debug("BgpServer successfully started.");
         return server;
     }
 
 
 package io.fd.honeycomb.infra.bgp;
 
-import com.google.inject.AbstractModule;
 import com.google.inject.Singleton;
 import com.google.inject.multibindings.Multibinder;
+import io.fd.honeycomb.northbound.NorthboundAbstractModule;
 import io.fd.honeycomb.translate.write.WriterFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-public class BgpWritersModule extends AbstractModule {
+public class BgpWritersModule extends NorthboundAbstractModule<BgpConfiguration> {
+    private static final Logger LOG = LoggerFactory.getLogger(BgpWritersModule.class);
+
+    public BgpWritersModule() {
+        super(new BgpConfigurationModule(), BgpConfiguration.class);
+    }
 
     protected void configure() {
+        if (!getConfiguration().isBgpEnabled()) {
+            LOG.debug("BGP disabled. Skipping initialization");
+            return;
+        }
+        LOG.debug("Initializing BgpReadersModule");
         // This should be part of BgpModule, but that one is Private and Multibinders + private BASE_MODULES
         // do not work together, that's why there's a dedicated module here
         // https://github.com/google/guice/issues/906
index a768b32..3ae2859 100644 (file)
@@ -32,6 +32,7 @@
 
     <modules>
         <module>common</module>
+        <module>bgp</module>
     </modules>
 
 </project>
\ No newline at end of file
index 4540520..845cad0 100644 (file)
@@ -43,7 +43,6 @@
     <module>minimal-distribution</module>
     <module>bgp-translate-api</module>
     <module>bgp-translate-impl</module>
-    <module>bgp-distribution</module>
     <module>it</module>
     <module>test-utils</module>
     <module>rpc</module>