[JBoss JIRA] Commented: (NETTY-317) IdleStateHandler not rational

Minas Abramyan (JIRA) jira-events at lists.jboss.org
Mon May 24 04:54:55 EDT 2010


    [ https://jira.jboss.org/browse/NETTY-317?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12532025#action_12532025 ] 

Minas Abramyan commented on NETTY-317:
--------------------------------------

Something like this:

public class MyIdleHandler {

    private static Hashtable<Channel, Long> iddleHandler = new Hashtable<Channel, Long>();
    private static int iddleTime;
    private static int checkPeriod; 
    private static Thread iddleController = new Thread(new Runnable() {

        public void run() {
            while (true) {

                long curTime = System.currentTimeMillis();

                for (Channel ch : iddleHandler.keySet()) {
                    if (curTime - iddleHandler.get(ch) > iddleTime) {
                        ch.close();
                    }
                }

                try {
                    Thread.sleep(checkPeriod);
                } catch (InterruptedException ex) {
                }
            }
        }
    });

    public static void init(int iddleTimeMills, int checkPeriodMills) {
        iddleTime = iddleTimeMills;
        checkPeriod = checkPeriodMills;
        iddleController.start();
    }

    @Override
    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
        iddleHandler.put(ctx.getChannel(), System.currentTimeMillis());
        super.messageReceived(ctx, e);
    }

    @Override
    public void writeRequested(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
        iddleHandler.put(ctx.getChannel(), System.currentTimeMillis());
        super.writeRequested(ctx, e);
    }

    @Override
    public void channelClosed(final ChannelHandlerContext ctx,
            final ChannelStateEvent e) throws Exception {
        iddleHandler.remove(ctx.getChannel());
		super.channelClosed(ctx, e);
    }
}


> IdleStateHandler not rational
> -----------------------------
>
>                 Key: NETTY-317
>                 URL: https://jira.jboss.org/browse/NETTY-317
>             Project: Netty
>          Issue Type: Quality Risk
>         Environment: Windows XP
>            Reporter: Minas Abramyan
>            Assignee: Trustin Lee
>             Fix For: 3.1.5.GA
>
>
> I do stress testing with IdleStateHandler and without it. I found that with IdleStateHandler, performance falls at 75-80%. I think that create new Timer at each session it is not rational. I suggest to create kind of like MINA IdleStatusChecker.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the netty-dev mailing list