hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r755683 - in /httpcomponents/httpcore/branches/ibm_compat_branch: ./ httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/ httpcore-nio/src/main/java/org/apache/http/nio/params/
Date Wed, 18 Mar 2009 18:13:04 GMT
Author: olegk
Date: Wed Mar 18 18:13:03 2009
New Revision: 755683

URL: http://svn.apache.org/viewvc?rev=755683&view=rev
Log:
HTTPCORE-155: Compatibility mode with IBM JRE and other JREs with naive (broken) implementation of SelectionKey.

Contributed by Marc Beyerle <marc.beyerle at de.ibm.com> 

Added:
    httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/InterestOpEntry.java   (with props)
Modified:
    httpcomponents/httpcore/branches/ibm_compat_branch/RELEASE_NOTES.txt
    httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java
    httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
    httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java
    httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
    httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/nio/params/NIOReactorPNames.java
    httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/nio/params/NIOReactorParams.java

Modified: httpcomponents/httpcore/branches/ibm_compat_branch/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/ibm_compat_branch/RELEASE_NOTES.txt?rev=755683&r1=755682&r2=755683&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/ibm_compat_branch/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpcore/branches/ibm_compat_branch/RELEASE_NOTES.txt Wed Mar 18 18:13:03 2009
@@ -1,5 +1,8 @@
 Changes since 4.0
 -------------------
+* [HTTPCORE-155] Compatibility mode with IBM JRE and other JREs with naive (broken) implementation 
+  of SelectionKey.
+  Contributed by Marc Beyerle <marc.beyerle at de.ibm.com> 
 
 * [HTTPCORE-191] Blocking HTTP connections are now capable of correctly preserving their internal 
   state on SocketTimeoutExceptions, which makes it possible to continue reading from the connection 

Modified: httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java?rev=755683&r1=755682&r2=755683&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java (original)
+++ httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractIOReactor.java Wed Mar 18 18:13:03 2009
@@ -40,9 +40,11 @@
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
 import java.nio.channels.SocketChannel;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Queue;
 import java.util.Set;
 import java.util.concurrent.ConcurrentLinkedQueue;
@@ -53,10 +55,10 @@
 import org.apache.http.nio.reactor.IOSession;
 
 /**
- * Generic implementation of {@link IOReactor} that can used as a subclass 
+ * Generic implementation of {@link IOReactor} that can used as a subclass
  * for more specialized I/O reactors. It is based on a single {@link Selector}
  * instance.
- * 
+ *
  *
  * @version $Revision$
  *
@@ -65,27 +67,31 @@
 public abstract class AbstractIOReactor implements IOReactor {
 
     private volatile IOReactorStatus status;
-    
+
     private final Object shutdownMutex;
     private final long selectTimeout;
+    private final boolean interestOpsQueueing;
     private final Selector selector;
     private final Set<IOSession> sessions;
+    private final List<InterestOpEntry> interestOpsQueue;
     private final Queue<IOSession> closedSessions;
     private final Queue<ChannelEntry> newChannels;
-    
+
     /**
      * Creates new AbstractIOReactor instance.
-     * 
+     *
      * @param selectTimeout the select timeout.
-     * @throws IOReactorException in case if a non-recoverable I/O error. 
+     * @throws IOReactorException in case if a non-recoverable I/O error.
      */
