public abstract class ChannelEndPoint extends AbstractEndPoint implements ManagedSelector.Selectable
Holds the channel and socket for an NIO endpoint.
| Modifier and Type | Class and Description |
|---|---|
private class |
ChannelEndPoint.RunnableCloseable |
private class |
ChannelEndPoint.RunnableTask |
| Modifier and Type | Field and Description |
|---|---|
private java.nio.channels.SocketChannel |
_channel |
private int |
_currentInterestOps |
private int |
_desiredInterestOps |
private java.nio.channels.SelectionKey |
_key |
private java.lang.Runnable |
_runCompleteWrite |
private java.lang.Runnable |
_runCompleteWriteFillable |
private java.lang.Runnable |
_runFillable |
private ManagedSelector |
_selector |
private ManagedSelector.SelectorUpdate |
_updateKeyAction |
private boolean |
_updatePending |
private static Logger |
LOG |
| Constructor and Description |
|---|
ChannelEndPoint(java.nio.channels.SocketChannel channel,
ManagedSelector selector,
java.nio.channels.SelectionKey key,
Scheduler scheduler) |
| Modifier and Type | Method and Description |
|---|---|
private void |
changeInterests(int operation) |
void |
doClose() |
protected void |
doShutdownOutput() |
int |
fill(java.nio.ByteBuffer buffer)
Fill the passed buffer with data from this endpoint.
|
boolean |
flush(java.nio.ByteBuffer... buffers)
Flush data from the passed header/buffer to this endpoint.
|
java.nio.channels.SocketChannel |
getChannel() |
java.net.InetSocketAddress |
getLocalAddress() |
java.net.InetSocketAddress |
getRemoteAddress() |
java.lang.Object |
getTransport() |
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 usage
|
protected void |
needsFillInterest() |
void |
onClose()
Callback method invoked when this
EndPoint is close. |
protected void |
onIncompleteFlush() |
java.lang.Runnable |
onSelected()
Callback method invoked when a read or write events has been
detected by the
ManagedSelector for this endpoint. |
void |
replaceKey(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.String |
toEndPointString() |
void |
updateKey()
Callback method invoked when all the keys selected by the
ManagedSelector for this endpoint have been processed. |
private void |
updateKeyAction(java.nio.channels.Selector selector) |
checkFill, checkFlush, close, close, doShutdownInput, fillInterested, getConnection, getCreatedTimeStamp, getFillInterest, getWriteFlusher, isFillInterested, isInputShutdown, isOutputShutdown, onClose, onIdleExpired, onOpen, reset, setConnection, shutdownInput, shutdownOutput, toConnectionString, toString, tryFillInterested, upgrade, writecheckIdleTimeout, getIdleFor, getIdleTimeout, getScheduler, notIdle, setIdleTimeoutclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetIdleTimeout, setIdleTimeoutprivate static final Logger LOG
private final java.nio.channels.SocketChannel _channel
private final ManagedSelector _selector
private java.nio.channels.SelectionKey _key
private boolean _updatePending
private int _currentInterestOps
private int _desiredInterestOps
private final ManagedSelector.SelectorUpdate _updateKeyAction
private final java.lang.Runnable _runFillable
private final java.lang.Runnable _runCompleteWrite
private final java.lang.Runnable _runCompleteWriteFillable
public ChannelEndPoint(java.nio.channels.SocketChannel channel,
ManagedSelector selector,
java.nio.channels.SelectionKey key,
Scheduler scheduler)
public java.net.InetSocketAddress getLocalAddress()
getLocalAddress in interface EndPointEndPoint is bound, or null
if this EndPoint does not represent a network connection.public java.net.InetSocketAddress getRemoteAddress()
getRemoteAddress in interface EndPointEndPoint is bound, or null
if this EndPoint does not represent a network connection.public boolean isOptimizedForDirectBuffers()
EndPointisOptimizedForDirectBuffers in interface EndPointisOptimizedForDirectBuffers in class AbstractEndPointpublic boolean isOpen()
IdleTimeoutisOpen in interface EndPointisOpen in class AbstractEndPointprotected void doShutdownOutput()
doShutdownOutput in class AbstractEndPointpublic void doClose()
doClose in class AbstractEndPointpublic void onClose()
EndPointCallback method invoked when this EndPoint is close.
onClose in interface EndPointonClose in class AbstractEndPointEndPoint.onOpen()public int fill(java.nio.ByteBuffer buffer)
throws java.io.IOException
EndPointfill in interface EndPointbuffer - 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.int value indicating the number of bytes
filled or -1 if EOF is read or the input is shutdown.java.io.IOException - if the endpoint is closed.public boolean flush(java.nio.ByteBuffer... buffers)
throws java.io.IOException
EndPointflush in interface EndPointbuffers - the buffers to flushjava.io.IOException - If the endpoint is closed or output is shutdown.public java.nio.channels.SocketChannel getChannel()
public java.lang.Object getTransport()
getTransport in interface EndPointprotected void needsFillInterest()
needsFillInterest in class AbstractEndPointprotected void onIncompleteFlush()
onIncompleteFlush in class AbstractEndPointpublic java.lang.Runnable onSelected()
ManagedSelector.SelectableManagedSelector for this endpoint.onSelected in interface ManagedSelector.Selectableprivate void updateKeyAction(java.nio.channels.Selector selector)
public void updateKey()
ManagedSelector.SelectableManagedSelector for this endpoint have been processed.updateKey in interface ManagedSelector.Selectablepublic void replaceKey(java.nio.channels.SelectionKey newKey)
ManagedSelector.SelectablereplaceKey in interface ManagedSelector.SelectablenewKey - the new SelectionKeyprivate void changeInterests(int operation)
public java.lang.String toEndPointString()
toEndPointString in class AbstractEndPoint