HONEYCOMB-355: move BGP to separate distribution 63/6763/5
authorMarek Gradzki <mgradzki@cisco.com>
Thu, 18 May 2017 14:46:46 +0000 (16:46 +0200)
committerMarek Gradzki <mgradzki@cisco.com>
Mon, 29 May 2017 06:36:30 +0000 (08:36 +0200)
Given current YangBindingProviderModule implementation (HONEYCOMB-358),
needed to preserve footprint of minimal distro.

The change also:
- reverts logger&persistence config changes
introduced by https://gerrit.fd.io/r/#/c/5972/
- improves logging for BGP component initialization

Change-Id: Ie223833518be21628edb7ace36c7618e427585e0
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
37 files changed:
infra/bgp-distribution/asciidoc/Readme.adoc [new file with mode: 0644]
infra/bgp-distribution/bgp_postman_collection.json [moved from infra/bgp_postman_collection.json with 100% similarity]
infra/bgp-distribution/pom.xml [new file with mode: 0644]
infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BGPDispatcherImplProvider.java [moved from infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BGPDispatcherImplProvider.java with 96% similarity]
infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BGPExtensionConsumerContextProvider.java [moved from infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BGPExtensionConsumerContextProvider.java with 85% similarity]
infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BGPPeerRegistryProvider.java [moved from infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BGPPeerRegistryProvider.java with 93% similarity]
infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfiguration.java [new file with mode: 0644]
infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfigurationModule.java [new file with mode: 0644]
infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpExtensionsModule.java [moved from infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpExtensionsModule.java with 98% similarity]
infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java [moved from infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpModule.java with 98% similarity]
infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpNettyThreadGroupProvider.java [moved from infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpNettyThreadGroupProvider.java with 87% similarity]
infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpRIBProvider.java [moved from infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpRIBProvider.java with 95% similarity]
infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpReaderFactoryProvider.java [moved from infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpReaderFactoryProvider.java with 98% similarity]
infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpReadersModule.java [moved from infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpReadersModule.java with 96% similarity]
infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpServerProvider.java [moved from infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpServerProvider.java with 90% similarity]
infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpWriterFactoryProvider.java [moved from infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpWriterFactoryProvider.java with 98% similarity]
infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpWritersModule.java [moved from infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/BgpWritersModule.java with 96% similarity]
infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/RIBExtensionConsumerContextProvider.java [moved from infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/bgp/RIBExtensionConsumerContextProvider.java with 85% similarity]
infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/distro/Main.java [new file with mode: 0644]
infra/bgp-distribution/src/main/resources/honeycomb-minimal-resources/config/bgp-peers.json [moved from infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/bgp-peers.json with 100% similarity]
infra/bgp-distribution/src/main/resources/honeycomb-minimal-resources/config/bgp.json [new file with mode: 0644]
infra/bgp-distribution/src/test/java/io/fd/honeycomb/infra/bgp/distro/BgpDistributionTest.java [new file with mode: 0644]
infra/bgp-distribution/src/test/resources/WEB-INF/web.xml [new file with mode: 0644]
infra/bgp-distribution/src/test/resources/bgp-peers.json [moved from infra/minimal-distribution/src/test/resources/bgp-peers.json with 100% similarity]
infra/bgp-distribution/src/test/resources/bgp.json [new file with mode: 0644]
infra/bgp-distribution/src/test/resources/honeycomb-keystore [new file with mode: 0644]
infra/bgp-distribution/src/test/resources/honeycomb.json [new file with mode: 0644]
infra/bgp-distribution/src/test/resources/logback.xml [new file with mode: 0644]
infra/minimal-distribution/pom.xml
infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java
infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java
infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/honeycomb.json
infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/logback.xml
infra/minimal-distribution/src/test/java/io/fd/honeycomb/infra/distro/BaseMinimalDistributionTest.java
infra/minimal-distribution/src/test/resources/honeycomb.json
infra/pom.xml
infra/translate-utils/src/main/java/io/fd/honeycomb/translate/util/write/BindingBrokerWriter.java

diff --git a/infra/bgp-distribution/asciidoc/Readme.adoc b/infra/bgp-distribution/asciidoc/Readme.adoc
new file mode 100644 (file)
index 0000000..f6222d4
--- /dev/null
@@ -0,0 +1,3 @@
+= 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/pom.xml b/infra/bgp-distribution/pom.xml
new file mode 100644 (file)
index 0000000..c70d030
--- /dev/null
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+        <groupId>io.fd.honeycomb.common</groupId>
+        <artifactId>minimal-distribution-parent</artifactId>
+        <version>1.17.07-SNAPSHOT</version>
+        <relativePath>../../common/minimal-distribution-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>
+
+    <dependencies>
+        <dependency>
+            <groupId>io.fd.honeycomb</groupId>
+            <artifactId>minimal-distribution</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <!-- ODL-BGP -->
+        <dependency>
+            <groupId>org.opendaylight.bgpcep</groupId>
+            <artifactId>bgp-rib-impl</artifactId>
+            <!-- TODO remove exclusion after bumping to Boron-SR4 -->
+            <exclusions>
+                <exclusion>
+                    <groupId>org.powermock</groupId>
+                    <artifactId>powermock</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.bgpcep</groupId>
+            <artifactId>bgp-openconfig-impl</artifactId>
+        </dependency>
+        <!-- BGP extensions -->
+        <dependency>
+            <groupId>org.opendaylight.bgpcep</groupId>
+            <artifactId>bgp-evpn</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.bgpcep</groupId>
+            <artifactId>bgp-inet</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.bgpcep</groupId>
+            <artifactId>bgp-labeled-unicast</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.bgpcep</groupId>
+            <artifactId>bgp-linkstate</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.bgpcep</groupId>
+            <artifactId>bgp-l3vpn</artifactId>
+        </dependency>
+
+        <!-- test dependencies -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.mashape.unirest</groupId>
+            <artifactId>unirest-java</artifactId>
+            <version>1.4.9</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.jcraft</groupId>
+            <artifactId>jsch</artifactId>
+            <version>0.1.54</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package io.fd.honeycomb.infra.distro.bgp;
+package io.fd.honeycomb.infra.bgp;
 
 import com.google.inject.Inject;
 import io.fd.honeycomb.infra.distro.ProviderTrait;