-    public AbstractIOReactor(long selectTimeout) throws IOReactorException {
+    public AbstractIOReactor(long selectTimeout, boolean interestOpsQueueing) throws IOReactorException {
         super();
         if (selectTimeout <= 0) {
             throw new IllegalArgumentException("Select timeout may not be negative or zero");
         }
         this.selectTimeout = selectTimeout;
+        this.interestOpsQueueing = interestOpsQueueing;
         this.sessions = Collections.synchronizedSet(new HashSet<IOSession>());
+        this.interestOpsQueue = new ArrayList<InterestOpEntry>();
         this.closedSessions = new ConcurrentLinkedQueue<IOSession>();
         this.newChannels = new ConcurrentLinkedQueue<ChannelEntry>();
         try {
@@ -101,16 +107,16 @@
      * Triggered when the key signals {@link SelectionKey#OP_ACCEPT} readiness.
      * <p>
      * Super-classes can implement this method to react to the event.
-     * 
+     *
      * @param key the selection key.
      */
     protected abstract void acceptable(SelectionKey key);
-    
+
     /**
      * Triggered when the key signals {@link SelectionKey#OP_CONNECT} readiness.
      * <p>
      * Super-classes can implement this method to react to the event.
-     * 
+     *
      * @param key the selection key.
      */
     protected abstract void connectable(SelectionKey key);
@@ -119,7 +125,7 @@
      * Triggered when the key signals {@link SelectionKey#OP_READ} readiness.
      * <p>
      * Super-classes can implement this method to react to the event.
-     * 
+     *
      * @param key the selection key.
      */
     protected abstract void readable(SelectionKey key);
@@ -128,70 +134,77 @@
      * Triggered when the key signals {@link SelectionKey#OP_WRITE} readiness.
      * <p>
      * Super-classes can implement this method to react to the event.
-     * 
+     *
      * @param key the selection key.
      */
     protected abstract void writable(SelectionKey key);
-    
+
     /**
-     * Triggered to verify whether the I/O session associated with the 
+     * Triggered to verify whether the I/O session associated with the
      * given selection key has not timed out.
      * <p>
      * Super-classes can implement this method to react to the event.
-     * 
+     *
      * @param key the selection key.
      * @param now current time as long value.
      */
     protected abstract void timeoutCheck(SelectionKey key, long now);
 
     /**
-     * Triggered to validate keys currently registered with the selector. This 
+     * Triggered to validate keys currently registered with the selector. This
      * method is called after each I/O select loop.
      * <p>
-     * Super-classes can implement this method to run validity checks on 
+     * Super-classes can implement this method to run validity checks on
      * active sessions and include additional processing that needs to be
      * executed after each I/O select loop.
-     * 
+     *
      * @param keys all selection keys registered with the selector.
      */
     protected abstract void validate(Set<SelectionKey> keys);
-    
+
     /**
      * Triggered when new session has been created.
      * <p>
      * Super-classes can implement this method to react to the event.
-     * 
+     *
      * @param key the selection key.
      * @param session new I/O session.
      */
     protected abstract void sessionCreated(SelectionKey key, IOSession session);
-    
+
     /**
      * Triggered when a session has been closed.
      * <p>
      * Super-classes can implement this method to react to the event.
-     * 
+     *
      * @param session closed I/O session.
      */
     protected abstract void sessionClosed(IOSession session);
-    
+
     /**
      * Obtains {@link IOSession} instance associated with the given selection
      * key.
-     * 
+     *
      * @param key the selection key.
      * @return I/O session.
      */
     protected abstract IOSession getSession(SelectionKey key);
-    
+
     public IOReactorStatus getStatus() {
         return this.status;
     }
 
     /**
+     * Returns <code>true</code> if interestOps queueing is enabled, <code>false</code> otherwise.
+     */
+    public boolean getInterestOpsQueueing() {
+        return this.interestOpsQueueing;
+    }
+
+    /**
      * Adds new channel entry. The channel will be asynchronously registered
      * with the selector.
-     *  
+     *
      * @param channelEntry the channel entry.
      */
     public void addChannel(final ChannelEntry channelEntry) {
@@ -201,17 +214,17 @@
         this.newChannels.add(channelEntry);
         this.selector.wakeup();
     }
-    
+
     /**
-     * Activates the I/O reactor. The I/O reactor will start reacting to 
+     * Activates the I/O reactor. The I/O reactor will start reacting to
      * I/O events and triggering notification methods.
      * <p>
-     * This method will enter the infinite I/O select loop on 
+     * This method will enter the infinite I/O select loop on
      * the {@link Selector} instance associated with this I/O reactor.
      * <p>
      * The method will remain blocked unto the I/O reactor is shut down or the
-     * execution thread is interrupted. 
-     * 
+     * execution thread is interrupted.
+     *
      * @see #acceptable(SelectionKey)
      * @see #connectable(SelectionKey)
      * @see #readable(SelectionKey)
@@ -220,16 +233,16 @@
      * @see #validate(Set)
      * @see #sessionCreated(SelectionKey, IOSession)
      * @see #sessionClosed(IOSession)
-     * 
-     * @throws InterruptedIOException if the dispatch thread is interrupted. 
-     * @throws IOReactorException in case if a non-recoverable I/O error. 
+     *
+     * @throws InterruptedIOException if the dispatch thread is interrupted.
+     * @throws IOReactorException in case if a non-recoverable I/O error.
      */
     protected void execute() throws InterruptedIOException, IOReactorException {
         this.status = IOReactorStatus.ACTIVE;
 
         try {
             for (;;) {
-                
+
                 int readyCount;
                 try {
                     readyCount = this.selector.select(this.selectTimeout);
@@ -238,7 +251,7 @@
                 } catch (IOException ex) {
                     throw new IOReactorException("Unexpected selector failure", ex);
                 }
-                
+
                 if (this.status == IOReactorStatus.SHUT_DOWN) {
                     // Hard shut down. Exit select loop immediately
                     break;
@@ -250,15 +263,15 @@
                     closeSessions();
                     closeNewChannels();
                 }
-                
-                // Process selected I/O events 
+
+                // Process selected I/O events
                 if (readyCount > 0) {
                     processEvents(this.selector.selectedKeys());
                 }
-                
+
                 // Validate active channels
                 validate(this.selector.keys());
-                
+
                 // Process closed sessions
                 processClosedSessions();
 
@@ -266,18 +279,23 @@
                 if (this.status == IOReactorStatus.ACTIVE) {
                     processNewChannels();
                 }
-                
+
                 // Exit select loop if graceful shutdown has been completed
-                if (this.status.compareTo(IOReactorStatus.ACTIVE) > 0 
+                if (this.status.compareTo(IOReactorStatus.ACTIVE) > 0
                         && this.sessions.isEmpty()) {
                     break;
                 }
-                
+
+                if (this.interestOpsQueueing) {
+                    // process all pending interestOps() operations
+                    processPendingInterestOps();
+                }
+
             }
-            
+
             // Close remaining active channels and the selector itself
             closeActiveChannels();
-            
+
         } catch (ClosedSelectorException ex) {
         } finally {
             synchronized (this.shutdownMutex) {
@@ -286,20 +304,20 @@
             }
         }
     }
-    
+
     private void processEvents(final Set<SelectionKey> selectedKeys) {
         for (Iterator<SelectionKey> it = selectedKeys.iterator(); it.hasNext(); ) {
-            
+
             SelectionKey key = it.next();
             processEvent(key);
-            
+
         }
         selectedKeys.clear();
     }
-    
+
     /**
      * Processes new event on the given selection key.
-     * 
+     *
      * @param key the selection key that triggered an event.
      */
     protected void processEvent(final SelectionKey key) {
@@ -318,14 +336,14 @@
             }
         } catch (CancelledKeyException ex) {
             IOSession session = getSession(key);
-            queueClosedSession(session);            
+            queueClosedSession(session);
             key.attach(null);
         }
     }
 
     /**
      * Queues the given I/O session to be processed asynchronously as closed.
-     *  
+     *
      * @param session the closed I/O session.
      */
     protected void queueClosedSession(final IOSession session) {
@@ -333,12 +351,12 @@
             this.closedSessions.add(session);
         }
     }
-    
-    
+
+
     private void processNewChannels() throws IOReactorException {
         ChannelEntry entry;
         while ((entry = this.newChannels.poll()) != null) {
-            
+
             SocketChannel channel;
             SelectionKey key;
             try {
@@ -362,9 +380,9 @@
                 public void sessionClosed(IOSession session) {
                     queueClosedSession(session);
                 }
-                
-            });
-            
+
+            }, this);
+
             int timeout = 0;
             try {
                 timeout = channel.socket().getSoTimeout();
@@ -373,14 +391,14 @@
                 // as the protocol layer is expected to overwrite
                 // this value anyways
             }
-            
+
             session.setAttribute(IOSession.ATTACHMENT_KEY, entry.getAttachment());
             session.setSocketTimeout(timeout);
             this.sessions.add(session);
 
             try {
                 sessionCreated(key, session);
-                
+
                 SessionRequestImpl sessionRequest = entry.getSessionRequest();
                 if (sessionRequest != null) {
                     sessionRequest.completed(session);
@@ -406,6 +424,36 @@
     }
 
     /**
+     * Processes all pending {@link java.nio.channels.SelectionKey#interestOps(int) interestOps(int)}
+     * operations.
+     */
+    protected void processPendingInterestOps() {
+        synchronized (this.interestOpsQueue) {
+            // determine this interestOps() queue's size
+            int size = this.interestOpsQueue.size();
+
+            for (int i = 0; i < size; i++) {
+                // get the first queue element
+                InterestOpEntry  entry = this.interestOpsQueue.remove(0);
+
+                // obtain the operation's details
+                IOSessionImpl ioSession = entry.getIoSession();
+                int operationType = entry.getOperationType();
+                int operationArgument = entry.getOperationArgument();
+
+                // perform the operation
+                if (operationType == InterestOpEntry.OPERATION_TYPE_SET_EVENT) {
+                    ioSession.setEventImpl(operationArgument);
+                } else if (operationType == InterestOpEntry.OPERATION_TYPE_CLEAR_EVENT) {
+                    ioSession.clearEventImpl(operationArgument);
+                } else if (operationType == InterestOpEntry.OPERATION_TYPE_SET_EVENT_MASK) {
+                    ioSession.setEventMaskImpl(operationArgument);
+                }
+            }
+        }
+    }
+
+    /**
      * Closes out all I/O sessions maintained by this I/O reactor.
      */
     protected void closeSessions() {
@@ -416,9 +464,9 @@
             }
         }
     }
-    
+
     /**
-     * Closes out all new channels pending registration with the selector of 
+     * Closes out all new channels pending registration with the selector of
      * this I/O reactor.
      * @throws IOReactorException - not thrown currently
      */
@@ -436,9 +484,9 @@
             }
         }
     }
