<dependencies>
<dependency>
<groupId>io.fd.honeycomb</groupId>
- <artifactId>bgp-distribution</artifactId>
+ <artifactId>minimal-distribution</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
/*
- * 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.
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;
@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();
}
+++ /dev/null
-= bgp-distribution
-
-Honeycomb distribution that adds BGP to NETCONF and RESTCONF northbound intrerfaces provided by minimal-distribution.
\ No newline at end of file
+++ /dev/null
-/*
- * 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();
- }
- }
-
-}
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>
--- /dev/null
+= bgp
+
+Adds BGP support to Honeycomb's northbound interfaces.
+Depends on ODL's BGP implementation.
\ No newline at end of file
<?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>
<version>${project.version}</version>
</dependency>
- <!-- ODL-BGP -->
+ <!-- ODL BGP -->
<dependency>
<groupId>org.opendaylight.bgpcep</groupId>
<artifactId>bgp-rib-impl</artifactId>
<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
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;
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);
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);
}
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;
@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
}
});
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
{
- "bgp-enabled": "true",
+ "bgp-enabled": "false",
"bgp-binding-address": "127.0.0.1",
"bgp-port": 1790,
"bgp-as-number": 65000,
<modules>
<module>common</module>
+ <module>bgp</module>
</modules>
</project>
\ No newline at end of file
<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>