summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2017-05-31 10:50:13 +0200
committerMarek Gradzki <mgradzki@cisco.com>2017-05-31 10:50:13 +0200
commitb09fb9d9df8ff2539710aa3fd05e1f9085d7a936 (patch)
treee4d575775a4590caed4f0d16f355db20aa4b62ee
parentcecb372cc2b664cc7f7b56aeb4cf6f90f7ea9b5c (diff)
Dedicated provider for BgpNeighbours
Change-Id: I1a98ea27dde5ba77f8b20382dfeb29496f3282b2 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
-rw-r--r--infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java9
-rw-r--r--infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpNeighboursProvider.java (renamed from infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BGPPeerRegistryProvider.java)16
-rw-r--r--infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/distro/Main.java3
3 files changed, 20 insertions, 8 deletions
diff --git a/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java
index 128e9f0de..efef5a71f 100644
--- a/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java
+++ b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java
@@ -32,9 +32,11 @@ import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
import org.opendaylight.protocol.bgp.openconfig.impl.BGPOpenConfigMappingServiceImpl;
import org.opendaylight.protocol.bgp.openconfig.spi.BGPOpenConfigMappingService;
+import org.opendaylight.protocol.bgp.rib.impl.StrictBGPPeerRegistry;
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;
public final class BgpModule extends PrivateModule {
@@ -49,11 +51,16 @@ public final class BgpModule extends PrivateModule {
// Configure peer registry
bind(BGPOpenConfigMappingService.class).toInstance(new BGPOpenConfigMappingServiceImpl());
- bind(BGPPeerRegistry.class).toProvider(BGPPeerRegistryProvider.class);
+ bind(BGPPeerRegistry.class).toInstance(StrictBGPPeerRegistry.instance());
+
// 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);
}
private void configureRIB() {
diff --git a/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BGPPeerRegistryProvider.java b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpNeighboursProvider.java
index 217c43823..fab14e827 100644
--- a/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BGPPeerRegistryProvider.java
+++ b/infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpNeighboursProvider.java
@@ -37,6 +37,7 @@ import org.opendaylight.protocol.bgp.rib.impl.config.BgpPeer;
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.BgpNeighborPeerGroupConfig;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.BgpNeighbors;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.Bgp;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Neighbors;
@@ -60,8 +61,8 @@ 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);
+final class BgpNeighboursProvider extends ProviderTrait<BgpNeighbors> {
+ private static final Logger LOG = LoggerFactory.getLogger(BgpNeighboursProvider.class);
private static final String PEERS_CFG = "/bgp-peers.json";
@Inject
private BindingToNormalizedNodeCodec codec;
@@ -71,11 +72,12 @@ final class BGPPeerRegistryProvider extends ProviderTrait<BGPPeerRegistry> {
private BGPOpenConfigMappingService mappingService;
@Inject
private SchemaService schemaService;
+ @Inject
+ private BGPPeerRegistry peerRegistry;
@Override
- protected BGPPeerRegistry create() {
- final BGPPeerRegistry peerRegistry = StrictBGPPeerRegistry.instance();
- final Neighbors neighbors = readNeighbours();
+ protected BgpNeighbors create() {
+ final BgpNeighbors neighbors = readNeighbours();
for (final Neighbor neighbor : neighbors.getNeighbor()) {
if (isApplicationPeer(neighbor)) {
LOG.trace("Starting AppPeer for {}", neighbor);
@@ -85,8 +87,8 @@ final class BGPPeerRegistryProvider extends ProviderTrait<BGPPeerRegistry> {
new BgpPeer(null, peerRegistry).start(globalRib, neighbor, mappingService, null);
}
}
- LOG.debug("Created BGPPeerRegistry with neighbours {}", neighbors);
- return peerRegistry;
+ LOG.debug("BgpNeighbours initialized: {}", neighbors);
+ return neighbors;
}
private Neighbors readNeighbours() {
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
index 0204e1f5c..bf6725a09 100644
--- 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
@@ -28,6 +28,7 @@ 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.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.BgpNeighbors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -54,6 +55,8 @@ public final class Main {
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!");
}