public final class NioProcessor extends AbstractPollingIoProcessor<NioSession>
| 限定符和类型 | 类和说明 |
|---|---|
protected static class |
NioProcessor.IoSessionIterator<NioSession>
An encapsulating iterator around the
Selector.selectedKeys() or
the Selector.keys() iterator; |
wakeupCalled| 构造器和说明 |
|---|
NioProcessor(java.util.concurrent.Executor executor)
Creates a new instance of NioProcessor.
|
NioProcessor(java.util.concurrent.Executor executor,
java.nio.channels.spi.SelectorProvider selectorProvider)
Creates a new instance of NioProcessor.
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected java.util.Iterator<NioSession> |
allSessions()
|
protected void |
destroy(NioSession session)
Destroy the underlying client socket handle
|
protected void |
doDispose()
Dispose the resources used by this
IoProcessor for polling the
client connections. |
protected SessionState |
getState(NioSession session)
Get the state of a session (One of OPENING, OPEN, CLOSING)
|
protected void |
init(NioSession session)
Initialize the polling of a session.
|
protected boolean |
isBrokenConnection()
Check that the select() has not exited immediately just because of a
broken connection.
|
protected boolean |
isInterestedInRead(NioSession session)
Tells if this session is registered for reading
|
protected boolean |
isInterestedInWrite(NioSession session)
Tells if this session is registered for writing
|
protected boolean |
isReadable(NioSession session)
Tells if the session ready for reading
|
protected boolean |
isSelectorEmpty()
Say if the list of
IoSession polled by this IoProcessor
is empty |
protected boolean |
isWritable(NioSession session)
Tells if the session ready for writing
|
protected int |
read(NioSession session,
IoBuffer buf)
|
protected void |
registerNewSelector()
In the case we are using the java select() method, this method is used to
trash the buggy selector and create a new one, registering all the
sockets on it.
|
protected int |
select()
poll those sessions forever
|
protected int |
select(long timeout)
poll those sessions for the given timeout
|
protected java.util.Iterator<NioSession> |
selectedSessions()
Get an
Iterator for the list of IoSession found selected
by the last call of AbstractPollingIoProcessor.select(long) |
protected void |
setInterestedInRead(NioSession session,
boolean isInterested)
Set the session to be informed when a read event should be processed
|
protected void |
setInterestedInWrite(NioSession session,
boolean isInterested)
Set the session to be informed when a write event should be processed
|
protected int |
transferFile(NioSession session,
FileRegion region,
int length)
Write a part of a file to a
IoSession, if the underlying API
isn't supporting system calls like sendfile(), you can throw a
UnsupportedOperationException so the file will be send using
usual AbstractPollingIoProcessor.write(AbstractIoSession, IoBuffer, int) call. |
protected void |
wakeup()
Interrupt the
AbstractPollingIoProcessor.select(long) call. |
protected int |
write(NioSession session,
IoBuffer buf,
int length)
Write a sequence of bytes to a
IoSession, means to be called when
a session was found ready for writing. |
add, dispose, flush, isDisposed, isDisposing, remove, updateTrafficControl, updateTrafficMask, writepublic NioProcessor(java.util.concurrent.Executor executor)
executor - The executor to usepublic NioProcessor(java.util.concurrent.Executor executor,
java.nio.channels.spi.SelectorProvider selectorProvider)
executor - The executor to useselectorProvider - The Selector provider to useprotected void doDispose()
throws java.lang.Exception
AbstractPollingIoProcessorIoProcessor for polling the
client connections. The implementing class doDispose method will be
called.doDispose 在类中 AbstractPollingIoProcessor<NioSession>java.lang.Exception - if some low level IO error occursprotected int select(long timeout)
throws java.lang.Exception
AbstractPollingIoProcessorselect 在类中 AbstractPollingIoProcessor<NioSession>timeout - milliseconds before the call timeout if no event appearjava.lang.Exception - if some low level IO error occursprotected int select()
throws java.lang.Exception
AbstractPollingIoProcessorselect 在类中 AbstractPollingIoProcessor<NioSession>java.lang.Exception - if some low level IO error occursprotected boolean isSelectorEmpty()
AbstractPollingIoProcessorIoSession polled by this IoProcessor
is emptyisSelectorEmpty 在类中 AbstractPollingIoProcessor<NioSession>IoProcessorprotected void wakeup()
AbstractPollingIoProcessorAbstractPollingIoProcessor.select(long) call.wakeup 在类中 AbstractPollingIoProcessor<NioSession>protected java.util.Iterator<NioSession> allSessions()
AbstractPollingIoProcessorallSessions 在类中 AbstractPollingIoProcessor<NioSession>Iterator of IoSessionprotected java.util.Iterator<NioSession> selectedSessions()
AbstractPollingIoProcessorIterator for the list of IoSession found selected
by the last call of AbstractPollingIoProcessor.select(long)selectedSessions 在类中 AbstractPollingIoProcessor<NioSession>Iterator of IoSession read for I/Os operationprotected void init(NioSession session) throws java.lang.Exception
AbstractPollingIoProcessorinit 在类中 AbstractPollingIoProcessor<NioSession>session - the IoSession to add to the pollingjava.lang.Exception - any exception thrown by the underlying system callsprotected void destroy(NioSession session) throws java.lang.Exception
AbstractPollingIoProcessordestroy 在类中 AbstractPollingIoProcessor<NioSession>session - the IoSessionjava.lang.Exception - any exception thrown by the underlying system callsprotected void registerNewSelector()
throws java.io.IOException
registerNewSelector 在类中 AbstractPollingIoProcessor<NioSession>java.io.IOException - If we got an exceptionprotected boolean isBrokenConnection()
throws java.io.IOException
isBrokenConnection 在类中 AbstractPollingIoProcessor<NioSession>java.io.IOException - If we got an exceptionprotected SessionState getState(NioSession session)
getState 在类中 AbstractPollingIoProcessor<NioSession>session - the IoSession to inspectprotected boolean isReadable(NioSession session)
AbstractPollingIoProcessorisReadable 在类中 AbstractPollingIoProcessor<NioSession>session - the queried sessionprotected boolean isWritable(NioSession session)
AbstractPollingIoProcessorisWritable 在类中 AbstractPollingIoProcessor<NioSession>session - the queried sessionprotected boolean isInterestedInRead(NioSession session)
AbstractPollingIoProcessorisInterestedInRead 在类中 AbstractPollingIoProcessor<NioSession>session - the queried sessionprotected boolean isInterestedInWrite(NioSession session)
AbstractPollingIoProcessorisInterestedInWrite 在类中 AbstractPollingIoProcessor<NioSession>session - the queried sessionprotected void setInterestedInRead(NioSession session, boolean isInterested) throws java.lang.Exception
setInterestedInRead 在类中 AbstractPollingIoProcessor<NioSession>session - the session for which we want to be interested in read eventsisInterested - true for registering, false for removingjava.lang.Exception - If there was a problem while registering the sessionprotected void setInterestedInWrite(NioSession session, boolean isInterested) throws java.lang.Exception
setInterestedInWrite 在类中 AbstractPollingIoProcessor<NioSession>session - the session for which we want to be interested in write eventsisInterested - true for registering, false for removingjava.lang.Exception - If there was a problem while registering the sessionprotected int read(NioSession session, IoBuffer buf) throws java.lang.Exception
AbstractPollingIoProcessorIoSession into the given
IoBuffer. Is called when the session was found ready for reading.read 在类中 AbstractPollingIoProcessor<NioSession>session - the session to readbuf - the buffer to filljava.lang.Exception - any exception thrown by the underlying system callsprotected int write(NioSession session, IoBuffer buf, int length) throws java.lang.Exception
AbstractPollingIoProcessorIoSession, means to be called when
a session was found ready for writing.write 在类中 AbstractPollingIoProcessor<NioSession>session - the session to writebuf - the buffer to writelength - the number of bytes to write can be superior to the number of
bytes remaining in the bufferjava.lang.Exception - any exception thrown by the underlying system callsprotected int transferFile(NioSession session, FileRegion region, int length) throws java.lang.Exception
AbstractPollingIoProcessorIoSession, if the underlying API
isn't supporting system calls like sendfile(), you can throw a
UnsupportedOperationException so the file will be send using
usual AbstractPollingIoProcessor.write(AbstractIoSession, IoBuffer, int) call.transferFile 在类中 AbstractPollingIoProcessor<NioSession>session - the session to writeregion - the file region to writelength - the length of the portion to sendjava.lang.Exception - any exception thrown by the underlying system calls