Package org.eclipse.jetty.io
Class ChannelEndPoint
- java.lang.Object
-
- org.eclipse.jetty.io.IdleTimeout
-
- org.eclipse.jetty.io.AbstractEndPoint
-
- org.eclipse.jetty.io.ChannelEndPoint
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,EndPoint
- Direct Known Subclasses:
SelectChannelEndPoint
public class ChannelEndPoint extends AbstractEndPoint
Channel End Point.Holds the channel and socket for an NIO endpoint.
-
-
Constructor Summary
Constructors Constructor Description ChannelEndPoint(Scheduler scheduler, SocketChannel channel)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close any backing stream associated with the endpointint
fill(ByteBuffer buffer)
Fill the passed buffer with data from this endpoint.boolean
flush(ByteBuffer... buffers)
Flush data from the passed header/buffer to this endpoint.ByteChannel
getChannel()
Socket
getSocket()
Object
getTransport()
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
isOptimizedForDirectBuffers()
Is the endpoint optimized for DirectBuffer usageboolean
isOutputShutdown()
Test if output is shutdown.protected void
needsFillInterest()
protected void
onIncompleteFlush()
protected void
shutdownInput()
void
shutdownOutput()
Shutdown the output.-
Methods inherited from class org.eclipse.jetty.io.AbstractEndPoint
close, fillInterested, getConnection, getCreatedTimeStamp, getFillInterest, getLocalAddress, getRemoteAddress, getWriteFlusher, isFillInterested, onIdleExpired, onOpen, setConnection, toString, tryFillInterested, upgrade, write
-
Methods inherited from class org.eclipse.jetty.io.IdleTimeout
checkIdleTimeout, getIdleFor, getIdleTimeout, getIdleTimestamp, getScheduler, notIdle, onClose, 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
getIdleTimeout, onClose, setIdleTimeout
-
-
-
-
Constructor Detail
-
ChannelEndPoint
public ChannelEndPoint(Scheduler scheduler, SocketChannel channel)
-
-
Method Detail
-
isOptimizedForDirectBuffers
public boolean isOptimizedForDirectBuffers()
Description copied from interface:EndPoint
Is the endpoint optimized for DirectBuffer usage- Specified by:
isOptimizedForDirectBuffers
in interfaceEndPoint
- Overrides:
isOptimizedForDirectBuffers
in classAbstractEndPoint
- Returns:
- True if direct buffers can be used optimally.
-
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
-
shutdownInput
protected void shutdownInput()
-
shutdownOutput
public 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()
.
-
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()
.- 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
.- Returns:
- True if the input is shutdown or the endpoint is closed.
-
close
public void close()
Description copied from interface:EndPoint
Close any backing stream associated with the endpoint- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceEndPoint
- Overrides:
close
in classAbstractEndPoint
-
fill
public int fill(ByteBuffer buffer) throws IOException
Description copied from interface:EndPoint
Fill 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 it's capacity. The limit is updated to include the filled bytes.- Parameters:
buffer
- 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
int
value indicating the number of bytes filled or -1 if EOF is read or the input is shutdown. - Throws:
IOException
- if the endpoint is closed.
-
flush
public boolean flush(ByteBuffer... buffers) throws IOException
Description copied from interface:EndPoint
Flush 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.- 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.
-
getChannel
public ByteChannel getChannel()
-
getTransport
public Object getTransport()
- Returns:
- The underlying transport object (socket, channel, etc.)
-
getSocket
public Socket getSocket()
-
onIncompleteFlush
protected void onIncompleteFlush()
- Specified by:
onIncompleteFlush
in classAbstractEndPoint
-
needsFillInterest
protected void needsFillInterest() throws IOException
- Specified by:
needsFillInterest
in classAbstractEndPoint
- Throws:
IOException
-
-