public final class AprIoProcessor extends AbstractPollingIoProcessor<AprSession>
AprSocketConnector
wakeupCalled
Constructor and Description |
---|
AprIoProcessor(Executor executor)
Create a new instance of
AprIoProcessor with a given Exector for
handling I/Os events. |
Modifier and Type | Method and Description |
---|---|
protected Iterator<AprSession> |
allSessions()
|
protected int |
allSessionsCount()
Get the number of
IoSession polled by this IoProcessor |
protected void |
destroy(AprSession 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(AprSession session)
Get the state of a session (One of OPENING, OPEN, CLOSING)
|
protected void |
init(AprSession 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(AprSession session)
Tells if this session is registered for reading
|
protected boolean |
isInterestedInWrite(AprSession session)
Tells if this session is registered for writing
|
protected boolean |
isReadable(AprSession 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(AprSession session)
Tells if the session ready for writing
|
protected int |
read(AprSession session,
IoBuffer buffer)
|
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, registring 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 Iterator<AprSession> |
selectedSessions()
Get an
Iterator for the list of IoSession found selected
by the last call of AbstractPollingIoProcessor.select(long) |
protected void |
setInterestedInRead(AprSession session,
boolean isInterested)
Set the session to be informed when a read event should be processed
|
protected void |
setInterestedInWrite(AprSession session,
boolean isInterested)
Set the session to be informed when a write event should be processed
|
protected int |
transferFile(AprSession 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(AprSession 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, write
public AprIoProcessor(Executor executor)
AprIoProcessor
with a given Exector for
handling I/Os events.executor
- the Executor
for handling I/O eventsprotected void doDispose()
IoProcessor
for polling the
client connections. The implementing class doDispose method will be
called.doDispose
in class AbstractPollingIoProcessor<AprSession>
protected int select() throws Exception
select
in class AbstractPollingIoProcessor<AprSession>
Exception
- if some low level IO error occursprotected int select(long timeout) throws Exception
select
in class AbstractPollingIoProcessor<AprSession>
timeout
- milliseconds before the call timeout if no event appearException
- if some low level IO error occursprotected boolean isSelectorEmpty()
IoSession
polled by this IoProcessor
is emptyisSelectorEmpty
in class AbstractPollingIoProcessor<AprSession>
IoProcessor
protected void wakeup()
AbstractPollingIoProcessor.select(long)
call.wakeup
in class AbstractPollingIoProcessor<AprSession>
protected Iterator<AprSession> allSessions()
allSessions
in class AbstractPollingIoProcessor<AprSession>
Iterator
of IoSession
protected int allSessionsCount()
IoSession
polled by this IoProcessor
allSessionsCount
in class AbstractPollingIoProcessor<AprSession>
IoProcessor
protected Iterator<AprSession> selectedSessions()
Iterator
for the list of IoSession
found selected
by the last call of AbstractPollingIoProcessor.select(long)
selectedSessions
in class AbstractPollingIoProcessor<AprSession>
Iterator
of IoSession
read for I/Os operationprotected void init(AprSession session) throws Exception
AbstractPollingIoProcessor
init
in class AbstractPollingIoProcessor<AprSession>
session
- the IoSession
to add to the pollingException
- any exception thrown by the underlying system callsprotected void destroy(AprSession session) throws Exception
destroy
in class AbstractPollingIoProcessor<AprSession>
session
- the IoSession
Exception
- any exception thrown by the underlying system callsprotected SessionState getState(AprSession session)
getState
in class AbstractPollingIoProcessor<AprSession>
session
- the IoSession
to inspectprotected boolean isReadable(AprSession session)
isReadable
in class AbstractPollingIoProcessor<AprSession>
session
- the queried sessionprotected boolean isWritable(AprSession session)
isWritable
in class AbstractPollingIoProcessor<AprSession>
session
- the queried sessionprotected boolean isInterestedInRead(AprSession session)
isInterestedInRead
in class AbstractPollingIoProcessor<AprSession>
session
- the queried sessionprotected boolean isInterestedInWrite(AprSession session)
isInterestedInWrite
in class AbstractPollingIoProcessor<AprSession>
session
- the queried sessionprotected void setInterestedInRead(AprSession session, boolean isInterested) throws Exception
setInterestedInRead
in class AbstractPollingIoProcessor<AprSession>
session
- the session for which we want to be interested in read eventsisInterested
- true for registering, false for removingException
- If there was a problem while registering the sessionprotected void setInterestedInWrite(AprSession session, boolean isInterested) throws Exception
setInterestedInWrite
in class AbstractPollingIoProcessor<AprSession>
session
- the session for which we want to be interested in write eventsisInterested
- true for registering, false for removingException
- If there was a problem while registering the sessionprotected int read(AprSession session, IoBuffer buffer) throws Exception
IoSession
into the given
IoBuffer
. Is called when the session was found ready for reading.read
in class AbstractPollingIoProcessor<AprSession>
session
- the session to readbuffer
- the buffer to fillException
- any exception thrown by the underlying system callsprotected int write(AprSession session, IoBuffer buf, int length) throws IOException
IoSession
, means to be called when
a session was found ready for writing.write
in class AbstractPollingIoProcessor<AprSession>
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 bufferIOException
- any exception thrown by the underlying system callsprotected int transferFile(AprSession session, FileRegion region, int length) throws Exception
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.transferFile
in class AbstractPollingIoProcessor<AprSession>
session
- the session to writeregion
- the file region to writelength
- the length of the portion to sendException
- any exception thrown by the underlying system callsprotected void registerNewSelector()
registerNewSelector
in class AbstractPollingIoProcessor<AprSession>
protected boolean isBrokenConnection() throws IOException
isBrokenConnection
in class AbstractPollingIoProcessor<AprSession>
IOException
- If we got an exceptionCopyright © 2004–2021 Apache MINA Project. All rights reserved.