-public final class BGPDispatcherImpl extends AbstractDispatcher<BGPSessionImpl, BGPSessionListener> implements BGPDispatcher, BGPServerDispatcher, AutoCloseable {
- private final MD5ServerChannelFactory<?> scf;
- private final MD5ChannelFactory<?> cf;
- private final BGPHandlerFactory hf;
- private final Timer timer;
- private KeyMapping keys;
-
- public BGPDispatcherImpl(final MessageRegistry messageRegistry, final Timer timer, final EventLoopGroup bossGroup,
- final EventLoopGroup workerGroup) {
- this(messageRegistry, timer, bossGroup, workerGroup, null, null);
+@Singleton
+@Component(immediate = true)
+public final class BGPDispatcherImpl implements BGPDispatcher {
+ private static final Logger LOG = LoggerFactory.getLogger(BGPDispatcherImpl.class);
+ private static final int SOCKET_BACKLOG_SIZE = 128;
+
+ private static final WriteBufferWaterMark WATER_MARK = new WriteBufferWaterMark(128 * 1024, 256 * 1024);
+
+ // An adaptive allocator, so we size our message buffers based on what we receive, but make sure we process one
+ // message at a time. This should be good enough for most cases, although we could optimize it a bit based on
+ // whether we actually negotiate use of large messages -- based on that the range of allocations can be constrained
+ // from the default 64-65536 range to 64-4096.
+ private static final RecvByteBufAllocator RECV_ALLOCATOR = new AdaptiveRecvByteBufAllocator().maxMessagesPerRead(1);
+
+ private final BGPHandlerFactory handlerFactory;
+ private final BGPPeerRegistry bgpPeerRegistry;
+ private final BGPNettyGroups nettyGroups;
+
+ @Inject
+ @Activate
+ public BGPDispatcherImpl(@Reference final BGPExtensionConsumerContext extensions,
+ @Reference final BGPNettyGroups nettyGroups, @Reference final BGPPeerRegistry bgpPeerRegistry) {
+ this.nettyGroups = requireNonNull(nettyGroups);
+ this.bgpPeerRegistry = requireNonNull(bgpPeerRegistry);
+ handlerFactory = new BGPHandlerFactory(extensions.getMessageRegistry());