-    
+
     /**
-     * Closes out all active channels registered with the selector of 
+     * Closes out all active channels registered with the selector of
      * this I/O reactor.
      * @throws IOReactorException - not thrown currently
      */
@@ -459,7 +507,7 @@
         } catch (IOException ignore) {
         }
     }
-    
+
     /**
      * Attempts graceful shutdown of this I/O reactor.
      */
@@ -471,7 +519,7 @@
         this.status = IOReactorStatus.SHUTTING_DOWN;
         this.selector.wakeup();
     }
-        
+
     /**
      * Attempts force-shutdown of this I/O reactor.
      */
@@ -484,11 +532,11 @@
         closeNewChannels();
         closeActiveChannels();
     }
-    
+
     /**
-     * Blocks for the given period of time in milliseconds awaiting 
+     * Blocks for the given period of time in milliseconds awaiting
      * the completion of the reactor shutdown.
-     *  
+     *
      * @param timeout the maximum wait time.
      * @throws InterruptedException if interrupted.
      */
@@ -507,7 +555,7 @@
             }
         }
     }
-        
+
     public void shutdown(long gracePeriod) throws IOReactorException {
         if (this.status != IOReactorStatus.INACTIVE) {
             gracefulShutdown();
@@ -520,9 +568,48 @@
             hardShutdown();
         }
     }
-    
+
     public void shutdown() throws IOReactorException {
         shutdown(1000);
     }
-    
+
+    /**
+     * Adds an {@link InterestOpEntry} to the {@link java.nio.channels.SelectionKey#interestOps(int)
+     * interestOps(int)} queue for this instance.
+     *
+     * @return <code>true</code> if the operation could be performed successfully,
+     * <code>false</code> otherwise.
+     */
+    public boolean addInterestOpsQueueElement(final InterestOpEntry queueElement) {
+        // validity checks
+        if (!this.interestOpsQueueing) {
+            throw new IllegalStateException("InterestOps queueing is disabled");
+        }
+        if (queueElement == null) {
+            return false;
+        }
+        if (queueElement.getIoSession() == null) {
+            return false;
+        }
+
+        // local variable
+        int operationType = queueElement.getOperationType();
+
+        /*
+            NOTE: Most of the operations are setEvent(), so check for this one first.
+        */
+        if ((operationType != InterestOpEntry.OPERATION_TYPE_SET_EVENT) &&
+            (operationType != InterestOpEntry.OPERATION_TYPE_CLEAR_EVENT) &&
+            (operationType != InterestOpEntry.OPERATION_TYPE_SET_EVENT_MASK)) {
+            return false;
+        }
+
+        synchronized(interestOpsQueue) {
+            // add this operation to the interestOps() queue
+            interestOpsQueue.add(queueElement);
+        }
+
+        return true;
+    }
+
 }

Modified: httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java?rev=755683&r1=755682&r2=755683&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java (original)
+++ httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java Wed Mar 18 18:13:03 2009
@@ -59,43 +59,43 @@
 import org.apache.http.params.HttpParams;
 
 /**
- * Generic implementation of {@link IOReactor} that can run multiple 
- * {@link BaseIOReactor} instance in separate worker threads and distribute 
+ * Generic implementation of {@link IOReactor} that can run multiple
+ * {@link BaseIOReactor} instance in separate worker threads and distribute
  * newly created I/O session equally across those I/O reactors for a more
- * optimal resource utilization and a better I/O performance. Usually it is 
+ * optimal resource utilization and a better I/O performance. Usually it is
  * recommended to have one worker I/O reactor per physical CPU core.
  * <p>
  * <strong>Important note about exception handling</strong>
  * <p>
- * Protocol specific exceptions as well as those I/O exceptions thrown in the 
- * course of interaction with the session's channel are to be expected are to be 
- * dealt with by specific protocol handlers. These exceptions may result in 
- * termination of an individual session but should not affect the I/O reactor 
- * and all other active sessions. There are situations, however, when the I/O 
- * reactor itself encounters an internal problem such as an I/O exception in 
- * the underlying NIO classes or an unhandled runtime exception. Those types of 
- * exceptions are usually fatal and will cause the I/O reactor to shut down 
+ * Protocol specific exceptions as well as those I/O exceptions thrown in the
+ * course of interaction with the session's channel are to be expected are to be
+ * dealt with by specific protocol handlers. These exceptions may result in
+ * termination of an individual session but should not affect the I/O reactor
+ * and all other active sessions. There are situations, however, when the I/O
+ * reactor itself encounters an internal problem such as an I/O exception in
+ * the underlying NIO classes or an unhandled runtime exception. Those types of
+ * exceptions are usually fatal and will cause the I/O reactor to shut down
  * automatically.
  * <p>
- * There is a possibility to override this behavior and prevent I/O reactors 
- * from shutting down automatically in case of a runtime exception or an I/O 
- * exception in internal classes. This can be accomplished by providing a custom 
- * implementation of the {@link IOReactorExceptionHandler} interface. 
+ * There is a possibility to override this behavior and prevent I/O reactors
+ * from shutting down automatically in case of a runtime exception or an I/O
+ * exception in internal classes. This can be accomplished by providing a custom
+ * implementation of the {@link IOReactorExceptionHandler} interface.
  * <p>
- * If an I/O reactor is unable to automatically recover from an I/O or a runtime 
- * exception it will enter the shutdown mode. First off, it cancel all pending 
- * new session requests. Then it will attempt to close all active I/O sessions 
- * gracefully giving them some time to flush pending output data and terminate 
- * cleanly. Lastly, it will forcibly shut down those I/O sessions that still 
- * remain active after the grace period. This is a fairly complex process, where 
- * many things can fail at the same time and many different exceptions can be 
- * thrown in the course of the shutdown process. The I/O reactor will record all 
- * exceptions thrown during the shutdown process, including the original one 
- * that actually caused the shutdown in the first place, in an audit log. One 
+ * If an I/O reactor is unable to automatically recover from an I/O or a runtime
+ * exception it will enter the shutdown mode. First off, it cancel all pending
+ * new session requests. Then it will attempt to close all active I/O sessions
+ * gracefully giving them some time to flush pending output data and terminate
+ * cleanly. Lastly, it will forcibly shut down those I/O sessions that still
+ * remain active after the grace period. This is a fairly complex process, where
+ * many things can fail at the same time and many different exceptions can be
+ * thrown in the course of the shutdown process. The I/O reactor will record all
+ * exceptions thrown during the shutdown process, including the original one
+ * that actually caused the shutdown in the first place, in an audit log. One
  * can obtain the audit log using {@link #getAuditLog()}, examine exceptions
- * thrown by the I/O reactor prior and in the course of the reactor shutdown 
+ * thrown by the I/O reactor prior and in the course of the reactor shutdown
  * and decide whether it is safe to restart the I/O reactor.
- * 
+ *
  *
  * @version $Revision$
  *
@@ -104,10 +104,11 @@
 public abstract class AbstractMultiworkerIOReactor implements IOReactor {
 
     protected volatile IOReactorStatus status;
-    
+
     protected final HttpParams params;
     protected final Selector selector;
     protected final long selectTimeout;
+    protected final boolean interestOpsQueueing;
 
     private final int workerCount;
     private final ThreadFactory threadFactory;
@@ -115,23 +116,23 @@
     private final Worker[] workers;
     private final Thread[] threads;
     private final Object statusLock;
-    
+
     protected IOReactorExceptionHandler exceptionHandler;
     protected List<ExceptionEvent> auditLog;
-    
+
     private int currentWorker = 0;
 
     /**
      * Creates an instance of AbstractMultiworkerIOReactor.
      *
-     * @param workerCount number of worker I/O reactors. 
-     * @param threadFactory the factory to create threads. 
+     * @param workerCount number of worker I/O reactors.
+     * @param threadFactory the factory to create threads.
      *   Can be <code>null</code>.
      * @param params HTTP parameters.
-     * @throws IOReactorException in case if a non-recoverable I/O error. 
+     * @throws IOReactorException in case if a non-recoverable I/O error.
      */
     public AbstractMultiworkerIOReactor(
-            int workerCount, 
+            int workerCount,
             final ThreadFactory threadFactory,
             final HttpParams params) throws IOReactorException {
         super();
@@ -148,6 +149,7 @@
         }
         this.params = params;
         this.selectTimeout = NIOReactorParams.getSelectInterval(params);
