An abstract implementation of Connector that provides a ConnectionFactory mechanism
for creating org. instances for various protocols (HTTP, SSL, etc).
Executor service is used to run all active tasks needed by this connector such as accepting connections
or handle HTTP requests. The default is to use the Server#getThreadPool() as an executor.
Scheduler service is used to monitor the idle timeouts of all connections and is also made available
to the connections to time such things as asynchronous request timeouts. The default is to use a new
ScheduledExecutorScheduler instance.
ByteBufferPool service is made available to all connections to be used to acquire and release
RetainableByteBuffer instances from a pool. The default is to use a new ArrayByteBufferPool
instance.
ContainerLifeCycle super class and
may either be managed or unmanaged beans.
ConnectionFactory instances, each of which are known by their
protocol name. The protocol name may be a real protocol (e.g. "http/1.1" or "h2") or it may be a private name
that represents a special connection factory. For example, the name "SSL-http/1.1" is used for
an SslConnectionFactory that has been instantiated with the HttpConnectionFactory as it's
next protocol.
ConnectionFactory may be constructor injected or modified with the
methods addConnectionFactory(ConnectionFactory), removeConnectionFactory(String) and
setConnectionFactories(Collection). Only a single ConnectionFactory instance may be configured
per protocol name, so if two factories with the same ConnectionFactory#getProtocol() are set, then
the second will replace the first.
The protocol factory used for newly accepted connections is specified by
the method setDefaultProtocol(String) or defaults to the protocol of the first configured factory.
Each Connection factory type is responsible for the configuration of the protocols that it accepts. Thus to
configure the HTTP protocol, you pass a HttpConfiguration instance to the HttpConnectionFactory
(or other factories that can also provide HTTP Semantics). Similarly the SslConnectionFactory is
configured by passing it a SslContextFactory and a next protocol name.
ConnectionFactorys may simply create a org.eclipse.jetty.io.Connection instance to support a specific
protocol. For example, the HttpConnectionFactory will create a HttpConnection instance
that can handle http/1.1, http/1.0 and http/0.9.
ConnectionFactorys may also create a chain of org. instances, using other ConnectionFactory instances.
For example, the SslConnectionFactory is configured with a next protocol name, so that once it has accepted
a connection and created an SslConnection, it then used the next ConnectionFactory from the
connector using the getConnectionFactory(String) method, to create a org. instance that
will handle the unencrypted bytes from the SslConnection. If the next protocol is "http/1.1", then the
SslConnectionFactory will have a protocol name of "SSL-http/1.1" and lookup "http/1.1" for the protocol
to run over the SSL connection.
ConnectionFactorys may also create temporary org. instances that will exchange bytes
over the connection to determine what is the next protocol to use. For example the ALPN protocol is an extension
of SSL to allow a protocol to be specified during the SSL handshake. ALPN is used by the HTTP/2 protocol to
negotiate the protocol that the client and server will speak. Thus to accept an HTTP/2 connection, the
connector will be configured with ConnectionFactorys for "SSL-ALPN", "h2", "http/1.1"
with the default protocol being "SSL-ALPN". Thus a newly accepted connection uses "SSL-ALPN", which specifies a
SSLConnectionFactory with "ALPN" as the next protocol. Thus an SSL connection instance is created chained to an ALPN
connection instance. The ALPN connection then negotiates with the client to determined the next protocol, which
could be "h2" or the default of "http/1.1". Once the next protocol is determined, the ALPN connection
calls getConnectionFactory(String) to create a connection instance that will replace the ALPN connection as
the connection chained to the SSL connection.
Exception service passed to the constructor.
The acceptor tasks run in a loop while the connector is running and repeatedly call the abstract accept(int) method.
The implementation of the accept method must:
getDefaultConnectionFactory() ConnectionFactory#newConnection(Connector, EndPoint)
method to create a new Connection instance.| Modifier and Type | Class and Description |
|---|---|
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private int | |
| private final Thread[] | |
| private final ByteBufferPool | |
| private ConnectionFactory | |
| private String | |
| private final Set | |
| private final Executor | |
| private final Map | |
| private long | |
| private final Set | |
| private ThreadPoolBudget. | |
| private final AutoLock | |
| private String | |
| private final Scheduler | |
| private final Server | |
| private final Condition | |
| private Graceful. | |
| private long | |
| protected static final Logger |
| Access | Constructor and Description |
|---|---|
| public | AbstractConnector(Server
The server, Executor Server this connector will be added to, must not be nullAn executor, Scheduler Executor for this connector or null to use the Server's ExecutorA scheduler, ByteBufferPool Scheduler for this connector or null to use the Server's SchedulerA bufferPool, int ByteBufferPool for this connector or null to use the Server's ByteBufferPoolthe 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. acceptors, ConnectionFactory... The factories)ConnectionFactory instances to use
|
| Modifier and Type | Method and Description |
|---|---|
| protected abstract void | |
| public void | |
| public void | |
| public void | |
| public void | |
| protected void | doStart()
Overrides org. |
| protected void | doStop()
Overrides org. |
| public int | |
| public int | |
| public ByteBufferPool | getByteBufferPool()
Implements org. ByteBufferPool to acquire buffers from and release buffers to.
|
| public Collection | |
| public Collection | |
| public ConnectionFactory | getConnectionFactory(String
the next protocol protocol)Implements org. |
| public <T> T | getConnectionFactory(Class<T> factoryType)
Implements org. |
| public ConnectionFactory | getDefaultConnectionFactory()
Implements org. ConnectionFactory associated with the default protocol name.
|
| public String | |
| public Executor | getExecutor()
Implements org. Executor used to submit tasks.
|
| public long | |
| public String | |
| public List | |
| public Scheduler | getScheduler()
Implements org. Scheduler used to schedule tasks.
|
| public Server | getServer()
Implements org. Server instance associated with this Connector.
|
| public long | |
| protected boolean | |
| protected void | |
| public boolean | |
| public boolean | |
| public void | |
| public void | |
| protected void | |
| protected void | |
| public ConnectionFactory | |
| public void | |
| public void | setAcceptorPriorityDelta(int
the acceptor priority delta acceptorPriorityDelta)Set the acceptor thread priority delta. |
| public void | |
| public void | |
| public void | setIdleTimeout(long
the idle timeout idleTimeout)Sets the maximum Idle time for a connection, which roughly translates to the |
| public void | |
| public void | |
| public CompletableFuture | |
| public String | toString()
Overrides org. |
| _accepting | back to summary |
|---|---|
| private boolean _accepting | |
| _acceptorPriorityDelta | back to summary |
|---|---|
| private int _acceptorPriorityDelta | |
| _acceptors | back to summary |
|---|---|
| private final Thread[] _acceptors | |
| _bufferPool | back to summary |
|---|---|
| private final ByteBufferPool _bufferPool | |
| _defaultConnectionFactory | back to summary |
|---|---|
| private ConnectionFactory _defaultConnectionFactory | |
| _defaultProtocol | back to summary |
|---|---|
| private String _defaultProtocol | |
| _endpoints | back to summary |
|---|---|
| private final Set<EndPoint> _endpoints | |
| _executor | back to summary |
|---|---|
| private final Executor _executor | |
| _factories | back to summary |
|---|---|
| private final Map<String, ConnectionFactory> _factories | |
| _idleTimeout | back to summary |
|---|---|
| private long _idleTimeout | |
| _immutableEndPoints | back to summary |
|---|---|
| private final Set<EndPoint> _immutableEndPoints | |
| _lease | back to summary |
|---|---|
| private ThreadPoolBudget. | |
| _lock | back to summary |
|---|---|
| private final AutoLock _lock Hides org. | |
| _name | back to summary |
|---|---|
| private String _name | |
| _scheduler | back to summary |
|---|---|
| private final Scheduler _scheduler | |
| _server | back to summary |
|---|---|
| private final Server _server | |
| _setAccepting | back to summary |
|---|---|
| private final Condition _setAccepting | |
| _shutdown | back to summary |
|---|---|
| private Graceful. | |
| _shutdownIdleTimeout | back to summary |
|---|---|
| private long _shutdownIdleTimeout | |
| LOG | back to summary |
|---|---|
| protected static final Logger LOG Hides org. | |
| AbstractConnector | back to summary |
|---|---|
public AbstractConnector(Server server, Executor executor, Scheduler scheduler, ByteBufferPool bufferPool, int acceptors, ConnectionFactory... factories)
| |
| accept | back to summary |
|---|---|
| protected abstract void accept(int acceptorID) throws IOException, InterruptedException | |
| addConnectionFactory | back to summary |
|---|---|
| public void addConnectionFactory(ConnectionFactory factory) | |
| addFirstConnectionFactory | back to summary |
|---|---|
| public void addFirstConnectionFactory(ConnectionFactory factory) | |
| addIfAbsentConnectionFactory | back to summary |
|---|---|
| public void addIfAbsentConnectionFactory(ConnectionFactory factory) | |
| clearConnectionFactories | back to summary |
|---|---|
| public void clearConnectionFactories() | |
| doStart | back to summary |
|---|---|
| protected void doStart() throws Exception Overrides org. Doc from org. Starts the managed lifecycle beans in the order they were added.
| |
| doStop | back to summary |
|---|---|
| protected void doStop() throws Exception Overrides org. Doc from org. Stops the managed lifecycle beans in the reverse order they were added.
| |
| getAcceptorPriorityDelta | back to summary |
|---|---|
public int getAcceptorPriorityDelta()
| |
| getAcceptors | back to summary |
|---|---|
public int getAcceptors()
| |
| getByteBufferPool | back to summary |
|---|---|
| public ByteBufferPool getByteBufferPool() Implements org. Doc from org. Get the
| |
| getConnectedEndPoints | back to summary |
|---|---|
| public Collection Implements org.
| |
| getConnectionFactories | back to summary |
|---|---|
| public Collection Implements org.
| |
| getConnectionFactory | back to summary |
|---|---|
| public ConnectionFactory getConnectionFactory(String protocol) Implements org.
| |
| getConnectionFactory | back to summary |
|---|---|
| public <T> T getConnectionFactory(Class<T> factoryType) Implements org.
| |
| getDefaultConnectionFactory | back to summary |
|---|---|
| public ConnectionFactory getDefaultConnectionFactory() Implements org. Doc from org. Get the default
| |
| getDefaultProtocol | back to summary |
|---|---|
public String getDefaultProtocol()
| |
| getExecutor | back to summary |
|---|---|
| public Executor getExecutor() Implements org. Doc from org. Get the | |
| getIdleTimeout | back to summary |
|---|---|
| public long getIdleTimeout() Implements org.
| |
| getName | back to summary |
|---|---|
| public String getName() Implements org. Doc from org. Get the connector name if set. A | |
| getProtocols | back to summary |
|---|---|
| public List Implements org.
| |
| getScheduler | back to summary |
|---|---|
| public Scheduler getScheduler() Implements org. Doc from org. Get the | |
| getServer | back to summary |
|---|---|
| public Server getServer() Implements org. | |
| getShutdownIdleTimeout | back to summary |
|---|---|
| public long getShutdownIdleTimeout() | |
| handleAcceptFailure | back to summary |
|---|---|
| protected boolean handleAcceptFailure(Throwable ex) | |
| interruptAcceptors | back to summary |
|---|---|
| protected void interruptAcceptors() | |
| isAccepting | back to summary |
|---|---|
public boolean isAccepting()
| |
| isShutdown | back to summary |
|---|---|
| public boolean isShutdown() Implements org.
| |
| join | back to summary |
|---|---|
| public void join() throws InterruptedException | |
| join | back to summary |
|---|---|
| public void join(long timeout) throws InterruptedException | |
| onEndPointClosed | back to summary |
|---|---|
| protected void onEndPointClosed(EndPoint endp) | |
| onEndPointOpened | back to summary |
|---|---|
| protected void onEndPointOpened(EndPoint endp) | |
| removeConnectionFactory | back to summary |
|---|---|
| public ConnectionFactory removeConnectionFactory(String protocol) | |
| setAccepting | back to summary |
|---|---|
| public void setAccepting(boolean accepting) | |
| setAcceptorPriorityDelta | back to summary |
|---|---|
| public void setAcceptorPriorityDelta(int acceptorPriorityDelta) Set the acceptor thread priority delta. This allows the acceptor thread to run at a different priority. Typically this would be used to lower the priority to give preference to handling previously accepted connections rather than accepting new connections
| |
| setConnectionFactories | back to summary |
|---|---|
| public void setConnectionFactories(Collection<ConnectionFactory> factories) | |
| setDefaultProtocol | back to summary |
|---|---|
| public void setDefaultProtocol(String defaultProtocol) | |
| setIdleTimeout | back to summary |
|---|---|
| public void setIdleTimeout(long idleTimeout) Sets the maximum Idle time for a connection, which roughly translates to the The max idle time is applied:
This value is interpreted as the maximum time between some progress being made on the connection. So if a single byte is read or written, then the timeout is reset.
| |
| setName | back to summary |
|---|---|
| public void setName(String name) Set a connector name. A context may be configured with virtual hosts in the form "@contextname" and will only serve requests from the named connector,
| |
| setShutdownIdleTimeout | back to summary |
|---|---|
| public void setShutdownIdleTimeout(long idle) | |
| shutdown | back to summary |
|---|---|
| public CompletableFuture Implements org. Doc from org. Shutdown the component. When this method returns, the component should not accept any new load.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides org. Doc from java. Returns a string representation of the object. | |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public String |
| Acceptor | back to summary |
|---|---|
| private Acceptor(int id) | |
| run | back to summary |
|---|---|
| public void run() Implements java. Doc from java. Runs this operation.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |