Hi,

I had the same problems. It was a synchronization issue with me. What I did was make a synchronized output stream wrapper (see attached file) which wraps all access to the output stream, and I synchronized on this output stream whenever I called event.close() on the Comet event (especially in the READ event). When doing serveral IO operations on the output stream which should not be interrupted, you can simply synchronize on it (since SynchronizedOutputStream locks on itself).

Regards,
Sebastiaan


Martin Perez wrote:
Hi all,

I have been testing Tomcat comet support during the last days. I've created
a test application that simulates data streaming to multiple clients.
Clients open a connection to the server and the connection is hold open. In the server there are several "sender" threads that leverage comet support to
periodically send stream updates to the subscribed clients. Once a client
receives a specified amount of data the communication is closed.

So, I'm running the test with tomcat svn version from 1 week ago. I have
configured 150 tomcat threads, plus 25 acceptor threads. Tomcat runs in a
Sun-Fire-V240 box with 2 CPU cores. I have 75 sender threads that
periodically sleep (100ms) to try to reduce the CPU usage. Once a sender
thread wakes up, it will send all the data to the assigned clients.

So basically the story is that the box is able to manage about 3500
persistent comet connections smoothly. But when I raise the level to 4000
(80% CPU usage, 1.2G mem.) I start to get these exceptions for some (not
all) connections:

Exception in thread "MessageSender[]" java.lang.NullPointerException
       at org.apache.coyote.http11.InternalNioOutputBuffer.addToBB(
InternalNioOutputBuffer.java:607)
       at org.apache.coyote.http11.InternalNioOutputBuffer.commit(
InternalNioOutputBuffer.java:600)
       at org.apache.coyote.http11.Http11NioProcessor.action(
Http11NioProcessor.java:1032)
       at org.apache.coyote.Response.action(Response.java:181)
       at org.apache.coyote.http11.InternalNioOutputBuffer.doWrite(
InternalNioOutputBuffer.java:571)
       at org.apache.coyote.Response.doWrite(Response.java:560)
       at org.apache.catalina.connector.OutputBuffer.realWriteBytes(
OutputBuffer.java:353)
       at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java
:434)
       at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:349)
       at org.apache.catalina.connector.OutputBuffer.writeBytes(
OutputBuffer.java:381)
       at org.apache.catalina.connector.OutputBuffer.write(
OutputBuffer.java:370)
       at org.apache.catalina.connector.CoyoteOutputStream.write(
CoyoteOutputStream.java:89)
       at org.apache.catalina.connector.CoyoteOutputStream.write(
CoyoteOutputStream.java:83)
       at com.cognotec.streaming.CometRateSender.run(CometRateSender.java
:86)
       at java.lang.Thread.run(Thread.java:595)

So well, does anybody knows what can be the problem? Any suggestions? It can
be also my problem, so I will be happy to provide more information.

Cheers,
Martin

package com.sebster.tunnel.util.io;

import java.io.IOException;
import java.io.OutputStream;

/**
 * This output stream simply wraps another output stream and synchronizes access
 * to the underlying output stream. The synchronization is done on the instance
 * of this class.
 * 
 * @author sebster
 */
public class SynchronizedOutputStream extends OutputStream {

	private final OutputStream out;

	public SynchronizedOutputStream(final OutputStream out) {
		if (out == null) {
			throw new NullPointerException("out"); //$NON-NLS-1$
		}
		this.out = out;
	}

	public synchronized void write(final byte[] b) throws IOException {
		out.write(b);
	}

	public synchronized void write(final byte[] b, final int off, final int len) throws IOException {
		out.write(b, off, len);
	}

	public synchronized void write(final int b) throws IOException {
		out.write(b);
	}

	public synchronized void flush() throws IOException {
		out.flush();
	}

	public synchronized void close() throws IOException {
		out.close();
	}

}

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to