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:
java.io.Closeable,java.lang.AutoCloseable,EndPoint,ManagedSelector.Selectable
- Direct Known Subclasses:
SocketChannelEndPoint
public abstract class ChannelEndPoint extends AbstractEndPoint implements ManagedSelector.Selectable
Channel End Point.Holds the channel and socket for an NIO endpoint.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classChannelEndPoint.RunnableCloseableprivate classChannelEndPoint.RunnableTask
-
Field Summary
Fields Modifier and Type Field Description private java.nio.channels.SocketChannel_channelprivate int_currentInterestOpsprivate int_desiredInterestOpsprivate java.nio.channels.SelectionKey_keyprivate java.lang.Runnable_runCompleteWriteprivate java.lang.Runnable_runCompleteWriteFillableprivate java.lang.Runnable_runFillableprivate ManagedSelector_selectorprivate ManagedSelector.SelectorUpdate_updateKeyActionprivate boolean_updatePendingprivate static LoggerLOG
-
Constructor Summary
Constructors Constructor Description ChannelEndPoint(java.nio.channels.SocketChannel channel, ManagedSelector selector, java.nio.channels.SelectionKey key, Scheduler scheduler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidchangeInterests(int operation)voiddoClose()protected voiddoShutdownOutput()intfill(java.nio.ByteBuffer buffer)Fill the passed buffer with data from this endpoint.booleanflush(java.nio.ByteBuffer... buffers)Flush data from the passed header/buffer to this endpoint.java.nio.channels.SocketChannelgetChannel()java.net.InetSocketAddressgetLocalAddress()java.net.InetSocketAddressgetRemoteAddress()java.lang.ObjectgetTransport()booleanisOpen()This abstract method should be called to check if idle timeouts should still be checked.booleanisOptimizedForDirectBuffers()Is the endpoint optimized for DirectBuffer usageprotected voidneedsFillInterest()voidonClose()Callback method invoked when this EndPoint is close.protected voidonIncompleteFlush()java.lang.RunnableonSelected()Callback method invoked when a read or write events has been detected by theManagedSelectorfor this endpoint.voidreplaceKey(java.nio.channels.SelectionKey newKey)Callback method invoked when the SelectionKey is replaced because the channel has been moved to a new selector.java.lang.StringtoEndPointString()voidupdateKey()Callback method invoked when all the keys selected by theManagedSelectorfor this endpoint have been processed.private voidupdateKeyAction(java.nio.channels.Selector selector)-
Methods inherited from class org.eclipse.jetty.io.AbstractEndPoint
checkFill, checkFlush, close, close, doShutdownInput, fillInterested, getConnection, getCreatedTimeStamp, getFillInterest, getWriteFlusher, isFillInterested, isInputShutdown, isOutputShutdown, onClose, onIdleExpired, onOpen, reset, setConnection, shutdownInput, shutdownOutput, toConnectionString, toString, tryFillInterested, upgrade, write
-
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
getIdleTimeout, setIdleTimeout
-
-
-
-
Field Detail
-
LOG
private static final Logger LOG
-
_channel
private final java.nio.channels.SocketChannel _channel
-
_selector
private final ManagedSelector _selector
-
_key
private java.nio.channels.SelectionKey _key
-
_updatePending
private boolean _updatePending
-
_currentInterestOps
private int _currentInterestOps
-
_desiredInterestOps
private int _desiredInterestOps
-
_updateKeyAction
private final ManagedSelector.SelectorUpdate _updateKeyAction
-
_runFillable
private final java.lang.Runnable _runFillable
-
_runCompleteWrite
private final java.lang.Runnable _runCompleteWrite
-
_runCompleteWriteFillable
private final java.lang.Runnable _runCompleteWriteFillable
-
-
Constructor Detail
-
ChannelEndPoint
public ChannelEndPoint(java.nio.channels.SocketChannel channel, ManagedSelector selector, java.nio.channels.SelectionKey key, Scheduler scheduler)
-
-
Method Detail
-
getLocalAddress
public java.net.InetSocketAddress getLocalAddress()
- Specified by:
getLocalAddressin interfaceEndPoint- Returns:
- The local Inet address to which this
EndPointis bound, ornullif thisEndPointdoes not represent a network connection.
-
getRemoteAddress
public java.net.InetSocketAddress getRemoteAddress()
- Specified by:
getRemoteAddressin interfaceEndPoint- Returns:
- The remote Inet address to which this
EndPointis bound, ornullif thisEndPointdoes not represent a network connection.
-
isOptimizedForDirectBuffers
public boolean isOptimizedForDirectBuffers()
Description copied from interface:EndPointIs the endpoint optimized for DirectBuffer usage- Specified by:
isOptimizedForDirectBuffersin interfaceEndPoint- Overrides:
isOptimizedForDirectBuffersin classAbstractEndPoint- Returns:
- True if direct buffers can be used optimally.
-
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- Overrides:
isOpenin classAbstractEndPoint- Returns:
- True if the entity monitored should still be checked for idle timeouts
-
doShutdownOutput
protected void doShutdownOutput()
- Overrides:
doShutdownOutputin classAbstractEndPoint
-
doClose
public void doClose()
- Overrides:
doClosein classAbstractEndPoint
-
onClose
public void onClose()
Description copied from interface:EndPointCallback method invoked when this EndPoint is close.
- Specified by:
onClosein interfaceEndPoint- Overrides:
onClosein classAbstractEndPoint- See Also:
EndPoint.onOpen()
-
fill
public int fill(java.nio.ByteBuffer buffer) throws java.io.IOExceptionDescription copied from interface:EndPointFill 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.- Specified by:
fillin interfaceEndPoint- 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
intvalue indicating the number of bytes filled or -1 if EOF is read or the input is shutdown. - Throws:
java.io.IOException- if the endpoint is closed.
-
flush
public boolean flush(java.nio.ByteBuffer... buffers) throws java.io.IOExceptionDescription copied from interface:EndPointFlush 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:
java.io.IOException- If the endpoint is closed or output is shutdown.
-
getChannel
public java.nio.channels.SocketChannel getChannel()
-
getTransport
public java.lang.Object getTransport()
- Specified by:
getTransportin interfaceEndPoint- Returns:
- The underlying transport object (socket, channel, etc.)
-
needsFillInterest
protected void needsFillInterest()
- Specified by:
needsFillInterestin classAbstractEndPoint
-
onIncompleteFlush
protected void onIncompleteFlush()
- Specified by:
onIncompleteFlushin classAbstractEndPoint
-
onSelected
public java.lang.Runnable onSelected()
Description copied from interface:ManagedSelector.SelectableCallback method invoked when a read or write events has been detected by theManagedSelectorfor this endpoint.- Specified by:
onSelectedin interfaceManagedSelector.Selectable- Returns:
- a job that may block or null
-
updateKeyAction
private void updateKeyAction(java.nio.channels.Selector selector)
-
updateKey
public void updateKey()
Description copied from interface:ManagedSelector.SelectableCallback method invoked when all the keys selected by theManagedSelectorfor this endpoint have been processed.- Specified by:
updateKeyin interfaceManagedSelector.Selectable
-
replaceKey
public void replaceKey(java.nio.channels.SelectionKey newKey)
Description copied from interface:ManagedSelector.SelectableCallback method invoked when the SelectionKey is replaced because the channel has been moved to a new selector.- Specified by:
replaceKeyin interfaceManagedSelector.Selectable- Parameters:
newKey- the new SelectionKey
-
changeInterests
private void changeInterests(int operation)
-
toEndPointString
public java.lang.String toEndPointString()
- Overrides:
toEndPointStringin classAbstractEndPoint
-
-