2008/9/4 JianXing Yi <[EMAIL PROTECTED]>

>
>
> 2008/9/4 Tuure Laurinolli <[EMAIL PROTECTED]>
>
>> JianXing Yi wrote:
>>
>>> 2008/9/4 Tuure Laurinolli <[EMAIL PROTECTED]>
>>>
>>>  JianXing Yi wrote:
>>>>
>>>>  Also, I print state info in SESSION_IDLE event handling every 2
>>>>> seconds,
>>>>> all
>>>>> sessions are in a same state (STATE_A). My statemachine expects a
>>>>> MESSAGE_SENT event to trigger it transit from STATE_A to STATE_B, it is
>>>>> obvious that the session receives no MESSAGE_SENT events any more.
>>>>>
>>>>>  What generates MESSAGE_SENT events? I.e. what doesn't happen (since no
>>>> events are generated)?
>>>>
>>> >
>>
>>> MESSAGE_SENT event generated by my sending out a message.
>>>
>>
>> How? Show some code.
>>
> @IoHandlerTransition(in = STATE_GETTING, on = MESSAGE_RECEIVED, next =
> STATE_RESULT_GOT)
>     public void resultGot(IoSession session, CWTPPDU pdu) {
>             if (pdu.getPDUType() == 2) {
>                 CWTPResult res = (CWTPResult) pdu;
>                 if (!pdu.getTTR()) {
>                     segData = new ByteArrayOutputStream(65536);
>                     try {
>                         segData.write(res.getPayload());
>                         seglast = (short) 0;
>                         StateControl.breakAndGotoNext("state_getting");
>                     } catch (IOException e) {
>                         e.printStackTrace();
>                     }
>                     return;
>                 }
>             }
>
>         if (pdu.getPDUType() == 6) {
>             CWTPSegmResult segResult = (CWTPSegmResult) pdu;
>             if (seglast + 1 == segResult.getPSN())
>                 seglast = segResult.getPSN();
>             if (!segResult.getTTR())
>                 StateControl.breakAndGotoNext("state_getting");
>             else {
>                 CWTPAck ack = new CWTPAck(pdu.getTID() & 0x7fff);
>                 byte[] payload = new byte[2];
>                 payload[0] = (byte) 25;
>                 payload[1] = (byte) (0x7f & segResult.getPSN());
>                 ack.setCON(true);
>                 ack.setPayload(payload);
>
> session.write(ack);---------------------------------------------------------------->MESSAGE_SENT
> generate here
>             }
>         }
>     }
>
>     @IoHandlerTransition(in = STATE_RESULT_GOT, on = MESSAGE_SENT, next =
> STATE_GETTING)
>     public void abort(IoSession session, CWTPPDU pdu) {
>         if (WapGetterContext.numWspSession.get() * 100 / 5000 < 90) {
>             try {
>                 Thread.sleep(5L);
>             } catch (InterruptedException e) {
>                 e.printStackTrace();
>             }
>         }
>
>         CWSPGet pdu2 = null;
>
> //        if (new Random().nextInt() % 2 == 0) {
>             pdu2 = new CWSPGet("
> http://10.56.135.64/wap-pete/T2000/2kb/index.wml";);
> //        } else {
> //            pdu2 = new CWSPGet("
> http://10.56.135.68/wap-pete/T2000/10kb_LG/10k_2.wml";);
> //        }
>         CWTPEvent wtpEvent = new CWTPEvent(pdu2.toByteArray(), (byte) 0);
>         CWTPInvoke send = new CWTPInvoke(wtpEvent.getUserData(),
>                 tid = generateNewTID(), (byte) 2);
>         session.write(send);
>     }
>
>
>>
>>  Also, have you tried with a different number of sessions? Start with one
>>>> and find out if the behabior is the same.
>>>>
>>> >
>>
>>> I've tried with a different number of sessions, for example 1000
>>> sessions,
>>> and I've not found this behavior yet.
>>>
>>
>> Hmm, interesting.
>
> Sorry for the mistake. For StateMachine case, it will always drop to 0
session. I tried to implement it based on IoHandler and have not found this
behavior for less than 3~4000 sessions yet.

Reply via email to