|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.grizzly.filter.ReadFilter
public class ReadFilter
Simple ProtocolFilter
implementation which read the available bytes
and delegate the processing to the next ProtocolFilter
in the ProtocolChain
.
If no bytes are available, no new ProtocolFilter
will be a invoked and
the connection (SelectionKey) will be cancelled. This filter can be used
for both UDP (reveive) and TCP (read).
Note that all ready OP_WRITE operations will be ignored.
Field Summary | |
---|---|
protected boolean |
continousExecution
true if a pipelined execution is required. |
static String |
DELAYED_CLOSE_NOTIFICATION
|
protected int |
readAttempts
|
static String |
UDP_SOCKETADDRESS
|
Fields inherited from interface com.sun.grizzly.ProtocolFilter |
---|
SUCCESSFUL_READ |
Constructor Summary | |
---|---|
ReadFilter()
|
Method Summary | |
---|---|
protected void |
checkEmptyRead(SocketChannel channel,
int size)
|
boolean |
execute(Context ctx)
Read available bytes and delegate the processing of them to the next ProtocolFilter in the ProtocolChain . |
protected boolean |
execute(Context ctx,
ByteBuffer byteBuffer)
Read available bytes to the specific ByteBuffer and delegate
the processing of them to the next ProtocolFilter in the ProtocolChain. |
int |
getReadAttempts()
Get the number of attempts the ReadFilter will try to read a data
from a channel. |
boolean |
isContinuousExecution()
Return true if the current ExecutorService can
re-execute its ProtocolFilter after a successful execution. |
protected void |
log(String msg,
Throwable t)
Log a message/exception. |
boolean |
postExecute(Context ctx)
If no bytes were available, close the connection by cancelling the SelectionKey. |
void |
setContinuousExecution(boolean continousExecution)
Set to true if the current ExecutorService can
re-execute its ProtocolFilter(s) after a successful execution. |
void |
setReadAttempts(int readAttempts)
Set the number of attempts the ReadFilter will try to read a data
from a channel. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DELAYED_CLOSE_NOTIFICATION
public static final String UDP_SOCKETADDRESS
protected boolean continousExecution
protected int readAttempts
Constructor Detail |
---|
public ReadFilter()
Method Detail |
---|
public boolean execute(Context ctx) throws IOException
ProtocolFilter
in the ProtocolChain
.
execute
in interface ProtocolFilter
ctx
- Context
IOException
protected boolean execute(Context ctx, ByteBuffer byteBuffer) throws IOException
ByteBuffer
and delegate
the processing of them to the next ProtocolFilter in the ProtocolChain.
IOException
public boolean postExecute(Context ctx) throws IOException
postExecute
in interface ProtocolFilter
ctx
- Context
IOException
public void setContinuousExecution(boolean continousExecution)
ExecutorService
can
re-execute its ProtocolFilter(s) after a successful execution. Enabling
this property is useful for protocol that needs to support pipelined
message requests as the ProtocolFilter are automatically re-executed,
avoiding the overhead of releasing the current Thread, registering
back the SelectionKey to the SelectorHandler
and waiting for a new
NIO event.
Some protocols (like http) can get the http headers in one
SocketChannel.read, parse the message and then get the next http message
on the second SocketChannel.read(). Not having to release the Thread
and re-execute the ProtocolFilter greatly improve performance.
setContinuousExecution
in interface ReinvokeAware
continousExecution
- true to enable continuous execution.
(default is false).public boolean isContinuousExecution()
ExecutorService
can
re-execute its ProtocolFilter after a successful execution.
isContinuousExecution
in interface ReinvokeAware
public int getReadAttempts()
ReadFilter
will try to read a data
from a channel.
ReadFilter
will try to read a data
from a channel.public void setReadAttempts(int readAttempts)
ReadFilter
will try to read a data
from a channel.
readAttempts
- the number of attempts the ReadFilter
will
try to read a data from a channel.protected void log(String msg, Throwable t)
msg
- String
t
- Throwable
protected final void checkEmptyRead(SocketChannel channel, int size)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |