Package org.jivesoftware.openfire.spi
Class NettyConnectionAcceptor
java.lang.Object
org.jivesoftware.openfire.spi.ConnectionAcceptor
org.jivesoftware.openfire.spi.NettyConnectionAcceptor
Responsible for accepting new (socket) connections, using Java NIO implementation provided by the Netty framework.
- Author:
- Matthew Vivian, Alex Gidman
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SystemProperty<Integer>Sets the maximum number of incoming connection requests that can be queued before the OS starts rejecting new connections.static final SystemProperty<Boolean>Enables TCP keep-alive on the socket to periodically check if the connection is still alive and prevent idle connections from being silently dropped.static final SystemProperty<Duration>Specifies how long a socket should wait to send remaining data when closed; negative disables SO_LINGER.static final SystemProperty<Integer>Defines the size (in bytes) of the TCP receive buffer for accepted sockets.static final SystemProperty<Boolean>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.static final SystemProperty<Integer>Defines the size (in bytes) of the TCP send buffer for accepted sockets.static final SystemProperty<Duration>Timeout in seconds to wait for the boss EventLoop to process the startup barrier task before logging a warning.static final SystemProperty<Boolean>Controls whether the Nagle algorithm is disabled (true) to send small packets immediately or enabled (false) to coalesce them.Fields inherited from class org.jivesoftware.openfire.spi.ConnectionAcceptor
configuration -
Constructor Summary
ConstructorsConstructorDescriptionNettyConnectionAcceptor(ConnectionConfiguration configuration) Instantiates, but does not start, a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a new ChannelHandler factory, which will cause ChannelHandlers to be added to existing and new Channels that are generated by this acceptor.Returns a copy of the collection of ChannelHandler factories that are registered with this instance.intgetPort()booleanisIdle()Determines if this instance is currently in a state where it is actively serving connections or not.voidreconfigure(ConnectionConfiguration configuration) Reloads the acceptor configuration, without causing a disconnect of already established connections.voidRemoves a new ChannelHandler factory, which will cause the ChannelHandler that it created to be removed from existing Channels that were generated by this acceptor.voidstart()Starts this acceptor by binding the socket acceptor.voidstop()Stops this acceptor by unbinding the socket acceptor.
-
Field Details
-
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
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
Controls whether the Nagle algorithm is disabled (true) to send small packets immediately or enabled (false) to coalesce them. -
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
Defines the size (in bytes) of the TCP send buffer for accepted sockets. -
SOCKET_RECEIVE_BUFFER_SIZE
Defines the size (in bytes) of the TCP receive buffer for accepted sockets. -
SOCKET_LINGER_DURATION
Specifies how long a socket should wait to send remaining data when closed; negative disables SO_LINGER. -
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
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:
startin classConnectionAcceptor
-
stop
public void stop()Stops this acceptor by unbinding the socket acceptor. Does nothing when the instance is not started.- Specified by:
stopin classConnectionAcceptor
-
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:
isIdlein classConnectionAcceptor- Returns:
- false when this instance is started and is currently being used to serve connections (otherwise true)
-
reconfigure
Description copied from class:ConnectionAcceptorReloads 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:
reconfigurein classConnectionAcceptor- Parameters:
configuration- The configuration for connections to be accepted (cannot be null).
-
addChannelHandler
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
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
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()
-