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, org.eclipse.jetty.util.component.Dumpable.DumpAppendable

    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

    LEGEND
  • Constructor Summary

    Constructors
    Constructor
    Description
    AFSocketServerConnector(org.eclipse.jetty.server.Server server, int acceptors, int selectors, org.eclipse.jetty.server.ConnectionFactory... factories)
    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)
    AFSocketServerConnector(org.eclipse.jetty.server.Server server, org.eclipse.jetty.server.ConnectionFactory... factories)
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    accept(int acceptorID)
     
    protected void
    Configures an incoming SocketChannel, setting socket options such as receive and send buffer sizes.
    protected void
     
    protected void
     
    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
    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.
     

    Methods inherited from class org.eclipse.jetty.server.AbstractConnector

    addConnectionFactory, addFirstConnectionFactory, addIfAbsentConnectionFactory, clearConnectionFactories, dump, 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, addManaged, contains, destroy, 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 Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.eclipse.jetty.util.component.Container

    getCachedBeans, getEventListeners

    Methods inherited from interface org.eclipse.jetty.util.component.Dumpable

    dumpSelf

    Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer

    isDumpable
  • Constructor Details

    • AFSocketServerConnector

      public AFSocketServerConnector(org.eclipse.jetty.server.Server server, org.eclipse.jetty.server.ConnectionFactory... factories)
      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)
      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 derived
      factories - 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)
      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 executor
      scheduler - A scheduler for this connector or null to either a Scheduler set as a server bean or if none set, then a new ScheduledExecutorScheduler instance.
      pool - A buffer pool for this connector or null to either a ByteBufferPool 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 derived
      factories - The Connection Factories to use.
  • Method Details

    • getUnixDomainPath

      @ManagedAttribute("The Unix-Domain path this connector listens to") @Deprecated public Path getUnixDomainPath()
      Deprecated.
      Returns the Unix-Domain path this connector listens to. Added for compatibility with jetty's UnixDomainServerConnector.
      Returns:
      The Unix-Domain path this connector listens to.
      See Also:
    • setUnixDomainPath

      @Deprecated public void setUnixDomainPath(Path unixDomainPath)
      Deprecated.
      Sets the Unix-Domain path this connector listens to. Added for compatibility with jetty's UnixDomainServerConnector.
      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, or null.
    • 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

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.eclipse.jetty.server.AbstractConnector
      Throws:
      Exception
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.eclipse.jetty.server.AbstractConnector
      Throws:
      Exception
    • accept

      protected void accept(int acceptorID) throws IOException
      Specified by:
      accept in class org.eclipse.jetty.server.AbstractConnector
      Throws:
      IOException
    • configure

      protected void configure(SocketChannel channel) throws IOException
      Configures an incoming SocketChannel, setting socket options such as receive and send buffer sizes.
      Parameters:
      channel - The socket channel to configure.
      Throws:
      IOException - on error.
    • getTransport

      public Object getTransport()
    • setAccepting

      public void setAccepting(boolean accepting)
      Overrides:
      setAccepting in class org.eclipse.jetty.server.AbstractConnector
    • toString

      public String toString()
      Overrides:
      toString in class org.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 implies setMayStopServer(true)