+        this.interestOpsQueueing = NIOReactorParams.getInterestOpsQueueing(params);
         this.statusLock = new Object();
         this.workerCount = workerCount;
         if (threadFactory != null) {
@@ -164,11 +166,11 @@
     public IOReactorStatus getStatus() {
         return this.status;
     }
-    
+
     /**
-     * Returns the audit log containing exceptions thrown by the I/O reactor 
+     * Returns the audit log containing exceptions thrown by the I/O reactor
      * prior and in the course of the reactor shutdown.
-     * 
+     *
      * @return audit log.
      */
     public synchronized List<ExceptionEvent> getAuditLog() {
@@ -182,9 +184,9 @@
     /**
      * Adds the given {@link Throwable} object with the given time stamp
      * to the audit log.
-     * 
+     *
      * @param ex the exception thrown by the I/O reactor.
-     * @param timestamp the time stamp of the exception. Can be 
+     * @param timestamp the time stamp of the exception. Can be
      * <code>null</code> in which case the current date / time will be used.
      */
     protected synchronized void addExceptionEvent(final Throwable ex, Date timestamp) {
@@ -199,10 +201,10 @@
         }
         this.auditLog.add(new ExceptionEvent(ex, timestamp));
     }
-    
+
     /**
      * Adds the given {@link Throwable} object to the audit log.
-     * 
+     *
      * @param ex the exception thrown by the I/O reactor.
      */
     protected void addExceptionEvent(final Throwable ex) {
@@ -211,59 +213,59 @@
 
     /**
      * Sets exception handler for this I/O reactor.
-     * 
-     * @param exceptionHandler the exception handler. 
+     *
+     * @param exceptionHandler the exception handler.
      */
     public void setExceptionHandler(final IOReactorExceptionHandler exceptionHandler) {
         this.exceptionHandler = exceptionHandler;
     }
-    
+
     /**
      * Triggered to process I/O events registered by the main {@link Selector}.
      * <p>
      * Super-classes can implement this method to react to the event.
-     * 
+     *
      * @param count event count.
-     * @throws IOReactorException in case if a non-recoverable I/O error. 
+     * @throws IOReactorException in case if a non-recoverable I/O error.
      */
     protected abstract void processEvents(int count) throws IOReactorException;
-    
+
     /**
      * Triggered to cancel pending session requests.
      * <p>
      * Super-classes can implement this method to react to the event.
-     * 
-     * @throws IOReactorException in case if a non-recoverable I/O error. 
+     *
+     * @throws IOReactorException in case if a non-recoverable I/O error.
      */
     protected abstract void cancelRequests() throws IOReactorException;
-    
+
     /**
-     * Activates the main I/O reactor as well as all worker I/O reactors. 
-     * The I/O main reactor will start reacting to I/O events and triggering 
-     * notification methods. The worker I/O reactor in their turn will start 
-     * reacting to I/O events and dispatch I/O event notifications to the given 
+     * Activates the main I/O reactor as well as all worker I/O reactors.
+     * The I/O main reactor will start reacting to I/O events and triggering
+     * notification methods. The worker I/O reactor in their turn will start
+     * reacting to I/O events and dispatch I/O event notifications to the given
      * {@link IOEventDispatch} interface.
      * <p>
-     * This method will enter the infinite I/O select loop on 
-     * the {@link Selector} instance associated with this I/O reactor and used 
+     * This method will enter the infinite I/O select loop on
+     * the {@link Selector} instance associated with this I/O reactor and used
      * to manage creation of new I/O channels. Once a new I/O channel has been
-     * created the processing of I/O events on that channel will be delegated 
+     * created the processing of I/O events on that channel will be delegated
      * to one of the worker I/O reactors.
      * <p>
      * The method will remain blocked unto the I/O reactor is shut down or the
-     * execution thread is interrupted. 
+     * execution thread is interrupted.
      * <p>
      * The following HTTP parameters affect execution of this method:
      * <p>
-     * The {@link NIOReactorPNames#SELECT_INTERVAL} parameter determines the 
-     * time interval in milliseconds at which the I/O reactor wakes up to check 
+     * The {@link NIOReactorPNames#SELECT_INTERVAL} parameter determines the
+     * time interval in milliseconds at which the I/O reactor wakes up to check
      * for timed out sessions and session requests.
-     * 
+     *
      * @see #processEvents(int)
      * @see #cancelRequests()
-     * 
-     * @throws InterruptedIOException if the dispatch thread is interrupted. 
-     * @throws IOReactorException in case if a non-recoverable I/O error. 
+     *
+     * @throws InterruptedIOException if the dispatch thread is interrupted.
+     * @throws IOReactorException in case if a non-recoverable I/O error.
      */
     public void execute(
             final IOEventDispatch eventDispatch) throws InterruptedIOException, IOReactorException {
@@ -282,7 +284,7 @@
             this.status = IOReactorStatus.ACTIVE;
             // Start I/O dispatchers
             for (int i = 0; i < this.dispatchers.length; i++) {
-                BaseIOReactor dispatcher = new BaseIOReactor(this.selectTimeout);
+                BaseIOReactor dispatcher = new BaseIOReactor(this.selectTimeout, this.interestOpsQueueing);
                 dispatcher.setExceptionHandler(exceptionHandler);
                 this.dispatchers[i] = dispatcher;
             }
@@ -300,7 +302,7 @@
                 }
                 this.threads[i].start();
             }
-            
+
             for (;;) {
                 int readyCount;
                 try {
@@ -310,7 +312,7 @@
                 } catch (IOException ex) {
                     throw new IOReactorException("Unexpected selector failure", ex);
                 }
-                
+
                 if (this.status.compareTo(IOReactorStatus.ACTIVE) > 0) {
                     break;
                 }
@@ -348,17 +350,17 @@
 
     /**
      * Activates the shutdown sequence for this reactor. This method will cancel
-     * all pending session requests, close out all active I/O channels, 
+     * all pending session requests, close out all active I/O channels,
      * make an attempt to terminate all worker I/O reactors gracefully,
      * and finally force-terminate those I/O reactors that failed to
      * terminate after the specified grace period.
      * <p>
      * The following HTTP parameters affect execution of this method:
      * <p>
-     * The {@link NIOReactorPNames#GRACE_PERIOD} parameter determines the grace 
-     * period the I/O reactors are expected to block waiting for individual 
+     * The {@link NIOReactorPNames#GRACE_PERIOD} parameter determines the grace
+     * period the I/O reactors are expected to block waiting for individual
      * worker threads to terminate cleanly.
-     * 
+     *
      * @throws InterruptedIOException if the shutdown sequence has been
      *   interrupted.
      */
@@ -368,14 +370,14 @@
         }
         this.status = IOReactorStatus.SHUTTING_DOWN;
         try {
-            cancelRequests();        
+            cancelRequests();
         } catch (IOReactorException ex) {
             if (ex.getCause() != null) {
                 addExceptionEvent(ex.getCause());
             }
         }
         this.selector.wakeup();
-        
+
         // Close out all channels
         if (this.selector.isOpen()) {
             Set<SelectionKey> keys = this.selector.keys();
@@ -405,7 +407,7 @@
         }
 
         long gracePeriod = NIOReactorParams.getGracePeriod(this.params);
-        
+
         try {
             // Force shut down I/O dispatchers if they fail to terminate
             // in time
@@ -438,7 +440,7 @@
 
     /**
      * Assigns the given channel entry to one of the worker I/O reactors.
-     *  
+     *
      * @param entry the channel entry.
      */
     protected void addChannel(final ChannelEntry entry) {
@@ -446,10 +448,10 @@
         int i = Math.abs(this.currentWorker++ % this.workerCount);
         this.dispatchers[i].addChannel(entry);
     }
-    
+
     /**
      * Registers the given channel with the main {@link Selector}.
-     * 
+     *
      * @param channel the channel.
      * @param ops interest ops.
      * @return  selection key.
@@ -465,24 +467,24 @@
      * <p>
      * The following HTTP parameters affect execution of this method:
      * <p>
-     * {@link CoreConnectionPNames#TCP_NODELAY} parameter determines whether 
-     * Nagle's algorithm is to be used. The Nagle's algorithm tries to conserve 
-     * bandwidth by minimizing the number of segments that are sent. When 
-     * applications wish to decrease network latency and increase performance, 
-     * they can disable Nagle's algorithm (that is enable TCP_NODELAY). Data 
-     * will be sent earlier, at the cost of an increase in bandwidth 
+     * {@link CoreConnectionPNames#TCP_NODELAY} parameter determines whether
+     * Nagle's algorithm is to be used. The Nagle's algorithm tries to conserve
+     * bandwidth by minimizing the number of segments that are sent. When
+     * applications wish to decrease network latency and increase performance,
+     * they can disable Nagle's algorithm (that is enable TCP_NODELAY). Data
+     * will be sent earlier, at the cost of an increase in bandwidth
      * consumption.
      * <p>
-     * {@link CoreConnectionPNames#SO_TIMEOUT} parameter defines the socket 
-     * timeout in milliseconds, which is the timeout for waiting for data. 
+     * {@link CoreConnectionPNames#SO_TIMEOUT} parameter defines the socket
+     * timeout in milliseconds, which is the timeout for waiting for data.
      * A timeout value of zero is interpreted as an infinite timeout.
      * <p>
-     * {@link CoreConnectionPNames#SO_LINGER} parameter defines linger time 
-     * in seconds. The maximum timeout value is platform specific. Value 
+     * {@link CoreConnectionPNames#SO_LINGER} parameter defines linger time
+     * in seconds. The maximum timeout value is platform specific. Value
      * <code>0</code> implies that the option is disabled. Value <code>-1</code>
-     * implies that the JRE default is to be used. The setting only affects 
+     * implies that the JRE default is to be used. The setting only affects
      * socket close.
-     *  
+     *
      * @param socket the socket
      * @throws IOException in case of an I/O error.
      */
@@ -496,11 +498,11 @@
     }
 
     /**
-     * Blocks for the given period of time in milliseconds awaiting 
-     * the completion of the reactor shutdown. If the value of 
+     * Blocks for the given period of time in milliseconds awaiting
+     * the completion of the reactor shutdown. If the value of
      * <code>timeout</code> is set to <code>0</code> this method blocks
-     * indefinitely. 
-     *  
+     * indefinitely.
+     *
      * @param timeout the maximum wait time.
      * @throws InterruptedException if interrupted.
      */
@@ -542,15 +544,15 @@
 
         final BaseIOReactor dispatcher;
         final IOEventDispatch eventDispatch;
-        
+
         private volatile Exception exception;
-        
+
         public Worker(final BaseIOReactor dispatcher, final IOEventDispatch eventDispatch) {
             super();
             this.dispatcher = dispatcher;
             this.eventDispatch = eventDispatch;
         }
-        
+
         public void run() {
             try {
                 this.dispatcher.execute(this.eventDispatch);
@@ -558,7 +560,7 @@
                 this.exception = ex;
             }
         }
-        
+
         public Exception getException() {
             return this.exception;
         }
@@ -568,11 +570,11 @@
     static class DefaultThreadFactory implements ThreadFactory {
 
         private static volatile int COUNT = 0;
-        
+
         public Thread newThread(final Runnable r) {
             return new Thread(r, "I/O dispatcher " + (++COUNT));
         }
-        
+
     }
-    
+
 }