@@ -25,8 +25,12 @@ import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderActivator;
 import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext;
 import org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext;
 import org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContextActivator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 final class BGPExtensionConsumerContextProvider extends ProviderTrait<BGPExtensionConsumerContext> {
+    private static final Logger LOG = LoggerFactory.getLogger(BGPExtensionConsumerContextProvider.class);
+
     @Inject
     private Set<BGPExtensionProviderActivator> activators;
 
@@ -35,6 +39,7 @@ final class BGPExtensionConsumerContextProvider extends ProviderTrait<BGPExtensi
         final BGPExtensionProviderContext ctx = new SimpleBGPExtensionProviderContext();
         final SimpleBGPExtensionProviderContextActivator activator =
             new SimpleBGPExtensionProviderContextActivator(ctx, new ArrayList<>(activators));
+        LOG.debug("Starting BGPExtensionConsumerContext with activators: {}", activators);
         activator.start();
         return ctx;
     }
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package io.fd.honeycomb.infra.distro.bgp;
+package io.fd.honeycomb.infra.bgp;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
@@ -57,8 +57,11 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 final class BGPPeerRegistryProvider extends ProviderTrait<BGPPeerRegistry> {
+    private static final Logger LOG = LoggerFactory.getLogger(BGPPeerRegistryProvider.class);
     private static final String PEERS_CFG = "/bgp-peers.json";
     @Inject
     private BindingToNormalizedNodeCodec codec;
@@ -75,15 +78,19 @@ final class BGPPeerRegistryProvider extends ProviderTrait<BGPPeerRegistry> {
         final Neighbors neighbors = readNeighbours();
         for (final Neighbor neighbor : neighbors.getNeighbor()) {
             if (isApplicationPeer(neighbor)) {
+                LOG.trace("Starting AppPeer for {}", neighbor);
                 new AppPeer().start(globalRib, neighbor, mappingService, null);
             } else {
+                LOG.trace("Starting BgpPeer for {}", neighbor);
                 new BgpPeer(null, peerRegistry).start(globalRib, neighbor, mappingService, null);
             }
         }
+        LOG.debug("Created BGPPeerRegistry with neighbours {}", neighbors);
         return peerRegistry;
     }
 
     private Neighbors readNeighbours() {
+        LOG.debug("Reading BGP neighbours from {}", PEERS_CFG);
         final InputStream resourceStream = this.getClass().getResourceAsStream(PEERS_CFG);
         checkState(resourceStream != null, "Resource %s not found", PEERS_CFG);
 
diff --git a/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfiguration.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfiguration.java
new file mode 100644 (file)
index 0000000..9182dd3
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * 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.common.base.MoreObjects;
+import java.util.Optional;
+import net.jmob.guice.conf.core.BindConfig;
+import net.jmob.guice.conf.core.InjectConfig;
+import net.jmob.guice.conf.core.Syntax;
+
+/**
+ * This is the Java equivalent for bgp.json file. We use guice-config library to load all the config attributes
+ * into this class instance.
+ *
+ * The BindConfig annotation tells that bgp.json file should be looked up on classpath root.
+ */
+@BindConfig(value = "bgp", syntax = Syntax.JSON)
+public class BgpConfiguration {
+
+    public boolean isBgpEnabled() {
+        return Boolean.valueOf(bgpEnabled);
+    }
+
+    public boolean isBgpMultiplePathsEnabled() {
+        return Boolean.valueOf(bgpMultiplePaths.get());
+    }
+
+    @InjectConfig("bgp-enabled")
+    public String bgpEnabled;
+    @InjectConfig("bgp-binding-address")
+    public Optional<String> bgpBindingAddress;
+    @InjectConfig("bgp-port")
+    public Optional<Integer> bgpPort;
+    @InjectConfig("bgp-as-number")
+    public Optional<Integer> bgpAsNumber;
+    @InjectConfig("bgp-receive-multiple-paths")
+    public Optional<String> bgpMultiplePaths;
+    @InjectConfig("bgp-send-max-paths")
+    public Optional<Integer> bgpSendMaxMaths;
+    @InjectConfig("bgp-netty-threads")
+    public Integer bgpNettyThreads;
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+                .add("bgpEnabled", bgpEnabled)
+                .add("bgpBindingAddress", bgpBindingAddress)
+                .add("bgpPort", bgpPort)
+                .add("bgp-as-number", bgpAsNumber)
+                .add("bgp-netty-threads", bgpNettyThreads)
+                .add("bgp-receive-multiple-paths", bgpMultiplePaths)
+                .add("bgp-send-max-paths", bgpSendMaxMaths)
+                .toString();
+    }
+}
diff --git a/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfigurationModule.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfigurationModule.java
new file mode 100644 (file)
index 0000000..a1c2e76
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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.AbstractModule;
+import net.jmob.guice.conf.core.ConfigurationModule;
+
+/**
+ * Load the configuration from json into HoneycombConfiguration and make it available.
+ */
+public class BgpConfigurationModule extends AbstractModule {
+
+    protected void configure() {
+        install(ConfigurationModule.create());
+        // Inject non-dependency configuration
+        requestInjection(BgpConfiguration.class);
+    }
+
+}
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package io.fd.honeycomb.infra.distro.bgp;
+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;
  * limitations under the License.
  */
 
-package io.fd.honeycomb.infra.distro.bgp;
+package io.fd.honeycomb.infra.bgp;
 
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
 import com.google.inject.Inject;
 import io.fd.honeycomb.infra.distro.ProviderTrait;
-import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration;
 import io.netty.channel.nio.NioEventLoopGroup;
 
 final class BgpNettyThreadGroupProvider extends ProviderTrait<NioEventLoopGroup> {
 
     @Inject
-    private HoneycombConfiguration cfgAttributes;
+    private BgpConfiguration cfgAttributes;
 
     @Override
     protected NioEventLoopGroup create() {
  * limitations under the License.
  */
 
-package io.fd.honeycomb.infra.distro.bgp;
+package io.fd.honeycomb.infra.bgp;
 
 import com.google.common.collect.ImmutableList;
 import com.google.inject.Inject;
 import io.fd.honeycomb.infra.distro.ProviderTrait;
-import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -51,11 +50,11 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 final class BgpRIBProvider extends ProviderTrait<RIB> {
-
+    private static final Logger LOG = LoggerFactory.getLogger(BgpRIBProvider.class);
     private static final String HC_BGP_INSTANCE_NAME = "hc-bgp-instance";
 
     @Inject
-    private HoneycombConfiguration cfg;
+    private BgpConfiguration cfg;
     @Inject
     private RIBExtensionConsumerContext extensions;
     @Inject
@@ -74,6 +73,7 @@ final class BgpRIBProvider extends ProviderTrait<RIB> {
         final AsNumber asNumber = new AsNumber(cfg.bgpAsNumber.get().longValue());
         final Ipv4Address routerId = new Ipv4Address(cfg.bgpBindingAddress.get());
         final ClusterIdentifier clusterId = new ClusterIdentifier(routerId);
+        LOG.debug("Creating BGP RIB: routerId={}, asNumber={}", routerId, asNumber);
         // TODO configure other BGP Multiprotocol extensions:
         final List<AfiSafi> afiSafi = ImmutableList.of(new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class)
             .addAugmentation(AfiSafi2.class,
@@ -91,6 +91,8 @@ final class BgpRIBProvider extends ProviderTrait<RIB> {
 
         // required for proper RIB's CodecRegistry initialization (based on RIBImpl.start)
         schemaService.registerSchemaContextListener(rib);
+
+        LOG.debug("BGP RIB created successfully: {}", rib);
         return rib;
     }
 
  * limitations under the License.
  */
 
-package io.fd.honeycomb.infra.distro.bgp;
+package io.fd.honeycomb.infra.bgp;
 
 import com.google.common.base.Preconditions;
 import com.google.inject.Inject;
 import io.fd.honeycomb.infra.distro.ProviderTrait;
-import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration;
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelConfig;
 import io.netty.channel.ChannelFuture;
@@ -35,10 +34,13 @@ import org.opendaylight.protocol.bgp.rib.impl.spi.PeerRegistryListener;
 import org.opendaylight.protocol.concepts.KeyMapping;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public final class BgpServerProvider  extends ProviderTrait<BgpServerProvider.BgpServer> {
+    private static final Logger LOG = LoggerFactory.getLogger(BgpServerProvider.class);
     @Inject
-    private HoneycombConfiguration cfg;
+    private BgpConfiguration cfg;
     @Inject
     private BGPPeerRegistry peerRegistry;
     @Inject
@@ -54,6 +56,7 @@ public final class BgpServerProvider  extends ProviderTrait<BgpServerProvider.Bg
             throw new IllegalArgumentException("Illegal BGP binding address", e);
         }
         final InetSocketAddress address = new InetSocketAddress(bindingAddress, cfg.bgpPort.get());
+        LOG.debug("Creating BgpServer for {}", address);
         final ChannelFuture localServer = dispatcher.createServer(peerRegistry, address);
         localServer.addListener(future -> {
             Preconditions.checkArgument(future.isSuccess(), "Unable to start bgp server on %s", address, future.cause());
@@ -62,7 +65,9 @@ public final class BgpServerProvider  extends ProviderTrait<BgpServerProvider.Bg
                 peerRegistry.registerPeerRegisterListener(new PeerRegistryListenerImpl(channel.config()));
             }
         });
-        return new BgpServer(localServer);
+        final BgpServer server = new BgpServer(localServer);
+        LOG.debug("BgpServer successfully created.");
+        return server;
     }
 
     public static final class BgpServer {
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package io.fd.honeycomb.infra.distro.bgp;
+package io.fd.honeycomb.infra.bgp;
 
 import com.google.common.collect.Sets;
 import com.google.inject.Inject;
@@ -64,7 +64,7 @@ final class BgpWriterFactoryProvider extends ProviderTrait<WriterFactory> {
             this.dataBroker = dataBroker;
         }
 
-        // TODO
+        // TODO (HONEYCOMB-359):
         // BGP models are huge, we need some kind of wildcarded subtree writer, that works for whole subtree.
         // 1) we can either move checking handledTypes to writers (getHandledTypes, isAffected, writer.getHandedTypes, ...)
         // but then precondition check in flatWriterRegistry might be slower (we need to check if we have all writers
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package io.fd.honeycomb.infra.distro.bgp;
+package io.fd.honeycomb.infra.bgp;
 
 import com.google.inject.Inject;
 import io.fd.honeycomb.infra.distro.ProviderTrait;
@@ -25,8 +25,11 @@ import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderActivator;
 import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext;
 import org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext;
 import org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContextActivator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class RIBExtensionConsumerContextProvider extends ProviderTrait<RIBExtensionConsumerContext> {
+    private static final Logger LOG = LoggerFactory.getLogger(RIBExtensionConsumerContextProvider.class);
     @Inject
     private Set<RIBExtensionProviderActivator> activators;
 
@@ -35,6 +38,7 @@ public class RIBExtensionConsumerContextProvider extends ProviderTrait<RIBExtens
         final RIBExtensionProviderContext ctx = new SimpleRIBExtensionProviderContext();
         final SimpleRIBExtensionProviderContextActivator activator =
             new SimpleRIBExtensionProviderContextActivator(ctx, new ArrayList<>(activators));
+        LOG.debug("Starting RIBExtensionConsumerContext with activators: {}", activators);
         activator.start();
         return ctx;
     }
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
new file mode 100644 (file)
index 0000000..0204e1f
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * 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 static io.fd.honeycomb.infra.distro.ActiveModuleProvider.STANDARD_MODULES_RELATIVE_PATH;
+import static io.fd.honeycomb.infra.distro.ActiveModuleProvider.aggregateResources;
+import static io.fd.honeycomb.infra.distro.ActiveModuleProvider.loadActiveModules;
+
+import com.google.inject.ConfigurationException;
+import com.google.inject.CreationException;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+import com.google.inject.ProvisionException;
+import io.fd.honeycomb.infra.bgp.BgpConfiguration;
+import io.fd.honeycomb.infra.bgp.BgpServerProvider;
+import java.util.Set;
+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) {
+        final ClassLoader classLoader = Main.class.getClassLoader();
+        init(loadActiveModules(aggregateResources(STANDARD_MODULES_RELATIVE_PATH, classLoader)));
+    }
+
+    /**
+     * Initialize the Honeycomb with provided modules
+     */
+    public static Injector init(final Set<? extends Module> modules) {
+        try {
+            Injector injector = io.fd.honeycomb.infra.distro.Main.init(modules);
+            final BgpConfiguration bgpAttributes = injector.getInstance(BgpConfiguration.class);
+
+            if (bgpAttributes.isBgpEnabled()) {
+                LOG.info("Starting BGP");
+                injector.getInstance(BgpServerProvider.BgpServer.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();
+        }
+    }
+
+}
diff --git a/infra/bgp-distribution/src/main/resources/honeycomb-minimal-resources/config/bgp.json b/infra/bgp-distribution/src/main/resources/honeycomb-minimal-resources/config/bgp.json
new file mode 100644 (file)
index 0000000..2664c9e
--- /dev/null
@@ -0,0 +1,9 @@
+{
+  "bgp-enabled": "true",
+  "bgp-binding-address": "127.0.0.1",
+  "bgp-port": 1790,
+  "bgp-as-number": 65000,
+  "bgp-receive-multiple-paths": "true",
+  "bgp-send-max-paths": 0,
+  "bgp-netty-threads": 2
+}
\ No newline at end of file
diff --git a/infra/bgp-distribution/src/test/java/io/fd/honeycomb/infra/bgp/distro/BgpDistributionTest.java b/infra/bgp-distribution/src/test/java/io/fd/honeycomb/infra/bgp/distro/BgpDistributionTest.java
new file mode 100644 (file)
index 0000000..095d61c
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2016 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 static com.google.common.collect.ImmutableSet.of;
+
+import com.google.common.io.ByteStreams;
+import com.google.inject.Module;
+import com.mashape.unirest.http.Unirest;
+import io.fd.honeycomb.infra.bgp.BgpConfigurationModule;
+import io.fd.honeycomb.infra.bgp.BgpExtensionsModule;
+import io.fd.honeycomb.infra.bgp.BgpModule;
+import io.fd.honeycomb.infra.bgp.BgpReadersModule;
+import io.fd.honeycomb.infra.bgp.BgpWritersModule;
+import io.fd.honeycomb.infra.distro.cfgattrs.CfgAttrsModule;
+import io.fd.honeycomb.infra.distro.data.ConfigAndOperationalPipelineModule;
+import io.fd.honeycomb.infra.distro.data.context.ContextPipelineModule;
+import io.fd.honeycomb.infra.distro.initializer.InitializerPipelineModule;
+import io.fd.honeycomb.infra.distro.netconf.NetconfModule;
+import io.fd.honeycomb.infra.distro.netconf.NetconfReadersModule;
+import io.fd.honeycomb.infra.distro.restconf.RestconfModule;
+import io.fd.honeycomb.infra.distro.schema.SchemaModule;
+import io.fd.honeycomb.infra.distro.schema.YangBindingProviderModule;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.util.Set;
+import javax.net.ssl.SSLContext;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.ssl.SSLContexts;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BgpDistributionTest {
+
+    private static final Logger LOG = LoggerFactory.getLogger(BgpDistributionTest.class);
+    private static final String CERT_PASSWORD = "testing";
+    private static final int HELLO_WAIT = 2500;
+
+    private static final int BGP_MSG_TYPE_OFFSET = 18; // 16 (MARKER) + 2 (LENGTH);
+    private static final byte BGP_OPEN_MSG_TYPE = 1;
+    private static final int BGP_PORT = 1790;
+
+    public static final Set<Module> BASE_MODULES = of(
+            new YangBindingProviderModule(),
+            new SchemaModule(),
+            new ConfigAndOperationalPipelineModule(),
+            new ContextPipelineModule(),
+            new InitializerPipelineModule(),
+            new NetconfModule(),
+            new NetconfReadersModule(),
+            new RestconfModule(),
+            new CfgAttrsModule(),
+            new BgpModule(),
+            new BgpExtensionsModule(),
+            new BgpReadersModule(),
+            new BgpWritersModule(),
+            new BgpConfigurationModule());
+
+    @Before
+    public void setUp() throws Exception {
+        SSLContext sslcontext = SSLContexts.custom()
+            .loadTrustMaterial(getClass().getResource("/honeycomb-keystore"),
+                CERT_PASSWORD.toCharArray(), new TrustSelfSignedStrategy())
+            .build();
+
+        SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext);
+        CloseableHttpClient httpclient = HttpClients.custom()
+            .setSSLSocketFactory(sslsf)
+            .build();
+        Unirest.setHttpClient(httpclient);
+    }
+
+    @Test(timeout = 60000)
+    public void test() throws Exception {
+        io.fd.honeycomb.infra.bgp.distro.Main.init(BASE_MODULES);
+        LOG.info("Testing Honeycomb BGP distribution");
+        assertBgp();
+    }
+
+    private byte[] readMessage(final InputStream inputStream) throws IOException {
+        final int available = inputStream.available();
+        final byte[] msg = new byte[available];
+        ByteStreams.read(inputStream, msg, 0, available);
+        return msg;
+    }
+
+    private void assertBgp() throws Exception {
+        // Wait until BGP server is started
+        Thread.sleep(HELLO_WAIT);
+        final InetAddress bgpHost = InetAddress.getByName("127.0.0.1");
+        final InetAddress bgpPeerAddress = InetAddress.getByName("127.0.0.2");
+        try (final Socket localhost = new Socket(bgpHost, BGP_PORT, bgpPeerAddress, 0);
+             final InputStream inputStream = localhost.getInputStream()) {
+            // Wait until bgp message is sent
+            Thread.sleep(HELLO_WAIT);
+
+            final byte[] msg = readMessage(inputStream);
+            LOG.info("Received BGP message: {}", msg);
+
+            Assert.assertEquals(BGP_OPEN_MSG_TYPE, msg[BGP_MSG_TYPE_OFFSET]);
+        }
+    }
+}
\ No newline at end of file
diff --git a/infra/bgp-distribution/src/test/resources/WEB-INF/web.xml b/infra/bgp-distribution/src/test/resources/WEB-INF/web.xml
new file mode 100644 (file)
index 0000000..6cf4871
--- /dev/null
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  ~ Copyright (c) 2016 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.
+  -->
+
+<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+    version="3.0">
+
+    <servlet>
+        <servlet-name>JAXRSRestconf</servlet-name>
+        <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>org.opendaylight.netconf.sal.rest.impl.RestconfApplication</param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>JAXRSRestconf</servlet-name>
+        <url-pattern>/*</url-pattern>
+    </servlet-mapping>
+    <filter>
+        <filter-name>cross-origin-restconf</filter-name>
+        <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
+        <init-param>
+            <param-name>allowedOrigins</param-name>
+            <param-value>*</param-value>
+        </init-param>
+        <init-param>
+            <param-name>allowedMethods</param-name>
+            <param-value>GET,POST,OPTIONS,DELETE,PUT,HEAD</param-value>
+        </init-param>
+        <init-param>
+            <param-name>allowedHeaders</param-name>
+            <param-value>origin, content-type, accept, authorization</param-value>
+        </init-param>
+        <init-param>
+            <param-name>exposedHeaders</param-name>
+            <param-value>location</param-value>
+        </init-param>
+    </filter>
+    <filter-mapping>
+        <filter-name>cross-origin-restconf</filter-name>
+        <url-pattern>/*</url-pattern>
+    </filter-mapping>
+
+    <security-constraint>
+        <web-resource-collection>
+            <web-resource-name>NB api</web-resource-name>
+            <url-pattern>/*</url-pattern>
+            <http-method>POST</http-method>
+            <http-method>GET</http-method>
+            <http-method>PUT</http-method>
+            <http-method>PATCH</http-method>
+            <http-method>DELETE</http-method>
+            <http-method>HEAD</http-method>
+        </web-resource-collection>
+    </security-constraint>
+
+</web-app>
diff --git a/infra/bgp-distribution/src/test/resources/bgp.json b/infra/bgp-distribution/src/test/resources/bgp.json
new file mode 100644 (file)
index 0000000..494b6a9
--- /dev/null
@@ -0,0 +1,9 @@
+  {
+  "bgp-enabled": "true",
+  "bgp-binding-address": "127.0.0.1",
+  "bgp-port": 1790,
+  "bgp-as-number": 65000,
+  "bgp-receive-multiple-paths": "true",
+  "bgp-send-max-paths": 0,
+  "bgp-netty-threads": 2
+}
\ No newline at end of file
diff --git a/infra/bgp-distribution/src/test/resources/honeycomb-keystore b/infra/bgp-distribution/src/test/resources/honeycomb-keystore
new file mode 100644 (file)
index 0000000..44093dc
Binary files /dev/null and b/infra/bgp-distribution/src/test/resources/honeycomb-keystore differ
diff --git a/infra/bgp-distribution/src/test/resources/honeycomb.json b/infra/bgp-distribution/src/test/resources/honeycomb.json
new file mode 100644 (file)
index 0000000..a0b2a63
--- /dev/null
@@ -0,0 +1,40 @@
+  {
+  "persisted-context-path": "/tmp/honeycomb/persist/context/data.json",
+  "persisted-context-restoration-type": "Merge",
+  "persisted-config-path": "/tmp/honeycomb/persist/config/data.json",
+  "persisted-config-restoration-type": "Merge",
+
+  "notification-service-queue-depth": 1,
+
+  "restconf-http-enabled": "true",
+  "restconf-root-path": "/restconf",
+  "restconf-binding-address": "127.0.0.1",
+  "restconf-port": 8182,
+  "restconf-https-enabled": "true",
+  "restconf-https-binding-address": "127.0.0.1",
+  "restconf-https-port": 8444,
+  "restconf-keystore": "/honeycomb-keystore",
+  "restconf-keystore-password": "testing",
+  "restconf-keystore-manager-password": "testing",
+  "restconf-truststore": "/honeycomb-keystore",
+  "restconf-truststore-password": "testing",
+  "restconf-websocket-port": 7780,
+  "restconf-pool-max-size": 10,
+  "restconf-pool-min-size": 1,
+  "restconf-acceptors-size": 1,
+  "restconf-selectors-size": 1,
+  "restconf-https-acceptors-size": 1,
+  "restconf-https-selectors-size": 1,
+
+  "netconf-netty-threads": 2,
+  "netconf-tcp-enabled" : "true",
+  "netconf-tcp-binding-address": "127.0.0.1",
+  "netconf-tcp-binding-port": 7778,
+  "netconf-ssh-enabled" : "true",
+  "netconf-ssh-binding-address": "127.0.0.1",
+  "netconf-ssh-binding-port": 2832,
+  "netconf-notification-stream-name": "honeycomb",
+
+  "username": "admin",
+  "password": "admin"
+}
\ No newline at end of file
diff --git a/infra/bgp-distribution/src/test/resources/logback.xml b/infra/bgp-distribution/src/test/resources/logback.xml
new file mode 100644 (file)
index 0000000..2ee89db
--- /dev/null
@@ -0,0 +1,31 @@
+ <!--
+  ~ Copyright (c) 2016 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.
+  -->
+
+<configuration scan="true">
+
+  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+    <encoder>
+      <pattern>%date{"yyyy-MM-dd HH:mm:ss.SSS z"} [%thread] %-5level %logger{36} - %msg%n</pattern>
+    </encoder>
+  </appender>
+
+  <root level="warn">
+    <appender-ref ref="STDOUT" />
+  </root>
+
+  <logger name="org.opendaylight" level="INFO"/>
+  <logger name="io.fd" level="INFO"/>
+</configuration>
index 342bcf6..6376407 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.bgp.BgpModule,
-            io.fd.honeycomb.infra.distro.bgp.BgpExtensionsModule,
-            io.fd.honeycomb.infra.distro.bgp.BgpReadersModule,
-            io.fd.honeycomb.infra.distro.bgp.BgpWritersModule,
             io.fd.honeycomb.infra.distro.cfgattrs.CfgAttrsModule
         </distribution.modules>
     </properties>
             <groupId>org.opendaylight.netconf</groupId>
             <artifactId>ietf-netconf-monitoring-extension</artifactId>
         </dependency>
-        <!-- ODL-BGP -->
-        <dependency>
-            <groupId>org.opendaylight.bgpcep</groupId>
-            <artifactId>bgp-rib-impl</artifactId>
-            <!-- TODO remove exclusion after bumping to Boron-SR4 -->
-            <exclusions>
-                <exclusion>
-                    <groupId>org.powermock</groupId>
-                    <artifactId>powermock</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.bgpcep</groupId>
-            <artifactId>bgp-openconfig-impl</artifactId>
-        </dependency>
-        <!-- BGP extensions -->
-        <dependency>
-            <groupId>org.opendaylight.bgpcep</groupId>
-            <artifactId>bgp-evpn</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.bgpcep</groupId>
-            <artifactId>bgp-inet</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.bgpcep</groupId>
-            <artifactId>bgp-labeled-unicast</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.bgpcep</groupId>
-            <artifactId>bgp-linkstate</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.bgpcep</groupId>
-            <artifactId>bgp-l3vpn</artifactId>
-        </dependency>
-
         <!-- Jersey + Jetty for RESTCONF -->
         <dependency>
             <groupId>org.eclipse.jetty</groupId>
index fc8fb0e..4769b57 100644 (file)
@@ -31,7 +31,6 @@ import com.google.inject.ProvisionException;
 import com.google.inject.name.Names;
 import io.fd.honeycomb.data.init.DataTreeInitializer;
 import io.fd.honeycomb.data.init.InitializerRegistry;
-import io.fd.honeycomb.infra.distro.bgp.BgpServerProvider;
 import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration;
 import io.fd.honeycomb.infra.distro.initializer.InitializerPipelineModule;
 import io.fd.honeycomb.infra.distro.netconf.HoneycombNotification2NetconfProvider;
@@ -120,11 +119,6 @@ public final class Main {
                 injector.getInstance(HoneycombNotification2NetconfProvider.HoneycombNotification2Netconf.class);
             }
 
-            if (cfgAttributes.isBgpEnabled()) {
-                LOG.info("Starting BGP");
-                injector.getInstance(BgpServerProvider.BgpServer.class);
-            }
-
             try {
                 LOG.info("Initializing configuration");
                 injector.getInstance(Key.get(InitializerRegistry.class,
index c3d406c..cc46f7b 100644 (file)
@@ -55,10 +55,6 @@ public class HoneycombConfiguration {
         return isNetconfTcpEnabled() || isNetconfSshEnabled();
     }
 
-    public boolean isBgpEnabled() {
-        return Boolean.valueOf(bgpEnabled);
-    }
-
     public boolean isConfigPersistenceEnabled() {
         return persistConfig.isPresent() && Boolean.valueOf(persistConfig.get());
     }
@@ -66,10 +62,6 @@ public class HoneycombConfiguration {
         return persistContext.isPresent() && Boolean.valueOf(persistContext.get());
     }
 
-    public boolean isBgpMultiplePathsEnabled() {
-        return Boolean.valueOf(bgpMultiplePaths.get());
-    }
-
     @InjectConfig("persist-context")
     public Optional<String> persistContext = Optional.of("true");
     @InjectConfig("persisted-context-path")
@@ -146,20 +138,6 @@ public class HoneycombConfiguration {
     public Optional<Integer> netconfSshBindingPort;
     @InjectConfig("netconf-notification-stream-name")
     public Optional<String> netconfNotificationStreamName = Optional.of("honeycomb");
-    @InjectConfig("bgp-enabled")
-    public String bgpEnabled;
-    @InjectConfig("bgp-binding-address")
-    public Optional<String> bgpBindingAddress;
-    @InjectConfig("bgp-port")
-    public Optional<Integer> bgpPort;
-    @InjectConfig("bgp-as-number")
-    public Optional<Integer> bgpAsNumber;
-    @InjectConfig("bgp-receive-multiple-paths")
-    public Optional<String> bgpMultiplePaths;
-    @InjectConfig("bgp-send-max-paths")
-    public Optional<Integer> bgpSendMaxMaths;
-    @InjectConfig("bgp-netty-threads")
-    public Integer bgpNettyThreads;
     @InjectConfig("username")
     public String username;
     @InjectConfig("password")
@@ -200,13 +178,6 @@ public class HoneycombConfiguration {
                 .add("netconfSshBindingAddress", netconfSshBindingAddress)
                 .add("netconfSshBindingPort", netconfSshBindingPort)
                 .add("netconfNotificationStreamName", netconfNotificationStreamName)
-                .add("bgpEnabled", bgpEnabled)
-                .add("bgpBindingAddress", bgpBindingAddress)
-                .add("bgpPort", bgpPort)
-                .add("bgp-as-number", bgpAsNumber)
-                .add("bgp-netty-threads", bgpNettyThreads)
-                .add("bgp-receive-multiple-paths", bgpMultiplePaths)
-                .add("bgp-send-max-paths", bgpSendMaxMaths)
                 .add("username", username)
                 .add("password", password)
                 .toString();
index 95ab712..1199f85 100644 (file)
@@ -1,8 +1,8 @@
   {
-  "persist-context": "false",
+  "persist-context": "true",
   "persisted-context-path": "/var/lib/honeycomb/persist/context/data.json",
   "persisted-context-restoration-type": "Merge",
-  "persist-config": "false",
+  "persist-config": "true",
   "persisted-config-path": "/var/lib/honeycomb/persist/config/data.json",
   "persisted-config-restoration-type": "Merge",
 
   "netconf-ssh-binding-port": 2831,
   "netconf-notification-stream-name": "honeycomb",
 
-  "bgp-enabled": "true",
-  "bgp-binding-address": "127.0.0.1",
-  "bgp-port": 1790,
-  "bgp-as-number": 65000,
-  "bgp-receive-multiple-paths": "true",
-  "bgp-send-max-paths": 0,
-  "bgp-netty-threads": 2,
-
   "username": "admin",
   "password": "admin"
 }
\ No newline at end of file
index 02e801d..6dd4d4f 100644 (file)
@@ -6,10 +6,10 @@
     </encoder>
   </appender>
   <appender name="honeycomb.log" class="ch.qos.logback.core.rolling.RollingFileAppender">
-    <file>honeycomb.log</file>
+    <file>/var/log/honeycomb/honeycomb.log</file>
 
     <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-      <fileNamePattern>logs/honeycomb.%d.log.zip</fileNamePattern>
+      <fileNamePattern>/var/log/honeycomb/logs/honeycomb.%d.log.zip</fileNamePattern>
       <maxHistory>1</maxHistory>
     </rollingPolicy>
 
index fdd265b..ced2959 100644 (file)
@@ -18,7 +18,6 @@ package io.fd.honeycomb.infra.distro;
 
 import static com.google.common.collect.ImmutableSet.of;
 import static org.hamcrest.CoreMatchers.containsString;
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 
@@ -31,10 +30,6 @@ import com.jcraft.jsch.JSch;
 import com.jcraft.jsch.Session;
 import com.mashape.unirest.http.HttpResponse;
 import com.mashape.unirest.http.Unirest;
-import io.fd.honeycomb.infra.distro.bgp.BgpExtensionsModule;
-import io.fd.honeycomb.infra.distro.bgp.BgpModule;
-import io.fd.honeycomb.infra.distro.bgp.BgpReadersModule;
-import io.fd.honeycomb.infra.distro.bgp.BgpWritersModule;
 import io.fd.honeycomb.infra.distro.cfgattrs.CfgAttrsModule;
 import io.fd.honeycomb.infra.distro.data.ConfigAndOperationalPipelineModule;
 import io.fd.honeycomb.infra.distro.data.context.ContextPipelineModule;
@@ -46,7 +41,6 @@ import io.fd.honeycomb.infra.distro.schema.SchemaModule;
 import io.fd.honeycomb.infra.distro.schema.YangBindingProviderModule;
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.InetAddress;
 import java.net.Socket;
 import java.util.Properties;
 import java.util.Set;
@@ -75,36 +69,28 @@ public class BaseMinimalDistributionTest {
     private static final String NETCONF_NAMESPACE = "urn:ietf:params:xml:ns:netconf:base:1.0";
     private static final int HELLO_WAIT = 2500;
 
-    private static final int BGP_MSG_TYPE_OFFSET = 18; // 16 (MARKER) + 2 (LENGTH);
-    private static final byte BGP_OPEN_MSG_TYPE = 1;
-    private static final int BGP_PORT = 1790;
-
     public static final Set<Module> BASE_MODULES = of(
-            new YangBindingProviderModule(),
-            new SchemaModule(),
-            new ConfigAndOperationalPipelineModule(),
-            new ContextPipelineModule(),
-            new InitializerPipelineModule(),
-            new NetconfModule(),
-            new NetconfReadersModule(),
-            new RestconfModule(),
-            new BgpModule(),
-            new BgpExtensionsModule(),
-            new BgpReadersModule(),
-            new BgpWritersModule(),
-            new CfgAttrsModule());
+        new YangBindingProviderModule(),
+        new SchemaModule(),
+        new ConfigAndOperationalPipelineModule(),
+        new ContextPipelineModule(),
+        new InitializerPipelineModule(),
+        new NetconfModule(),
+        new NetconfReadersModule(),
+        new RestconfModule(),
+        new CfgAttrsModule());
 
     @Before
     public void setUp() throws Exception {
         SSLContext sslcontext = SSLContexts.custom()
-                .loadTrustMaterial(getClass().getResource("/honeycomb-keystore"),
-                        CERT_PASSWORD.toCharArray(), new TrustSelfSignedStrategy())
-                .build();
+            .loadTrustMaterial(getClass().getResource("/honeycomb-keystore"),
+                CERT_PASSWORD.toCharArray(), new TrustSelfSignedStrategy())
+            .build();
 
         SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext);
         CloseableHttpClient httpclient = HttpClients.custom()
-                .setSSLSocketFactory(sslsf)
-                .build();
+            .setSSLSocketFactory(sslsf)
+            .build();
         Unirest.setHttpClient(httpclient);
     }
 
@@ -124,8 +110,6 @@ public class BaseMinimalDistributionTest {
         assertRestconfHttp();
         LOG.info("Testing RESTCONF HTTPS");
         assertRestconfHttps();
-        LOG.info("Testing BGP");
-        assertBgp();
     }
 
     private void assertNetconfTcp() throws Exception {
@@ -182,13 +166,13 @@ public class BaseMinimalDistributionTest {
 
     private void assertRestconfHttp() throws Exception {
         final String url =
-                "http://127.0.0.1:" + HTTP_PORT + "/restconf/operational/ietf-netconf-monitoring:netconf-state";
+            "http://127.0.0.1:" + HTTP_PORT + "/restconf/operational/ietf-netconf-monitoring:netconf-state";
         LOG.info("RESTCONF HTTP GET to {}", url);
         final HttpResponse<String> jsonNodeHttpResponse = Unirest.get(url)
-                .basicAuth(UNAME, PASSWORD)
-                .asString();
+            .basicAuth(UNAME, PASSWORD)
+            .asString();
         LOG.info("RESTCONF HTTP GET to {}, status: {}, data: {}",
-                url, jsonNodeHttpResponse.getStatus(), jsonNodeHttpResponse.getBody());
+            url, jsonNodeHttpResponse.getStatus(), jsonNodeHttpResponse.getBody());
 
         assertSuccessStatus(jsonNodeHttpResponse);
         assertSuccessResponseForNetconfMonitoring(jsonNodeHttpResponse);
@@ -196,13 +180,13 @@ public class BaseMinimalDistributionTest {
 
     private void assertRestconfHttps() throws Exception {
         final String url =
-                "https://127.0.0.1:" + HTTPS_PORT + "/restconf/operational/ietf-netconf-monitoring:netconf-state";
+            "https://127.0.0.1:" + HTTPS_PORT + "/restconf/operational/ietf-netconf-monitoring:netconf-state";
         LOG.info("RESTCONF HTTPS GET to {}", url);
         final HttpResponse<String> jsonNodeHttpResponse = Unirest.get(url)
-                .basicAuth(UNAME, PASSWORD)
-                .asString();
+            .basicAuth(UNAME, PASSWORD)
+            .asString();
         LOG.info("RESTCONF HTTPS GET to {}, status: {}, data: {}",
-                url, jsonNodeHttpResponse.getStatus(), jsonNodeHttpResponse.getBody());
+            url, jsonNodeHttpResponse.getStatus(), jsonNodeHttpResponse.getBody());
 
         assertSuccessStatus(jsonNodeHttpResponse);
         assertSuccessResponseForNetconfMonitoring(jsonNodeHttpResponse);
@@ -217,19 +201,4 @@ public class BaseMinimalDistributionTest {
         assertTrue(jsonNodeHttpResponse.getStatus() >= 200);
         assertTrue(jsonNodeHttpResponse.getStatus() < 400);
     }
-
-    private void assertBgp() throws Exception {
-        final InetAddress bgpHost = InetAddress.getByName("127.0.0.1");
-        final InetAddress bgpPeerAddress = InetAddress.getByName("127.0.0.2");
-        try (final Socket localhost = new Socket(bgpHost, BGP_PORT, bgpPeerAddress, 0);
-             final InputStream inputStream = localhost.getInputStream()) {
-            // wait until bgp message is sent
-            Thread.sleep(HELLO_WAIT);
-
-            final byte[] msg = readMessage(inputStream);
-            LOG.info("Received BGP message: {}", msg);
-
-            assertEquals(BGP_OPEN_MSG_TYPE, msg[BGP_MSG_TYPE_OFFSET]);
-        }
-    }
 }
\ No newline at end of file
index be62774..a0b2a63 100644 (file)
   "netconf-ssh-binding-port": 2832,
   "netconf-notification-stream-name": "honeycomb",
 
-  "bgp-enabled": "true",
-  "bgp-binding-address": "127.0.0.1",
-  "bgp-port": 1790,
-  "bgp-as-number": 65000,
-  "bgp-receive-multiple-paths": "true",
-  "bgp-send-max-paths": 0,
-  "bgp-netty-threads": 2,
-
   "username": "admin",
   "password": "admin"
 }
\ No newline at end of file
index a32defa..1a49fba 100644 (file)
@@ -41,6 +41,7 @@
     <module>cfg-init</module>
     <module>impl</module>
     <module>minimal-distribution</module>
+    <module>bgp-distribution</module>
     <module>it</module>
     <module>test-utils</module>
     <module>rpc</module>
index c9be4ae..f06e6ae 100644 (file)
@@ -33,9 +33,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 /**
  * Simple DataBroker backed writer allowing to delegate writes to different brokers.
  */
-public final class BindingBrokerWriter<D extends DataObject>
-    implements Writer<D> {
-
+public final class BindingBrokerWriter<D extends DataObject> implements Writer<D> {
     private final InstanceIdentifier<D> instanceIdentifier;
     private final DataBroker dataBroker;