You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fh...@apache.org on 2003/12/20 01:48:52 UTC

cvs commit: jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp ReplicationListener.java ReplicationTransmitter.java TcpReplicationThread.java ThreadPool.java WorkerThread.java

fhanik      2003/12/19 16:48:52

  Modified:    modules/cluster/src/share/org/apache/catalina/cluster/io
                        XByteBuffer.java
               modules/cluster/src/share/org/apache/catalina/cluster/tcp
                        ReplicationListener.java
                        ReplicationTransmitter.java
                        TcpReplicationThread.java ThreadPool.java
                        WorkerThread.java
  Log:
  removed a lot of synchronization that created overhead.
  
  Revision  Changes    Path
  1.4       +10 -10    jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/io/XByteBuffer.java
  
  Index: XByteBuffer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/io/XByteBuffer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XByteBuffer.java	19 Dec 2003 21:22:13 -0000	1.3
  +++ XByteBuffer.java	20 Dec 2003 00:48:52 -0000	1.4
  @@ -128,7 +128,7 @@
        * Returns the bytes in the buffer, in its exact length
        * @return
        */
  -    public synchronized byte[] getBytes() {
  +    public byte[] getBytes() {
           byte[] b = new byte[bufSize];
           System.arraycopy(buf,0,b,0,bufSize);
           return b;
  @@ -137,7 +137,7 @@
       /**
        * Resets the buffer
        */
  -    public synchronized void clear() {
  +    public void clear() {
           bufSize = 0;
       }
   
  @@ -149,7 +149,7 @@
        * @param len - the number of bytes to append.
        * @return true if the data was appended correctly. Returns false if the package is incorrect, ie missing header or something, or the length of data is 0
        */
  -    public synchronized boolean append(byte[] b, int off, int len) {
  +    public boolean append(byte[] b, int off, int len) {
           if ((off < 0) || (off > b.length) || (len < 0) ||
               ((off + len) > b.length) || ((off + len) < 0))  {
               throw new IndexOutOfBoundsException();
  @@ -180,7 +180,7 @@
        * within the buffer
        * @return - true if a complete package (header,size,data,footer) exists within the buffer
        */
  -    protected synchronized int packageExists()
  +    protected int packageExists()
       {
           int pos = START_DATA.length;
           //first check start header
  @@ -204,7 +204,7 @@
        * Method to check if a package exists in this byte buffer.
        * @return - true if a complete package (header,size,data,footer) exists within the buffer
        */
  -    public synchronized boolean doesPackageExist()  {
  +    public boolean doesPackageExist()  {
           return (packageExists()>0);
       }//doesPackageExist
   
  @@ -214,7 +214,7 @@
        * @param clearFromBuffer - if true, the package will be removed from the byte buffer
        * @return - returns the actual message bytes (header, size and footer not included).
        */
  -    public synchronized byte[] extractPackage(boolean clearFromBuffer) throws java.io.IOException {
  +    public byte[] extractPackage(boolean clearFromBuffer) throws java.io.IOException {
           int size = packageExists();
           if ( size == 0 ) throw new java.lang.IllegalStateException("No package exists in XByteBuffer");
           byte[] data = new byte[size];
  
  
  
  1.7       +8 -5      jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationListener.java
  
  Index: ReplicationListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationListener.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ReplicationListener.java	18 Dec 2003 04:20:15 -0000	1.6
  +++ ReplicationListener.java	20 Dec 2003 00:48:52 -0000	1.7
  @@ -229,8 +229,11 @@
               // thread becomes available.  This design could
               // be improved.
               return;
  +        } else {
  +            // invoking this wakes up the worker thread then returns
  +            worker.serviceChannel(key, synchronous);
  +            return;
           }
  -        // invoking this wakes up the worker thread then returns
  -        worker.serviceChannel (key,synchronous);
       }
  +
   }
  
  
  
  1.11      +4 -4      jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java
  
  Index: ReplicationTransmitter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ReplicationTransmitter.java	19 Dec 2003 21:29:22 -0000	1.10
  +++ ReplicationTransmitter.java	20 Dec 2003 00:48:52 -0000	1.11
  @@ -123,7 +123,7 @@
           }//while
       }//stop
   
  -    public synchronized IDataSender[] getSenders()
  +    public IDataSender[] getSenders()
       {
           java.util.Iterator i = map.entrySet().iterator();
           java.util.Vector v = new java.util.Vector();
  
  
  
  1.5       +4 -4      jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/TcpReplicationThread.java
  
  Index: TcpReplicationThread.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/TcpReplicationThread.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TcpReplicationThread.java	19 Dec 2003 21:22:13 -0000	1.4
  +++ TcpReplicationThread.java	20 Dec 2003 00:48:52 -0000	1.5
  @@ -156,7 +156,7 @@
        * re-enables OP_READ and calls wakeup() on the selector
        * so the selector will resume watching this channel.
        */
  -    void drainChannel (SelectionKey key)
  +    private void drainChannel (SelectionKey key)
           throws Exception
       {
           boolean packetReceived=false;
  
  
  
  1.3       +8 -7      jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ThreadPool.java
  
  Index: ThreadPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ThreadPool.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ThreadPool.java	18 Apr 2003 02:51:24 -0000	1.2
  +++ ThreadPool.java	20 Dec 2003 00:48:52 -0000	1.3
  @@ -93,6 +93,7 @@
               // set thread name for debugging, start it
               thread.setName (threadClass.getName()+"[" + (i + 1)+"]");
               thread.setDaemon(true);
  +            thread.setPriority(Thread.MAX_PRIORITY);
               thread.start();
   
               idle.add (thread);
  @@ -106,11 +107,11 @@
       {
           WorkerThread worker = null;
   
  -        synchronized (idle) {
  +        //synchronized (idle) {
               if (idle.size() > 0) {
                   worker = (WorkerThread) idle.remove (0);
               }
  -        }
  +        //}
   
           return (worker);
       }
  @@ -121,8 +122,8 @@
        */
       void returnWorker (WorkerThread worker)
       {
  -        synchronized (idle) {
  +        //synchronized (idle) {
               idle.add (worker);
  -        }
  +        //}
       }
   }
  
  
  
  1.4       +6 -6      jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/WorkerThread.java
  
  Index: WorkerThread.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/modules/cluster/src/share/org/apache/catalina/cluster/tcp/WorkerThread.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- WorkerThread.java	18 Apr 2003 02:51:24 -0000	1.3
  +++ WorkerThread.java	20 Dec 2003 00:48:52 -0000	1.4
  @@ -71,12 +71,12 @@
       protected ThreadPool pool;
       protected boolean doRun = true;
   
  -   
  +
       public void setPool(ThreadPool pool) {
  -        this.pool = pool;        
  +        this.pool = pool;
       }
   
  -    public synchronized void close()
  +    public void close()
       {
           doRun = false;
           notify();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org