Hi
Poking around a bit more on the list I found that you can use the
returned WriteFuture to wait for the buffer to be sent.
On another matter (still...)
My application sends multiple objects across the wire (in binary
format using DataInput/DataOutput) on the server side I implemented my
version of StreamIOHandler you can seen at the end of the email.
Now my problem is that my object (t) is always the same object even
though I'm sure the clients are writing new objects to the buffer.
I think the calls on the read() methods of the inputstream are not
making the buffer progress.
Any ideas?
Regards
David Alves
private static class DataIoHandler extends StreamIoHandler {
private static class Reader implements Runnable {
private InputStream stream;
DataInputStream input;
private IoSession session;
/**
* @param in2
* @param session
*/
public Reader(InputStream stream, IoSession session) {
this.stream = stream;
input = new DataInputStream(this.stream);
this.session = session;
}
/*
* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
while (session.isConnected() &&
!session.isClosing()) {
Tuple t = new Tuple();
try {
t.readFields(input);
LOG.info(t);
serverCounter.getAndIncrement();
if (serverCounter.get() % 10000
== 0) {
LOG.info("Response Time: " + (System.currentTimeMillis() -
t.getEmissionTime()));
}
} catch (IOException e) {
LOG.error("Error input
server.", e);
break;
}
}
}
}
private static Log LOG = LogFactory.getLog(DataIoHandler.class);
/*
* (non-Javadoc)
* @see
org
.apache
.mina
.handler
.stream
.StreamIoHandler#processStreamIo(org.apache.mina.core.session.IoSession,
* java.io.InputStream, java.io.OutputStream)
*/
@Override
protected void processStreamIo(IoSession session, InputStream in,
OutputStream out) {
LOG.info("Started new Reader Thread" + in);
new Thread(new Reader(in, session)).start();
}
}
On Feb 10, 2009, at 1:04 PM, Ashish wrote:
On Tue, Feb 10, 2009 at 6:23 PM, David Alves <[email protected]> wrote:
Hi
Thanks for the pointer ashish, 3x performance increase seams
like a
bliss :)
Regarding another mater...
Can the client flush on-demand, emptying the client buffer?
I tried bufferedwriterfilter adding it to the last of the
filter
chain but for some reason the fw simply stopped sending messages.
Anyhow it
would be great if I could flush based on the business logic. Is this
possible?
I am afraid I don't have answer right now. Will explore further and
let you know.
Can Anyone help us out here??