Class StreamEndPoint
- All Implemented Interfaces:
 Closeable, AutoCloseable, Content.Sink, EndPoint
An EndPoint implementation on top of a QUIC stream.
The correspondent Connection associated to this StreamEndPoint
parses and generates the protocol specific bytes transported by QUIC.
- 
Nested Class Summary
Nested classes/interfaces inherited from interface EndPoint
EndPoint.Pipe, EndPoint.SslSessionData, EndPoint.Wrapper - 
Field Summary
 - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptioncancelWrite(Throwable cause) Cancel any currentEndPoint.write(Callback, ByteBuffer...)operation in progress.voidCloses any backing stream associated with the endpoint, passing a possiblynullfailure cause.voiddisconnect(long appError, Throwable failure, boolean disconnectStream, Promise.Invocable<StreamEndPoint> promise) fill()Fills from thisStreamEndPoint.intfill(ByteBuffer sink) Fills the passed buffer with data from this endpoint.voidfillInterested(Callback callback) Requests callback methods to be invoked when a call toEndPoint.fill(ByteBuffer)would return data or EOF.booleanflush(ByteBuffer... buffers) Flushes data from the passed header/buffer to this endpoint.longlongReturns the idle timeout in ms.Returns the SslSessionData of a secure end point.booleanbooleanTests if the input is shutdown.booleanisOpen()booleanTests if output is shutdown.voidCallback method invoked when thisEndPointis closed.voidonOpen()Callback method invoked when this EndPoint is opened.voidsetConnection(Connection connection) voidsetIdleTimeout(long idleTimeout) Sets the idle timeout.voidshutdownInput(long appError) voidShuts down the output.voidshutdownOutput(long appError, Promise.Invocable<StreamEndPoint> promise) toString()booleantryFillInterested(Callback callback) Requests callback methods to be invoked when a call toEndPoint.fill(ByteBuffer)would return data or EOF.voidupgrade(Connection newConnection) Upgrades this EndPoint from the current connection to the given new connection.voidwrite(boolean last, ByteBuffer byteBuffer, Callback callback) Writes the givenByteBuffer, notifying theCallbackwhen the write is complete.voidwrite(boolean last, List<ByteBuffer> buffers, Callback callback) voidwrite(Callback callback, 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. 
- 
Constructor Details
- 
StreamEndPoint
 
 - 
 - 
Method Details
- 
getProtocolSession
 - 
getStream
 - 
getLocalSocketAddress
- Specified by:
 getLocalSocketAddressin interfaceEndPoint- Returns:
 - the local SocketAddress to which this 
EndPointis bound ornullif thisEndPointis not bound to a Socket address. 
 - 
getRemoteSocketAddress
- Specified by:
 getRemoteSocketAddressin interfaceEndPoint- Returns:
 - The remote SocketAddress to which this 
EndPointis connected, ornullif thisEndPointis not connected to a Socket address. 
 - 
isOpen
 - 
getCreatedTimeStamp
public long getCreatedTimeStamp()- Specified by:
 getCreatedTimeStampin interfaceEndPoint- Returns:
 - the epoch time in milliseconds when this EndPoint was created
 
 - 
getTransport
- Specified by:
 getTransportin interfaceEndPoint- Returns:
 - The underlying transport object (socket, channel, etc.)
 
 - 
getIdleTimeout
public long getIdleTimeout()Description copied from interface:EndPointReturns the idle timeout in ms.
The idle timeout is the time the endpoint can be idle before its close is initiated.
A timeout less than or equal to
0implies an infinite timeout.- Specified by:
 getIdleTimeoutin interfaceEndPoint- Returns:
 - the idle timeout in ms
 
 - 
setIdleTimeout
public void setIdleTimeout(long idleTimeout) Description copied from interface:EndPointSets the idle timeout.
- Specified by:
 setIdleTimeoutin interfaceEndPoint- Parameters:
 idleTimeout- the idle timeout in MS. Timeout <= 0 implies an infinite timeout
 - 
shutdownOutput
public void shutdownOutput()Description copied from interface:EndPointShuts down the output.
This call indicates that no more data will be sent from this endpoint and that the remote endpoint should read an EOF once all previously sent data has been read. Shutdown may be done either at the TCP/IP level, as a protocol exchange (for example, 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
 - 
isOutputShutdown
public boolean isOutputShutdown()Description copied from interface:EndPointTests if output is shutdown.
The output is shutdown by a call to
EndPoint.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:EndPointTests if the input is shutdown.
The input is shutdown if an EOF has been read while doing a
EndPoint.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.
 
 - 
shutdownInput
public void shutdownInput(long appError)  - 
shutdownOutput
 - 
close
 - 
disconnect
public void disconnect(long appError, Throwable failure, boolean disconnectStream, Promise.Invocable<StreamEndPoint> promise)  - 
onClose
 - 
fill
Description copied from interface:EndPointFills the passed buffer with data from this endpoint.
The bytes are appended to any data already in the buffer by writing from the buffers limit up to its capacity. The limit is updated to include the filled bytes.
- Specified by:
 fillin interfaceEndPoint- Parameters:
 sink- The buffer to fill. The position and limit are modified during the fill. After the operation, the position is unchanged and the limit is increased to reflect the new data filled.- Returns:
 - an 
intvalue indicating the number of bytes filled or -1 if EOF is read or the input is shutdown. - Throws:
 IOException- if the endpoint is closed.
 - 
fill
Fills from this
StreamEndPoint.This method should be used in alternative to
fill(ByteBuffer), when theConnectioninstalled on top of thisStreamEndPointneeds to know both the bytes and whether the QUIC data is the last in the stream, for example in HTTP/3.The code calling this method is responsible to organize for the returned
Content.Chunkto be eventuallyreleased.- Returns:
 - a 
Content.Chunkwith data bytes or a failure, ornullif there are no data bytes 
 - 
flush
Description copied from interface:EndPointFlushes data from the passed header/buffer to this endpoint.
As many bytes as can be consumed are taken from the header/buffer position up until the buffer limit. The header/buffers position is updated to indicate how many bytes have been consumed.
- Specified by:
 flushin interfaceEndPoint- Parameters:
 buffers- the buffers to flush- Returns:
 - True IFF all the buffers have been consumed and the endpoint has flushed the data to its destination (ie is not buffering any data).
 - Throws:
 IOException- If the endpoint is closed or output is shutdown.
 - 
write
Description 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:
 WritePendingException- if another write operation is concurrent.
 - 
write
Description copied from interface:Content.SinkWrites the given
ByteBuffer, notifying theCallbackwhen the write is complete.Implementations guarantee that calls to this method are safely reentrant so that stack overflows are avoided in the case of mutual recursion between the execution of the
Callbackand a call to this method.- Specified by:
 writein interfaceContent.Sink- Specified by:
 writein interfaceEndPoint- Parameters:
 last- whether the ByteBuffer is the last to writebyteBuffer- the ByteBuffer to writecallback- the callback to notify when the write operation is complete
 - 
cancelWrite
Description copied from interface:EndPointCancel any currentEndPoint.write(Callback, ByteBuffer...)operation in progress. Calling this method with cause future calls toEndPoint.write(Callback, ByteBuffer...)and its variants, to fail the passedCallback.- Specified by:
 cancelWritein interfaceEndPoint- Parameters:
 cause- the cause- Returns:
 - The callback passed to a pending/in progress 
writeornullif there was none. 
 - 
write
 - 
isFillInterested
public boolean isFillInterested()- Specified by:
 isFillInterestedin interfaceEndPoint- Returns:
 - whether 
EndPoint.fillInterested(Callback)has been called, butEndPoint.fill(ByteBuffer)has not yet been called 
 - 
fillInterested
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
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
 
 - 
getConnection
- Specified by:
 getConnectionin interfaceEndPoint- Returns:
 - the 
Connectionassociated with this EndPoint - See Also:
 
 - 
setConnection
- Specified by:
 setConnectionin interfaceEndPoint- Parameters:
 connection- theConnectionassociated with this EndPoint- See Also:
 
 - 
onOpen
 - 
upgrade
Description copied from interface:EndPointUpgrades 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.UpgradeFromthen 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. - 
getSslSessionData
Description copied from interface:EndPointReturns the SslSessionData of a secure end point.
- Specified by:
 getSslSessionDatain interfaceEndPoint- Returns:
 - A 
EndPoint.SslSessionDatainstance (with possibly null field values) if secure, elsenull. 
 - 
toString
 
 -