BUG-4689: Advertising performance fix
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / BGPDispatcherImpl.java
index 4034eec7a381dc516125d4209e4865f25373bae1..3fcb966ed3a7153a45c643eba4c1fd5199411f17 100644 (file)
@@ -49,6 +49,9 @@ import org.slf4j.LoggerFactory;
 public class BGPDispatcherImpl implements BGPDispatcher, AutoCloseable {
     private static final Logger LOG = LoggerFactory.getLogger(BGPDispatcherImpl.class);
     private static final int SOCKET_BACKLOG_SIZE = 128;
+    private static final int HIGH_WATER_MARK = 256 * 1024;
+    private static final int LOW_WATER_MARK = 128 * 1024;
+
     private final MD5ServerChannelFactory<?> serverChannelFactory;
     private final MD5ChannelFactory<?> channelFactory;
     private final BGPHandlerFactory handlerFactory;
@@ -99,6 +102,8 @@ public class BGPDispatcherImpl implements BGPDispatcher, AutoCloseable {
         // Make sure we are doing round-robin processing
         bootstrap.option(ChannelOption.MAX_MESSAGES_PER_READ, 1);
         bootstrap.option(ChannelOption.SO_KEEPALIVE, Boolean.TRUE);
+        bootstrap.option(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, HIGH_WATER_MARK);
+        bootstrap.option(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, LOW_WATER_MARK);
 
         if (bootstrap.group() == null) {
             bootstrap.group(this.workerGroup);
@@ -139,6 +144,8 @@ public class BGPDispatcherImpl implements BGPDispatcher, AutoCloseable {
         serverBootstrap.childHandler(BGPChannel.createChannelInitializer(initializer, new DefaultPromise(BGPDispatcherImpl.this.executor)));
         serverBootstrap.option(ChannelOption.SO_BACKLOG, Integer.valueOf(SOCKET_BACKLOG_SIZE));
         serverBootstrap.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
+        serverBootstrap.childOption(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, HIGH_WATER_MARK);
+        serverBootstrap.childOption(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, LOW_WATER_MARK);
         if (this.keys.isPresent()) {
             if (this.serverChannelFactory == null) {
                 throw new UnsupportedOperationException("No key access instance available, cannot use key mapping");