diff options
Diffstat (limited to 'infra/bgp-distribution/src/main')
-rw-r--r-- | infra/bgp-distribution/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java | 9 | ||||
-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.java | 3 |
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!"); } |