|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IIoHandler
The IIoHandler
is responsible to perform the low level io operation of a
IConnection
. Each connection holds a dedicated io handler. There
is always a 1:1 life cycle relationship between the connection instance and the io handler
instance.
Because a connection object is stateful, the io handler is (implicit) stateful, too.
The io handler has to handle the read and write operations independently. There is no
implicit call behaviour like request-response.
The io handler is responsible to notify io events by calling the assigned
IIoHandlerContext
reference.
The implementation needn`t to be threadsafe
This class is experimental and is subject to change
Method Summary | |
---|---|
void |
close(boolean immediate)
non-blocking close of the handler. |
java.util.LinkedList<java.nio.ByteBuffer> |
drainIncoming()
drains the handler`s read buffer. |
int |
getConnectionTimeoutSec()
returns the connection timeout. |
java.lang.String |
getId()
return a unique conection id |
int |
getIdleTimeoutSec()
returns the idle timeout. |
java.net.InetAddress |
getLocalAddress()
returns the local address of the underlying connection. |
int |
getLocalPort()
returns the local port of the underlying connection. |
java.lang.Object |
getOption(java.lang.String name)
returns the vlaue of a option |
java.util.Map<java.lang.String,java.lang.Class> |
getOptions()
Returns an unmodifiable map of the options supported by this endpont. |
int |
getPendingWriteDataSize()
returns the size of the data which have already been written, but not yet transferred to the underlying socket. |
java.net.InetAddress |
getRemoteAddress()
returns the address of the remote host of the underlying connection. |
int |
getRemotePort()
returns the port of the remote host of the underlying connection. |
void |
init(IIoHandlerCallback callbackHandler)
"starts" the handler. |
boolean |
isOpen()
check, if the handler (underlying connection) is open. |
void |
resumeRead()
resume reading data from the underlying subsystem |
void |
setConnectionTimeoutSec(int timeout)
sets the connection timout. |
void |
setIdleTimeoutSec(int timeout)
sets the idle timeout. |
void |
setOption(java.lang.String name,
java.lang.Object value)
set a option |
void |
suspendRead()
suspend reading data from the underlying subsystem |
void |
writeOutgoing(java.nio.ByteBuffer buffer)
non-blocking write. |
void |
writeOutgoing(java.util.LinkedList<java.nio.ByteBuffer> buffers)
non-blocking write. |
Method Detail |
---|
void init(IIoHandlerCallback callbackHandler) throws java.io.IOException
callbackHandler
- the callback handler
java.io.IOException
java.net.InetAddress getLocalAddress()
int getLocalPort()
java.net.InetAddress getRemoteAddress()
int getRemotePort()
void setIdleTimeoutSec(int timeout)
timeout
- the idle timeoutjava.lang.String getId()
void setConnectionTimeoutSec(int timeout)
timeout
- the connection timeoutint getConnectionTimeoutSec()
int getIdleTimeoutSec()
java.lang.Object getOption(java.lang.String name) throws java.io.IOException
name
- the name of the option
java.io.IOException
- In an I/O error occursjava.util.Map<java.lang.String,java.lang.Class> getOptions()
void setOption(java.lang.String name, java.lang.Object value) throws java.io.IOException
name
- the option namevalue
- the option value
java.io.IOException
- In an I/O error occursboolean isOpen()
void close(boolean immediate) throws java.io.IOException
immediate
- if true, close the connection immediate. If false remaining
out buffers (collected by the writOutgoing methods) has
to written before closing
java.io.IOException
- If some other I/O error occursvoid writeOutgoing(java.nio.ByteBuffer buffer) throws ClosedConnectionException, java.io.IOException
IIoHandlerCallback#onWritten(IOException)
call back method has been called.
buffer
- the data to add into the out buffer
ClosedConnectionException
- if the underlying connection is already closed
java.io.IOException
- If some other I/O error occursvoid writeOutgoing(java.util.LinkedList<java.nio.ByteBuffer> buffers) throws ClosedConnectionException, java.io.IOException
IIoHandlerCallback#onWritten(IOException)
call back method has been called.
buffers
- the datas to add into the out buffer
ClosedConnectionException
- if the underlying connection is already closed
java.io.IOException
- If some other I/O error occursint getPendingWriteDataSize()
void suspendRead() throws java.io.IOException
java.io.IOException
- If some other I/O error occursvoid resumeRead() throws java.io.IOException
java.io.IOException
- If some other I/O error occursjava.util.LinkedList<java.nio.ByteBuffer> drainIncoming()
IIoHandlerCallback.onDataRead()
method.
Example Stacktrace: [DataReaderThread] <IIoHandler>.drainIncomming() <IIoHandlerCallback>.onDataRead() ...
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |