dev@grizzly.java.net

Re: A question about outbound connection cache

From: Minoru Nitta <minoru.nitta_at_jp.fujitsu.com>
Date: Fri, 20 Feb 2009 09:31:28 +0900

Hi Alexey,


 Thank you for your concern. I tried your suggestion and here is the result.
Before I tried your modification, I modified my test program a bit. I modified
TestFilter.execute as follows, to simulate more real world.

int number = counter % 4;
if (number == 0)
    destination = new InetSocketAddress(InetAddress.getLocalHost(), 5063);
else if (number == 1)
    destination = new InetSocketAddress(InetAddress.getLocalHost(), 5064);
else if (number == 2)
    destination = new InetSocketAddress(InetAddress.getLocalHost(), 5065);
else if (number == 3)
    destination = new InetSocketAddress(InetAddress.getLocalHost(), 5066);
counter++;

 In addition to that, I changed the highest watermark to 100.

In main(), I tried the following code.

    for (int i = 0; i < 20; i++){
        DatagramPacket packet = new DatagramPacket(data, 0, data.length, local,5060);
        socket.send(packet);
        Thread.sleep(1 * 1000);
        socket.send(packet);
        Thread.sleep(1 * 1000);
        socket.send(packet);
        Thread.sleep(1 * 1000);
    }

The result is as follows.

[root_at_rx200-3 ~]# netstat -a -u
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
udp 0 0 *:2727 *:*
udp 0 0 *:4520 *:*
udp 0 0 *:836 *:*
udp 0 0 *:839 *:*
udp 0 0 *:5065 *:*
udp 0 0 *:4569 *:*
udp 0 0 *:sunrpc *:*
udp 0 0 *:ipp *:*
udp 0 0 rx200-3:ntp *:*
udp 0 0 localhost.localdomain:ntp *:*
udp 0 0 *:ntp *:*
udp 0 0 rx200-3:32806 rx200-3:5063 ESTABLISHED
udp 0 0 rx200-3:32809 rx200-3:5064 ESTABLISHED
udp 0 0 rx200-3:32810 rx200-3:5065 ESTABLISHED
udp 0 0 rx200-3:32811 rx200-3:5066 ESTABLISHED
udp 0 0 *:5060 *:*
udp 0 0 *:5062 *:*
udp 0 0 *:ntp *:*


The aboeve is exactly the same as what I expected. Then, I removed
'Thread.sleep' from main(), as follows.

    for (int i = 0; i < 20; i++){
        DatagramPacket packet = new DatagramPacket(data, 0, data.length, local,5060);
        socket.send(packet);
        socket.send(packet);
        socket.send(packet);
    }

The result is below.

[root_at_rx200-3 ~]# netstat -a -u
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
udp 0 0 *:2727 *:*
udp 0 0 *:4520 *:*
udp 0 0 *:836 *:*
udp 0 0 *:839 *:*
udp 0 0 *:5065 *:*
udp 0 0 *:4569 *:*
udp 0 0 *:sunrpc *:*
udp 0 0 *:ipp *:*
udp 0 0 rx200-3:ntp *:*
udp 0 0 localhost.localdomain:ntp *:*
udp 0 0 *:ntp *:*
udp 0 0 *:5060 *:*
udp 0 0 *:5062 *:*
udp 0 0 *:ntp *:*

I do not know why, but there is no connection to port 5063, 5064, 5065 and 5066.
I am wondering why two results are different. I thought that two results should be same.


Minoru

> Hi Minoru,
>
> please try this fix in your code to check if it works:
>
> try {
> connectorHandler.write(buffer, false);
> } catch (Exception e) {
> } finally {
> /*FIX ---> */ connectorHandler.close();
> }
>
>
> Thanks.
>
> WBR,
> Alexey.
>
>