Question: Why ExecutionHandler in netty only support upstream?

李巍 kouxing2000 at gmail.com
Tue Mar 23 22:06:41 EDT 2010


Dear netty users

    Netty is supposed to support SEDA (Staged Event-Driven Architecture),
but in org.jboss.netty.handler.execution.ExecutionHandler, the executor is
only used in handleUpstream(), what about handleDownstream()? If I want to
only put the encoding logic in another thread pool, how to deal with that?
If I remember correctly, Mina support this.

    I tried to write related classes(attached) to support this, but failed
to get it run. The application failed at startup. If enable that in client
mode, even can not build socket connection with server.
    I hope someone can help me. thanks in advance.

class ExecutionHandler

    public void handleUpstream(
            ChannelHandlerContext context, ChannelEvent e) throws Exception
{
        executor.execute(new ChannelEventRunnable(context, e));
    }

    public void handleDownstream(
            ChannelHandlerContext ctx, ChannelEvent e) throws Exception {
        if (e instanceof ChannelStateEvent) {
            ChannelStateEvent cse = (ChannelStateEvent) e;
            if (cse.getState() == ChannelState.INTEREST_OPS &&
                (((Integer) cse.getValue()).intValue() & Channel.OP_READ) !=
0) {

                // setReadable(true) requested
                boolean readSuspended = ctx.getAttachment() != null;
                if (readSuspended) {
                    // Drop the request silently if MemoryAwareThreadPool
has
                    // set the flag.
                    e.getFuture().setSuccess();
                    return;
                }
            }
        }

        ctx.sendDownstream(e);
    }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20100324/4402cab0/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DownStreamExecutionHandler.java
Type: application/octet-stream
Size: 1577 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100324/4402cab0/attachment-0002.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DownStreamChannelEventRunnable.java
Type: application/octet-stream
Size: 1094 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20100324/4402cab0/attachment-0003.obj 


More information about the netty-users mailing list