You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@mina.apache.org by Wenrui Guo <we...@ericsson.com> on 2008/07/23 15:16:51 UTC
RE: BufferedData continue to grow up -
The following two encoder classes are taking the role to transform
messages.
public class PDUWrapEncoder<T> implements MessageEncoder<T> {
public void encode(IoSession session, T message,
ProtocolEncoderOutput out)
throws Exception {
PDU pdu = (PDU) message;
out.write(IoBuffer.wrap(pdu.getData().getBuffer()));
}
}
public class ForwardMsgEncoder<T> implements MessageEncoder<T> {
public void encode(IoSession session, T message,
ProtocolEncoderOutput out)
throws Exception {
}
}
I already debugged the application under light workload, it seems ok.
But as long as I apply more than one thousand messages to the
application, it always throws the exception of dataLength.
I think maybe some mistaken inside my source code. Is there anybody can
help to figure it out?
BR
anderson
RE: BufferedData continue to grow up -
Posted by Wenrui Guo <we...@ericsson.com>.
As you mentioned, The IoBuffer will continue to grow up until it exhausts all memory of JVM?
Or how can I clear the buffer without affecting the normal execution of mina-core?
BR
anderson
-----Original Message-----
From: Emmanuel Lecharny [mailto:elecharny@gmail.com]
Sent: Wednesday, July 23, 2008 10:55 PM
To: users@mina.apache.org
Subject: Re: BufferedData continue to grow up -
Wenrui Guo wrote:
> I already locate the position where exception occurs. It seems like
> when MINA receive a network packet which is longer than one message
> size, it maybe move to not the start of a new message, instead, I
> notice it is placed at the last byte of last message.
>
The buffer is auto-growing, allowing many PDU parts to be added to the buffer until the codec get it.
As soon as you have dealt with the buffer, you can clear it, otherwise it will continue to grow, IFAIK.
--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org
Re: BufferedData continue to grow up -
Posted by Emmanuel Lecharny <el...@gmail.com>.
Wenrui Guo wrote:
> I already locate the position where exception occurs. It seems like when
> MINA receive a network packet which is longer than one message size, it
> maybe move to not the start of a new message, instead, I notice it is
> placed at the last byte of last message.
>
The buffer is auto-growing, allowing many PDU parts to be added to the
buffer until the codec get it.
As soon as you have dealt with the buffer, you can clear it, otherwise
it will continue to grow, IFAIK.
--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org
Re: BufferedData continue to grow up -
Posted by Oscar <ro...@gmail.com>.
On Wed, Jul 23, 2008 at 10:00 PM, Wenrui Guo <we...@ericsson.com>
wrote:
> I already locate the position where exception occurs. It seems like when
> MINA receive a network packet which is longer than one message size, it
> maybe move to not the start of a new message, instead, I notice it is
> placed at the last byte of last message.
Which parts of MINA to hande it? ( I mean, the class or the function)
>
> I don't know why this happened? Did I violate basic rules defined by
> MINA?
>
> BR
> anderson
>
> -----Original Message-----
> From: Wenrui Guo [mailto:wenrui.guo@ericsson.com]
> Sent: Wednesday, July 23, 2008 9:39 PM
> To: users@mina.apache.org
> Subject: RE: BufferedData continue to grow up -
>
> The Util class looks like this:
>
> public class Util {
>
> private Util() {
> }
>
> public static boolean prefixedDataAvailable(IoBuffer in, int
> prefixLength,
> int maxLength) {
> if (in.remaining() < prefixLength)
> return false;
>
> int dataLength;
>
> switch (prefixLength) {
> case 1:
> dataLength = in.getUnsigned(in.position());
> break;
> case 2:
> dataLength = in.getUnsignedShort(in.position());
> break;
> case 4:
> dataLength = in.getInt(in.position());
> break;
> default:
> throw new
> IllegalArgumentException("prefixLength: " + prefixLength);
> }
>
> if (dataLength < 0 || dataLength > maxLength) {
> throw new BufferDataException("dataLength: " +
> dataLength);
> }
> return in.remaining() >= dataLength;
> }
>
> BR
> -----Original Message-----
> From: Wenrui Guo [mailto:wenrui.guo@ericsson.com]
> Sent: Wednesday, July 23, 2008 9:17 PM
> To: users@mina.apache.org
> Subject: RE: BufferedData continue to grow up -
>
> The following two encoder classes are taking the role to transform
> messages.
>
> public class PDUWrapEncoder<T> implements MessageEncoder<T> {
>
>
> public void encode(IoSession session, T message,
> ProtocolEncoderOutput out)
> throws Exception {
> PDU pdu = (PDU) message;
> out.write(IoBuffer.wrap(pdu.getData().getBuffer()));
> }
>
> }
>
> public class ForwardMsgEncoder<T> implements MessageEncoder<T> {
>
> public void encode(IoSession session, T message,
> ProtocolEncoderOutput out)
> throws Exception {
> }
> }
>
> I already debugged the application under light workload, it seems ok.
> But as long as I apply more than one thousand messages to the
> application, it always throws the exception of dataLength.
>
> I think maybe some mistaken inside my source code. Is there anybody can
> help to figure it out?
>
> BR
> anderson
>
RE: BufferedData continue to grow up -
Posted by Wenrui Guo <we...@ericsson.com>.
I already locate the position where exception occurs. It seems like when
MINA receive a network packet which is longer than one message size, it
maybe move to not the start of a new message, instead, I notice it is
placed at the last byte of last message.
I don't know why this happened? Did I violate basic rules defined by
MINA?
BR
anderson
-----Original Message-----
From: Wenrui Guo [mailto:wenrui.guo@ericsson.com]
Sent: Wednesday, July 23, 2008 9:39 PM
To: users@mina.apache.org
Subject: RE: BufferedData continue to grow up -
The Util class looks like this:
public class Util {
private Util() {
}
public static boolean prefixedDataAvailable(IoBuffer in, int
prefixLength,
int maxLength) {
if (in.remaining() < prefixLength)
return false;
int dataLength;
switch (prefixLength) {
case 1:
dataLength = in.getUnsigned(in.position());
break;
case 2:
dataLength = in.getUnsignedShort(in.position());
break;
case 4:
dataLength = in.getInt(in.position());
break;
default:
throw new
IllegalArgumentException("prefixLength: " + prefixLength);
}
if (dataLength < 0 || dataLength > maxLength) {
throw new BufferDataException("dataLength: " +
dataLength);
}
return in.remaining() >= dataLength;
}
BR
-----Original Message-----
From: Wenrui Guo [mailto:wenrui.guo@ericsson.com]
Sent: Wednesday, July 23, 2008 9:17 PM
To: users@mina.apache.org
Subject: RE: BufferedData continue to grow up -
The following two encoder classes are taking the role to transform
messages.
public class PDUWrapEncoder<T> implements MessageEncoder<T> {
public void encode(IoSession session, T message,
ProtocolEncoderOutput out)
throws Exception {
PDU pdu = (PDU) message;
out.write(IoBuffer.wrap(pdu.getData().getBuffer()));
}
}
public class ForwardMsgEncoder<T> implements MessageEncoder<T> {
public void encode(IoSession session, T message,
ProtocolEncoderOutput out)
throws Exception {
}
}
I already debugged the application under light workload, it seems ok.
But as long as I apply more than one thousand messages to the
application, it always throws the exception of dataLength.
I think maybe some mistaken inside my source code. Is there anybody can
help to figure it out?
BR
anderson
RE: BufferedData continue to grow up -
Posted by Wenrui Guo <we...@ericsson.com>.
The Util class looks like this:
public class Util {
private Util() {
}
public static boolean prefixedDataAvailable(IoBuffer in, int
prefixLength,
int maxLength) {
if (in.remaining() < prefixLength)
return false;
int dataLength;
switch (prefixLength) {
case 1:
dataLength = in.getUnsigned(in.position());
break;
case 2:
dataLength = in.getUnsignedShort(in.position());
break;
case 4:
dataLength = in.getInt(in.position());
break;
default:
throw new
IllegalArgumentException("prefixLength: " + prefixLength);
}
if (dataLength < 0 || dataLength > maxLength) {
throw new BufferDataException("dataLength: " +
dataLength);
}
return in.remaining() >= dataLength;
}
BR
-----Original Message-----
From: Wenrui Guo [mailto:wenrui.guo@ericsson.com]
Sent: Wednesday, July 23, 2008 9:17 PM
To: users@mina.apache.org
Subject: RE: BufferedData continue to grow up -
The following two encoder classes are taking the role to transform
messages.
public class PDUWrapEncoder<T> implements MessageEncoder<T> {
public void encode(IoSession session, T message,
ProtocolEncoderOutput out)
throws Exception {
PDU pdu = (PDU) message;
out.write(IoBuffer.wrap(pdu.getData().getBuffer()));
}
}
public class ForwardMsgEncoder<T> implements MessageEncoder<T> {
public void encode(IoSession session, T message,
ProtocolEncoderOutput out)
throws Exception {
}
}
I already debugged the application under light workload, it seems ok.
But as long as I apply more than one thousand messages to the
application, it always throws the exception of dataLength.
I think maybe some mistaken inside my source code. Is there anybody can
help to figure it out?
BR
anderson