Netty 3 to Netty 4 porting OrderedMemoryAwareThreadPool

51 views
Skip to first unread message

Aykut

unread,
Oct 5, 2018, 8:45:14 PM10/5/18
to Netty discussions
Hi all, 

I am trying to port a multichannel application to Netty 4, which is currently working with Netty 3.

In the current setup with Netty 3, when I add my main handler to the pipeline I am using the OrderedMemoryAwareThreadPoolExecutor.

By this threadpool executor, I can monitor the current active threads, tasks in queue etc, so that I can understand when there is a lock or a heavy job that makes the system wait.

Now when I try to port to Netty 4, There is no OrderedMemoryAwareThreadPoolExecutor. 

People say that I should use DefaultEventLoopGroup (with number of threads) instead which is not suitable for me as I can not get the active threads from DefaultEventLoopGroup etc. 

So, to solve the problem I checked for a Multithreaded executor and I saw the UnorderedThreadPoolEventExecutor, but this has no ordering of channel events. 
I will also need the ordering that 
OrderedMemoryAwareThreadPoolExecutor provided. 

So how can I run a netty handler with a threadpool executor that also has the ordering ? 

Thanks in advance



Message has been deleted

Aykut

unread,
Oct 27, 2018, 7:56:32 AM10/27/18
to Netty discussions
Hi everyone, 

Since no one has answered this question I think it is time for me to write down what I have found and what I ended up with.

I found out that I need to use DefaultEventLoop, which I have already known earlier. 
Now I found out that I can not reach the thread there (maybe it is possible with reflection, but other than that ..), but the class gives you the threadstate. 

I thought that I should be counting threads with RUNNABLE and BLOCKED states so I ended up with something like below. 
Any suggestions on this solution and the question would be appreciated :)

Iterator<EventExecutor> iterator = xxx.getEventLoopGroup().iterator();
while (iterator.hasNext()) {
DefaultEventLoop eventExecutor = (DefaultEventLoop) iterator.next();

pendingCount += eventExecutor.pendingTasks();
if (eventExecutor.threadProperties().state() == Thread.State.RUNNABLE || eventExecutor.threadProperties().state() == Thread.State.BLOCKED)
activeCount++;
}
Reply all
Reply to author
Forward
0 new messages