diff options
Diffstat (limited to 'infra/northbound/bgp')
3 files changed, 36 insertions, 23 deletions
diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BGPExtensionConsumerContextProvider.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BGPExtensionConsumerContextProvider.java index 106a882ec..1bb0c5a1b 100644 --- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BGPExtensionConsumerContextProvider.java +++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BGPExtensionConsumerContextProvider.java @@ -18,6 +18,7 @@ package io.fd.honeycomb.infra.bgp; import com.google.inject.Inject; import io.fd.honeycomb.binding.init.ProviderTrait; +import io.fd.honeycomb.data.init.ShutdownHandler; import java.util.ArrayList; import java.util.Set; import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionConsumerContext; @@ -34,6 +35,9 @@ final class BGPExtensionConsumerContextProvider extends ProviderTrait<BGPExtensi @Inject private Set<BGPExtensionProviderActivator> activators; + @Inject + private ShutdownHandler shutdownHandler; + @Override protected BGPExtensionConsumerContext create() { final BGPExtensionProviderContext ctx = new SimpleBGPExtensionProviderContext(); @@ -41,6 +45,7 @@ final class BGPExtensionConsumerContextProvider extends ProviderTrait<BGPExtensi new SimpleBGPExtensionProviderContextActivator(ctx, new ArrayList<>(activators)); LOG.debug("Starting BGPExtensionConsumerContext with activators: {}", activators); activator.start(); + shutdownHandler.register("bgp-extension-context-activator", activator); return ctx; } } diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpRIBProvider.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpRIBProvider.java index a25808850..60d478325 100644 --- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpRIBProvider.java +++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpRIBProvider.java @@ -21,6 +21,7 @@ import static org.opendaylight.protocol.bgp.rib.impl.config.OpenConfigMappingUti import com.google.common.collect.ImmutableList; import com.google.inject.Inject; import io.fd.honeycomb.binding.init.ProviderTrait; +import io.fd.honeycomb.data.init.ShutdownHandler; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -70,6 +71,8 @@ final class BgpRIBProvider extends ProviderTrait<RIB> { private BGPTableTypeRegistryConsumer tableTypeRegistry; @Inject private SchemaService schemaService; + @Inject + private ShutdownHandler shutdownHandler; @Override protected RIB create() { @@ -79,48 +82,49 @@ final class BgpRIBProvider extends ProviderTrait<RIB> { 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, - new AfiSafi2Builder().setReceive(cfg.isBgpMultiplePathsEnabled()) - .setSendMax(cfg.bgpSendMaxMaths.get().shortValue()).build()) - .build(), - new AfiSafiBuilder().setAfiSafiName(IPV4LABELLEDUNICAST.class) - .addAugmentation(AfiSafi2.class, - new AfiSafi2Builder().setReceive(cfg.isBgpMultiplePathsEnabled()) - .setSendMax(cfg.bgpSendMaxMaths.get().shortValue()).build()) - .build() - ); + new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class) + .addAugmentation(AfiSafi2.class, + new AfiSafi2Builder().setReceive(cfg.isBgpMultiplePathsEnabled()) + .setSendMax(cfg.bgpSendMaxMaths.get().shortValue()).build()) + .build(), + new AfiSafiBuilder().setAfiSafiName(IPV4LABELLEDUNICAST.class) + .addAugmentation(AfiSafi2.class, + new AfiSafi2Builder().setReceive(cfg.isBgpMultiplePathsEnabled()) + .setSendMax(cfg.bgpSendMaxMaths.get().shortValue()).build()) + .build() + ); final Map<TablesKey, PathSelectionMode> pathSelectionModes = - OpenConfigMappingUtil.toPathSelectionMode(afiSafi, tableTypeRegistry) - .entrySet().stream().collect(Collectors.toMap(entry -> - new TablesKey(entry.getKey().getAfi(), entry.getKey().getSafi()), Map.Entry::getValue)); + OpenConfigMappingUtil.toPathSelectionMode(afiSafi, tableTypeRegistry) + .entrySet().stream().collect(Collectors.toMap(entry -> + new TablesKey(entry.getKey().getAfi(), entry.getKey().getSafi()), Map.Entry::getValue)); // based on org.opendaylight.protocol.bgp.rib.impl.config.RibImpl.createRib + final PingPongDataBroker pingPongDataBroker = new PingPongDataBroker(domBroker); final RIBImpl rib = - new RIBImpl(new NoopClusterSingletonServiceProvider(), new RibId(cfg.bgpProtocolInstanceName.get()), - asNumber, new BgpId(routerId), clusterId, extensions, dispatcher, codec, - new PingPongDataBroker(domBroker), toTableTypes(afiSafi, tableTypeRegistry), pathSelectionModes, - extensions.getClassLoadingStrategy(), null); + new RIBImpl(new NoopClusterSingletonServiceProvider(), new RibId(cfg.bgpProtocolInstanceName.get()), + asNumber, new BgpId(routerId), clusterId, extensions, dispatcher, codec, + pingPongDataBroker, toTableTypes(afiSafi, tableTypeRegistry), pathSelectionModes, + extensions.getClassLoadingStrategy(), null); // required for proper RIB's CodecRegistry initialization (based on RIBImpl.start) schemaService.registerSchemaContextListener(rib); - + shutdownHandler.register("ping-pong-data-broker", pingPongDataBroker); LOG.debug("BGP RIB created successfully: {}", rib); return rib; } /** - * HC does not support clustering, but BGP uses {@link ClusterSingletonServiceProvider} - * to initialize {@link RIBImpl}. Therefore we provide this dummy implementation. + * HC does not support clustering, but BGP uses {@link ClusterSingletonServiceProvider} to initialize {@link + * RIBImpl}. Therefore we provide this dummy implementation. */ private static final class NoopClusterSingletonServiceProvider implements ClusterSingletonServiceProvider { private static final Logger LOG = LoggerFactory.getLogger(NoopClusterSingletonServiceProvider.class); private static final ClusterSingletonServiceRegistration REGISTRATION = - () -> LOG.debug("Closing ClusterSingletonServiceRegistration"); + () -> LOG.debug("Closing ClusterSingletonServiceRegistration"); @Override public ClusterSingletonServiceRegistration registerClusterSingletonService( - final ClusterSingletonService clusterSingletonService) { + final ClusterSingletonService clusterSingletonService) { clusterSingletonService.instantiateServiceInstance(); return REGISTRATION; } diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/RIBExtensionConsumerContextProvider.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/RIBExtensionConsumerContextProvider.java index 696726ac4..07ab86992 100644 --- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/RIBExtensionConsumerContextProvider.java +++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/RIBExtensionConsumerContextProvider.java @@ -18,6 +18,7 @@ package io.fd.honeycomb.infra.bgp; import com.google.inject.Inject; import io.fd.honeycomb.binding.init.ProviderTrait; +import io.fd.honeycomb.data.init.ShutdownHandler; import java.util.ArrayList; import java.util.Set; import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionConsumerContext; @@ -32,6 +33,8 @@ public class RIBExtensionConsumerContextProvider extends ProviderTrait<RIBExtens private static final Logger LOG = LoggerFactory.getLogger(RIBExtensionConsumerContextProvider.class); @Inject private Set<RIBExtensionProviderActivator> activators; + @Inject + private ShutdownHandler shutdownHandler; @Override protected RIBExtensionConsumerContext create() { @@ -40,6 +43,7 @@ public class RIBExtensionConsumerContextProvider extends ProviderTrait<RIBExtens new SimpleRIBExtensionProviderContextActivator(ctx, new ArrayList<>(activators)); LOG.debug("Starting RIBExtensionConsumerContext with activators: {}", activators); activator.start(); + shutdownHandler.register("rib-extension-consumer-context-activator", activator); return ctx; } } |