tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thom Park <tp...@borland.com>
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.

e.g:

<Engine.....>
	<DefaultContext>
  		<InstanceListener>
    			org.myco.listener
  		</InstanceListener>
	</DefaultContext>
</Engine>

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,

e.g:
  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.

-Thom

-----Original Message-----
From: Grobe, Gary [mailto:Gary_Grobe@bmc.com]
Sent: Wednesday, August 01, 2001 2:24 PM
To: 'tomcat-user@jakarta.apache.org'
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
took?

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.



Mime
View raw message