cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2004-12-10 Thread billbarker
billbarker2004/12/10 19:52:56

  Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  We need to set the local copies, otherwise the thread counts get wacked.
  
  This mostly effects the TC 3.3 legacy Connectors.  It is almost impossible 
for the Coyote Connectors to throw out of 'runIt'.
  
  Revision  ChangesPath
  1.30  +2 -2  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- ThreadPool.java   12 Oct 2004 08:03:33 -  1.29
  +++ ThreadPool.java   11 Dec 2004 03:52:56 -  1.30
  @@ -699,8 +699,8 @@
   * The meaning is that we should release the 
thread from
   * the pool.
   */
  -shouldTerminate = true;
  -shouldRun = false;
  +_shouldTerminate = true;
  +_shouldRun = false;
   p.notifyThreadEnd(this);
   } finally {
   if (_shouldRun) {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2004-10-12 Thread remm
remm2004/10/12 01:03:33

  Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  - Use the interval field (bug 31663).
  
  Revision  ChangesPath
  1.29  +1 -1  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- ThreadPool.java   30 Aug 2004 19:24:02 -  1.28
  +++ ThreadPool.java   12 Oct 2004 08:03:33 -  1.29
  @@ -556,7 +556,7 @@
   
   // Sleep for a while.
   synchronized(this) {
  -this.wait(WORK_WAIT_TIMEOUT);
  +this.wait(interval);
   }
   
   // Check if should terminate.
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2004-10-12 Thread Yoshinori$B!!(BAshizawa
[EMAIL PROTECTED] wrote:
(B remm2004/10/12 01:03:33
(B 
(B   Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
(B   Log:
(B   - Use the interval field (bug 31663).
(B   
(B   Revision  ChangesPath
(B   1.29  +1 -1  
(B jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
(B   
(B   Index: ThreadPool.java
(B   ===
(B   RCS file: 
(B /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
(B   retrieving revision 1.28
(B   retrieving revision 1.29
(B   diff -u -r1.28 -r1.29
(B   --- ThreadPool.java 30 Aug 2004 19:24:02 -  1.28
(B   +++ ThreadPool.java 12 Oct 2004 08:03:33 -  1.29
(B   @@ -556,7 +556,7 @@
(B
(B// Sleep for a while.
(Bsynchronized(this) {
(B   -this.wait(WORK_WAIT_TIMEOUT);
(B   +this.wait(interval);
(B}
(B
(B// Check if should terminate.
(B   
(B   
(B   
(B 
(B -
(B To unsubscribe, e-mail: [EMAIL PROTECTED]
(B For additional commands, e-mail: [EMAIL PROTECTED]
(B 
(B 
(B
(B
(B-
(BTo unsubscribe, e-mail: [EMAIL PROTECTED]
(BFor additional commands, e-mail: [EMAIL PROTECTED]

cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2004-08-29 Thread yoavs
yoavs   2004/08/29 10:14:42

  Modified:coyote/src/java/org/apache/coyote/tomcat3
Tomcat3Adapter.java
   coyote/src/java/org/apache/coyote/tomcat4
CoyoteConnector.java CoyoteResponse.java
   jk/java/org/apache/ajp Ajp13Packet.java
   jk/java/org/apache/jk/config ApacheConfig.java
BaseJkConfig.java IISConfig.java NSConfig.java
   util/java/org/apache/tomcat/util IntrospectionUtils.java
   util/java/org/apache/tomcat/util/buf Base64.java
ByteChunk.java CharChunk.java MessageBytes.java
UEncoder.java
   util/java/org/apache/tomcat/util/compat Jdk14Compat.java
JdkCompat.java
   util/java/org/apache/tomcat/util/digester
CallMethodRule.java NodeCreateRule.java
   util/java/org/apache/tomcat/util/http/mapper Mapper.java
   util/java/org/apache/tomcat/util/net
TcpConnectionHandler.java
   util/java/org/apache/tomcat/util/net/jsse
JSSESocketFactory.java
   util/java/org/apache/tomcat/util/res StringManager.java
   util/java/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  A few JavaDoc fixes.  Many more needed ;(
  
  Revision  ChangesPath
  1.8   +2 -1  
jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3/Tomcat3Adapter.java
  
  Index: Tomcat3Adapter.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat3/Tomcat3Adapter.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Tomcat3Adapter.java   24 Feb 2004 08:54:30 -  1.7
  +++ Tomcat3Adapter.java   29 Aug 2004 17:14:41 -  1.8
  @@ -24,7 +24,8 @@
*  This class handles the task of passing of an individual request to
*  Tomcat to handle.  Also some of the connection-specific methods are
*  delegated to here.
  - *  @Author Bill Barker
  + *
  + *  @author Bill Barker
*/
   public class Tomcat3Adapter implements Adapter {
   ContextManager cm;
  
  
  
  1.35  +4 -4  
jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteConnector.java
  
  Index: CoyoteConnector.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteConnector.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- CoyoteConnector.java  24 Feb 2004 08:54:29 -  1.34
  +++ CoyoteConnector.java  29 Aug 2004 17:14:41 -  1.35
  @@ -365,7 +365,7 @@
   /**
* Set the connection linger for this Connector.
*
  - * @param count The new connection linge
  + * @param connectionLinger The new connection linger
*/
   public void setConnectionLinger(int connectionLinger) {
   
  @@ -387,7 +387,7 @@
   /**
* Set the connection timeout for this Connector.
*
  - * @param count The new connection timeout
  + * @param connectionTimeout The new connection timeout
*/
   public void setConnectionTimeout(int connectionTimeout) {
   
  @@ -431,7 +431,7 @@
   /**
* Set the server socket timeout for this Connector.
*
  - * @param connectionUploadTimeout The new server socket timeout
  + * @param serverSocketTimeout The new server socket timeout
*/
   public void setServerSocketTimeout(int serverSocketTimeout) {
   
  
  
  
  1.40  +2 -2  
jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteResponse.java
  
  Index: CoyoteResponse.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat4/CoyoteResponse.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- CoyoteResponse.java   29 Aug 2004 15:33:45 -  1.39
  +++ CoyoteResponse.java   29 Aug 2004 17:14:41 -  1.40
  @@ -129,7 +129,7 @@
   /**
* Set the Coyote response.
* 
  - * @param response The Coyote response
  + * @param coyoteResponse The Coyote response
*/
   public void setCoyoteResponse(Response coyoteResponse) {
   this.coyoteResponse = coyoteResponse;
  
  
  
  1.14  +3 -3  
jakarta-tomcat-connectors/jk/java/org/apache/ajp/Ajp13Packet.java
  
  Index: Ajp13Packet.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/ajp/Ajp13Packet.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- 

cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2004-05-27 Thread yoavs
yoavs   2004/05/27 09:12:54

  Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  Added support for threadPriority attribute 
(http://nagoya.apache.org/bugzilla/show_bug.cgi?id=28914).
  
  Revision  ChangesPath
  1.25  +50 -12
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- ThreadPool.java   8 Mar 2004 14:48:28 -   1.24
  +++ ThreadPool.java   27 May 2004 16:12:54 -  1.25
  @@ -24,7 +24,10 @@
   /**
* A thread pool that is trying to copy the apache process management.
*
  + * Should we remove this in favor of Doug Lea's thread package?
  + *
* @author Gal Shachor
  + * @author Yoav Shapira [EMAIL PROTECTED]
*/
   public class ThreadPool  {
   
  @@ -104,6 +107,11 @@
*/
   protected int sequence = 1;
   
  +/**
  + * Thread priority.
  + */
  +protected int threadPriority = Thread.NORM_PRIORITY;
  +
   
   /**
* Constructor.
  @@ -120,22 +128,11 @@
   
   /** Create a ThreadPool instance.
*
  - * @param jmx True if you want a pool with JMX support. A regular pool
  - *  will be returned if JMX or the modeler are not available.
  - *
  + * @param jmx UNUSED 
* @return ThreadPool instance. If JMX support is requested, you need to
*   call register() in order to set a name.
*/
   public static ThreadPool createThreadPool(boolean jmx) {
  -//if( jmx ) {
  -//try {
  -//Class.forName( org.apache.commons.modeler.Registry);
  -//Class tpc=Class.forName( 
org.apache.tomcat.util.threads.ThreadPoolMX);
  -//ThreadPool res=(ThreadPool)tpc.newInstance();
  -//return res;
  -//} catch( Exception ex ) {
  -//}
  -//}
   return new ThreadPool();
   }
   
  @@ -157,6 +154,47 @@
   public MonitorRunnable getMonitor() {
   return monitor;
   }
  +  
  +/**
  + * Sets the thread priority for current
  + * and future threads in this pool.
  + *
  + * @param threadPriority The new priority
  + * @throws IllegalArgumentException If the specified
  + *  priority is less than Thread.MIN_PRIORITY or
  + *  more than Thread.MAX_PRIORITY 
  + */
  +public synchronized void setThreadPriority(int threadPriority) {
  +  System.out.println(getClass().getName() +
  + : setPriority( + threadPriority + ): here.);
  +
  +  if (threadPriority  Thread.MIN_PRIORITY) {
  +throw new IllegalArgumentException(new priority  MIN_PRIORITY);
  +  } else if (threadPriority  Thread.MAX_PRIORITY) {
  +throw new IllegalArgumentException(new priority  MIN_PRIORITY);
  +  }
  +
  +  // Set for future threads
  +  this.threadPriority = threadPriority;
  +
  +  Enumeration currentThreads = getThreads();
  +  Thread t = null;
  +  while(currentThreads.hasMoreElements()) {
  +t = (Thread) currentThreads.nextElement();
  +t.setPriority(threadPriority);
  +  } 
  +}
  +
  +/**
  + * Returns the priority level of current and
  + * future threads in this pool.
  + *
  + * @return The priority
  + */
  +public int getThreadPriority() {
  +  return threadPriority;
  +}   
  + 
   
   public void setMaxThreads(int maxThreads) {
   this.maxThreads = maxThreads;
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2004-05-27 Thread billbarker
billbarker2004/05/27 19:49:35

  Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  Change logging message to DEBUG level.
  
  Revision  ChangesPath
  1.26  +3 -2  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- ThreadPool.java   27 May 2004 16:12:54 -  1.25
  +++ ThreadPool.java   28 May 2004 02:49:35 -  1.26
  @@ -165,8 +165,9 @@
*  more than Thread.MAX_PRIORITY 
*/
   public synchronized void setThreadPriority(int threadPriority) {
  -  System.out.println(getClass().getName() +
  - : setPriority( + threadPriority + ): here.);
  +if(log.isDebugEnabled())
  +log.debug(getClass().getName() +
  +  : setPriority( + threadPriority + ): here.);
   
 if (threadPriority  Thread.MIN_PRIORITY) {
   throw new IllegalArgumentException(new priority  MIN_PRIORITY);
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2004-03-08 Thread remm
remm2004/03/08 06:48:28

  Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  - 27513, submitted by Sergei Zhirikov.
  
  Revision  ChangesPath
  1.24  +1 -1  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- ThreadPool.java   24 Feb 2004 08:50:05 -  1.23
  +++ ThreadPool.java   8 Mar 2004 14:48:28 -   1.24
  @@ -349,7 +349,7 @@
   monitor.terminate();
   monitor = null;
   }
  -for(int i = 0 ; i  (currentThreadCount - currentThreadsBusy - 1) ; 
i++) {
  +for(int i = 0; i  currentThreadCount - currentThreadsBusy; i++) {
   try {
   pool[i].terminate();
   } catch(Throwable t) {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2004-01-21 Thread remm
remm2004/01/21 09:54:02

  Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  - Don't create a monitor thread unless maxSpareThreads  maxThreads.
  
  Revision  ChangesPath
  1.21  +7 -3  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- ThreadPool.java   8 Jan 2004 13:56:36 -   1.20
  +++ ThreadPool.java   21 Jan 2004 17:54:02 -  1.21
  @@ -193,7 +193,9 @@
   pool = new ControlRunnable[maxThreads];
   
   openThreads(minSpareThreads);
  -monitor = new MonitorRunnable(this);
  +if (maxSpareThreads  maxThreads) {
  +monitor = new MonitorRunnable(this);
  +}
   }
   
   public MonitorRunnable getMonitor() {
  @@ -387,8 +389,10 @@
   public synchronized void shutdown() {
   if(!stopThePool) {
   stopThePool = true;
  -monitor.terminate();
  -monitor = null;
  +if (monitor != null) {
  +monitor.terminate();
  +monitor = null;
  +}
   for(int i = 0 ; i  (currentThreadCount - currentThreadsBusy - 1) ; 
i++) {
   try {
   pool[i].terminate();
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2004-01-08 Thread remm
remm2004/01/08 05:56:36

  Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  - Some suggestions that were sent by Dave Dice. Jean François assured me
he did test this, so since this looks harmless to me (and won't hurt performance
either), I'm willing to try them. Actually, this looks to me that it won't do 
anything,
but what do I know ;-)
  
  Revision  ChangesPath
  1.20  +15 -9 
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- ThreadPool.java   25 Dec 2003 03:08:31 -  1.19
  +++ ThreadPool.java   8 Jan 2004 13:56:36 -   1.20
  @@ -644,17 +644,23 @@
   }
   
   public void run() {
  +boolean _shouldRun = false;
  +boolean _shouldTerminate = false; 
  +ThreadPoolRunnable _toRun = null;
 try {
   while(true) {
   try {
   /* Wait for work. */
   synchronized(this) {
  -if(!shouldRun  !shouldTerminate) {
  +while (!shouldRun  !shouldTerminate) {
   this.wait();
   }
  +_shouldRun = shouldRun;
  +_shouldTerminate = shouldTerminate;
  +_toRun = toRun;
   }
   
  -if( shouldTerminate ) {
  +if( _shouldTerminate ) {
   if( p.log.isDebugEnabled())
   p.log.debug( Terminate);
   break;
  @@ -663,8 +669,8 @@
   /* Check if should execute a runnable.  */
   try {
   if(noThData) {
  -if( toRun != null ) {
  -Object thData[]=toRun.getInitData();
  +if( _toRun != null ) {
  +Object thData[]=_toRun.getInitData();
   t.setThreadData(p, thData);
   if(p.log.isDebugEnabled())
   p.log.debug( Getting new thread data);
  @@ -672,9 +678,9 @@
   noThData = false;
   }
   
  -if(shouldRun) {
  - if( toRun != null ) { 
  -toRun.runIt(t.getThreadData(p));
  +if(_shouldRun) {
  + if( _toRun != null ) { 
  +_toRun.runIt(t.getThreadData(p));
   } else if( toRunRunnable != null ) { 
   toRunRunnable.run();
   } else {
  @@ -696,7 +702,7 @@
   shouldRun = false;
   p.notifyThreadEnd(this);
   } finally {
  -if(shouldRun) {
  +if(_shouldRun) {
   shouldRun = false;
   /*
 * Notify the pool that the thread is now idle.
  @@ -709,7 +715,7 @@
 * Check if should terminate.
 * termination happens when the pool is shutting down.
 */
  -if(shouldTerminate) {
  +if(_shouldTerminate) {
   break;
   }
   } catch(InterruptedException ie) { /* for the wait operation */
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2003-12-26 Thread Remy Maucherat
Bill Barker wrote:
I was thinking that on a big enough SMP machine it would be possible to
check noThreadData before the constructor exists.  Of course, it's not since
the check is after the wait(), and notify() can't be called until the
constructor exits.  I realized this about half an hour after the commit, but
it didn't seem worth reverting.  I can revert it if people want.
This is a little bit more correct, so I recommend to leave the patch in.

Rémy

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2003-12-25 Thread Remy Maucherat
[EMAIL PROTECTED] wrote:
billbarker2003/12/24 19:08:31

  Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  Fix potential race condition.
  
  You'll need some pretty high-end hardware to see this in the real world, but it's still technically a bug.
When can it occur, and what does the problem do ? All calls to 
openThreads are synced on the pool, so new threads should be created 
sequentially.

  Revision  ChangesPath
  1.19  +1 -1  jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ThreadPool.java	6 Nov 2003 19:05:23 -	1.18
  +++ ThreadPool.java	25 Dec 2003 03:08:31 -	1.19
  @@ -638,9 +638,9 @@
   t = new ThreadWithAttributes(p, this);
   t.setDaemon(true);
   t.setName(p.getName() + -Processor + p.getSequence());
  -t.start();
   p.addThread( t, this );
   	noThData=true;
  +t.start();
   }
   
   public void run() {
Rémy



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2003-12-25 Thread Bill Barker

- Original Message - 
From: Remy Maucherat [EMAIL PROTECTED]
To: Tomcat Developers List [EMAIL PROTECTED]
Sent: Thursday, December 25, 2003 1:15 AM
Subject: Re: cvs commit:
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads
ThreadPool.java


 [EMAIL PROTECTED] wrote:
  billbarker2003/12/24 19:08:31
 
Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
Log:
Fix potential race condition.
 
You'll need some pretty high-end hardware to see this in the real
world, but it's still technically a bug.

 When can it occur, and what does the problem do ? All calls to
 openThreads are synced on the pool, so new threads should be created
 sequentially.


I was thinking that on a big enough SMP machine it would be possible to
check noThreadData before the constructor exists.  Of course, it's not since
the check is after the wait(), and notify() can't be called until the
constructor exits.  I realized this about half an hour after the commit, but
it didn't seem worth reverting.  I can revert it if people want.

Revision  ChangesPath
1.19  +1 -1
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPoo
l.java
 
Index: ThreadPool.java
===
RCS file:
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads
/ThreadPool.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- ThreadPool.java 6 Nov 2003 19:05:23 - 1.18
+++ ThreadPool.java 25 Dec 2003 03:08:31 - 1.19
@@ -638,9 +638,9 @@
 t = new ThreadWithAttributes(p, this);
 t.setDaemon(true);
 t.setName(p.getName() + -Processor + p.getSequence());
-t.start();
 p.addThread( t, this );
 noThData=true;
+t.start();
 }
 
 public void run() {

 Rémy



 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



This message is intended only for the use of the person(s) listed above as the 
intended recipient(s), and may contain information that is PRIVILEGED and 
CONFIDENTIAL.  If you are not an intended recipient, you may not read, copy, or 
distribute this message or any attachment. If you received this communication in 
error, please notify us immediately by e-mail and then delete all copies of this 
message and any attachments.

In addition you should be aware that ordinary (unencrypted) e-mail sent through the 
Internet is not secure. Do not send confidential or sensitive information, such as 
social security numbers, account numbers, personal identification numbers and 
passwords, to us via ordinary (unencrypted) e-mail.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2003-12-24 Thread billbarker
billbarker2003/12/24 19:08:31

  Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  Fix potential race condition.
  
  You'll need some pretty high-end hardware to see this in the real world, but it's 
still technically a bug.
  
  Revision  ChangesPath
  1.19  +1 -1  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ThreadPool.java   6 Nov 2003 19:05:23 -   1.18
  +++ ThreadPool.java   25 Dec 2003 03:08:31 -  1.19
  @@ -638,9 +638,9 @@
   t = new ThreadWithAttributes(p, this);
   t.setDaemon(true);
   t.setName(p.getName() + -Processor + p.getSequence());
  -t.start();
   p.addThread( t, this );
noThData=true;
  +t.start();
   }
   
   public void run() {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2003-11-06 Thread luehe
luehe   2003/11/06 10:23:20

  Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  Moved the adjustment of maxThreads settings 10 from setMaxThreads()
  to adjustLimits()
  
  Revision  ChangesPath
  1.17  +6 -8  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ThreadPool.java   3 Nov 2003 21:54:24 -   1.16
  +++ ThreadPool.java   6 Nov 2003 18:23:20 -   1.17
  @@ -201,14 +201,7 @@
   }
   
   public void setMaxThreads(int maxThreads) {
  -if (maxThreads  MAX_THREADS_MIN) {
  -log.warn(sm.getString(threadpool.max_threads_too_low,
  -  new Integer(maxThreads),
  -  new Integer(MAX_THREADS_MIN)));
  -this.maxThreads = MAX_THREADS_MIN;
  -} else {
  -this.maxThreads = maxThreads;
  -}
  +this.maxThreads = maxThreads;
   }
   
   public int getMaxThreads() {
  @@ -477,6 +470,11 @@
   protected void adjustLimits() {
   if(maxThreads = 0) {
   maxThreads = MAX_THREADS;
  +} else if (maxThreads  MAX_THREADS_MIN) {
  +log.warn(sm.getString(threadpool.max_threads_too_low,
  +  new Integer(maxThreads),
  +  new Integer(MAX_THREADS_MIN)));
  +maxThreads = MAX_THREADS_MIN;
   }
   
   if(maxSpareThreads = maxThreads) {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2003-09-10 Thread billbarker
billbarker2003/09/10 21:05:02

  Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  Fix potential problem with dying threads when the pool is empty.
  
  Functionally, this isn't that much different from what Remy posted on Bug #21763.  
However (at least on high-end machines) it should be able to respond faster to a 
released CM.  Since the case that all threads are dead may be able to be handled, be 
less aggressive on checking this case.
  
  Also adding debug statements, since I'm not convinced that this is the fix for 21763 
(so I'm going to do some more testing before I close the bug).
  
  Revision  ChangesPath
  1.14  +31 -23
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ThreadPool.java   7 Sep 2003 13:25:26 -   1.13
  +++ ThreadPool.java   11 Sep 2003 04:05:02 -  1.14
  @@ -308,14 +308,14 @@
   private ControlRunnable findControlRunnable() {
   ControlRunnable c=null;
   
  -if (0 == currentThreadCount || stopThePool) {
  +if ( stopThePool ) {
   throw new IllegalStateException();
   }
   
   // Obtain a free thread from the pool.
   synchronized(this) {
   
  -if (currentThreadsBusy == currentThreadCount) {
  +while (currentThreadsBusy == currentThreadCount) {
// All threads are busy
   if (currentThreadCount  maxThreads) {
   // Not all threads were open,
  @@ -323,29 +323,34 @@
   int toOpen = currentThreadCount + minSpareThreads;
   openThreads(toOpen);
   } else {
  - logFull(log, currentThreadCount, maxThreads);
  +logFull(log, currentThreadCount, maxThreads);
   // Wait for a thread to become idel.
  -while(currentThreadsBusy == currentThreadCount) {
  -try {
  -this.wait();
  -}
  - // was just catch Throwable -- but no other
  - // exceptions can be thrown by wait, right?
  - // So we catch and ignore this one, since
  - // it'll never actually happen, since nowhere
  - // do we say pool.interrupt().
  - catch(InterruptedException e) {
  - log.error(Unexpected exception, e);
  -}
  -
  -// Pool was stopped. Get away of the pool.
  -if(0 == currentThreadCount || stopThePool) {
  -throw new IllegalStateException();
  -}
  +try {
  +this.wait();
  +}
  +// was just catch Throwable -- but no other
  +// exceptions can be thrown by wait, right?
  +// So we catch and ignore this one, since
  +// it'll never actually happen, since nowhere
  +// do we say pool.interrupt().
  +catch(InterruptedException e) {
  +log.error(Unexpected exception, e);
  +}
  + if( log.isDebugEnabled() ) {
  + log.debug(Finished waiting: CTC=+currentThreadCount +
  +   , CTB= + currentThreadsBusy);
  +}
  +// Pool was stopped. Get away of the pool.
  +if( stopThePool) {
  +break;
   }
   }
   }
  -
  +// Pool was stopped. Get away of the pool.
  +if(0 == currentThreadCount || stopThePool) {
  +throw new IllegalStateException();
  +}
  +
   // If we are here it means that there is a free thread. Take it.
   int pos = currentThreadCount - currentThreadsBusy - 1;
   c = pool[pos];
  @@ -363,8 +368,11 @@
   increase maxThreads or check the servlet +
status + currentThreadCount +   +
   maxThreads  );
  - logfull=false;
  - } 
  +logfull=false;
  +} else if( log.isDebugEnabled() ) {
  +log.debug(All threads are busy  + currentThreadCount +   +
  +  maxThreads );
  +}
   }
   
   /**
  
  
  

-
To 

cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2003-09-10 Thread billbarker
billbarker2003/09/10 21:15:42

  Modified:util/java/org/apache/tomcat/util/threads Tag: coyote_10
ThreadPool.java
  Log:
  port patch
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.9.2.2   +34 -24
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.9.2.1
  retrieving revision 1.9.2.2
  diff -u -r1.9.2.1 -r1.9.2.2
  --- ThreadPool.java   25 Jan 2003 04:49:24 -  1.9.2.1
  +++ ThreadPool.java   11 Sep 2003 04:15:42 -  1.9.2.2
  @@ -276,7 +276,7 @@
   throw new NullPointerException();
   }
   
  -if(0 == currentThreadCount || stopThePool) {
  +if( stopThePool ) {
   throw new IllegalStateException();
   }
   
  @@ -284,39 +284,46 @@
   
   // Obtain a free thread from the pool.
   synchronized(this) {
  -if(currentThreadsBusy == currentThreadCount) {
  +while (currentThreadsBusy == currentThreadCount) {
// All threads are busy
  -if(currentThreadCount  maxThreads) {
  +if (currentThreadCount  maxThreads) {
   // Not all threads were open,
   // Open new threads up to the max number of idel threads
   int toOpen = currentThreadCount + minSpareThreads;
   openThreads(toOpen);
   } else {
  - logFull(log, currentThreadCount, maxThreads);
  +logFull(log, currentThreadCount, maxThreads);
   // Wait for a thread to become idel.
  -while(currentThreadsBusy == currentThreadCount) {
  -try {
  -this.wait();
  -}
  - // was just catch Throwable -- but no other
  - // exceptions can be thrown by wait, right?
  - // So we catch and ignore this one, since
  - // it'll never actually happen, since nowhere
  - // do we say pool.interrupt().
  - catch(InterruptedException e) {
  - log.error(Unexpected exception, e);
  -}
  -
  -// Pool was stopped. Get away of the pool.
  -if(0 == currentThreadCount || stopThePool) {
  -throw new IllegalStateException();
  -}
  +try {
  +this.wait();
  +}
  +// was just catch Throwable -- but no other
  +// exceptions can be thrown by wait, right?
  +// So we catch and ignore this one, since
  +// it'll never actually happen, since nowhere
  +// do we say pool.interrupt().
  +catch(InterruptedException e) {
  +log.error(Unexpected exception, e);
  +}
  + if( log.isDebugEnabled() ) {
  + log.debug(Finished waiting: CTC=+currentThreadCount +
  +   , CTB= + currentThreadsBusy);
  +}
  +// Pool was stopped. Get away of the pool.
  +if( stopThePool) {
  +break;
   }
   }
   }
  -
  +// Pool was stopped. Get away of the pool.
  +if(0 == currentThreadCount || stopThePool) {
  +throw new IllegalStateException();
  +}
  +
   // If we are here it means that there is a free thread. Take it.
  -c = pool[currentThreadCount - currentThreadsBusy - 1];
  +int pos = currentThreadCount - currentThreadsBusy - 1;
  +c = pool[pos];
  +pool[pos] = null;
   currentThreadsBusy++;
   }
   c.runIt(r);
  @@ -330,7 +337,10 @@
status + currentThreadCount +   +
   maxThreads  );
logfull=false;
  - } 
  + }  else if( log.isDebugEnabled() ) {
  +log.debug(All threads are busy  + currentThreadCount +   +
  +  maxThreads );
  +}
   }
   
   /**
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2003-09-07 Thread remm
remm2003/09/07 06:25:26

  Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  - Null a busy processor in the pool array. This isn't particularly useful, but is
more consistent with the rest of the algorithm, and helps get a clearer picture
when debugging.
  
  Revision  ChangesPath
  1.13  +13 -4 
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ThreadPool.java   28 Jul 2003 11:23:56 -  1.12
  +++ ThreadPool.java   7 Sep 2003 13:25:26 -   1.13
  @@ -308,14 +308,16 @@
   private ControlRunnable findControlRunnable() {
   ControlRunnable c=null;
   
  -if(0 == currentThreadCount || stopThePool) {
  +if (0 == currentThreadCount || stopThePool) {
   throw new IllegalStateException();
   }
  +
   // Obtain a free thread from the pool.
   synchronized(this) {
  -if(currentThreadsBusy == currentThreadCount) {
  +
  +if (currentThreadsBusy == currentThreadCount) {
// All threads are busy
  -if(currentThreadCount  maxThreads) {
  +if (currentThreadCount  maxThreads) {
   // Not all threads were open,
   // Open new threads up to the max number of idel threads
   int toOpen = currentThreadCount + minSpareThreads;
  @@ -345,8 +347,11 @@
   }
   
   // If we are here it means that there is a free thread. Take it.
  -c = pool[currentThreadCount - currentThreadsBusy - 1];
  +int pos = currentThreadCount - currentThreadsBusy - 1;
  +c = pool[pos];
  +pool[pos] = null;
   currentThreadsBusy++;
  +
   }
   return c;
   }
  @@ -395,6 +400,7 @@
   if(stopThePool) {
   return;
   }
  +
   if((currentThreadCount - currentThreadsBusy)  maxSpareThreads) {
   int toFree = currentThreadCount -
currentThreadsBusy -
  @@ -406,7 +412,9 @@
   pool[currentThreadCount - currentThreadsBusy - 1] = null;
   currentThreadCount --;
   }
  +
   }
  +
   }
   
   /**
  @@ -527,6 +535,7 @@
   public void run() {
   while(true) {
   try {
  +
   // Sleep for a while.
   synchronized(this) {
   this.wait(WORK_WAIT_TIMEOUT);
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2003-07-28 Thread remm
remm2003/07/28 04:23:57

  Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  - Beautify the thread names.
  
  Revision  ChangesPath
  1.12  +20 -2 
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ThreadPool.java   3 Apr 2003 00:51:44 -   1.11
  +++ ThreadPool.java   28 Jul 2003 11:23:56 -  1.12
  @@ -133,7 +133,12 @@
   
   /** Name of the threadpool
*/
  -protected String name=null;
  +protected String name = TP;
  +
  +/**
  + * Sequence.
  + */
  +protected int sequence = 1;
   
   /**
* Helper object for logging
  @@ -240,6 +245,18 @@
   return isDaemon;
   }
   
  +public void setName(String name) {
  +this.name = name;
  +}
  +
  +public String getName() {
  +return name;
  +}
  +
  +public int getSequence() {
  +return sequence++;
  +}
  +
   public void addThread( Thread t, ControlRunnable cr ) {
   threads.put( t, cr );
   for( int i=0; ilisteners.size(); i++ ) {
  @@ -499,7 +516,7 @@
   shouldTerminate = false;
   t = new Thread(this);
   t.setDaemon(p.getDaemon() );
  - t.setName( MonitorRunnable );
  + t.setName(p.getName() + -Monitor);
   t.start();
   }
   
  @@ -592,6 +609,7 @@
   this.p = p;
   t = new ThreadWithAttributes(p, this);
   t.setDaemon(true);
  +t.setName(p.getName() + -Processor + p.getSequence());
   t.start();
   p.addThread( t, this );
noThData=true;
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2003-04-02 Thread costin
costin  2003/04/02 16:51:45

  Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  Few changes - hopefully no backward incompatibilities.
  
  The most important is the use of the threadData property in
  ThreadWithAttribute.  Previously - we created a simple thread, and
  used Runnable - however this mechanism is more powerfull and allows
  us to share info that was usually private.
  
  In particular we need the thread data exposed so we can use the
  ObjectName and unregister the connector and components.
  
  I also added support for Runnable - it's a long time since I wanted to
  do this. The reason we used ThreadPoolRunnable was the lack of ThreadData
  in JDK1.1. However ThreadWithAttributes provide the same functionality
  and is much cleaner. Now it would be possible to run more stuff in
  thread pools.
  
  Finally - I moved the code that gets info from ThreadPoolMX - there is no
  need and no dependency on JMX, the registration happens in the listener.
  
  Revision  ChangesPath
  1.11  +114 -30   
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ThreadPool.java   21 Jan 2003 00:17:11 -  1.10
  +++ ThreadPool.java   3 Apr 2003 00:51:44 -   1.11
  @@ -159,15 +159,15 @@
*   call register() in order to set a name.
*/
   public static ThreadPool createThreadPool(boolean jmx) {
  -if( jmx ) {
  -try {
  -Class.forName( org.apache.commons.modeler.Registry);
  -Class tpc=Class.forName( 
org.apache.tomcat.util.threads.ThreadPoolMX);
  -ThreadPool res=(ThreadPool)tpc.newInstance();
  -return res;
  -} catch( Exception ex ) {
  -}
  -}
  +//if( jmx ) {
  +//try {
  +//Class.forName( org.apache.commons.modeler.Registry);
  +//Class tpc=Class.forName( 
org.apache.tomcat.util.threads.ThreadPoolMX);
  +//ThreadPool res=(ThreadPool)tpc.newInstance();
  +//return res;
  +//} catch( Exception ex ) {
  +//}
  +//}
   return new ThreadPool();
   }
   
  @@ -264,6 +264,11 @@
   return threads.keys();
   }
   
  +public void run(Runnable r) {
  +ControlRunnable c = findControlRunnable();
  +c.runIt(r);
  +}
  +
   //
   // You may wonder what you see here ... basically I am trying
   // to maintain a stack of threads. This way locality in time
  @@ -275,17 +280,20 @@
* Executes a given Runnable on a thread in the pool, block if needed.
*/
   public void runIt(ThreadPoolRunnable r) {
  -
   if(null == r) {
   throw new NullPointerException();
   }
   
  +ControlRunnable c = findControlRunnable();
  +c.runIt(r);
  +}
  +
  +private ControlRunnable findControlRunnable() {
  +ControlRunnable c=null;
  +
   if(0 == currentThreadCount || stopThePool) {
   throw new IllegalStateException();
   }
  -
  -ControlRunnable c = null;
  -
   // Obtain a free thread from the pool.
   synchronized(this) {
   if(currentThreadsBusy == currentThreadCount) {
  @@ -323,7 +331,7 @@
   c = pool[currentThreadCount - currentThreadsBusy - 1];
   currentThreadsBusy++;
   }
  -c.runIt(r);
  +return c;
   }
   
   static boolean logfull=true;
  @@ -542,27 +550,29 @@
   /**
 * ThreadPool where this thread will be returned
 */
  -ThreadPool p;
  +private ThreadPool p;
   
/**
 * The thread that executes the actions
 */
  -Thread t;
  +private ThreadWithAttributes t;
   
/**
 * The method that is executed in this thread
 */
  -ThreadPoolRunnable   toRun;
  +
  +private ThreadPoolRunnable   toRun;
  +private Runnable toRunRunnable;
   
/**
 * Stop this thread
 */
  - booleanshouldTerminate;
  + private booleanshouldTerminate;
   
/**
 * Activate the execution of the action
 */
  -booleanshouldRun;
  +private booleanshouldRun;
   
/**
 * Per thread data - can be used only if all actions are
  @@ -570,8 +580,7 @@
 *  A better mechanism is possible ( that would allow association of
 *  thread data with action type ), but right now it's enough.
 */
  - boolean noThData;
  - Object thData[]=null;

RE: cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java ThreadPoolMX.java

2003-01-27 Thread Larry Isaacs
Hi Costin,

jtc/util still contains org.apache.tomcat.util.mx.DynamicMBeanProxy
which imports javax.management.*.  Is the intent to update or remove
this class so the dependency on JMX can be removed?  Thanks.

Cheers,
Larry

 -Original Message-
 From: Costin Manolache [mailto:[EMAIL PROTECTED]] 
 Sent: Monday, January 27, 2003 10:39 AM
 To: [EMAIL PROTECTED]
 Subject: Re: cvs commit: 
 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/thr
 eads ThreadPool.java ThreadPoolMX.java
 
 
 FYI: I did the same in the main branch. All of DynamicMBean 
 features are
 now porte to modeler. There is no need for JMX dependency in jtc/util
 ( the branch is still needed in coyote, jk, http11 )
 
 Costin
 
 
 
 [EMAIL PROTECTED] wrote:
  billbarker2003/01/24 20:49:24
  
Modified:util/java/org/apache/tomcat/util/threads 
 Tag: coyote_10
  ThreadPool.java
Removed: util/java/org/apache/tomcat/util/threads 
 Tag: coyote_10
  ThreadPoolMX.java
Log:
Removing JMX dependencies from this branch (as voted on 
 in tomcat-dev).

Revision  ChangesPath
No   revision


No   revision


1.9.2.1   +0 -9  
 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/thr
 eads/ThreadPool.java

Index: ThreadPool.java

 ===
RCS file: 
 /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomca
 t/util/threads/ThreadPool.java,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -u -r1.9 -r1.9.2.1
--- ThreadPool.java   14 Jan 2003 18:47:39 -  1.9
+++ ThreadPool.java   25 Jan 2003 04:49:24 -  1.9.2.1
@@ -159,15 +159,6 @@
  *   call register() in order to set a name.
  */
 public static ThreadPool createThreadPool(boolean jmx) {
-if( jmx ) {
-try {
-Class.forName( 
 org.apache.commons.modeler.Registry);
-Class tpc=Class.forName( 
 org.apache.tomcat.util.threads.ThreadPoolMX);
-ThreadPool res=(ThreadPool)tpc.newInstance();
-return res;
-} catch( Exception ex ) {
-}
-}
 return new ThreadPool();
 }
 
 
 
 
 --
 To unsubscribe, e-mail:   
 mailto:tomcat-dev- [EMAIL PROTECTED]
 For 
 additional commands, 
 e-mail: mailto:[EMAIL PROTECTED]
 
 

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java ThreadPoolMX.java

2003-01-27 Thread Costin Manolache
Larry Isaacs wrote:

 Hi Costin,
 
 jtc/util still contains org.apache.tomcat.util.mx.DynamicMBeanProxy
 which imports javax.management.*.  Is the intent to update or remove
 this class so the dependency on JMX can be removed?  Thanks.

To deprecate - for sure, there is no point in maintaining it when the
same functionality is in modeler. I made quite a few improvements to
the equivalent code in modeler ( support for more types, automatic detection
of .xml descriptors, etc ).

About remove - I don't know if it was included in any official release,
and if removing it won't break code. I know of a use in 3.3, is anyone
else using it ? 

We definitely need a way to document what APIs are FROZEN 
( like mozilla ). 


Costin

 
 Cheers,
 Larry
 
 -Original Message-
 From: Costin Manolache [mailto:[EMAIL PROTECTED]]
 Sent: Monday, January 27, 2003 10:39 AM
 To: [EMAIL PROTECTED]
 Subject: Re: cvs commit:
 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/thr
 eads ThreadPool.java ThreadPoolMX.java
 
 
 FYI: I did the same in the main branch. All of DynamicMBean
 features are
 now porte to modeler. There is no need for JMX dependency in jtc/util
 ( the branch is still needed in coyote, jk, http11 )
 
 Costin
 
 
 
 [EMAIL PROTECTED] wrote:
  billbarker2003/01/24 20:49:24
  
Modified:util/java/org/apache/tomcat/util/threads
 Tag: coyote_10
  ThreadPool.java
Removed: util/java/org/apache/tomcat/util/threads
 Tag: coyote_10
  ThreadPoolMX.java
Log:
Removing JMX dependencies from this branch (as voted on
 in tomcat-dev).

Revision  ChangesPath
No   revision


No   revision


1.9.2.1   +0 -9
 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/thr
 eads/ThreadPool.java

Index: ThreadPool.java

 ===
RCS file:
 /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomca
 t/util/threads/ThreadPool.java,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -u -r1.9 -r1.9.2.1
--- ThreadPool.java  14 Jan 2003 18:47:39 -  1.9
+++ ThreadPool.java  25 Jan 2003 04:49:24 -  1.9.2.1
@@ -159,15 +159,6 @@
  *   call register() in order to set a name.
  */
 public static ThreadPool createThreadPool(boolean jmx) {
-if( jmx ) {
-try {
-Class.forName(
 org.apache.commons.modeler.Registry);
-Class tpc=Class.forName(
 org.apache.tomcat.util.threads.ThreadPoolMX);
-ThreadPool res=(ThreadPool)tpc.newInstance();
-return res;
-} catch( Exception ex ) {
-}
-}
 return new ThreadPool();
 }
 
 
 
 
 --
 To unsubscribe, e-mail:
 mailto:tomcat-dev- [EMAIL PROTECTED]
 For
 additional commands,
 e-mail: mailto:[EMAIL PROTECTED]
 




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java ThreadPoolMX.java

2003-01-27 Thread Larry Isaacs
I'll assume DynamicMBeanProxy will stay for now and
make sure the jtc/util projects in Gump still show a
dependency on JMX.

Larry

 -Original Message-
 From: Costin Manolache [mailto:[EMAIL PROTECTED]] 
 Sent: Monday, January 27, 2003 3:55 PM
 To: [EMAIL PROTECTED]
 Subject: RE: cvs commit: 
 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/thr
 eads ThreadPool.java ThreadPoolMX.java
 
 
 Larry Isaacs wrote:
 
  Hi Costin,
  
  jtc/util still contains org.apache.tomcat.util.mx.DynamicMBeanProxy
  which imports javax.management.*.  Is the intent to 
 update or remove
  this class so the dependency on JMX can be removed?  Thanks.
 
 To deprecate - for sure, there is no point in maintaining it when the
 same functionality is in modeler. I made quite a few improvements to
 the equivalent code in modeler ( support for more types, 
 automatic detection
 of .xml descriptors, etc ).
 
 About remove - I don't know if it was included in any 
 official release,
 and if removing it won't break code. I know of a use in 3.3, is anyone
 else using it ? 
 
 We definitely need a way to document what APIs are FROZEN 
 ( like mozilla ). 
 
 
 Costin
 
  
  Cheers,
  Larry
  
  -Original Message-
  From: Costin Manolache [mailto:[EMAIL PROTECTED]]
  Sent: Monday, January 27, 2003 10:39 AM
  To: [EMAIL PROTECTED]
  Subject: Re: cvs commit:
  jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/thr
  eads ThreadPool.java ThreadPoolMX.java
  
  
  FYI: I did the same in the main branch. All of DynamicMBean
  features are
  now porte to modeler. There is no need for JMX dependency 
 in jtc/util
  ( the branch is still needed in coyote, jk, http11 )
  
  Costin
  
  
  
  [EMAIL PROTECTED] wrote:
   billbarker2003/01/24 20:49:24
   
 Modified:util/java/org/apache/tomcat/util/threads
  Tag: coyote_10
   ThreadPool.java
 Removed: util/java/org/apache/tomcat/util/threads
  Tag: coyote_10
   ThreadPoolMX.java
 Log:
 Removing JMX dependencies from this branch (as voted on
  in tomcat-dev).
 
 Revision  ChangesPath
 No   revision
 
 
 No   revision
 
 
 1.9.2.1   +0 -9
  jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/thr
  eads/ThreadPool.java
 
 Index: ThreadPool.java
 
  ===
 RCS file:
  /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomca
  t/util/threads/ThreadPool.java,v
 retrieving revision 1.9
 retrieving revision 1.9.2.1
 diff -u -r1.9 -r1.9.2.1
 --- ThreadPool.java  14 Jan 2003 18:47:39 -  1.9
 +++ ThreadPool.java  25 Jan 2003 04:49:24 -
   1.9.2.1
 @@ -159,15 +159,6 @@
   *   call register() in order to set a name.
   */
  public static ThreadPool createThreadPool(boolean jmx) {
 -if( jmx ) {
 -try {
 -Class.forName(
  org.apache.commons.modeler.Registry);
 -Class tpc=Class.forName(
  org.apache.tomcat.util.threads.ThreadPoolMX);
 -ThreadPool res=(ThreadPool)tpc.newInstance();
 -return res;
 -} catch( Exception ex ) {
 -}
 -}
  return new ThreadPool();
  }
  
  
  
  
  --
  To unsubscribe, e-mail:
  mailto:tomcat-dev- [EMAIL PROTECTED]
  For
  additional commands,
  e-mail: mailto:[EMAIL PROTECTED]
  
 
 
 
 
 --
 To unsubscribe, e-mail:   
 mailto:tomcat-dev- [EMAIL PROTECTED]
 For 
 additional commands, 
 e-mail: mailto:[EMAIL PROTECTED]
 
 

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java ThreadPoolMX.java

2003-01-26 Thread Bill Barker
I'll take Sam's suggestions (probably tomorrow, since it is a bit late for
me to get it right now :).

It's a bit of a gray area.  Tomcat 3.3 should gump-build fine as is.  As
long as you are using the HEAD commons-modeler, then you have no problems
building the HEAD j-t-c.  The branch is for the 'standard-build' of TC 3.3
(which, until Larry's patch) had no dependencies on any version of
commons-modeler.

- Original Message -
From: Ignacio J. Ortega [EMAIL PROTECTED]
To: 'Tomcat Developers List' [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Saturday, January 25, 2003 8:35 AM
Subject: RE: cvs commit:
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads
ThreadPool.java ThreadPoolMX.java


 Bill, we will need another gump descriptor to build coyote_10 tag jtc
 sources obviously, to allow tc33 to be gumped correctly?

 Anyone with more knowledge of gump can help ?

  billbarker2003/01/24 20:49:24
 
Modified:util/java/org/apache/tomcat/util/threads Tag: coyote_10
  ThreadPool.java
Removed: util/java/org/apache/tomcat/util/threads Tag: coyote_10
  ThreadPoolMX.java

 (Care with double posting please)

 Saludos,
 Ignacio J. Ortega

 --
 To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
mailto:[EMAIL PROTECTED]



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java ThreadPoolMX.java

2003-01-25 Thread Ignacio J. Ortega
Bill, we will need another gump descriptor to build coyote_10 tag jtc
sources obviously, to allow tc33 to be gumped correctly?

Anyone with more knowledge of gump can help ?

 billbarker2003/01/24 20:49:24
 
   Modified:util/java/org/apache/tomcat/util/threads Tag: coyote_10
 ThreadPool.java
   Removed: util/java/org/apache/tomcat/util/threads Tag: coyote_10
 ThreadPoolMX.java

(Care with double posting please)

Saludos, 
Ignacio J. Ortega 

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java ThreadPoolMX.java

2003-01-24 Thread billbarker
billbarker2003/01/24 20:49:24

  Modified:util/java/org/apache/tomcat/util/threads Tag: coyote_10
ThreadPool.java
  Removed: util/java/org/apache/tomcat/util/threads Tag: coyote_10
ThreadPoolMX.java
  Log:
  Removing JMX dependencies from this branch (as voted on in tomcat-dev).
  
  Revision  ChangesPath
  No   revision
  
  
  No   revision
  
  
  1.9.2.1   +0 -9  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.9
  retrieving revision 1.9.2.1
  diff -u -r1.9 -r1.9.2.1
  --- ThreadPool.java   14 Jan 2003 18:47:39 -  1.9
  +++ ThreadPool.java   25 Jan 2003 04:49:24 -  1.9.2.1
  @@ -159,15 +159,6 @@
*   call register() in order to set a name.
*/
   public static ThreadPool createThreadPool(boolean jmx) {
  -if( jmx ) {
  -try {
  -Class.forName( org.apache.commons.modeler.Registry);
  -Class tpc=Class.forName( 
org.apache.tomcat.util.threads.ThreadPoolMX);
  -ThreadPool res=(ThreadPool)tpc.newInstance();
  -return res;
  -} catch( Exception ex ) {
  -}
  -}
   return new ThreadPool();
   }
   
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java ThreadPoolMX.java

2003-01-20 Thread costin
costin  2003/01/20 16:17:11

  Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
ThreadPoolMX.java
  Log:
  Remove the dependency on JMX.
  ThreadPoolMX will be wrapped in a model mbean - but it doesn't need to depend
  on JMX.
  
  Revision  ChangesPath
  1.10  +0 -5  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ThreadPool.java   14 Jan 2003 18:47:39 -  1.9
  +++ ThreadPool.java   21 Jan 2003 00:17:11 -  1.10
  @@ -171,11 +171,6 @@
   return new ThreadPool();
   }
   
  -public void register( String domain, String name ) {
  -// nothing in the base class - it'll register in jmx mode
  -// We could use the name to create a ThreadGroup and name threads
  -}
  -
   public synchronized void start() {
stopThePool=false;
   currentThreadCount  = 0;
  
  
  
  1.4   +0 -13 
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPoolMX.java
  
  Index: ThreadPoolMX.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPoolMX.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ThreadPoolMX.java 14 Jan 2003 18:47:39 -  1.3
  +++ ThreadPoolMX.java 21 Jan 2003 00:17:11 -  1.4
  @@ -63,7 +63,6 @@
   import java.util.*;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  -import org.apache.commons.modeler.Registry;
   
   /**
* Manageable thread pool
  @@ -72,24 +71,12 @@
*/
   public class ThreadPoolMX extends ThreadPool {
   static Log log = LogFactory.getLog(ThreadPoolMX.class);
  -Registry reg;
   protected String domain;
   
   protected String name;
   
   public ThreadPoolMX() {
   super();
  -}
  -
  -public void register(String domain, String name) {
  -this.name=name;
  -this.domain=domain;
  -reg=Registry.getRegistry();
  -try {
  -reg.registerComponent(this, domain, ThreadPool,  name);
  -} catch( Exception ex ) {
  -log.error( Error registering thread pool, ex );
  -}
   }
   
   public synchronized void start() {
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java ThreadPoolMX.java

2003-01-14 Thread costin
costin  2003/01/14 10:47:39

  Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
ThreadPoolMX.java
  Log:
  Pass the domain.
  ThreadPools should be registered in the same domain with all catalina
  mbeans.
  
  Revision  ChangesPath
  1.9   +1 -1  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ThreadPool.java   12 Jan 2003 19:07:07 -  1.8
  +++ ThreadPool.java   14 Jan 2003 18:47:39 -  1.9
  @@ -171,7 +171,7 @@
   return new ThreadPool();
   }
   
  -public void register( String name ) {
  +public void register( String domain, String name ) {
   // nothing in the base class - it'll register in jmx mode
   // We could use the name to create a ThreadGroup and name threads
   }
  
  
  
  1.3   +2 -1  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPoolMX.java
  
  Index: ThreadPoolMX.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPoolMX.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ThreadPoolMX.java 12 Jan 2003 19:07:07 -  1.2
  +++ ThreadPoolMX.java 14 Jan 2003 18:47:39 -  1.3
  @@ -81,8 +81,9 @@
   super();
   }
   
  -public void register(String name) {
  +public void register(String domain, String name) {
   this.name=name;
  +this.domain=domain;
   reg=Registry.getRegistry();
   try {
   reg.registerComponent(this, domain, ThreadPool,  name);
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java ThreadPoolMX.java

2003-01-12 Thread costin
costin  2003/01/12 11:07:07

  Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
ThreadPoolMX.java
  Log:
  Few more changes ( on the new jmx code ).
  Old code will continue to use the normal pool, new code can get a JMX
  pool if JMX is available.
  
  We could move some of the methods I added to ThreadPoolMX.
  
  One big issue: support for chainging pool params at runtime !
  
  Revision  ChangesPath
  1.8   +27 -10
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ThreadPool.java   11 Jan 2003 06:55:24 -  1.7
  +++ ThreadPool.java   12 Jan 2003 19:07:07 -  1.8
  @@ -123,8 +123,6 @@
   
   /* Flag to control if the main thread is 'daemon' */
   protected boolean isDaemon=true;
  -
  -static int debug=0;
   
   /** The threads that are part of the pool.
* Key is Thread, value is the ControlRunnable
  @@ -133,6 +131,10 @@
   
   protected Vector listeners=new Vector();
   
  +/** Name of the threadpool
  + */
  +protected String name=null;
  +
   /**
* Helper object for logging
**/
  @@ -148,17 +150,32 @@
   }
   
   
  -public static ThreadPool createThreadPool() {
  -try {
  -Class.forName( org.apache.commons.modeler.Registry);
  -Class tpc=Class.forName( org.apache.tomcat.util.threads.ThreadPoolMX);
  -ThreadPool res=(ThreadPool)tpc.newInstance();
  -return res;
  -} catch( Exception ex ) {
  +/** Create a ThreadPool instance.
  + *
  + * @param jmx True if you want a pool with JMX support. A regular pool
  + *  will be returned if JMX or the modeler are not available.
  + *
  + * @return ThreadPool instance. If JMX support is requested, you need to
  + *   call register() in order to set a name.
  + */
  +public static ThreadPool createThreadPool(boolean jmx) {
  +if( jmx ) {
  +try {
  +Class.forName( org.apache.commons.modeler.Registry);
  +Class tpc=Class.forName( 
org.apache.tomcat.util.threads.ThreadPoolMX);
  +ThreadPool res=(ThreadPool)tpc.newInstance();
  +return res;
  +} catch( Exception ex ) {
  +}
   }
   return new ThreadPool();
   }
   
  +public void register( String name ) {
  +// nothing in the base class - it'll register in jmx mode
  +// We could use the name to create a ThreadGroup and name threads
  +}
  +
   public synchronized void start() {
stopThePool=false;
   currentThreadCount  = 0;
  @@ -213,7 +230,7 @@
   }
   
   public static int getDebug() {
  -return debug;
  +return 0;
   }
   
   /** The default is true - the created threads will be
  
  
  
  1.2   +2 -14 
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPoolMX.java
  
  Index: ThreadPoolMX.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPoolMX.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ThreadPoolMX.java 11 Jan 2003 06:52:27 -  1.1
  +++ ThreadPoolMX.java 12 Jan 2003 19:07:07 -  1.2
  @@ -81,23 +81,11 @@
   super();
   }
   
  -public void setDomain(String domain) {
  -this.domain=domain;
  -}
  -public String getDomain() {
  -return domain;
  -}
  -
  -public String getName() {
  -return name;
  -}
  -
  -public void setName(String name) {
  +public void register(String name) {
   this.name=name;
   reg=Registry.getRegistry();
   try {
  -reg.registerComponent(this, domain, ThreadPool,
  -name= + name);
  +reg.registerComponent(this, domain, ThreadPool,  name);
   } catch( Exception ex ) {
   log.error( Error registering thread pool, ex );
   }
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2003-01-10 Thread costin
costin  2003/01/10 22:55:24

  Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  Update ThreadPool.
  
  Revision  ChangesPath
  1.7   +20 -51
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ThreadPool.java   24 Dec 2002 17:02:54 -  1.6
  +++ ThreadPool.java   11 Jan 2003 06:55:24 -  1.7
  @@ -147,6 +147,18 @@
   stopThePool = false;
   }
   
  +
  +public static ThreadPool createThreadPool() {
  +try {
  +Class.forName( org.apache.commons.modeler.Registry);
  +Class tpc=Class.forName( org.apache.tomcat.util.threads.ThreadPoolMX);
  +ThreadPool res=(ThreadPool)tpc.newInstance();
  +return res;
  +} catch( Exception ex ) {
  +}
  +return new ThreadPool();
  +}
  +
   public synchronized void start() {
stopThePool=false;
   currentThreadCount  = 0;
  @@ -295,7 +307,7 @@
   }
   }
   
  -// If we are here it means that there is a free thred. Take it.
  +// If we are here it means that there is a free thread. Take it.
   c = pool[currentThreadCount - currentThreadsBusy - 1];
   currentThreadsBusy++;
   }
  @@ -371,7 +383,9 @@
   return;
   }
   
  +// atomic
   currentThreadsBusy--;
  +
   pool[currentThreadCount - currentThreadsBusy - 1] = c;
   notify();
   }
  @@ -424,6 +438,10 @@
   }
   }
   
  +/** Create missing threads.
  + *
  + * @param toOpen Total number of threads we'll have open
  + */
   protected void openThreads(int toOpen) {
   
   if(toOpen  maxThreads) {
  @@ -636,10 +654,7 @@
* @param toRun
*/
   public synchronized void runIt(ThreadPoolRunnable toRun) {
  - if( toRun == null ) {
  - throw new NullPointerException(No Runnable);
  - }
  -this.toRun = toRun;
  + this.toRun = toRun;
// Do not re-init, the whole idea is to run init only once per
// thread - the pool is supposed to run a single task, that is
// initialized once.
  @@ -659,52 +674,6 @@
   public synchronized void terminate() {
   shouldTerminate = true;
   this.notify();
  -}
  -}
  -
  -/** Special thread that allows storing of attributes and notes.
  - *  A guard is used to prevent untrusted code from accessing the
  - *  attributes.
  - *
  - *  This avoids hash lookups and provide something very similar
  - * with ThreadLocal ( but compatible with JDK1.1 and faster on
  - * JDK  1.4 ).
  - *
  - * The main use is to store 'state' for monitoring ( like processing
  - * request 'GET /' ).
  - */
  -public static class ThreadWithAttributes extends Thread {
  -private Object control;
  -public static int MAX_NOTES=16;
  -private Object notes[]=new Object[MAX_NOTES];
  -private Hashtable attributes=new Hashtable();
  -private String currentStage;
  -
  -public ThreadWithAttributes(Object control, Runnable r) {
  -super(r);
  -this.control=control;
  -}
  -
  -public void setNote( Object control, int id, Object value ) {
  -if( this.control != control ) return;
  -notes[id]=value;
  -}
  -
  -public String getCurrentStage() {
  -return currentStage;
  -}
  -
  -public void setCurrentStage(String currentStage) {
  -this.currentStage = currentStage;
  -}
  -
  -public Object getNote(Object control, int id ) {
  -if( this.control != control ) return null;
  -return notes[id];
  -}
  -
  -public Hashtable getAttributes(Object control) {
  -return attributes;
   }
   }
   
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2002-12-24 Thread costin
costin  2002/12/24 09:02:55

  Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  When the thread ends, remove it from the list of active threads.
  
  Obtained from: Michael
  
  Revision  ChangesPath
  1.6   +4 -1  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ThreadPool.java   19 Dec 2002 05:45:42 -  1.5
  +++ ThreadPool.java   24 Dec 2002 17:02:54 -  1.6
  @@ -560,7 +560,7 @@
   }
   
   public void run() {
  -
  +  try {
   while(true) {
   try {
/* Wait for work. */
  @@ -626,6 +626,9 @@
p.log.error(Unexpected exception, ie);
   }
   }
  +  } finally {
  +  p.removeThread(Thread.currentThread());
  +  }
   }
   
   /** Run a task
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2002-12-18 Thread costin
costin  2002/12/18 21:45:42

  Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  - use commons-logging directly.
  - remove unused imports ( thanks idea )
  - added a ThreadListener. It'll be used to add
   JMX proxies for the thread pool ( and it can be used to
  get notifications of thread start and end ).
  - added missing getters
  - added a method to list the threads in the pool
  - (experimental) instead of creating Thread, the code
  will create ThreadWithAttributes. This would allow O(1)
  notes to be stored.
  
  I want to add JMX support and make calls to store the
  state of the thread, i.e. what is the thread doing.
  This would allow people to debug hunged threads and
  allow more control.
  
  Revision  ChangesPath
  1.5   +161 -33   
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ThreadPool.java   27 Nov 2002 20:12:17 -  1.4
  +++ ThreadPool.java   19 Dec 2002 05:45:42 -  1.5
  @@ -1,7 +1,4 @@
   /*
  - * $Header$
  - * $Revision$
  - * $Date$
*
* 
*
  @@ -63,11 +60,9 @@
   
   package org.apache.tomcat.util.threads;
   
  -import java.util.zip.*;
  -import java.net.*;
   import java.util.*;
  -import java.io.*;
  -import org.apache.tomcat.util.log.*; 
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   
   /**
* A thread pool that is trying to copy the apache process management.
  @@ -75,6 +70,7 @@
* @author Gal Shachor
*/
   public class ThreadPool  {
  +static Log log = LogFactory.getLog(ThreadPool.class);
   
   /*
* Default values ...
  @@ -130,10 +126,17 @@
   
   static int debug=0;
   
  +/** The threads that are part of the pool.
  + * Key is Thread, value is the ControlRunnable
  + */
  +protected Hashtable threads=new Hashtable();
  +
  +protected Vector listeners=new Vector();
  +
   /**
* Helper object for logging
**/
  -Log loghelper = Log.getLog(tc/ThreadPool, ThreadPool);
  +//Log loghelper = Log.getLog(tc/ThreadPool, ThreadPool);
   
   public ThreadPool() {
   maxThreads  = MAX_THREADS;
  @@ -157,6 +160,10 @@
   monitor = new MonitorRunnable(this);
   }
   
  +public MonitorRunnable getMonitor() {
  +return monitor;
  +}
  +
   public void setMaxThreads(int maxThreads) {
   this.maxThreads = maxThreads;
   }
  @@ -181,6 +188,22 @@
   return maxSpareThreads;
   }
   
  +public int getCurrentThreadCount() {
  +return currentThreadCount;
  +}
  +
  +public int getCurrentThreadsBusy() {
  +return currentThreadsBusy;
  +}
  +
  +public boolean isDaemon() {
  +return isDaemon;
  +}
  +
  +public static int getDebug() {
  +return debug;
  +}
  +
   /** The default is true - the created threads will be
*  in daemon mode. If set to false, the control thread
*  will not be daemon - and will keep the process alive.
  @@ -192,7 +215,31 @@
   public boolean getDaemon() {
   return isDaemon;
   }
  -
  +
  +public void addThread( Thread t, ControlRunnable cr ) {
  +threads.put( t, cr );
  +for( int i=0; ilisteners.size(); i++ ) {
  +ThreadPoolListener tpl=(ThreadPoolListener)listeners.elementAt(i);
  +tpl.threadStart(this, t);
  +}
  +}
  +
  +public void removeThread( Thread t ) {
  +threads.remove(t);
  +for( int i=0; ilisteners.size(); i++ ) {
  +ThreadPoolListener tpl=(ThreadPoolListener)listeners.elementAt(i);
  +tpl.threadEnd(this, t);
  +}
  +}
  +
  +public void addThreadPoolListener( ThreadPoolListener tpl ) {
  +listeners.addElement( tpl );
  +}
  +
  +public Enumeration getThreads(){
  +return threads.keys();
  +}
  +
   //
   // You may wonder what you see here ... basically I am trying
   // to maintain a stack of threads. This way locality in time
  @@ -225,7 +272,7 @@
   int toOpen = currentThreadCount + minSpareThreads;
   openThreads(toOpen);
   } else {
  - logFull(loghelper, currentThreadCount, maxThreads);
  + logFull(log, currentThreadCount, maxThreads);
   // Wait for a thread to become idel.
   while(currentThreadsBusy == currentThreadCount) {
   try {
  @@ -237,7 +284,7 @@
// it'll never 

cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2002-11-27 Thread remm
remm2002/11/27 12:12:17

  Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  - Replace the Vector with an array. The code is equivalent (or at least it
should be).
  - If this is Not Good (TM), -1 and revert ;-)
  - I have questions on the TP and related code. Would it be possible to
consider refactoring it, or is it a bad idea ?
  
  Revision  ChangesPath
  1.4   +13 -16
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ThreadPool.java   2 Jul 2002 19:57:49 -   1.3
  +++ ThreadPool.java   27 Nov 2002 20:12:17 -  1.4
  @@ -87,7 +87,7 @@
   /*
* Where the threads are held.
*/
  -protected Vector pool;
  +protected ControlRunnable[] pool = null;
   
   /*
* A monitor thread that monitors the pool for idel threads.
  @@ -151,6 +151,8 @@
   
   adjustLimits();
   
  +pool = new ControlRunnable[maxThreads];
  +
   openThreads(minSpareThreads);
   monitor = new MonitorRunnable(this);
   }
  @@ -247,8 +249,7 @@
   }
   
   // If we are here it means that there is a free thred. Take it.
  -c = (ControlRunnable)pool.lastElement();
  -pool.removeElement(c);
  +c = pool[currentThreadCount - currentThreadsBusy - 1];
   currentThreadsBusy++;
   }
   c.runIt(r);
  @@ -273,9 +274,9 @@
   stopThePool = true;
   monitor.terminate();
   monitor = null;
  -for(int i = 0 ; i  (currentThreadCount - currentThreadsBusy) ; i++) {
  +for(int i = 0 ; i  (currentThreadCount - currentThreadsBusy - 1) ; 
i++) {
   try {
  -((ControlRunnable)(pool.elementAt(i))).terminate();
  +pool[i].terminate();
   } catch(Throwable t) {
   /*
 * Do nothing... The show must go on, we are shutting
  @@ -304,9 +305,9 @@
maxSpareThreads;
   
   for(int i = 0 ; i  toFree ; i++) {
  -ControlRunnable c = (ControlRunnable)pool.firstElement();
  -pool.removeElement(c);
  +ControlRunnable c = pool[currentThreadCount - currentThreadsBusy - 
1];
   c.terminate();
  +pool[currentThreadCount - currentThreadsBusy - 1] = null;
   currentThreadCount --;
   }
   }
  @@ -324,7 +325,7 @@
   }
   
   currentThreadsBusy--;
  -pool.addElement(c);
  +pool[currentThreadCount - currentThreadsBusy - 1] = c;
   notify();
   }
   
  @@ -382,12 +383,8 @@
   toOpen = maxThreads;
   }
   
  -if(0 == currentThreadCount) {
  -pool = new Vector(toOpen);
  -}
  -
   for(int i = currentThreadCount ; i  toOpen ; i++) {
  -pool.addElement(new ControlRunnable(this));
  +pool[i - currentThreadsBusy] = new ControlRunnable(this);
   }
   
   currentThreadCount = toOpen;
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads ThreadPool.java

2002-07-02 Thread costin

costin  2002/07/02 12:57:49

  Modified:util/java/org/apache/tomcat/util/threads ThreadPool.java
  Log:
  Allow customization of thread.setDaemon().
  
  Previous versions of TP set all the threads in non-daemon mode, but
  this can create restart problems in some cases. However non-daemon mode
  is usefull in some cases
  
  Revision  ChangesPath
  1.3   +19 -4 
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java
  
  Index: ThreadPool.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/threads/ThreadPool.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ThreadPool.java   22 Apr 2002 18:55:56 -  1.2
  +++ ThreadPool.java   2 Jul 2002 19:57:49 -   1.3
  @@ -125,6 +125,9 @@
*/
   protected boolean stopThePool;
   
  +/* Flag to control if the main thread is 'daemon' */
  +protected boolean isDaemon=true;
  +
   static int debug=0;
   
   /**
  @@ -176,6 +179,18 @@
   return maxSpareThreads;
   }
   
  +/** The default is true - the created threads will be
  + *  in daemon mode. If set to false, the control thread
  + *  will not be daemon - and will keep the process alive.
  + */
  +public void setDaemon( boolean b ) {
  +isDaemon=b;
  +}
  +
  +public boolean getDaemon() {
  +return isDaemon;
  +}
  +
   //
   // You may wonder what you see here ... basically I am trying
   // to maintain a stack of threads. This way locality in time
  @@ -395,7 +410,7 @@
   shouldTerminate = false;
   this.p = p;
   t = new Thread(this);
  -t.setDaemon(true);
  +t.setDaemon(p.getDaemon() );
t.setName( MonitorRunnable );
   t.start();
   }
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]