Bug 52777 - Automatically shut down old versions in parallel deployment
Summary: Automatically shut down old versions in parallel deployment
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Catalina (show other bugs)
Version: trunk
Hardware: All All
: P2 enhancement with 1 vote (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-27 03:30 UTC by Ari Maniatis
Modified: 2012-09-08 21:12 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ari Maniatis 2012-02-27 03:30:27 UTC
Under parallel deployment, when an older version in an application has zero sessions, shut it down automatically to release tomcat and JVM resources.

Christopher Schultz suggested these approaches might be possible (on the Tomcat user list):

1. Modify the parallel deployment code to register an MBean
NotificationListener that filters for useful events (such as expiring
session notifications on the outgoing webapp).

2. When the listener receives a notification, check the current state
(e.g. session count=0; or, I suppose you could make this a part of
your filter in step #1). If session count = 0, start a new thread that
stops the outgoing webapp and de-registers the listener.

Or.

1. Install a SessionEventListener that counts-down the sessions
(you'll have to get the count from JMX, I suppose) until they equal 0,
then starts a new thread that ... etc.

Or.

1. Install a Timer thread that polls at intervals (1 minute?) to see
if all the sessions are dead and then starts a thread ... etc.

The first idea seems the cleanest, though Tomcat might not actually
fire MBean events for things like session count changing.
Comment 1 Mark Thomas 2012-03-20 22:02:02 UTC
A variation of the last approach would be to get the auto deployment code to check the current session count for old context versions and undeploy them once the count is zero.
Comment 2 Mark Thomas 2012-09-08 21:12:42 UTC
This has been implemented in trunk and 7.0.x and will be included in 7.0.31 onwards. It is optional and controlled by a new attribute (undeployOldVersions) on the Host.