tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1478017 - in /tomcat/trunk/java/org/apache/coyote: ./ http11/
Date Wed, 01 May 2013 14:23:55 GMT
Author: markt
Date: Wed May  1 14:23:55 2013
New Revision: 1478017

URL: http://svn.apache.org/r1478017
Log:
Refactor to simplify support for non-blocking IO across all HTTP
connectors

Modified:
    tomcat/trunk/java/org/apache/coyote/AbstractProcessor.java
    tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
    tomcat/trunk/java/org/apache/coyote/http11/AbstractOutputBuffer.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java
    tomcat/trunk/java/org/apache/coyote/http11/InternalAprOutputBuffer.java
    tomcat/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java
    tomcat/trunk/java/org/apache/coyote/http11/InternalOutputBuffer.java

Modified: tomcat/trunk/java/org/apache/coyote/AbstractProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/AbstractProcessor.java?rev=1478017&r1=1478016&r2=1478017&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/AbstractProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/AbstractProcessor.java Wed May  1 14:23:55 2013
@@ -57,7 +57,6 @@ public abstract class AbstractProcessor<
         response = new Response();
         response.setHook(this);
         request.setResponse(response);
-
     }
 
 

Modified: tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java?rev=1478017&r1=1478016&r2=1478017&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java Wed May  1 14:23:55
2013
@@ -56,12 +56,20 @@ public abstract class AbstractHttp11Proc
 
     protected abstract Log getLog();
 
+
     /**
      * The string manager for this package.
      */
     protected static final StringManager sm =
         StringManager.getManager(Constants.Package);
 
+
+    /**
+     * Output.
+     */
+    protected AbstractOutputBuffer<S> outputBuffer;
+
+
     /*
      * Tracks how many internal filters are in the filter library so they
      * are skipped when looking for pluggable filters.
@@ -184,12 +192,6 @@ public abstract class AbstractHttp11Proc
 
 
     /**
-     * Socket buffering.
-     */
-    protected int socketBuffer = -1;
-
-
-    /**
      * Max saved post size.
      */
     protected int maxSavePostSize = 4 * 1024;
@@ -458,14 +460,14 @@ public abstract class AbstractHttp11Proc
      * Set the socket buffer flag.
      */
     public void setSocketBuffer(int socketBuffer) {
-        this.socketBuffer = socketBuffer;
+        outputBuffer.setSocketBuffer(socketBuffer);
     }
 
     /**
      * Get the socket buffer flag.
      */
     public int getSocketBuffer() {
-        return socketBuffer;
+        return outputBuffer.getSocketBuffer();
     }
 
     /**

Modified: tomcat/trunk/java/org/apache/coyote/http11/AbstractOutputBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/AbstractOutputBuffer.java?rev=1478017&r1=1478016&r2=1478017&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/AbstractOutputBuffer.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/AbstractOutputBuffer.java Wed May  1 14:23:55
2013
@@ -32,7 +32,7 @@ import org.apache.tomcat.util.net.Abstra
 import org.apache.tomcat.util.net.SocketWrapper;
 import org.apache.tomcat.util.res.StringManager;
 
-public abstract class AbstractOutputBuffer<S> implements OutputBuffer{
+public abstract class AbstractOutputBuffer<S> implements OutputBuffer {
 
     // ----------------------------------------------------- Instance Variables
 
@@ -95,9 +95,14 @@ public abstract class AbstractOutputBuff
      */
     protected long byteCount = 0;
 
-    // -------------------------------------------------------------- Variables
+    /**
+     * Socket buffering.
+     */
+    protected int socketBuffer = -1;
 
 
+    // -------------------------------------------------------------- Variables
+
     /**
      * The string manager for this package.
      */
@@ -163,10 +168,25 @@ public abstract class AbstractOutputBuff
     }
 
 
- // --------------------------------------------------- OutputBuffer Methods
+    /**
+     * Set the socket buffer flag.
+     */
+    public void setSocketBuffer(int socketBuffer) {
+        this.socketBuffer = socketBuffer;
+    }
 
 
     /**
+     * Get the socket buffer flag.
+     */
+    public int getSocketBuffer() {
+        return socketBuffer;
+    }
+
+
+    // --------------------------------------------------- OutputBuffer Methods
+
+    /**
      * Write the contents of a byte chunk.
      *
      * @param chunk byte chunk
@@ -548,9 +568,15 @@ public abstract class AbstractOutputBuff
         }
     }
 
-    // --------------------------------------------------------- Public Methods
 
+    //------------------------------------------------------ Non-blocking writes
 
-    public abstract boolean supportsNonBlocking();
+    protected abstract boolean hasDataToWrite();
+    protected abstract void setBlocking(boolean blocking);
+    protected abstract boolean flushBuffer(boolean block) throws IOException;
 
+
+    protected final boolean isReady() {
+        return !hasDataToWrite();
+    }
 }

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java?rev=1478017&r1=1478016&r2=1478017&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java Wed May  1 14:23:55
2013
@@ -82,12 +82,6 @@ public class Http11AprProcessor extends 
 
 
     /**
-     * Output.
-     */
-    protected final InternalAprOutputBuffer outputBuffer;
-
-
-    /**
      * Sendfile data.
      */
     protected AprEndpoint.SendfileData sendfileData = null;

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java?rev=1478017&r1=1478016&r2=1478017&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java Wed May  1 14:23:55
2013
@@ -87,12 +87,6 @@ public class Http11NioProcessor extends 
 
 
     /**
-     * Output.
-     */
-    protected final InternalNioOutputBuffer outputBuffer;
-
-
-    /**
      * Sendfile data.
      */
     protected NioEndpoint.SendfileData sendfileData = null;

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java?rev=1478017&r1=1478016&r2=1478017&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11Processor.java Wed May  1 14:23:55 2013
@@ -74,12 +74,6 @@ public class Http11Processor extends Abs
 
 
     /**
-     * Output.
-     */
-    protected final InternalOutputBuffer outputBuffer;
-
-
-    /**
      * SSL information.
      */
     protected SSLSupport sslSupport;

