Ordered downstream events

ochtar fear ochtar.fear at gmail.com
Fri Apr 30 06:24:06 EDT 2010


Hi Trustin!

Thanks for your reply.

In fact, mutex is what I was trying to avoid asking that question. Since the
encrypt method already takes some time and it's still subject to change and
complication, such synchronized block will reduce prefomance gained using
asynchronous architecture. I think.

Anyway, I've implemented DownstreamExecutionHandler I talked about. Here's
what I've got:

I started with handler:

@ChannelPipelineCoverage("all")
public class DownstreamExecutionHandler implements ChannelDownstreamHandler,
		ExternalResourceReleasable {

	private final Executor executor;
	
	public DownstreamExecutionHandler(Executor executor) {
		this.executor = executor;
	}
	
	@Override
	public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e)
			throws Exception {
		executor.execute(new ChannelDownstreamEventRunnable(ctx, e));
	}

	@Override
	public void releaseExternalResources() {
		ExecutorUtil.terminate(executor);
	}

}

Next step was:

public class ChannelDownstreamEventRunnable extends ChannelEventRunnable{

	public ChannelDownstreamEventRunnable(ChannelHandlerContext ctx,
			ChannelEvent e) {
		super(ctx, e);
	}

	@Override
	public void run()
	{
		getContext().sendDownstream(getEvent());
	}
	
}

Then I added this handler with OrederedMemoryAwareThreadPoolExecutor to
pipeline after the encryptor. Am I doing it right? 

I'm still asking because, though the encryption problem has been solved,
another problem has shown up.

Before Netty we used rough unhandy handmade framework built on java.nio
library which somehow did what it was supposed to do, but was really hard to
maintain and change. And it wasn't scalable. So we decided to switch to
Netty. Thanks again - it was really easy to set up. But when we tried it out
our perfomance decreased 2.5 times! I can't be more specific for now,
because I haven't digged into this yet. But should it have something to do
with that DownstreamHandler and you point it out for me I'd be very
thankful. And if I find that it isn't my fault (what I really doubt) I'll
surely send you my results.

Regards!
-- 
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Ordered-downstream-events-tp4889832p4984879.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list