Radim Kolar SF.NET wrote:
>> OK I guess the Write filter needs to be re-worked :-) Let me take a look
>> today.
> I reworked writer as follows:
>
> UDPWriteFilter f4 = new UDPWriteFilter() {
> @Override
> public boolean postExecute(Context ctx) throws IOException {
> ctx.setKeyRegistrationState(Context.KeyRegistrationState.REGISTER);
> ((WorkerThread)Thread.currentThread()).getByteBuffer().clear();
>
> return true;
> }
>
> and my app starts working nicely without known race conditions.
Your change looks good. I will incorporate it.
>
> Can grizzly framework increase number of buffered arriving UDP packets so
> no packets gets lost on traffic spikes?
>
> I suspect that Grizzly can serve more than 1 packet at once using different
> threads, right? I have to check app and framework for more possible race
> conditions.
Can you try it by applying the following:
UDPSelectorHandler ush = new UDPSelectorHandler(){
/**
* Handle OP_READ.
* @param ctx <code>Context</code>
* @param key <code>SelectionKey</code>
* @return false if handled by a <code>CallbackHandler</code>,
otherwise true
*/
public boolean onReadInterest(final SelectionKey key,final Context ctx)
throws IOException{
// Keep the packet coming
//key.interestOps(key.interestOps() & (~SelectionKey.OP_READ));
Object attach = key.attachment();
if (asyncQueueReader.isAsyncQueueReaderEnabledFor(key)) {
final Context context = pollContext(ctx, key);
context.setCurrentOpType(Context.OpType.OP_READ);
invokeAsyncQueueReader(context);
return false;
} else if (attach instanceof CallbackHandler){
final Context context = pollContext(ctx, key);
context.setCurrentOpType(Context.OpType.OP_READ);
invokeCallbackHandler((CallbackHandler) attach, context);
return false;
} else {
return true;
}
}
}
and let us know if the performance improved? What I did is commented out
the key.interestOps(key.interestOps() & (~SelectionKey.OP_READ)), which
means as soon as OP_READ are available, the Selector will wakes up. I
suspect this is what you need.
Thanks!
-- Jeanfrancois
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>