tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thom Park <>
Subject RE: do callbacks to engine exist?
Date Thu, 02 Aug 2001 16:10:45 GMT
You could try adding a <defaultContext> entry at the engine level
which contains an <InstanceListener>.

In the InstanceListener, you could then trap the "before" service event
followed by the "after" service event.

The delta between those two times should be how long the container
spent 'executing' the service.



If you just wanted to monitor one specific webapp, just add the
<InstanceListener> at the
<Context> level.

In the instance listener you'd do something like this:

in the instanceEvent method, you could determine which event you were
interested in,

  public void instanceEvent(InstanceEvent event) {
    String eventType = event.getType();
	if ( eventType.compareIgnoreCase("beforeService") == 0 ) {
		// start counter
	if ( eventType.compareIgnoreCase("afterService") == 0 ) {
		// stop counter
	// then process the result

note you'd have to track the servlet name, and app being used - all
available from the servlet wrapper and
context. I use the current (convenient) fact that the same thread that the
before event occurs on is hte same
thread as the after event. That way I can use thread local storage to keep
track of the relevent information
pertaining to the servlet.


-----Original Message-----
From: Grobe, Gary []
Sent: Wednesday, August 01, 2001 2:24 PM
To: ''
Subject: do callbacks to engine exist?

After reading the Tomcat architecure docs, I have a question.

Is there anyway to call the invoke method of a container from the webserver
whenever needed. i.e. If I wanted to get the time it takes for the web
server to process a request, could the server engine be invoke()'d to
startTime and when the webserver finished handling the request, is there
some way it could be invoked again to stopTime so that I'd know how long it

I know that in order for the servlet to do this it must handle the request
and I could get the times from the response and then the request, but I'm
looking to see if I can *monitor* (if that's the right word) the web servers
performance or it's requests in some way. Maybe someway to make callbacks to
the webserver?

My reason for wanting apache to handle the requests is because of sites that
have very large connection loads that our clients/or Tomcat will not accept
performace wise. If this part doesn't make sense, please ignore as their are
other reasons also.

View raw message