Modified: httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java?rev=755683&r1=755682&r2=755683&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java (original)
+++ httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/BaseIOReactor.java Wed Mar 18 18:13:03 2009
@@ -48,9 +48,9 @@
 /**
  * Default implementation of {@link AbstractIOReactor} that serves as a base
  * for more advanced {@link IOReactor} implementations. This class adds
- * support for the I/O event dispatching using {@link IOEventDispatch}, 
+ * support for the I/O event dispatching using {@link IOEventDispatch},
  * management of buffering sessions, and session timeout handling.
- *   
+ *
  *
  * @version $Revision$
  *
@@ -68,12 +68,12 @@
 
     /**
      * Creates new BaseIOReactor instance.
-     * 
+     *
      * @param selectTimeout the select timeout.
-     * @throws IOReactorException in case if a non-recoverable I/O error. 
+     * @throws IOReactorException in case if a non-recoverable I/O error.
      */
-    public BaseIOReactor(long selectTimeout) throws IOReactorException {
-        super(selectTimeout);
+    public BaseIOReactor(long selectTimeout, boolean interestOpsQueueing) throws IOReactorException {
+        super(selectTimeout, interestOpsQueueing);
         this.bufferingSessions = new HashSet<IOSession>();
         this.timeoutCheckInterval = selectTimeout;
         this.lastTimeoutCheck = System.currentTimeMillis();
@@ -81,11 +81,11 @@
 
     /**
      * Activates the I/O reactor. The I/O reactor will start reacting to I/O
-     * events and dispatch I/O event notifications to the given 
+     * events and dispatch I/O event notifications to the given
      * {@link IOEventDispatch}.
-     * 
-     * @throws InterruptedIOException if the dispatch thread is interrupted. 
-     * @throws IOReactorException in case if a non-recoverable I/O error. 
+     *
+     * @throws InterruptedIOException if the dispatch thread is interrupted.
+     * @throws IOReactorException in case if a non-recoverable I/O error.
      */
     public void execute(
             final IOEventDispatch eventDispatch) throws InterruptedIOException, IOReactorException {
@@ -98,18 +98,18 @@
 
     /**
      * Sets exception handler for this I/O reactor.
-     * 
-     * @param exceptionHandler the exception handler. 
+     *
+     * @param exceptionHandler the exception handler.
      */
     public void setExceptionHandler(IOReactorExceptionHandler exceptionHandler) {
         this.exceptionHandler = exceptionHandler;
     }
 
     /**
-     * Handles the given {@link RuntimeException}. This method delegates 
-     * handling of the exception to the {@link IOReactorExceptionHandler}, 
+     * Handles the given {@link RuntimeException}. This method delegates
+     * handling of the exception to the {@link IOReactorExceptionHandler},
      * if available.
-     * 
+     *
      * @param ex the runtime exception.
      */
     protected void handleRuntimeException(final RuntimeException ex) {
@@ -119,7 +119,7 @@
     }
 
     /**
-     * This I/O reactor implementation does not react to the 
+     * This I/O reactor implementation does not react to the
      * {@link SelectionKey#OP_ACCEPT} event.
      * <p>
      * Super-classes can override this method to react to the event.
@@ -129,7 +129,7 @@
     }
 
     /**
-     * This I/O reactor implementation does not react to the 
+     * This I/O reactor implementation does not react to the
      * {@link SelectionKey#OP_CONNECT} event.
      * <p>
      * Super-classes can override this method to react to the event.
@@ -140,7 +140,7 @@
 
     /**
      * Processes {@link SelectionKey#OP_READ} event on the given selection key.
-     * This method dispatches the event notification to the 
+     * This method dispatches the event notification to the
      * {@link IOEventDispatch#inputReady(IOSession)} method.
      */
     @Override
@@ -164,7 +164,7 @@
 
     /**
      * Processes {@link SelectionKey#OP_WRITE} event on the given selection key.
-     * This method dispatches the event notification to the 
+     * This method dispatches the event notification to the
      * {@link IOEventDispatch#outputReady(IOSession)} method.
      */
     @Override
@@ -186,11 +186,11 @@
     /**
      * Verifies whether any of the sessions associated with the given selection
      * keys timed out by invoking the {@link #timeoutCheck(SelectionKey, long)}
-     * method. 
+     * method.
      * <p>
-     * This method will also invoke the 
-     * {@link IOEventDispatch#inputReady(IOSession)} method on all sessions 
-     * that have buffered input data. 
+     * This method will also invoke the
+     * {@link IOEventDispatch#inputReady(IOSession)} method on all sessions
+     * that have buffered input data.
      */
     @Override
     protected void validate(final Set<SelectionKey> keys) {
@@ -211,7 +211,7 @@
                     it.remove();
                     continue;
                 }
-                
+
                 int ops = 0;
                 try {
                     ops = session.getEventMask();
@@ -220,7 +220,7 @@
                     queueClosedSession(session);
                     continue;
                 }
-                
+
                 if ((ops & EventMask.READ) > 0) {
                     try {
                         this.eventDispatch.inputReady(session);
@@ -239,7 +239,7 @@
     }
 
     /**
-     * Performs timeout check for the I/O session associated with the given 
+     * Performs timeout check for the I/O session associated with the given
      * selection key.
      */
     @Override
@@ -265,7 +265,7 @@
     }
 
     /**
-     * Processes newly created I/O session. This method dispatches the event 
+     * Processes newly created I/O session. This method dispatches the event
      * notification to the {@link IOEventDispatch#connected(IOSession)} method.
      */
     @Override
@@ -294,8 +294,8 @@
     }
 
     /**
-     * Processes closed I/O session. This method dispatches the event 
-     * notification to the {@link IOEventDispatch#disconnected(IOSession)} 
+     * Processes closed I/O session. This method dispatches the event
+     * notification to the {@link IOEventDispatch#disconnected(IOSession)}
      * method.
      */
     @Override

Modified: httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java?rev=755683&r1=755682&r2=755683&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java (original)
+++ httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java Wed Mar 18 18:13:03 2009
@@ -46,41 +46,51 @@
 
 /**
  * Default implementation of {@link IOSession}.
- * 
+ *
  *
  * @version $Revision$
  *
  * @since 4.0
  */
 public class IOSessionImpl implements IOSession {
-    
+
     private volatile int status;
-    
+
     private final SelectionKey key;
     private final ByteChannel channel;
     private final SessionClosedCallback callback;
     private final Map<String, Object> attributes;
-    
+    private final boolean interestOpsQueueing;
+    private final AbstractIOReactor abstractIOReactor;
+
     private SessionBufferStatus bufferStatus;
     private int socketTimeout;
-    
-    public IOSessionImpl(final SelectionKey key, final SessionClosedCallback callback) {
+
+    public IOSessionImpl(final SelectionKey key, final SessionClosedCallback callback, final AbstractIOReactor abstractIOReactor) {
         super();
         if (key == null) {
             throw new IllegalArgumentException("Selection key may not be null");
         }
+
+        // validity check
+        if (abstractIOReactor == null) {
+            throw new IllegalArgumentException("IO reactor may not be null");
+        }
+
         this.key = key;
         this.channel = (ByteChannel) this.key.channel();
+        this.abstractIOReactor = abstractIOReactor;
+        this.interestOpsQueueing = abstractIOReactor.getInterestOpsQueueing();
         this.callback = callback;
         this.attributes = Collections.synchronizedMap(new HashMap<String, Object>());
         this.socketTimeout = 0;
         this.status = ACTIVE;
     }
-    
+
     public ByteChannel channel() {
         return this.channel;
     }
-    
+
     public SocketAddress getLocalAddress() {
         Channel channel = this.key.channel();
         if (channel instanceof SocketChannel) {
@@ -100,18 +110,57 @@
     }
 
     public int getEventMask() {
+        if (interestOpsQueueing) {
+            // flush the interestOps() queue
+            abstractIOReactor.processPendingInterestOps();
+        }
+
         return this.key.interestOps();
     }
-    
+
     public void setEventMask(int ops) {
+        if (this.interestOpsQueueing) {
+            // local variable
+            InterestOpEntry queueElement = new InterestOpEntry(this,
+                    InterestOpEntry.OPERATION_TYPE_SET_EVENT_MASK, ops);
+
+            // add this operation to the interestOps() queue
+            this.abstractIOReactor.addInterestOpsQueueElement(queueElement);
+
+            // wake up this key's selector
+            this.key.selector().wakeup();
+        } else {
+            // simply invoke the actual implementation
+            setEventMaskImpl(ops);
+        }
+    }
+
+    protected void setEventMaskImpl(int ops) {
         if (this.status == CLOSED) {
             return;
         }
         this.key.interestOps(ops);
         this.key.selector().wakeup();
     }
-    
+
     public void setEvent(int op) {
+        if (this.interestOpsQueueing) {
+            // local variable
+            InterestOpEntry queueElement = new InterestOpEntry(this,
+                    InterestOpEntry.OPERATION_TYPE_SET_EVENT, op);
+
+            // add this operation to the interestOps() queue
+            this.abstractIOReactor.addInterestOpsQueueElement(queueElement);
+
+            // wake up this key's selector
+            this.key.selector().wakeup();
+        } else {
+            // simply invoke the actual implementation
+            setEventImpl(op);
+        }
+    }
+
+    protected void setEventImpl(int op) {
         if (this.status == CLOSED) {
             return;
         }
@@ -121,8 +170,24 @@
         }
         this.key.selector().wakeup();
     }
-    
+
     public void clearEvent(int op) {
+        if (interestOpsQueueing) {
+            // local variable
+            InterestOpEntry queueElement = new InterestOpEntry(this, InterestOpEntry.OPERATION_TYPE_CLEAR_EVENT, op);
+
+            // add this operation to the interestOps() queue
+            abstractIOReactor.addInterestOpsQueueElement(queueElement);
+
+            // wake up this key's selector
+            this.key.selector().wakeup();
+        } else {
+            // simply invoke the actual implementation
+            clearEventImpl(op);
+        }
+    }
+
+    protected void clearEventImpl(int op) {
         if (this.status == CLOSED) {
             return;
         }
@@ -132,15 +197,15 @@
         }
         this.key.selector().wakeup();
     }
-    
+
     public int getSocketTimeout() {
         return this.socketTimeout;
     }
-    
+
     public void setSocketTimeout(int timeout) {
         this.socketTimeout = timeout;
     }
-    
+
     public void close() {
         if (this.status == CLOSED) {
             return;
@@ -160,7 +225,7 @@
             this.key.selector().wakeup();
         }
     }
-    
+
     public int getStatus() {
         return this.status;
     }
@@ -168,17 +233,17 @@
     public boolean isClosed() {
         return this.status == CLOSED || !this.key.isValid();
     }
-    
+
     public void shutdown() {
         // For this type of session, a close() does exactly
         // what we need and nothing more.
         close();
     }
-    
+
     public boolean hasBufferedInput() {
         return this.bufferStatus != null && this.bufferStatus.hasBufferedInput();
     }
-    
+
     public boolean hasBufferedOutput() {
         return this.bufferStatus != null && this.bufferStatus.hasBufferedOutput();
     }
@@ -186,7 +251,7 @@
     public void setBufferStatus(final SessionBufferStatus bufferStatus) {
         this.bufferStatus = bufferStatus;
     }
-    
+
     public Object getAttribute(final String name) {
         return this.attributes.get(name);
     }
@@ -215,13 +280,19 @@
         }
         buffer.append(']');
     }
-    
+
     @Override
     public String toString() {
         StringBuffer buffer = new StringBuffer();
         buffer.append("[");
         if (this.key.isValid()) {
             buffer.append("interested ops: ");
+
+            if (interestOpsQueueing) {
+                // flush the interestOps() queue
+                abstractIOReactor.processPendingInterestOps();
+            }
+
             formatOps(buffer, this.key.interestOps());
             buffer.append("; ready ops: ");
             formatOps(buffer, this.key.readyOps());

Added: httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/InterestOpEntry.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/InterestOpEntry.java?rev=755683&view=auto
==============================================================================
--- httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/InterestOpEntry.java (added)
+++ httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/InterestOpEntry.java Wed Mar 18 18:13:03 2009
@@ -0,0 +1,117 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.impl.nio.reactor;
+
+/**
+ * Helper class, representing an element on an {@link java.nio.channels.SelectionKey#interestOps(int)
+ * interestOps(int)} queue.
+ */
+class InterestOpEntry {
+    /**
+        Constant indicating the <CODE>OPERATION_TYPE_SET_EVENT_MASK</CODE> operation type.
+    */
+    public static final int OPERATION_TYPE_SET_EVENT_MASK = 0;
+
+    /**
+        Constant indicating the <CODE>OPERATION_TYPE_SET_EVENT</CODE> operation type.
+    */
+    public static final int OPERATION_TYPE_SET_EVENT = 1;
+
+    /**
+        Constant indicating the <CODE>OPERATION_TYPE_CLEAR_EVENT</CODE> operation type.
+    */
+    public static final int OPERATION_TYPE_CLEAR_EVENT = 2;
+
+    // instance members
+    private IOSessionImpl ioSession;
+    private int operationType;
+    private int operationArgument;
+
+    /**
+        Default constructor for the <CODE>IOSessionQueueElement</CODE> class.
+    */
+    public InterestOpEntry() {
+        // initialize instance members
+        ioSession = null;
+        operationType = 0;
+        operationArgument = 0;
+    }
+
+    /**
+        Constructor for the <CODE>IOSessionQueueElement</CODE> class.
+    */
+    public InterestOpEntry(IOSessionImpl ioSession, int operationType, int operationArgument) {
+        // initialize instance members
+        this.ioSession = ioSession;
+        this.operationType = operationType;
+        this.operationArgument = operationArgument;
+    }
+
+    /**
+        Getter for the <CODE>ioSession</CODE> property.
+    */
+    public IOSessionImpl getIoSession() {
+        return ioSession;
+    }
+
+    /**
+        Setter for the <CODE>ioSession</CODE> property.
+    */
+    public void setIoSession(IOSessionImpl ioSession) {
+        this.ioSession = ioSession;
+    }
+
+    /**
+        Getter for the <CODE>operationType</CODE> property.
+    */
+    public int getOperationType() {
+        return operationType;
+    }
+
+    /**
+        Setter for the <CODE>operationType</CODE> property.
+    */
+    public void setOperationType(int operationType) {
+        this.operationType = operationType;
+    }
+
+    /**
+        Getter for the <CODE>operationArgument</CODE> property.
+    */
+    public int getOperationArgument() {
+        return operationArgument;
+    }
+
+    /**
+        Setter for the <CODE>operationArgument</CODE> property.
+    */
+    public void setOperationArgument(int operationArgument) {
+        this.operationArgument = operationArgument;
+    }
+
+}

Propchange: httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/InterestOpEntry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/InterestOpEntry.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/InterestOpEntry.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/nio/params/NIOReactorPNames.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/nio/params/NIOReactorPNames.java?rev=755683&r1=755682&r2=755683&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/nio/params/NIOReactorPNames.java (original)
+++ httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/nio/params/NIOReactorPNames.java Wed Mar 18 18:13:03 2009
@@ -33,10 +33,10 @@
 
 /**
  * Parameter names for I/O reactors.
- * 
- * 
+ *
+ *
  * @version $Revision$
- * 
+ *
  * @since 4.0
  */
 public interface NIOReactorPNames {
@@ -48,7 +48,7 @@
      * This parameter expects a value of type {@link Integer}.
      * </p>
      */
-    public static final String CONTENT_BUFFER_SIZE = "http.nio.content-buffer-size"; 
+    public static final String CONTENT_BUFFER_SIZE = "http.nio.content-buffer-size";
 
     /**
      * Determines the time interval in milliseconds at which the
@@ -57,7 +57,7 @@
      * This parameter expects a value of type {@link Long}.
      * </p>
      */
-    public static final String SELECT_INTERVAL = "http.nio.select-interval"; 
+    public static final String SELECT_INTERVAL = "http.nio.select-interval";
 
     /**
      * Determines the grace period the I/O reactors are expected to block
@@ -66,6 +66,14 @@
      * This parameter expects a value of type {@link Long}.
      * </p>
      */
-    public static final String GRACE_PERIOD = "http.nio.grace-period"; 
+    public static final String GRACE_PERIOD = "http.nio.grace-period";
+
+    /**
+     * Determines whether interestOps() queueing is enabled for the I/O reactors.
+     * <p>
+     * This parameter expects a value of type {@link Boolean}.
+     * </p>
+     */
+    public static final String INTEREST_OPS_QUEUEING = "http.nio.interest-ops-queueing";
 
 }

Modified: httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/nio/params/NIOReactorParams.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/nio/params/NIOReactorParams.java?rev=755683&r1=755682&r2=755683&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/nio/params/NIOReactorParams.java (original)
+++ httpcomponents/httpcore/branches/ibm_compat_branch/httpcore-nio/src/main/java/org/apache/http/nio/params/NIOReactorParams.java Wed Mar 18 18:13:03 2009
@@ -35,10 +35,10 @@
 
 /**
  * Utility class for accessing I/O reactor parameters in {@link HttpParams}.
- * 
- * 
+ *
+ *
  * @version $Revision$
- * 
+ *
  * @since 4.0
  *
  * @see NIOReactorPNames
@@ -55,7 +55,7 @@
         }
         return params.getIntParameter(CONTENT_BUFFER_SIZE, 1024);
     }
-    
+
     public static void setContentBufferSize(final HttpParams params, int size) {
         if (params == null) {
             throw new IllegalArgumentException("HTTP parameters may not be null");
@@ -69,7 +69,7 @@
         }
         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");
@@ -83,7 +83,7 @@
         }
         return params.getLongParameter(GRACE_PERIOD, 500);
     }
-    
+
     public static void setGracePeriod(final HttpParams params, long ms) {
         if (params == null) {
             throw new IllegalArgumentException("HTTP parameters may not be null");
@@ -91,4 +91,18 @@
         params.setLongParameter(GRACE_PERIOD, ms);
     }
 
+    public static boolean getInterestOpsQueueing(final HttpParams params) {
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        return params.getBooleanParameter(INTEREST_OPS_QUEUEING, false);
+    }
+
+    public static void setInterestOpsQueueing(final HttpParams params, boolean interestOpsQueueing) {
+        if (params == null) {
+            throw new IllegalArgumentException("HTTP parameters may not be null");
+        }
+        params.setBooleanParameter(INTEREST_OPS_QUEUEING, interestOpsQueueing);
+    }
+
 }



Mime
View raw message