Class DatagramServerConnector
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Connector
,NetworkConnector
,Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,Graceful
,LifeCycle
- Direct Known Subclasses:
QuicheServerConnector
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopException
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer, Dumpable.DumpAppendable
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Graceful
Graceful.Shutdown, Graceful.ThrowingRunnable
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.server.NetworkConnector
NetworkConnector.Listener
-
Field Summary
Fields inherited from class org.eclipse.jetty.server.AbstractConnector
LOG
-
Constructor Summary
ConstructorsConstructorDescriptionDatagramServerConnector
(Server server, Executor executor, Scheduler scheduler, ByteBufferPool bufferPool, ConnectionFactory... factories) DatagramServerConnector
(Server server, ConnectionFactory... factories) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
accept
(int acceptorID) void
close()
Performs the activities needed to close the network communication (for example, to stop accepting network connections).protected void
doStart()
Starts the managed lifecycle beans in the order they were added.protected void
doStop()
Stops the managed lifecycle beans in the reverse order they were added.int
Get the underlying socket, channel, buffer etc. for the connector..boolean
isOpen()
A Connector may be opened and not started (to reserve a port) or closed and running (to allow graceful shutdown of existing connections)protected Connection
newConnection
(EndPoint endpoint) protected EndPoint
newEndPoint
(DatagramChannel channel, ManagedSelector selector, SelectionKey selectionKey) void
open()
Performs the activities needed to open the network communication (for example, to start accepting incoming network connections).protected DatagramChannel
void
setIdleTimeout
(long idleTimeout) Sets the maximum Idle time for a connection, which roughly translates to theSocket.setSoTimeout(int)
call, although with NIO implementations other mechanisms may be used to implement the timeout.Methods inherited from class org.eclipse.jetty.server.AbstractNetworkConnector
getHost, getPort, handleAcceptFailure, setHost, setPort, shutdown, 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, interruptAcceptors, isAccepting, isShutdown, join, join, onEndPointClosed, onEndPointOpened, removeConnectionFactory, setAccepting, setAcceptorPriorityDelta, setConnectionFactories, setDefaultProtocol, setName, setShutdownIdleTimeout
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.server.Connector
getByteBufferPool, getConnectedEndPoints, getConnectionFactories, getConnectionFactory, getConnectionFactory, getDefaultConnectionFactory, getExecutor, getIdleTimeout, getName, getProtocols, getScheduler, getServer
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.DumpableContainer
isDumpable
Methods inherited from interface org.eclipse.jetty.util.component.Graceful
isShutdown
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addEventListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeEventListener, start, stop
-
Constructor Details
-
DatagramServerConnector
-
DatagramServerConnector
public DatagramServerConnector(Server server, Executor executor, Scheduler scheduler, ByteBufferPool bufferPool, ConnectionFactory... factories)
-
-
Method Details
-
getLocalPort
public int getLocalPort()- Specified by:
getLocalPort
in interfaceNetworkConnector
- Overrides:
getLocalPort
in classAbstractNetworkConnector
- Returns:
- The actual port the connector is listening on, or -1 if it has not been opened, or -2 if it has been closed.
-
isOpen
public boolean isOpen()Description copied from interface:NetworkConnector
A Connector may be opened and not started (to reserve a port) or closed and running (to allow graceful shutdown of existing connections)- Returns:
- True if the connector is Open.
-
doStart
Description copied from class:ContainerLifeCycle
Starts the managed lifecycle beans in the order they were added.- Overrides:
doStart
in classAbstractNetworkConnector
- Throws:
Exception
- If there was a problem starting. Will cause a transition to FAILED state
-
open
Description copied from interface:NetworkConnector
Performs the activities needed to open the network communication (for example, to start accepting incoming network connections).
Implementation must be idempotent.
- Specified by:
open
in interfaceNetworkConnector
- Overrides:
open
in classAbstractNetworkConnector
- Throws:
IOException
- if this connector cannot be opened- See Also:
-
openDatagramChannel
- Throws:
IOException
-
setIdleTimeout
public void setIdleTimeout(long idleTimeout) Description copied from class:AbstractConnector
Sets the maximum Idle time for a connection, which roughly translates to the
Socket.setSoTimeout(int)
call, although with NIO implementations other mechanisms may be used to implement the timeout.The max idle time is applied:
- When waiting for a new message to be received on a connection
- When waiting for a new message to be sent on a connection
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.
- Overrides:
setIdleTimeout
in classAbstractConnector
- Parameters:
idleTimeout
- the idle timeout
-
doStop
Description copied from class:ContainerLifeCycle
Stops the managed lifecycle beans in the reverse order they were added.- Overrides:
doStop
in classAbstractNetworkConnector
- Throws:
Exception
- If there was a problem stopping. Will cause a transition to FAILED state
-
close
public void close()Description copied from interface:NetworkConnector
Performs the activities needed to close the network communication (for example, to stop accepting network connections).
Once a connector has been closed, it cannot be opened again without first calling
LifeCycle.stop()
and it will not be active again until a subsequent call toLifeCycle.start()
.Implementation must be idempotent.
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceNetworkConnector
- Overrides:
close
in classAbstractNetworkConnector
-
getTransport
-
accept
protected void accept(int acceptorID) - Specified by:
accept
in classAbstractConnector
-
newEndPoint
protected EndPoint newEndPoint(DatagramChannel channel, ManagedSelector selector, SelectionKey selectionKey) -
newConnection
-