From: Stefan R. <sr...@ap...> - 2003-06-30 17:31:07
|
Just a reminder: increment/decrement operations are NOT atomic. Read and write operations on 32-Bit types are. Since we are dealing with statistics, I think we can live with the "lost update" problem, but these values should be declared volatile to ensure that other threads can observe the increment. On Sonntag, Juni 29, 2003, at 07:08 Uhr, jbo...@li... wrote: > > Index: EmbeddedCatalinaService41.java > =================================================================== > RCS file: > /cvsroot/jboss/contrib/tomcat41/src/main/org/jboss/web/catalina/ > EmbeddedCatalinaService41.java,v > retrieving revision 1.4.2.11 > retrieving revision 1.4.2.12 > diff -u -r1.4.2.11 -r1.4.2.12 > --- EmbeddedCatalinaService41.java 29 Jun 2003 04:57:32 > -0000 1.4.2.11 > +++ EmbeddedCatalinaService41.java 29 Jun 2003 10:48:23 > -0000 1.4.2.12 > @@ -46,14 +46,14 @@ > import org.apache.catalina.core.StandardWrapper; > import org.apache.catalina.startup.Embedded; > > +import org.jboss.web.catalina.mbean.ServletInfo; > import org.jboss.web.catalina.session.ClusterManager; > -import > org.jboss.web.catalina.session.ClusteringNotSupportedException; > import org.jboss.web.catalina.session.ClusteredSessionValve; > +import > org.jboss.web.catalina.session.ClusteringNotSupportedException; > import org.jboss.web.catalina.session.InstantSnapshotManager; > import org.jboss.web.catalina.session.IntervalSnapshotManager; > import org.jboss.web.catalina.session.SnapshotManager; > -import org.jboss.web.catalina.mbean.ServletInfo; > -import org.jboss.web.catalina.mbean.StatsValve; > +import org.jboss.web.catalina.statistics.ContainerStatsValve; > > > /** An implementation of the AbstractWebContainer for the Jakarta > Tomcat > @@ -66,7 +66,7 @@ > @see org.apache.catalina.startup.Embedded > > @author Sco...@jb... > - @version $Revision: 1.4.2.11 $ > + @version $Revision: 1.4.2.12 $ > */ > public class EmbeddedCatalinaService41 extends AbstractWebContainer > implements EmbeddedCatalinaService41MBean > @@ -101,6 +101,12 @@ > /** With IntervalSnapshotManager use this interval (in ms) for > snapshotting */ > private int snapshotInterval = 1000; > > + /** The active thread count */ > + private int activeThreadCount = 0; > + > + /** The maximal active thread count since start of container */ > + private int maxActiveThreadCount = 0; > + > public EmbeddedCatalinaService41() > { > } > @@ -196,6 +202,35 @@ > this.extendedConfig = config; > } > > + /** Get the active thread count */ > + public int getActiveThreadCount() > + { > + return this.activeThreadCount; > + } > + > + /** Get the maximal active thread count */ > + public int getMaxActiveThreadCount() > + { > + return this.maxActiveThreadCount; > + } > + > + /** Increment active thread count. Maybe this must be > synchronized, but the increment-operator is atomic. */ > + public void incActiveThreadCount() > + { > + this.activeThreadCount++; > + > + if (this.activeThreadCount>this.maxActiveThreadCount) > + { > + this.maxActiveThreadCount=this.activeThreadCount; > + } > + } > + > + /** Decrement active thread count. Maybe this must be > synchronized, but the decrement-operator is atomic. */ > + public void decActiveThreadCount() > + { > + this.activeThreadCount--; > + } > + > public void startService() throws Exception > { > // Start create the embeded catalina container but don't let > it overwrite the thread class loader > @@ -433,6 +468,11 @@ > log.error("Failed to setup clustering, clustering > disabled"); > } > } > + > + // Add the statistics valve to the context > + ContainerStatsValve valve=new ContainerStatsValve(this); > + valve.setContainer(context); > + context.addValve(valve); > > /* We need to establish the JNDI ENC prior to the start of > the web container > so that init on startup servlets are able to interact with > their ENC. We > |