- 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,ChannelEndPoint,SslConnection.DecryptedEndPoint
public abstract class AbstractEndPoint extends IdleTimeout implements EndPoint
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.io.EndPoint
EndPoint.Wrapper
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractEndPoint(org.eclipse.jetty.util.thread.Scheduler scheduler)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcheckFill()voidcheckFlush()voidclose()Close any backing stream associated with the endpointvoidclose(java.lang.Throwable failure)Close any backing stream associated with the endpoint, passing a causeprotected voiddoClose()protected voiddoShutdownInput()protected voiddoShutdownOutput()voidfillInterested(org.eclipse.jetty.util.Callback callback)Requests callback methods to be invoked when a call toEndPoint.fill(ByteBuffer)would return data or EOF.ConnectiongetConnection()longgetCreatedTimeStamp()FillInterestgetFillInterest()WriteFlushergetWriteFlusher()booleanisFillInterested()booleanisInputShutdown()Test if the input is shutdown.booleanisOpen()This abstract method should be called to check if idle timeouts should still be checked.booleanisOutputShutdown()Test if output is shutdown.protected abstract voidneedsFillInterest()voidonClose()voidonClose(java.lang.Throwable failure)Callback method invoked when thisEndPointis close.protected voidonIdleExpired(java.util.concurrent.TimeoutException timeout)This abstract method is called when the idle timeout has expired.protected abstract voidonIncompleteFlush()voidonOpen()Callback method invoked when thisEndPointis opened.protected voidreset()voidsetConnection(Connection connection)protected voidshutdownInput()voidshutdownOutput()Shutdown the output.java.lang.StringtoConnectionString()java.lang.StringtoEndPointString()java.lang.StringtoString()booleantryFillInterested(org.eclipse.jetty.util.Callback callback)Requests callback methods to be invoked when a call toEndPoint.fill(ByteBuffer)would return data or EOF.voidupgrade(Connection newConnection)Upgrade connections.voidwrite(org.eclipse.jetty.util.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, getLocalAddress, getRemoteAddress, getTransport, setIdleTimeout
-
-
-
-
Method Detail
-
shutdownInput
protected final void shutdownInput()
-
shutdownOutput
public final void shutdownOutput()
Description copied from interface:EndPointShutdown 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:
shutdownOutputin interfaceEndPoint
-
close
public final void close()
Description copied from interface:EndPointClose any backing stream associated with the endpoint
-
close
public final void close(java.lang.Throwable failure)
Description copied from interface:EndPointClose 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:EndPointTest if output is shutdown. The output is shutdown by a call toEndPoint.shutdownOutput()orEndPoint.close().- Specified by:
isOutputShutdownin interfaceEndPoint- Returns:
- true if the output is shutdown or the endpoint is closed.
-
isInputShutdown
public boolean isInputShutdown()
Description copied from interface:EndPointTest 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:
isInputShutdownin interfaceEndPoint- Returns:
- True if the input is shutdown or the endpoint is closed.
-
isOpen
public boolean isOpen()
Description copied from class:IdleTimeoutThis abstract method should be called to check if idle timeouts should still be checked.- Specified by:
isOpenin interfaceEndPoint- Specified by:
isOpenin classIdleTimeout- Returns:
- True if the entity monitored should still be checked for idle timeouts
-
checkFlush
public void checkFlush() throws java.io.IOException- Throws:
java.io.IOException
-
checkFill
public void checkFill() throws java.io.IOException- Throws:
java.io.IOException
-
getCreatedTimeStamp
public long getCreatedTimeStamp()
- Specified by:
getCreatedTimeStampin interfaceEndPoint
-
getConnection
public Connection getConnection()
- Specified by:
getConnectionin interfaceEndPoint- Returns:
- the
Connectionassociated with thisEndPoint - See Also:
EndPoint.setConnection(Connection)
-
setConnection
public void setConnection(Connection connection)
- Specified by:
setConnectionin interfaceEndPoint- Parameters:
connection- theConnectionassociated with thisEndPoint- See Also:
EndPoint.getConnection(),EndPoint.upgrade(Connection)
-
reset
protected void reset()
-
onOpen
public void onOpen()
Description copied from interface:EndPointCallback method invoked when this
EndPointis opened.- Specified by:
onOpenin interfaceEndPoint- Overrides:
onOpenin classIdleTimeout- See Also:
EndPoint.onClose(Throwable)
-
onClose
public final void onClose()
- Overrides:
onClosein classIdleTimeout
-
onClose
public void onClose(java.lang.Throwable failure)
Description copied from interface:EndPointCallback method invoked when this
EndPointis close.- Specified by:
onClosein interfaceEndPoint- Parameters:
failure- The reason for the close, or null if a normal close.- See Also:
EndPoint.onOpen()
-
fillInterested
public void fillInterested(org.eclipse.jetty.util.Callback callback)
Description copied from interface:EndPointRequests callback methods to be invoked when a call to
EndPoint.fill(ByteBuffer)would return data or EOF.- Specified by:
fillInterestedin interfaceEndPoint- Parameters:
callback- the callback to call when an error occurs or we are readable. The callback may implement theInvocableinterface to self declare its blocking status. Non-blocking callbacks may be called more efficiently without dispatch delays.
-
tryFillInterested
public boolean tryFillInterested(org.eclipse.jetty.util.Callback callback)
Description copied from interface:EndPointRequests callback methods to be invoked when a call to
EndPoint.fill(ByteBuffer)would return data or EOF.- Specified by:
tryFillInterestedin interfaceEndPoint- Parameters:
callback- the callback to call when an error occurs or we are readable. The callback may implement theInvocableinterface 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:
isFillInterestedin interfaceEndPoint- Returns:
- whether
EndPoint.fillInterested(Callback)has been called, butEndPoint.fill(ByteBuffer)has not yet been called
-
write
public void write(org.eclipse.jetty.util.Callback callback, java.nio.ByteBuffer... buffers) throws java.lang.IllegalStateExceptionDescription copied from interface:EndPointWrites 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:
writein interfaceEndPoint- Parameters:
callback- the callback to call when an error occurs or the write completed. The callback may implement theInvocableinterface to self declare its blocking status. Non-blocking callbacks may be called more efficiently without dispatch delays.buffers- one or moreByteBuffers that will be flushed.- Throws:
java.nio.channels.WritePendingException- if another write operation is concurrent.java.lang.IllegalStateException
-
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:IdleTimeoutThis abstract method is called when the idle timeout has expired.- Specified by:
onIdleExpiredin classIdleTimeout- Parameters:
timeout- a TimeoutException
-
upgrade
public void upgrade(Connection newConnection)
Description copied from interface:EndPointUpgrade connections. Close the old connection, update the endpoint and open the new connection. If the oldConnection is an instance ofConnection.UpgradeFromthen a prefilled buffer is requested and passed to the newConnection if it is an instance ofConnection.UpgradeTo
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toEndPointString
public java.lang.String toEndPointString()
-
toConnectionString
public java.lang.String toConnectionString()
-
-