Modified: tomcat/trunk/java/org/apache/coyote/http11/InternalAprOutputBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/InternalAprOutputBuffer.java?rev=1478017&r1=1478016&r2=1478017&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/InternalAprOutputBuffer.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/InternalAprOutputBuffer.java Wed May  1 14:23:55
2013
@@ -86,11 +86,6 @@ public class InternalAprOutputBuffer ext
     // --------------------------------------------------------- Public Methods
 
     @Override
-    public boolean supportsNonBlocking() {
-        return false;
-    }
-
-    @Override
     public void init(SocketWrapper<Long> socketWrapper,
             AbstractEndpoint endpoint) throws IOException {
 
@@ -214,8 +209,29 @@ public class InternalAprOutputBuffer ext
     }
 
 
-    // ----------------------------------- OutputStreamOutputBuffer Inner Class
+    //------------------------------------------------------ Non-blocking writes
+
+    @Override
+    protected boolean hasDataToWrite() {
+        // TODO
+        return false;
+    }
+
 
+    @Override
+    protected void setBlocking(boolean blocking) {
+        // TODO
+    }
+
+
+    @Override
+    protected boolean flushBuffer(boolean block) throws IOException {
+        // TODO
+        return false;
+    }
+
+
+    // ----------------------------------- OutputStreamOutputBuffer Inner Class
 
     /**
      * This class is an output buffer which will write data to an output

Modified: tomcat/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java?rev=1478017&r1=1478016&r2=1478017&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java Wed May  1 14:23:55
2013
@@ -150,11 +150,6 @@ public class InternalNioOutputBuffer ext
 
     // --------------------------------------------------------- Public Methods
 
-    @Override
-    public boolean supportsNonBlocking() {
-        return true;
-    }
-
     /**
      * Flush the response.
      *
@@ -329,6 +324,7 @@ public class InternalNioOutputBuffer ext
     /**
      * Callback to write data from the buffer.
      */
+    @Override
     protected boolean flushBuffer(boolean block) throws IOException {
 
         //prevent timeout for async,
@@ -420,14 +416,17 @@ public class InternalNioOutputBuffer ext
         }
     }
 
-    //----------------------------------------non blocking writes -----------------
+
+    //------------------------------------------------------ Non-blocking writes
+
+    @Override
     public void setBlocking(boolean blocking) {
         this.blocking = blocking;
         if (blocking)
             bufferedWrite = null;
         else
             bufferedWrite = new LinkedBlockingDeque<>();
-}
+    }
 
     public void setBufferedWriteSize(int bufferedWriteSize) {
         this.bufferedWriteSize = bufferedWriteSize;
@@ -448,6 +447,7 @@ public class InternalNioOutputBuffer ext
         return result;
     }
 
+    @Override
     public boolean hasDataToWrite() {
         return hasMoreDataToFlush() || hasBufferedData();
     }
@@ -455,8 +455,4 @@ public class InternalNioOutputBuffer ext
     public int getBufferedWriteSize() {
         return bufferedWriteSize;
     }
-
-    public boolean isReady() {
-        return !hasDataToWrite();
-    }
 }

Modified: tomcat/trunk/java/org/apache/coyote/http11/InternalOutputBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/InternalOutputBuffer.java?rev=1478017&r1=1478016&r2=1478017&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/InternalOutputBuffer.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/InternalOutputBuffer.java Wed May  1 14:23:55
2013
@@ -81,6 +81,7 @@ public class InternalOutputBuffer extend
     /**
      * Set the socket buffer size.
      */
+    @Override
     public void setSocketBuffer(int socketBufferSize) {
 
         if (socketBufferSize > 500) {
@@ -89,18 +90,12 @@ public class InternalOutputBuffer extend
         } else {
             useSocketBuffer = false;
         }
-
     }
 
 
     // --------------------------------------------------------- Public Methods
 
     @Override
-    public boolean supportsNonBlocking() {
-        return false;
-    }
-
-    @Override
     public void init(SocketWrapper<Socket> socketWrapper,
             AbstractEndpoint endpoint) throws IOException {
 
@@ -222,9 +217,30 @@ public class InternalOutputBuffer extend
     }
 
 
-    // ----------------------------------- OutputStreamOutputBuffer Inner Class
+    //------------------------------------------------------ Non-blocking writes
+
+    @Override
+    protected boolean hasDataToWrite() {
+        // TODO
+        return false;
+    }
 
 
+    @Override
+    protected void setBlocking(boolean blocking) {
+        // TODO
+    }
+
+
+    @Override
+    protected boolean flushBuffer(boolean block) throws IOException {
+        // TODO
+        return false;
+    }
+
+
+    // ----------------------------------- OutputStreamOutputBuffer Inner Class
+
     /**
      * This class is an output buffer which will write data to an output
      * stream.



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


Mime
View raw message