hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r547977 - in /jakarta/httpcomponents/httpcore/trunk: ./ module-nio/src/main/java/org/apache/http/impl/nio/reactor/ module-nio/src/main/java/org/apache/http/nio/params/
Date Sat, 16 Jun 2007 20:34:31 GMT
Author: olegk
Date: Sat Jun 16 13:34:30 2007
New Revision: 547977

URL: http://svn.apache.org/viewvc?view=rev&rev=547977
Log:
HTTPCORE-63: Made I/O select interval configurable for all default I/O reactor implementations

Contributed by Oleg Kalnichevski and Anders Wallgren <anders_wallgren at alum.mit.edu>

Modified:
    jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/params/HttpNIOParams.java

Modified: jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt?view=diff&rev=547977&r1=547976&r2=547977
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt (original)
+++ jakarta/httpcomponents/httpcore/trunk/RELEASE_NOTES.txt Sat Jun 16 13:34:30 2007
@@ -1,5 +1,14 @@
 Changes since 4.0 Alpha 4
 
+* [HTTPCORE-63] Made I/O select interval configurable for all default I/O
+  reactor implementations.
+  Contributed by Oleg Kalnichevski <olegk at apache.org> and 
+  Anders Wallgren <anders_wallgren at alum.mit.edu>
+
+* [HTTPCORE-82] Revised linking of HttpParams to reduce potential for misuse. 
+  Method #setDefaults() removed from the HttpParams interface.
+  Contributed by Roland Weber <rolandw at apache.org>
+
 * [HTTPCORE-81]: Maximum line length and maximum header counts parameters are now 
   correctly enforced in both base and NIO modules. Fixed maximum line length check
   when parsing folded header lines.

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java?view=diff&rev=547977&r1=547976&r2=547977
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
Sat Jun 16 13:34:30 2007
@@ -40,12 +40,13 @@
 
 public abstract class AbstractMultiworkerIOReactor implements IOReactor {
 
+    private final long selectTimeout;
     private final int workerCount;
     private final ThreadFactory threadFactory;
     private final BaseIOReactor[] ioReactors;
     private final Worker[] workers;
     private final Thread[] threads;
-
+    
     private volatile boolean shutdown;
     
     private int currentWorker = 0;
@@ -58,6 +59,7 @@
         if (workerCount <= 0) {
             throw new IllegalArgumentException("Worker count may not be negative or zero");
         }
+        this.selectTimeout = selectTimeout;
         this.workerCount = workerCount;
         if (threadFactory != null) {
             this.threadFactory = threadFactory;
@@ -72,6 +74,10 @@
         this.threads = new Thread[workerCount];
     }
 
+    protected long getSelectTimeout() {
+        return this.selectTimeout;
+    }
+    
     protected void startWorkers(final IOEventDispatch eventDispatch) {
         for (int i = 0; i < this.workerCount; i++) {
             BaseIOReactor ioReactor = this.ioReactors[i];

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java?view=diff&rev=547977&r1=547976&r2=547977
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultConnectingIOReactor.java
Sat Jun 16 13:34:30 2007
@@ -45,6 +45,7 @@
 import java.util.Set;
 
 import org.apache.http.util.concurrent.ThreadFactory;
+import org.apache.http.nio.params.HttpNIOParams;
 import org.apache.http.nio.reactor.ConnectingIOReactor;
 import org.apache.http.nio.reactor.IOEventDispatch;
 import org.apache.http.nio.reactor.IOReactorException;
@@ -56,8 +57,6 @@
 public class DefaultConnectingIOReactor extends AbstractMultiworkerIOReactor 
         implements ConnectingIOReactor {
 
-    public static int TIMEOUT_CHECK_INTERVAL = 1000;
-    
     private volatile boolean closed = false;
     
     private final HttpParams params;
@@ -70,10 +69,7 @@
             int workerCount, 
             final ThreadFactory threadFactory,
             final HttpParams params) throws IOReactorException {
-        super(TIMEOUT_CHECK_INTERVAL, workerCount, threadFactory);
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        super(HttpNIOParams.getSelectInterval(params), workerCount, threadFactory);
         this.params = params;
         this.requestQueue = new SessionRequestQueue();
         this.lastTimeoutCheck = System.currentTimeMillis();
@@ -99,7 +95,7 @@
         for (;;) {
             int readyCount;
             try {
-                readyCount = this.selector.select(TIMEOUT_CHECK_INTERVAL);
+                readyCount = this.selector.select(getSelectTimeout());
             } catch (InterruptedIOException ex) {
                 throw ex;
             } catch (IOException ex) {
@@ -117,7 +113,7 @@
             }
             
             long currentTime = System.currentTimeMillis();
-            if( (currentTime - this.lastTimeoutCheck) >= TIMEOUT_CHECK_INTERVAL) {
+            if( (currentTime - this.lastTimeoutCheck) >= getSelectTimeout()) {
                 this.lastTimeoutCheck = currentTime;
                 Set keys = this.selector.keys();
                 if (keys != null) {

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java?view=diff&rev=547977&r1=547976&r2=547977
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java
Sat Jun 16 13:34:30 2007
@@ -44,6 +44,7 @@
 import java.util.Set;
 
 import org.apache.http.util.concurrent.ThreadFactory;
+import org.apache.http.nio.params.HttpNIOParams;
 import org.apache.http.nio.reactor.IOEventDispatch;
 import org.apache.http.nio.reactor.IOReactorException;
 import org.apache.http.nio.reactor.IOReactorExceptionHandler;
@@ -54,8 +55,6 @@
 public class DefaultListeningIOReactor extends AbstractMultiworkerIOReactor 
         implements ListeningIOReactor {
 
-    public static int TIMEOUT_CHECK_INTERVAL = 1000;
-    
     private volatile boolean closed = false;
     
     private final HttpParams params;
@@ -67,10 +66,7 @@
             int workerCount, 
             final ThreadFactory threadFactory,
             final HttpParams params) throws IOReactorException {
-        super(TIMEOUT_CHECK_INTERVAL, workerCount, threadFactory);
-        if (params == null) {
-            throw new IllegalArgumentException("HTTP parameters may not be null");
-        }
+        super(HttpNIOParams.getSelectInterval(params), workerCount, threadFactory);
         this.params = params;
         try {
             this.selector = Selector.open();
@@ -99,7 +95,7 @@
 
             int readyCount;
             try {
-                readyCount = this.selector.select(TIMEOUT_CHECK_INTERVAL);
+                readyCount = this.selector.select(getSelectTimeout());
             } catch (InterruptedIOException ex) {
                 throw ex;
             } catch (IOException ex) {

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/params/HttpNIOParams.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/params/HttpNIOParams.java?view=diff&rev=547977&r1=547976&r2=547977
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/params/HttpNIOParams.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/params/HttpNIOParams.java
Sat Jun 16 13:34:30 2007
@@ -55,7 +55,14 @@
     public static final String CONTENT_BUFFER_SIZE = "http.nio.content-buffer-size"; 
 
     /**
+     * Determines the time interval in milliseconds at which the I/O reactor wakes up 
+     * to check for timed out sessions and session requests.
+     * <p>
+     * This parameter expects a value of type {@link Long}.
+     * </p>
      */
+    public static final String SELECT_INTERVAL = "http.nio.select-interval"; 
+
     private HttpNIOParams() {
         super();
     }
@@ -72,6 +79,20 @@
             throw new IllegalArgumentException("HTTP parameters may not be null");
         }
         params.setIntParameter(CONTENT_BUFFER_SIZE, size);
+    }
+
+    public static long getSelectInterval(final HttpParams params) {
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        return params.getLongParameter(SELECT_INTERVAL, 1000);
+    }
+    
+    public static void setSelectInterval(final HttpParams params, long ms) {
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        params.setLongParameter(SELECT_INTERVAL, ms);
     }
 
 }



Mime
View raw message