Class AbstractEndPoint
- java.lang.Object
-
- org.eclipse.jetty.io.IdleTimeout
-
- org.eclipse.jetty.io.AbstractEndPoint
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,EndPoint
- Direct Known Subclasses:
ByteArrayEndPoint
,QuicStreamEndPoint
,SelectableChannelEndPoint
,SslConnection.DecryptedEndPoint
public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint
Partial implementation of EndPoint that uses
FillInterest
andWriteFlusher
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.io.EndPoint
EndPoint.Wrapper
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractEndPoint(Scheduler scheduler)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
Close any backing stream associated with the endpointvoid
close(java.lang.Throwable failure)
Close any backing stream associated with the endpoint, passing a causeprotected void
doClose()
protected void
doShutdownInput()
protected void
doShutdownOutput()
void
fillInterested(Callback callback)
Requests callback methods to be invoked when a call toEndPoint.fill(ByteBuffer)
would return data or EOF.Connection
getConnection()
long
getCreatedTimeStamp()
FillInterest
getFillInterest()
java.net.InetSocketAddress
getLocalAddress()
java.net.SocketAddress
getLocalSocketAddress()
java.net.InetSocketAddress
getRemoteAddress()
java.net.SocketAddress
getRemoteSocketAddress()
WriteFlusher
getWriteFlusher()
boolean
isFillInterested()
boolean
isInputShutdown()
Test if the input is shutdown.boolean
isOpen()
This abstract method should be called to check if idle timeouts should still be checked.boolean
isOutputShutdown()
Test if output is shutdown.protected abstract void
needsFillInterest()
void
onClose()
void
onClose(java.lang.Throwable failure)
Callback method invoked when thisEndPoint
is closed.protected void
onIdleExpired(java.util.concurrent.TimeoutException timeout)
This abstract method is called when the idle timeout has expired.protected abstract void
onIncompleteFlush()
void
onOpen()
Callback method invoked when this EndPoint is opened.protected void
reset()
void
setConnection(Connection connection)
protected void
shutdownInput()
void
shutdownOutput()
Shutdown the output.java.lang.String
toConnectionString()
java.lang.String
toEndPointString()
java.lang.String
toString()
boolean
tryFillInterested(Callback callback)
Requests callback methods to be invoked when a call toEndPoint.fill(ByteBuffer)
would return data or EOF.void
upgrade(Connection newConnection)
Upgrades this EndPoint from the current connection to the given new connection.void
write(Callback callback, java.nio.ByteBuffer... buffers)
Writes the given buffers viaEndPoint.flush(ByteBuffer...)
and invokes callback methods when either all the data has been flushed or an error occurs.-
Methods inherited from class org.eclipse.jetty.io.IdleTimeout
checkIdleTimeout, getIdleFor, getIdleTimeout, getScheduler, notIdle, setIdleTimeout
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.io.EndPoint
fill, flush, getIdleTimeout, getTransport, setIdleTimeout
-
-
-
-
Constructor Detail
-
AbstractEndPoint
protected AbstractEndPoint(Scheduler scheduler)
-
-
Method Detail
-
getLocalAddress
public java.net.InetSocketAddress getLocalAddress()
- Specified by:
getLocalAddress
in interfaceEndPoint
- Returns:
- The local InetSocketAddress to which this
EndPoint
is bound, ornull
if thisEndPoint
is not bound to a Socket address.
-
getLocalSocketAddress
public java.net.SocketAddress getLocalSocketAddress()
- Specified by:
getLocalSocketAddress
in interfaceEndPoint
- Returns:
- the local SocketAddress to which this
EndPoint
is bound ornull
if thisEndPoint
is not bound to a Socket address.
-
getRemoteAddress
public java.net.InetSocketAddress getRemoteAddress()
- Specified by:
getRemoteAddress
in interfaceEndPoint
- Returns:
- The remote InetSocketAddress to which this
EndPoint
is connected, ornull
if thisEndPoint
is not connected to a Socket address.
-
getRemoteSocketAddress
public java.net.SocketAddress getRemoteSocketAddress()
- Specified by:
getRemoteSocketAddress
in interfaceEndPoint
- Returns:
- The remote SocketAddress to which this
EndPoint
is connected, ornull
if thisEndPoint
is not connected to a Socket address.
-
shutdownInput
protected final void shutdownInput()
-
shutdownOutput
public final void shutdownOutput()
Description copied from interface:EndPoint
Shutdown the output.This call indicates that no more data will be sent on this endpoint that that the remote end should read an EOF once all previously sent data has been consumed. Shutdown may be done either at the TCP/IP level, as a protocol exchange (Eg TLS close handshake) or both.
If the endpoint has
EndPoint.isInputShutdown()
true, then this call has the same effect asEndPoint.close()
.- Specified by:
shutdownOutput
in interfaceEndPoint
-
close
public final void close()
Description copied from interface:EndPoint
Close any backing stream associated with the endpoint
-
close
public final void close(java.lang.Throwable failure)
Description copied from interface:EndPoint
Close any backing stream associated with the endpoint, passing a cause
-
doShutdownInput
protected void doShutdownInput()
-
doShutdownOutput
protected void doShutdownOutput()
-
doClose
protected void doClose()
-
isOutputShutdown
public boolean isOutputShutdown()
Description copied from interface:EndPoint
Test if output is shutdown. The output is shutdown by a call toEndPoint.shutdownOutput()
orEndPoint.close()
.- Specified by:
isOutputShutdown
in interfaceEndPoint
- Returns:
- true if the output is shutdown or the endpoint is closed.
-
isInputShutdown
public boolean isInputShutdown()
Description copied from interface:EndPoint
Test if the input is shutdown. The input is shutdown if an EOF has been read while doing aEndPoint.fill(ByteBuffer)
. Once the input is shutdown, all calls toEndPoint.fill(ByteBuffer)
will return -1, until such time as the end point is close, when they will returnEofException
.- Specified by:
isInputShutdown
in interfaceEndPoint
- Returns:
- True if the input is shutdown or the endpoint is closed.
-
isOpen
public boolean isOpen()
Description copied from class:IdleTimeout
This abstract method should be called to check if idle timeouts should still be checked.- Specified by:
isOpen
in interfaceEndPoint
- Specified by:
isOpen
in classIdleTimeout
- Returns:
- True if the entity monitored should still be checked for idle timeouts
-
getCreatedTimeStamp
public long getCreatedTimeStamp()
- Specified by:
getCreatedTimeStamp
in interfaceEndPoint
- Returns:
- the epoch time in milliseconds when this EndPoint was created
-
getConnection
public Connection getConnection()
- Specified by:
getConnection
in interfaceEndPoint
- Returns:
- the
Connection
associated with this EndPoint - See Also:
EndPoint.setConnection(Connection)
-
setConnection
public void setConnection(Connection connection)
- Specified by:
setConnection
in interfaceEndPoint
- Parameters:
connection
- theConnection
associated with this EndPoint- See Also:
EndPoint.getConnection()
,EndPoint.upgrade(Connection)
-
reset
protected void reset()
-
onOpen
public void onOpen()
Description copied from interface:EndPoint
Callback method invoked when this EndPoint is opened.
- Specified by:
onOpen
in interfaceEndPoint
- Overrides:
onOpen
in classIdleTimeout
- See Also:
EndPoint.onClose(Throwable)
-
onClose
public final void onClose()
- Overrides:
onClose
in classIdleTimeout
-
onClose
public void onClose(java.lang.Throwable failure)
Description copied from interface:EndPoint
Callback method invoked when this
EndPoint
is closed.- Specified by:
onClose
in interfaceEndPoint
- Parameters:
failure
- The reason for the close, or null if a normal close.- See Also:
EndPoint.onOpen()
-
fillInterested
public void fillInterested(Callback callback)
Description copied from interface:EndPoint
Requests callback methods to be invoked when a call to
EndPoint.fill(ByteBuffer)
would return data or EOF.- Specified by:
fillInterested
in interfaceEndPoint
- Parameters:
callback
- the callback to call when an error occurs or we are readable. The callback may implement theInvocable
interface to self declare its blocking status. Non-blocking callbacks may be called more efficiently without dispatch delays.
-
tryFillInterested
public boolean tryFillInterested(Callback callback)
Description copied from interface:EndPoint
Requests callback methods to be invoked when a call to
EndPoint.fill(ByteBuffer)
would return data or EOF.- Specified by:
tryFillInterested
in interfaceEndPoint
- Parameters:
callback
- the callback to call when an error occurs or we are readable. The callback may implement theInvocable
interface to self declare its blocking status. Non-blocking callbacks may be called more efficiently without dispatch delays.- Returns:
- true if set
-
isFillInterested
public boolean isFillInterested()
- Specified by:
isFillInterested
in interfaceEndPoint
- Returns:
- whether
EndPoint.fillInterested(Callback)
has been called, butEndPoint.fill(ByteBuffer)
has not yet been called
-
write
public void write(Callback callback, java.nio.ByteBuffer... buffers) throws java.nio.channels.WritePendingException
Description copied from interface:EndPoint
Writes the given buffers via
EndPoint.flush(ByteBuffer...)
and invokes callback methods when either all the data has been flushed or an error occurs.- Specified by:
write
in interfaceEndPoint
- Parameters:
callback
- the callback to call when an error occurs or the write completed. The callback may implement theInvocable
interface to self declare its blocking status. Non-blocking callbacks may be called more efficiently without dispatch delays.buffers
- one or moreByteBuffer
s that will be flushed.- Throws:
java.nio.channels.WritePendingException
- if another write operation is concurrent.
-
onIncompleteFlush
protected abstract void onIncompleteFlush()
-
needsFillInterest
protected abstract void needsFillInterest() throws java.io.IOException
- Throws:
java.io.IOException
-
getFillInterest
public FillInterest getFillInterest()
-
getWriteFlusher
public WriteFlusher getWriteFlusher()
-
onIdleExpired
protected void onIdleExpired(java.util.concurrent.TimeoutException timeout)
Description copied from class:IdleTimeout
This abstract method is called when the idle timeout has expired.- Specified by:
onIdleExpired
in classIdleTimeout
- Parameters:
timeout
- a TimeoutException
-
upgrade
public void upgrade(Connection newConnection)
Description copied from interface:EndPoint
Upgrades this EndPoint from the current connection to the given new connection.
Closes the current connection, links this EndPoint to the new connection and then opens the new connection.
If the current connection is an instance of
Connection.UpgradeFrom
then a buffer of unconsumed bytes is requested. If the buffer of unconsumed bytes is non-null and non-empty, then the new connection is tested: if it is an instance ofConnection.UpgradeTo
, then the unconsumed buffer is passed to the new connection; otherwise, an exception is thrown since there are unconsumed bytes that cannot be consumed by the new connection.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toEndPointString
public java.lang.String toEndPointString()
-
toConnectionString
public java.lang.String toConnectionString()
-
-