geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject cvs commit: incubator-geronimo/modules/network/src/test/org/apache/geronimo/network/protocol/control ControlProtocolTest.java
Date Thu, 08 Jul 2004 22:07:55 GMT
djencks     2004/07/08 15:07:55

  Modified:    modules/core project.xml
               modules/core/src/java/org/apache/geronimo/pool
                        ThreadPool.java
               modules/security/src/test/org/apache/geronimo/security/network/protocol
                        SubjectCarryingProtocolTest.java
               modules/network/src/java/org/apache/geronimo/network
                        SelectorManager.java
               modules/network/src/java/org/apache/geronimo/network/protocol
                        BufferProtocol.java GSSAPIClientProtocol.java
               modules/network/src/test/org/apache/geronimo/network/protocol
                        DatagramProtocolTest.java GSSAPIProtocolTest.java
                        ProtocolStackTest.java
                        SocketProtocolStressTest.java
                        SocketProtocolTest.java
               modules/network/src/test/org/apache/geronimo/network/protocol/control
                        ControlProtocolTest.java
  Log:
  Change ThreadPool to use a queue for waiting tasks and to have a hard size limit
  
  Revision  Changes    Path
  1.56      +5 -5      incubator-geronimo/modules/core/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/project.xml,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- project.xml	24 Jun 2004 20:59:46 -0000	1.55
  +++ project.xml	8 Jul 2004 22:07:54 -0000	1.56
  @@ -6,16 +6,16 @@
       Licensed under the Apache License, Version 2.0 (the "License");
       you may not use this file except in compliance with the License.
       You may obtain a copy of the License at
  -  
  +
          http://www.apache.org/licenses/LICENSE-2.0
  -  
  +
       Unless required by applicable law or agreed to in writing, software
       distributed under the License is distributed on an "AS IS" BASIS,
       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       See the License for the specific language governing permissions and
       limitations under the License.
   -->
  -  
  +
   
   <!-- $Revision$ $Date$ -->
   
  @@ -141,7 +141,7 @@
           <dependency>
               <groupId>concurrent</groupId>
               <artifactId>concurrent</artifactId>
  -            <version>1.3.2</version>
  +            <version>1.3.4</version>
           </dependency>
   
           <dependency>
  
  
  
  1.2       +42 -27    incubator-geronimo/modules/core/src/java/org/apache/geronimo/pool/ThreadPool.java
  
  Index: ThreadPool.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/pool/ThreadPool.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ThreadPool.java	8 Jul 2004 05:13:29 -0000	1.1
  +++ ThreadPool.java	8 Jul 2004 22:07:54 -0000	1.2
  @@ -20,6 +20,7 @@
   import EDU.oswego.cs.dl.util.concurrent.Executor;
   import EDU.oswego.cs.dl.util.concurrent.PooledExecutor;
   import EDU.oswego.cs.dl.util.concurrent.ThreadFactory;
  +import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.geronimo.gbean.GBeanInfo;
  @@ -31,20 +32,20 @@
   /**
    * @version $Revision$ $Date$
    */
  -public class ThreadPool implements GBeanLifecycle {
  +public class ThreadPool implements Executor, ExecutorFactory, GBeanLifecycle {
   
       static private final Log log = LogFactory.getLog(ThreadPool.class);
   
  -    private PooledExecutor workManager;
  +    private PooledExecutor executor;
       private long keepAliveTime;
  -    private int minimumPoolSize;
  +    private int poolSize;
       private int maximumPoolSize;
       private String poolName;
   
       private int nextWorkerID = 0;
   
  -    public Executor getWorkManager() {
  -        return workManager;
  +    public Executor getExecutor() {
  +        return new ExecutorWrapper(executor);
       }
   
       public long getKeepAliveTime() {
  @@ -55,26 +56,22 @@
           this.keepAliveTime = keepAliveTime;
       }
   
  -    public int getMinimumPoolSize() {
  -        return minimumPoolSize;
  +    public int getPoolSize() {
  +        return poolSize;
       }
   
  -    public void setMinimumPoolSize(int minimumPoolSize) {
  -        this.minimumPoolSize = minimumPoolSize;
  -    }
  -
  -    public int getMaximumPoolSize() {
  -        return maximumPoolSize;
  -    }
  -
  -    public void setMaximumPoolSize(int maximumPoolSize) {
  -        this.maximumPoolSize = maximumPoolSize;
  +    public void setPoolSize(int poolSize) {
  +        this.poolSize = poolSize;
       }
   
       public String getPoolName() {
           return poolName;
       }
   
  +    public void execute(Runnable command) throws InterruptedException {
  +        executor.execute(command);
  +    }
  +
       public void setPoolName(String poolName) {
           this.poolName = poolName;
       }
  @@ -84,23 +81,25 @@
       }
   
       public void doStart() throws WaitingException, Exception {
  -        PooledExecutor p = new PooledExecutor();
  +        PooledExecutor p = new PooledExecutor(new LinkedQueue(), poolSize);
           p.setKeepAliveTime(keepAliveTime);
  -        p.setMinimumPoolSize(minimumPoolSize);
  -        p.setMaximumPoolSize(maximumPoolSize);
  +        //I think this does nothing with a LinkedQueue present
  +        p.setMaximumPoolSize(poolSize);
           p.setThreadFactory(new ThreadFactory() {
               public Thread newThread(Runnable arg0) {
                   return new Thread(arg0, poolName + " " + getNextWorkerID());
               }
           });
  +        //I think this does nothing with a LinkedQueue present
  +        p.waitWhenBlocked();
   
  -        workManager = p;
  +        executor = p;
   
           log.info("Thread pool " + poolName + " started");
       }
   
       public void doStop() throws WaitingException, Exception {
  -        workManager.shutdownNow();
  +        executor.shutdownNow();
           log.info("Thread pool " + poolName + " stopped");
       }
   
  @@ -108,7 +107,19 @@
           try {
               doStop();
           } catch (Exception e) {
  -            log.error("Failded to shutdown", e);
  +            log.error("Failed to shutdown", e);
  +        }
  +    }
  +
  +    private static class ExecutorWrapper implements Executor {
  +        private final Executor delegate;
  +
  +        public ExecutorWrapper(Executor delegate) {
  +            this.delegate = delegate;
  +        }
  +
  +        public void execute(Runnable command) throws InterruptedException {
  +            delegate.execute(command);
           }
       }
   
  @@ -118,10 +129,12 @@
           GBeanInfoFactory infoFactory = new GBeanInfoFactory(ThreadPool.class);
   
           infoFactory.addAttribute("keepAliveTime", long.class, true);
  -        infoFactory.addAttribute("minimumPoolSize", int.class, true);
  -        infoFactory.addAttribute("maximumPoolSize", int.class, true);
  +        infoFactory.addAttribute("poolSize", int.class, true);
           infoFactory.addAttribute("poolName", String.class, true);
  -        infoFactory.addOperation("getWorkManager");
  +        infoFactory.addOperation("getExecutor");
  +
  +        infoFactory.addInterface(Executor.class);
  +        infoFactory.addInterface(ExecutorFactory.class);
   
           GBEAN_INFO = infoFactory.getBeanInfo();
       }
  @@ -129,4 +142,6 @@
       public static GBeanInfo getGBeanInfo() {
           return GBEAN_INFO;
       }
  +
  +
   }
  
  
  
  1.13      +3 -5      incubator-geronimo/modules/security/src/test/org/apache/geronimo/security/network/protocol/SubjectCarryingProtocolTest.java
  
  Index: SubjectCarryingProtocolTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/security/src/test/org/apache/geronimo/security/network/protocol/SubjectCarryingProtocolTest.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- SubjectCarryingProtocolTest.java	8 Jul 2004 05:13:29 -0000	1.12
  +++ SubjectCarryingProtocolTest.java	8 Jul 2004 22:07:54 -0000	1.13
  @@ -96,8 +96,7 @@
           public Object run() throws Exception {
               ThreadPool tp = new ThreadPool();
               tp.setKeepAliveTime(1 * 1000);
  -            tp.setMinimumPoolSize(1);
  -            tp.setMaximumPoolSize(5);
  +            tp.setPoolSize(1);
               tp.setPoolName("Client TP");
               tp.doStart();
   
  @@ -176,8 +175,7 @@
           public Object run() throws Exception {
               ThreadPool tp = new ThreadPool();
               tp.setKeepAliveTime(1 * 1000);
  -            tp.setMinimumPoolSize(1);
  -            tp.setMaximumPoolSize(5);
  +            tp.setPoolSize(1);
               tp.setPoolName("Server TP");
               tp.doStart();
   
  
  
  
  1.13      +4 -4      incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/SelectorManager.java
  
  Index: SelectorManager.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/SelectorManager.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- SelectorManager.java	8 Jul 2004 05:13:29 -0000	1.12
  +++ SelectorManager.java	8 Jul 2004 22:07:54 -0000	1.13
  @@ -183,17 +183,17 @@
                           if (key.isReadable()) {
                               log.trace("-OP_READ " + key);
                               key.interestOps(key.interestOps() & (~SelectionKey.OP_READ));
  -                            threadPool.getWorkManager().execute(new Event(key, SelectionKey.OP_READ));
  +                            threadPool.getExecutor().execute(new Event(key, SelectionKey.OP_READ));
                           }
                           if (key.isWritable()) {
                               log.trace("-OP_WRITE " + key);
                               key.interestOps(key.interestOps() & (~SelectionKey.OP_WRITE));
  -                            threadPool.getWorkManager().execute(new Event(key, SelectionKey.OP_WRITE));
  +                            threadPool.getExecutor().execute(new Event(key, SelectionKey.OP_WRITE));
                           }
                           if (key.isAcceptable()) {
                               log.trace("-OP_ACCEPT " + key);
                               key.interestOps(key.interestOps() & (~SelectionKey.OP_ACCEPT));
  -                            threadPool.getWorkManager().execute(new Event(key, SelectionKey.OP_ACCEPT));
  +                            threadPool.getExecutor().execute(new Event(key, SelectionKey.OP_ACCEPT));
                           }
   
                           i.remove(); // Remove the key from the set of selected keys
  
  
  
  1.5       +3 -3      incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol/BufferProtocol.java
  
  Index: BufferProtocol.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol/BufferProtocol.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BufferProtocol.java	8 Jul 2004 05:13:29 -0000	1.4
  +++ BufferProtocol.java	8 Jul 2004 22:07:54 -0000	1.5
  @@ -56,7 +56,7 @@
           log.trace("Starting");
           running = true;
           try {
  -            threadPool.getWorkManager().execute(new Runnable() {
  +            threadPool.getExecutor().execute(new Runnable() {
                   public void run() {
                       try {
                           while (running) {
  @@ -70,7 +70,7 @@
                       }
                   }
               });
  -            threadPool.getWorkManager().execute(new Runnable() {
  +            threadPool.getExecutor().execute(new Runnable() {
                   public void run() {
                       try {
                           while (running) {
  
  
  
  1.6       +3 -3      incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol/GSSAPIClientProtocol.java
  
  Index: GSSAPIClientProtocol.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol/GSSAPIClientProtocol.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- GSSAPIClientProtocol.java	8 Jul 2004 05:13:29 -0000	1.5
  +++ GSSAPIClientProtocol.java	8 Jul 2004 22:07:54 -0000	1.6
  @@ -119,7 +119,7 @@
               context.requestInteg(integrity);
               context.requestCredDeleg(true);
   
  -            threadPool.getWorkManager().execute(new Runnable() {
  +            threadPool.getExecutor().execute(new Runnable() {
                   public void run() {
                       try {
                           byte[] token = new byte[0];
  @@ -164,7 +164,7 @@
                       if (context.getMutualAuthState()) log.trace("MUTUAL AUTHENTICATION
IN PLACE");
                       if (context.getConfState()) log.trace("CONFIDENTIALITY IN PLACE");
                       if (context.getIntegState()) log.trace("INTEGRITY IN PLACE");
  -                    
  +
                       log.trace("RELEASING " + startupLatch);
                       startupLatch.release();
                       log.trace("RELEASED " + startupLatch);
  
  
  
  1.6       +3 -5      incubator-geronimo/modules/network/src/test/org/apache/geronimo/network/protocol/DatagramProtocolTest.java
  
  Index: DatagramProtocolTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/network/src/test/org/apache/geronimo/network/protocol/DatagramProtocolTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DatagramProtocolTest.java	8 Jul 2004 05:13:28 -0000	1.5
  +++ DatagramProtocolTest.java	8 Jul 2004 22:07:54 -0000	1.6
  @@ -37,8 +37,7 @@
       public void test() throws Exception {
           ThreadPool tp = new ThreadPool();
           tp.setKeepAliveTime(100);
  -        tp.setMinimumPoolSize(5);
  -        tp.setMaximumPoolSize(25);
  +        tp.setPoolSize(5);
           tp.setPoolName("TP");
           tp.doStart();
   
  @@ -118,8 +117,7 @@
       public void testClone() throws Exception {
           ThreadPool tp = new ThreadPool();
           tp.setKeepAliveTime(100);
  -        tp.setMinimumPoolSize(5);
  -        tp.setMaximumPoolSize(25);
  +        tp.setPoolSize(5);
           tp.setPoolName("TP");
           tp.doStart();
   
  
  
  
  1.7       +3 -5      incubator-geronimo/modules/network/src/test/org/apache/geronimo/network/protocol/GSSAPIProtocolTest.java
  
  Index: GSSAPIProtocolTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/network/src/test/org/apache/geronimo/network/protocol/GSSAPIProtocolTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- GSSAPIProtocolTest.java	8 Jul 2004 05:13:28 -0000	1.6
  +++ GSSAPIProtocolTest.java	8 Jul 2004 22:07:54 -0000	1.7
  @@ -85,8 +85,7 @@
           public Object run() throws Exception {
               ThreadPool tp = new ThreadPool();
               tp.setKeepAliveTime(1 * 1000);
  -            tp.setMinimumPoolSize(1);
  -            tp.setMaximumPoolSize(5);
  +            tp.setPoolSize(1);
               tp.setPoolName("Client TP");
               tp.doStart();
   
  @@ -166,8 +165,7 @@
           public Object run() throws Exception {
               ThreadPool tp = new ThreadPool();
               tp.setKeepAliveTime(1 * 1000);
  -            tp.setMinimumPoolSize(1);
  -            tp.setMaximumPoolSize(5);
  +            tp.setPoolSize(1);
               tp.setPoolName("Server TP");
               tp.doStart();
   
  
  
  
  1.8       +3 -4      incubator-geronimo/modules/network/src/test/org/apache/geronimo/network/protocol/ProtocolStackTest.java
  
  Index: ProtocolStackTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/network/src/test/org/apache/geronimo/network/protocol/ProtocolStackTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ProtocolStackTest.java	8 Jul 2004 05:13:28 -0000	1.7
  +++ ProtocolStackTest.java	8 Jul 2004 22:07:54 -0000	1.8
  @@ -39,8 +39,7 @@
       public void test() throws Exception {
           ThreadPool tp = new ThreadPool();
           tp.setKeepAliveTime(1 * 1000);
  -        tp.setMinimumPoolSize(5);
  -        tp.setMaximumPoolSize(25);
  +        tp.setPoolSize(5);
           tp.setPoolName("TP");
           tp.doStart();
   
  @@ -157,7 +156,7 @@
   
           tp.doStop();
       }
  -    
  +
       static volatile long id = 0;
   
       public DatagramDownPacket getDatagramPacket() {
  
  
  
  1.10      +2 -3      incubator-geronimo/modules/network/src/test/org/apache/geronimo/network/protocol/SocketProtocolStressTest.java
  
  Index: SocketProtocolStressTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/network/src/test/org/apache/geronimo/network/protocol/SocketProtocolStressTest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SocketProtocolStressTest.java	8 Jul 2004 05:13:28 -0000	1.9
  +++ SocketProtocolStressTest.java	8 Jul 2004 22:07:54 -0000	1.10
  @@ -101,8 +101,7 @@
   
           tp = new ThreadPool();
           tp.setKeepAliveTime(60 * 1000);
  -        tp.setMinimumPoolSize(5);
  -        tp.setMaximumPoolSize(25);
  +        tp.setPoolSize(5);
           tp.setPoolName("TP");
           tp.doStart();
   
  
  
  
  1.8       +2 -3      incubator-geronimo/modules/network/src/test/org/apache/geronimo/network/protocol/SocketProtocolTest.java
  
  Index: SocketProtocolTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/network/src/test/org/apache/geronimo/network/protocol/SocketProtocolTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SocketProtocolTest.java	8 Jul 2004 05:13:28 -0000	1.7
  +++ SocketProtocolTest.java	8 Jul 2004 22:07:54 -0000	1.8
  @@ -40,8 +40,7 @@
       public void test() throws Exception {
           ThreadPool tp = new ThreadPool();
           tp.setKeepAliveTime(1 * 1000);
  -        tp.setMinimumPoolSize(5);
  -        tp.setMaximumPoolSize(25);
  +        tp.setPoolSize(5);
           tp.setPoolName("TP");
           tp.doStart();
   
  
  
  
  1.9       +2 -3      incubator-geronimo/modules/network/src/test/org/apache/geronimo/network/protocol/control/ControlProtocolTest.java
  
  Index: ControlProtocolTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/network/src/test/org/apache/geronimo/network/protocol/control/ControlProtocolTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ControlProtocolTest.java	8 Jul 2004 05:13:29 -0000	1.8
  +++ ControlProtocolTest.java	8 Jul 2004 22:07:54 -0000	1.9
  @@ -49,8 +49,7 @@
       public void test() throws Exception {
           ThreadPool tp = new ThreadPool();
           tp.setKeepAliveTime(100 * 1000);
  -        tp.setMinimumPoolSize(5);
  -        tp.setMaximumPoolSize(25);
  +        tp.setPoolSize(5);
           tp.setPoolName("TP");
           tp.doStart();
   
  
  
  

Mime
View raw message