Why is there is one selector per SocketConnector?
Could it be reused system wide?

On Tue, May 20, 2008 at 9:19 AM, 이희승 (Trustin Lee) <[EMAIL PROTECTED]> wrote:
> Please provide a working test application, instead of partial code.
>
> On Mon, 19 May 2008 22:43:46 +0900, Michael Qi <[EMAIL PROTECTED]>
> wrote:
>
>> Hi,
>>   I am using mina 1.1.7 and try to simulate many client to a server
>> for stress test.
>>
>> and I make 50 clientSessoins, each has a SocketConnector, and the
>> ClientSession.start()  is :
>> private static ThreadPoolExecutor exService = new ThreadPoolExecutor(20,
>>                        40, 60L, TimeUnit.SECONDS, new
>> ArrayBlockingQueue<Runnable>(30),
>>                        new ThreadPoolExecutor.DiscardPolicy());
>>
>> public void start() {
>>                connector = new SocketConnector(4, exService);
>>                SocketConnectorConfig scfg = connector.getDefaultConfig();
>>                scfg.setThreadModel(ThreadModel.MANUAL);
>>                scfg.setConnectTimeout(15);
>>                scfg.getFilterChain().addFirst("mmog_protocol_filter",
>>                                new ProtocolCodecFilter(new
>> MMOGCodecFactory()));
>>                ConnectFuture cf = connector.connect(address, new
>> ClientHandler());
>>                cf.join();
>>
>>                if (cf.isConnected()) {
>>                        session = cf.getSession();
>>                } else {
>>                        log.error("could not connect cm");
>>                        return;
>>                }
>>
>>                Message m = null;
>>                m = new Message();
>>                m.setCommand(Message.LOGIN);
>>
>>                byte[] body = new byte[16];
>>                byte[] tmp = Util.intToByteArray(streamId);
>>                int p = 0, q = 0;
>>                for (q = 0; q < 4; p++, q++) {
>>                        body[p] = tmp[q];
>>                }
>>                tmp = Util.floatToByteArray(x);
>>                for (q = 0; q < 4; p++, q++) {
>>                        body[p] = tmp[q];
>>                }
>>
>>                tmp = Util.floatToByteArray(y);
>>                for (q = 0; q < 4; p++, q++) {
>>                        body[p] = tmp[q];
>>                }
>>
>>                tmp = Util.floatToByteArray(0);
>>                for (q = 0; q < 4; p++, q++) {
>>                        body[p] = tmp[q];
>>                }
>>                m.setBody(body);
>>
>>                WriteFuture wf = session.write(m);
>>                wf.join();
>>        }
>>
>>
>> The problem is:  I new 50 ClientSession and call start one by one :
>> for (ClientSession cs : sessions) {
>>                        cs.start();
>>                        log.debug("start id = " + s);
>>                        s++;
>> }
>>
>> and the log said :
>> 08 May 19 21:31:44,645 [main] DEBUG
>> com.qihe.study.ClientTest.main(ClientTest.java:107)
>> com.qihe.study.ClientTest  - start id = 0
>> 08 May 19 21:31:44,648 [main] DEBUG
>> com.qihe.study.ClientTest.main(ClientTest.java:107)
>> com.qihe.study.ClientTest  - start id = 1
>> 08 May 19 21:31:44,650 [main] DEBUG
>> com.qihe.study.ClientTest.main(ClientTest.java:107)
>> com.qihe.study.ClientTest  - start id = 2
>> 08 May 19 21:31:44,653 [main] DEBUG
>> com.qihe.study.ClientTest.main(ClientTest.java:107)
>> com.qihe.study.ClientTest  - start id = 3
>> 08 May 19 21:31:44,656 [main] DEBUG
>> com.qihe.study.ClientTest.main(ClientTest.java:107)
>> com.qihe.study.ClientTest  - start id = 4
>> 08 May 19 21:31:44,658 [main] DEBUG
>> com.qihe.study.ClientTest.main(ClientTest.java:107)
>> com.qihe.study.ClientTest  - start id = 5
>> 08 May 19 21:31:44,660 [main] DEBUG
>> com.qihe.study.ClientTest.main(ClientTest.java:107)
>> com.qihe.study.ClientTest  - start id = 6
>> 08 May 19 21:31:44,666 [main] DEBUG
>> com.qihe.study.ClientTest.main(ClientTest.java:107)
>> com.qihe.study.ClientTest  - start id = 7
>> 08 May 19 21:31:44,668 [main] DEBUG
>> com.qihe.study.ClientTest.main(ClientTest.java:107)
>> com.qihe.study.ClientTest  - start id = 8
>> 08 May 19 21:31:44,670 [main] DEBUG
>> com.qihe.study.ClientTest.main(ClientTest.java:107)
>> com.qihe.study.ClientTest  - start id = 9
>> 08 May 19 21:32:44,640 [main] ERROR
>> com.qihe.study.ClientSession.start(ClientSession.java:64)
>> com.qihe.study.ClientSession  - could not connect server
>> 08 May 19 21:32:44,640 [main] DEBUG
>> com.qihe.study.ClientTest.main(ClientTest.java:107)
>> com.qihe.study.ClientTest  - start id = 10
>> 08 May 19 21:32:44,655 [main] DEBUG
>> com.qihe.study.ClientTest.main(ClientTest.java:107)
>> com.qihe.study.ClientTest  - start id = 11
>> 08 May 19 21:32:44,640 [main] DEBUG
>> com.qihe.study.ClientTest.main(ClientTest.java:107)
>> com.qihe.study.ClientTest  - start id = 10
>> 08 May 19 21:32:44,655 [main] DEBUG
>> com.qihe.study.ClientTest.main(ClientTest.java:107)
>> com.qihe.study.ClientTest  - start id = 11
>> 08 May 19 21:32:44,660 [main] DEBUG
>> com.qihe.study.ClientTest.main(ClientTest.java:107)
>> com.qihe.study.ClientTest  - start id = 12
>> 08 May 19 21:32:44,664 [main] DEBUG
>> com.qihe.study.ClientTest.main(ClientTest.java:107)
>> com.qihe.study.ClientTest  - start id = 13
>> 08 May 19 21:32:44,672 [main] DEBUG
>> com.qihe.study.ClientTest.main(ClientTest.java:107)
>> com.qihe.study.ClientTest  - start id = 14
>>
>>
>> and then it hang!
>> after "start id = 9" it hanged too! After a while it said could not
>> connect to server
>>
>> Why this? Could you please tell me?
>>
>> Thank you.
>>
>>
>>  Regards
>>
>> QiHe
>
>
>
> --
> Trustin Lee - Principal Software Engineer, JBoss, Red Hat
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
>

Reply via email to