public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPoint, ConnectedEndPoint
SelectorManager.| Modifier and Type | Field and Description |
|---|---|
static Logger |
LOG |
_channel, _gather2, _local, _maxIdleTime, _remote, _socket| Constructor and Description |
|---|
SelectChannelEndPoint(SocketChannel channel,
SelectorManager.SelectSet selectSet,
SelectionKey key,
int maxIdleTime) |
| Modifier and Type | Method and Description |
|---|---|
void |
asyncDispatch()
Dispatch the endpoint.
|
boolean |
blockReadable(long timeoutMs) |
boolean |
blockWritable(long timeoutMs) |
void |
cancelTimeout(Timeout.Task task) |
void |
checkIdleTimestamp(long now) |
void |
close()
Close any backing stream associated with the endpoint
|
void |
dispatch()
Dispatch the endpoint if it is not already dispatched
|
int |
fill(Buffer buffer)
Fill the buffer from the current putIndex to it's capacity from whatever
byte source is backing the buffer.
|
int |
flush(Buffer buffer)
Flush the buffer from the current getIndex to it's putIndex using whatever byte
sink is backing the buffer.
|
int |
flush(Buffer header,
Buffer buffer,
Buffer trailer)
Flush the buffer from the current getIndex to it's putIndex using whatever byte
sink is backing the buffer.
|
Connection |
getConnection() |
long |
getIdleTimestamp() |
SelectionKey |
getSelectionKey() |
SelectorManager |
getSelectManager() |
SelectorManager.SelectSet |
getSelectSet() |
protected void |
handle() |
boolean |
hasProgressed() |
boolean |
isCheckForIdle()
Get if the endpoint should be checked for idleness
|
boolean |
isInterruptable() |
boolean |
isWritable() |
protected void |
notIdle() |
void |
onIdleExpired(long idleForMs)
Callback when idle.
|
void |
schedule()
Called by selectSet to schedule handling
|
void |
scheduleTimeout(Timeout.Task task,
long timeoutMs) |
void |
scheduleWrite()
Schedule a write dispatch.
|
void |
setCheckForIdle(boolean check)
Set if the endpoint should be checked for idleness
|
void |
setConnection(Connection connection) |
void |
setInterruptable(boolean interupable)
Set the interruptable mode of the endpoint.
|
void |
setMaxIdleTime(int timeMs)
Don't set the SoTimeout
|
String |
toString() |
protected boolean |
undispatch()
Called when a dispatched thread is no longer handling the endpoint.
|
flush, gatheringFlush, getChannel, getLocalAddr, getLocalHost, getLocalPort, getMaxIdleTime, getRemoteAddr, getRemoteHost, getRemotePort, getTransport, isBlocking, isInputShutdown, isOpen, isOutputShutdown, shutdownChannelInput, shutdownChannelOutput, shutdownInput, shutdownOutputclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitflush, getLocalAddr, getLocalHost, getLocalPort, getMaxIdleTime, getRemoteAddr, getRemoteHost, getRemotePort, getTransport, isBlocking, isInputShutdown, isOpen, isOutputShutdown, shutdownInput, shutdownOutputpublic static final Logger LOG
public SelectChannelEndPoint(SocketChannel channel, SelectorManager.SelectSet selectSet, SelectionKey key, int maxIdleTime) throws IOException
IOExceptionpublic SelectionKey getSelectionKey()
public SelectorManager getSelectManager()
public Connection getConnection()
getConnection in interface ConnectedEndPointpublic void setConnection(Connection connection)
setConnection in interface ConnectedEndPointpublic long getIdleTimestamp()
public void schedule()
public void asyncDispatch()
AsyncEndPointasyncDispatch in interface AsyncEndPointpublic void dispatch()
AsyncEndPointdispatch in interface AsyncEndPointprotected boolean undispatch()
public void cancelTimeout(Timeout.Task task)
cancelTimeout in interface AsyncEndPointpublic void scheduleTimeout(Timeout.Task task, long timeoutMs)
scheduleTimeout in interface AsyncEndPointpublic void setCheckForIdle(boolean check)
AsyncEndPointsetCheckForIdle in interface AsyncEndPointpublic boolean isCheckForIdle()
AsyncEndPointisCheckForIdle in interface AsyncEndPointprotected void notIdle()
public void checkIdleTimestamp(long now)
public void onIdleExpired(long idleForMs)
AsyncEndPointAn endpoint is idle if there has been no IO activity for
EndPoint.getMaxIdleTime() and AsyncEndPoint.isCheckForIdle() is true.
onIdleExpired in interface AsyncEndPointidleForMs - TODOpublic int fill(Buffer buffer) throws IOException
EndPointfill in interface EndPointfill in class ChannelEndPointint value indicating the number of bytes
filled or -1 if EOF is reached.EofException - If input is shutdown or the endpoint is closed.IOExceptionpublic int flush(Buffer header, Buffer buffer, Buffer trailer) throws IOException
EndPointflush in interface EndPointflush in class ChannelEndPointheader - A buffer to write before flushing this buffer. This buffers getIndex is updated.buffer - The buffer to flush. This buffers getIndex is updated.trailer - A buffer to write after flushing this buffer. This buffers getIndex is updated.IOExceptionpublic int flush(Buffer buffer) throws IOException
EndPointflush in interface EndPointflush in class ChannelEndPointbuffer - The buffer to flush. This buffers getIndex is updated.EofException - If the endpoint is closed or output is shutdown.IOExceptionpublic boolean blockReadable(long timeoutMs)
throws IOException
blockReadable in interface EndPointblockReadable in class ChannelEndPointIOExceptionpublic boolean blockWritable(long timeoutMs)
throws IOException
blockWritable in interface EndPointblockWritable in class ChannelEndPointIOExceptionpublic void setInterruptable(boolean interupable)
interupable - public boolean isInterruptable()
public void scheduleWrite()
AsyncEndPointscheduleWrite in interface AsyncEndPointAsyncEndPoint.scheduleWrite()public boolean isWritable()
isWritable in interface AsyncEndPointpublic boolean hasProgressed()
hasProgressed in interface AsyncEndPointAsyncEndPoint.hasProgressed()protected void handle()
public void close()
throws IOException
EndPointclose in interface EndPointclose in class ChannelEndPointIOExceptionpublic SelectorManager.SelectSet getSelectSet()
public void setMaxIdleTime(int timeMs)
throws IOException
setMaxIdleTime in interface EndPointsetMaxIdleTime in class ChannelEndPointtimeMs - the max idle time in MS. Timeout <= 0 implies an infinite timeoutIOException - if the timeout cannot be set.ChannelEndPoint.setMaxIdleTime(int)Copyright © 1995-2015 Mort Bay Consulting. All Rights Reserved.