Class NettyConnectionAcceptor

java.lang.Object
org.jivesoftware.openfire.spi.ConnectionAcceptor
org.jivesoftware.openfire.spi.NettyConnectionAcceptor

public class NettyConnectionAcceptor extends ConnectionAcceptor
Responsible for accepting new (socket) connections, using Java NIO implementation provided by the Netty framework.
Author:
Matthew Vivian, Alex Gidman
  • Field Details

    • SOCKET_BACKLOG

      public static final SystemProperty<Integer> SOCKET_BACKLOG
      Sets the maximum number of incoming connection requests that can be queued before the OS starts rejecting new connections.
    • SOCKET_KEEP_ALIVE_ENABLED

      public static final SystemProperty<Boolean> SOCKET_KEEP_ALIVE_ENABLED
      Enables TCP keep-alive on the socket to periodically check if the connection is still alive and prevent idle connections from being silently dropped.
    • TCP_NODELAY_ENABLED

      public static final SystemProperty<Boolean> TCP_NODELAY_ENABLED
      Controls whether the Nagle algorithm is disabled (true) to send small packets immediately or enabled (false) to coalesce them.
    • SOCKET_REUSE_ADDRESS_ENABLED

      public static final SystemProperty<Boolean> SOCKET_REUSE_ADDRESS_ENABLED
      Allows the socket to bind to a port even if a previous connection on that port is in the TIME_WAIT state, enabling faster server restarts.
    • SOCKET_SEND_BUFFER_SIZE

      public static final SystemProperty<Integer> SOCKET_SEND_BUFFER_SIZE
      Defines the size (in bytes) of the TCP send buffer for accepted sockets.
    • SOCKET_RECEIVE_BUFFER_SIZE

      public static final SystemProperty<Integer> SOCKET_RECEIVE_BUFFER_SIZE
      Defines the size (in bytes) of the TCP receive buffer for accepted sockets.
    • SOCKET_LINGER_DURATION

      public static final SystemProperty<Duration> SOCKET_LINGER_DURATION
      Specifies how long a socket should wait to send remaining data when closed; negative disables SO_LINGER.
    • STARTUP_LATCH_TIMEOUT

      public static final SystemProperty<Duration> STARTUP_LATCH_TIMEOUT
      Timeout in seconds to wait for the boss EventLoop to process the startup barrier task before logging a warning.
  • Constructor Details

    • NettyConnectionAcceptor

      public NettyConnectionAcceptor(ConnectionConfiguration configuration)
      Instantiates, but does not start, a new instance.
  • Method Details

    • start

      public void start()
      Starts this acceptor by binding the socket acceptor. When the acceptor is already started, a warning will be logged and the method invocation is otherwise ignored.
      Specified by:
      start in class ConnectionAcceptor
    • stop

      public void stop()
      Stops this acceptor by unbinding the socket acceptor. Does nothing when the instance is not started.
      Specified by:
      stop in class ConnectionAcceptor
    • isIdle

      public boolean isIdle()
      Determines if this instance is currently in a state where it is actively serving connections or not. Channel must be open with no connections if it is idle
      Specified by:
      isIdle in class ConnectionAcceptor
      Returns:
      false when this instance is started and is currently being used to serve connections (otherwise true)
    • reconfigure

      public void reconfigure(ConnectionConfiguration configuration)
      Description copied from class: ConnectionAcceptor
      Reloads the acceptor configuration, without causing a disconnect of already established connections. A best-effort reload will be attempted. Configuration changes that require a restart of connections, such as the bind-address and port, will not be applied. The configuration that's provided will replace the existing configuration. A restart of the connection acceptor after this method was invoked will apply all configuration changes.
      Specified by:
      reconfigure in class ConnectionAcceptor
      Parameters:
      configuration - The configuration for connections to be accepted (cannot be null).
    • addChannelHandler

      public void addChannelHandler(NettyChannelHandlerFactory factory)
      Adds a new ChannelHandler factory, which will cause ChannelHandlers to be added to existing and new Channels that are generated by this acceptor. Note that instances of NettyConnectionAcceptor are replaced when the configuration of the ConnectionListener is modified. The new instance will not automatically have the factory that was added to an earlier instance. Listen for ConnectionAcceptor events to be able to re-supply the factory if need be
      Parameters:
      factory - A factory of ChannelHandler instances.
      See Also:
    • removeChannelHandler

      public void removeChannelHandler(NettyChannelHandlerFactory factory)
      Removes a new ChannelHandler factory, which will cause the ChannelHandler that it created to be removed from existing Channels that were generated by this acceptor. New Channels will no longer get a ChannelHandler from this factory either.
      Parameters:
      factory - A factory of ChannelHandler instances.
    • getChannelHandlerFactories

      public Set<NettyChannelHandlerFactory> getChannelHandlerFactories()
      Returns a copy of the collection of ChannelHandler factories that are registered with this instance.
      Returns:
      A collection of ChannelHandler factory instances.
    • getPort

      public int getPort()