Package org.newsclub.net.unix.jetty
Class AFSocketServerConnector
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.server.AbstractConnector
org.newsclub.net.unix.jetty.AFSocketServerConnector
- All Implemented Interfaces:
org.eclipse.jetty.server.Connector
,org.eclipse.jetty.util.component.Container
,org.eclipse.jetty.util.component.Destroyable
,org.eclipse.jetty.util.component.Dumpable
,org.eclipse.jetty.util.component.Dumpable.DumpableContainer
,org.eclipse.jetty.util.component.Graceful
,org.eclipse.jetty.util.component.LifeCycle
@ManagedObject
public class AFSocketServerConnector
extends org.eclipse.jetty.server.AbstractConnector
A
Connector
implementation for junixsocket server socket channels (Unix domains etc.)
Based upon jetty's UnixDomainServerConnector.
This implementation should work with jetty version 9.4.12 or newer.-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener, org.eclipse.jetty.util.component.AbstractLifeCycle.StopException
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
org.eclipse.jetty.util.component.Dumpable.DumpableContainer
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Graceful
org.eclipse.jetty.util.component.Graceful.Shutdown, org.eclipse.jetty.util.component.Graceful.ThrowingRunnable
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
org.eclipse.jetty.util.component.LifeCycle.Listener
-
Field Summary
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
FAILED, STARTED, STARTING, STOPPED, STOPPING
Fields inherited from interface org.eclipse.jetty.util.component.Dumpable
KEY
-
Constructor Summary
ConstructorDescriptionAFSocketServerConnector
(org.eclipse.jetty.server.Server server, int acceptors, int selectors, org.eclipse.jetty.server.ConnectionFactory... factories) Creates a newAFSocketServerConnector
.AFSocketServerConnector
(org.eclipse.jetty.server.Server server, Executor executor, org.eclipse.jetty.util.thread.Scheduler scheduler, org.eclipse.jetty.io.ByteBufferPool pool, int acceptors, int selectors, org.eclipse.jetty.server.ConnectionFactory... factories) Creates a newAFSocketServerConnector
.AFSocketServerConnector
(org.eclipse.jetty.server.Server server, org.eclipse.jetty.server.ConnectionFactory... factories) Creates a newAFSocketServerConnector
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
accept
(int acceptorID) protected void
configure
(SocketChannel channel) Configures an incomingSocketChannel
, setting socket options such as receive and send buffer sizes.protected void
doStart()
protected void
doStop()
int
Returns the SO_RCVBUF size for accepted sockets.int
Returns the SO_SNDBUF size for accepted sockets.int
Returns the accept queue size (backlog) for the server socket.org.newsclub.net.unix.AFSocketAddress
Returns the socket address this connector listens to.Deprecated.boolean
Checks whether this connector uses a server channel inherited from the JVM.boolean
Checks if this connector may stop the server when it's no longer able to serve and no other connectors are available.boolean
Checks if this connector may stop the server when it's no longer able to serve, even if other connectors are available.void
setAcceptedReceiveBufferSize
(int acceptedReceiveBufferSize) Sets the SO_RCVBUF size for accepted sockets.void
setAcceptedSendBufferSize
(int acceptedSendBufferSize) Sets the SO_SNDBUF size for accepted sockets.void
setAccepting
(boolean accepting) void
setAcceptQueueSize
(int acceptQueueSize) Sets the accept queue size (backlog) for the server socket.void
setInheritChannel
(boolean inheritChannel) Sets whether this connector uses a server channel inherited from the JVM.void
setListenSocketAddress
(org.newsclub.net.unix.AFSocketAddress addr) Sets the socket address this connector listens to.void
setMayStopServer
(boolean mayStopServer) Sets if this connector may stop the server when it's no longer able to serve and no other connectors are available.void
setMayStopServerForce
(boolean b) Sets if this connector may stop the server when it's no longer able to serve and no other connectors are available.void
setUnixDomainPath
(Path unixDomainPath) Deprecated.UsesetListenSocketAddress(AFSocketAddress)
instead.toString()
Methods inherited from class org.eclipse.jetty.server.AbstractConnector
addConnectionFactory, addFirstConnectionFactory, addIfAbsentConnectionFactory, clearConnectionFactories, getAcceptorPriorityDelta, getAcceptors, getByteBufferPool, getConnectedEndPoints, getConnectionFactories, getConnectionFactory, getConnectionFactory, getDefaultConnectionFactory, getDefaultProtocol, getExecutor, getIdleTimeout, getName, getProtocols, getScheduler, getServer, getShutdownIdleTimeout, handleAcceptFailure, interruptAcceptors, isAccepting, isShutdown, join, join, onEndPointClosed, onEndPointOpened, removeConnectionFactory, setAcceptorPriorityDelta, setConnectionFactories, setDefaultProtocol, setIdleTimeout, setName, setShutdownIdleTimeout, shutdown
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, installBean, installBean, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeans
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.util.component.Container
addBean, addBean, addEventListener, getBean, getBeans, getBeans, getCachedBeans, getContainedBeans, getEventListeners, isManaged, manage, removeBean, removeEventListener, unmanage
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable
dump, dump, dumpSelf
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addEventListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeEventListener, start, stop
-
Constructor Details
-
AFSocketServerConnector
public AFSocketServerConnector(org.eclipse.jetty.server.Server server, org.eclipse.jetty.server.ConnectionFactory... factories) Creates a newAFSocketServerConnector
.- Parameters:
server
- The server this connector will be added to. Must not be null.factories
- The Connection Factories to use.
-
AFSocketServerConnector
public AFSocketServerConnector(org.eclipse.jetty.server.Server server, int acceptors, int selectors, org.eclipse.jetty.server.ConnectionFactory... factories) Creates a newAFSocketServerConnector
.- Parameters:
server
- The server this connector will be added to. Must not be null.acceptors
- the number of acceptor threads to use, or -1 for a default value. If 0, then no acceptor threads will be launched and some other mechanism will need to be used to accept new connections.selectors
- The number of selectors to use, or -1 for a default derivedfactories
- The Connection Factories to use.
-
AFSocketServerConnector
public AFSocketServerConnector(org.eclipse.jetty.server.Server server, Executor executor, org.eclipse.jetty.util.thread.Scheduler scheduler, org.eclipse.jetty.io.ByteBufferPool pool, int acceptors, int selectors, org.eclipse.jetty.server.ConnectionFactory... factories) Creates a newAFSocketServerConnector
.- Parameters:
server
- The server this connector will be added to. Must not be null.executor
- An executor for this connector or null to use the servers executorscheduler
- A scheduler for this connector or null to either aScheduler
set as a server bean or if none set, then a newScheduledExecutorScheduler
instance.pool
- A buffer pool for this connector or null to either aByteBufferPool
set as a server bean or none set, the new {code ArrayByteBufferPool} instance.acceptors
- the number of acceptor threads to use, or -1 for a default value. If 0, then no acceptor threads will be launched and some other mechanism will need to be used to accept new connections.selectors
- The number of selectors to use, or -1 for a default derivedfactories
- The Connection Factories to use.
-
-
Method Details
-
getUnixDomainPath
@ManagedAttribute("The Unix-Domain path this connector listens to") @Deprecated public Path getUnixDomainPath()Deprecated.UsegetListenSocketAddress()
instead.Returns the Unix-Domain path this connector listens to. Added for compatibility with jetty'sUnixDomainServerConnector
.- Returns:
- The Unix-Domain path this connector listens to.
- See Also:
-
setUnixDomainPath
Deprecated.UsesetListenSocketAddress(AFSocketAddress)
instead.Sets the Unix-Domain path this connector listens to. Added for compatibility with jetty'sUnixDomainServerConnector
.- Parameters:
unixDomainPath
- The path.- See Also:
-
getListenSocketAddress
@ManagedAttribute("The socket address this connector listens to") public org.newsclub.net.unix.AFSocketAddress getListenSocketAddress()Returns the socket address this connector listens to.- Returns:
- The socket address, or
null
if none set.
-
setListenSocketAddress
public void setListenSocketAddress(org.newsclub.net.unix.AFSocketAddress addr) Sets the socket address this connector listens to.- Parameters:
addr
- The socket address, ornull
.
-
isInheritChannel
@ManagedAttribute("Whether this connector uses a server channel inherited from the JVM") public boolean isInheritChannel()Checks whether this connector uses a server channel inherited from the JVM.- Returns:
true
if so.
-
setInheritChannel
public void setInheritChannel(boolean inheritChannel) Sets whether this connector uses a server channel inherited from the JVM.- Parameters:
inheritChannel
-true
if so.
-
getAcceptQueueSize
@ManagedAttribute("The accept queue size (backlog) for the server socket") public int getAcceptQueueSize()Returns the accept queue size (backlog) for the server socket.- Returns:
- The backlog.
-
setAcceptQueueSize
public void setAcceptQueueSize(int acceptQueueSize) Sets the accept queue size (backlog) for the server socket.- Parameters:
acceptQueueSize
- The backlog.
-
getAcceptedReceiveBufferSize
@ManagedAttribute("The SO_RCVBUF option for accepted sockets") public int getAcceptedReceiveBufferSize()Returns the SO_RCVBUF size for accepted sockets.- Returns:
- The buffer size.
-
setAcceptedReceiveBufferSize
public void setAcceptedReceiveBufferSize(int acceptedReceiveBufferSize) Sets the SO_RCVBUF size for accepted sockets.- Parameters:
acceptedReceiveBufferSize
- The buffer size.
-
getAcceptedSendBufferSize
@ManagedAttribute("The SO_SNDBUF option for accepted sockets") public int getAcceptedSendBufferSize()Returns the SO_SNDBUF size for accepted sockets.- Returns:
- The buffer size.
-
setAcceptedSendBufferSize
public void setAcceptedSendBufferSize(int acceptedSendBufferSize) Sets the SO_SNDBUF size for accepted sockets.- Parameters:
acceptedSendBufferSize
- The buffer size.
-
doStart
-
doStop
-
accept
- Specified by:
accept
in classorg.eclipse.jetty.server.AbstractConnector
- Throws:
IOException
-
configure
Configures an incomingSocketChannel
, setting socket options such as receive and send buffer sizes.- Parameters:
channel
- The socket channel to configure.- Throws:
IOException
- on error.
-
getTransport
-
setAccepting
public void setAccepting(boolean accepting) - Overrides:
setAccepting
in classorg.eclipse.jetty.server.AbstractConnector
-
toString
- Overrides:
toString
in classorg.eclipse.jetty.server.AbstractConnector
-
isMayStopServer
@ManagedAttribute("Whether this connector may stop the server when it\'s no longer able to serve and no other connectors are available") public boolean isMayStopServer()Checks if this connector may stop the server when it's no longer able to serve and no other connectors are available.- Returns:
true
if so.
-
setMayStopServer
public void setMayStopServer(boolean mayStopServer) Sets if this connector may stop the server when it's no longer able to serve and no other connectors are available.- Parameters:
mayStopServer
-true
if so.
-
isMayStopServerForce
@ManagedAttribute("Whether this connector may stop the server when it\'s no longer able to serve, even if other connectors are available") public boolean isMayStopServerForce()Checks if this connector may stop the server when it's no longer able to serve, even if other connectors are available.- Returns:
true
if so.
-
setMayStopServerForce
public void setMayStopServerForce(boolean b) Sets if this connector may stop the server when it's no longer able to serve and no other connectors are available.- Parameters:
b
-true
if so (which then also impliessetMayStopServer(true)
-
getListenSocketAddress()
instead.