hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1767344 - in /httpcomponents/httpcore/trunk: httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/ httpcore5/src/main/java/org/apache/hc/core5/reactor/ httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/
Date Mon, 31 Oct 2016 17:35:14 GMT
Author: olegk
Date: Mon Oct 31 17:35:13 2016
New Revision: 1767344

URL: http://svn.apache.org/viewvc?rev=1767344&view=rev
Log:
Removed obsolete I/O session functionality

Removed:
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/AbstractIOEventHandler.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/SessionBufferStatus.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/SocketAccessor.java
Modified:
    httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/AbstractIOReactor.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/BaseIOReactor.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSession.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java?rev=1767344&r1=1767343&r2=1767344&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/LoggingIOSession.java
Mon Oct 31 17:35:13 2016
@@ -35,11 +35,10 @@ import java.nio.channels.SelectionKey;
 import java.util.Deque;
 
 import org.apache.commons.logging.Log;
-import org.apache.hc.core5.testing.classic.Wire;
 import org.apache.hc.core5.reactor.Command;
 import org.apache.hc.core5.reactor.IOEventHandler;
 import org.apache.hc.core5.reactor.IOSession;
-import org.apache.hc.core5.reactor.SessionBufferStatus;
+import org.apache.hc.core5.testing.classic.Wire;
 
 /**
  * Decorator class intended to transparently extend an {@link IOSession}
@@ -175,42 +174,6 @@ public class LoggingIOSession implements
     }
 
     @Override
-    public void setBufferStatus(final SessionBufferStatus status) {
-        this.session.setBufferStatus(status);
-    }
-
-    @Override
-    public boolean hasBufferedInput() {
-        return this.session.hasBufferedInput();
-    }
-
-    @Override
-    public boolean hasBufferedOutput() {
-        return this.session.hasBufferedOutput();
-    }
-
-    @Override
-    public Object getAttribute(final String name) {
-        return this.session.getAttribute(name);
-    }
-
-    @Override
-    public void setAttribute(final String name, final Object obj) {
-        if (this.log.isDebugEnabled()) {
-            this.log.debug(this.id + " " + this.session + ": Set attribute " + name);
-        }
-        this.session.setAttribute(name, obj);
-    }
-
-    @Override
-    public Object removeAttribute(final String name) {
-        if (this.log.isDebugEnabled()) {
-            this.log.debug(this.id + " " + this.session + ": Remove attribute " + name);
-        }
-        return this.session.removeAttribute(name);
-    }
-
-    @Override
     public IOEventHandler getHandler() {
         return this.session.getHandler();
     }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/AbstractIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/AbstractIOReactor.java?rev=1767344&r1=1767343&r2=1767344&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/AbstractIOReactor.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/AbstractIOReactor.java
Mon Oct 31 17:35:13 2016
@@ -343,7 +343,6 @@ abstract class AbstractIOReactor impleme
             try {
                 final SessionRequestImpl sessionRequest = pendingSession.sessionRequest;
                 if (sessionRequest != null) {
-                    session.setAttribute(IOSession.ATTACHMENT_KEY, sessionRequest.getAttachment());
                     sessionRequest.completed(session);
                 }
                 sessionCreated(session);

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/BaseIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/BaseIOReactor.java?rev=1767344&r1=1767343&r2=1767344&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/BaseIOReactor.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/BaseIOReactor.java
Mon Oct 31 17:35:13 2016
@@ -30,8 +30,6 @@ package org.apache.hc.core5.reactor;
 import java.io.InterruptedIOException;
 import java.nio.channels.CancelledKeyException;
 import java.nio.channels.SelectionKey;
-import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Set;
 
 /**
@@ -43,7 +41,6 @@ import java.util.Set;
 public class BaseIOReactor extends AbstractIOReactor {
 
     private final long timeoutCheckInterval;
-    private final Set<IOSession> bufferingSessions;
     private final IOReactorExceptionHandler exceptionHandler;
 
     private long lastTimeoutCheck;
@@ -59,7 +56,6 @@ public class BaseIOReactor extends Abstr
             final IOReactorConfig reactorConfig,
             final IOReactorExceptionHandler exceptionHandler) {
         super(eventHandlerFactory, reactorConfig);
-        this.bufferingSessions = new HashSet<>();
         this.timeoutCheckInterval = reactorConfig.getSelectInterval();
         this.exceptionHandler = exceptionHandler;
         this.lastTimeoutCheck = System.currentTimeMillis();
@@ -122,19 +118,7 @@ public class BaseIOReactor extends Abstr
         final IOSession session = getSession(key);
         try {
             final IOEventHandler eventHandler = ensureEventHandler(session);
-            // Try to gently feed more data to the event dispatcher
-            // if the session input buffer has not been fully exhausted
-            // (the choice of 5 iterations is purely arbitrary)
-            for (int i = 0; i < 5; i++) {
-                eventHandler.inputReady(session);
-                if (!session.hasBufferedInput()
-                        || (session.getEventMask() & SelectionKey.OP_READ) == 0) {
-                    break;
-                }
-            }
-            if (session.hasBufferedInput()) {
-                this.bufferingSessions.add(session);
-            }
+            eventHandler.inputReady(session);
         } catch (final CancelledKeyException ex) {
             session.shutdown();
             key.attach(null);
@@ -178,29 +162,6 @@ public class BaseIOReactor extends Abstr
                 }
             }
         }
-        if (!this.bufferingSessions.isEmpty()) {
-            for (final Iterator<IOSession> it = this.bufferingSessions.iterator();
it.hasNext(); ) {
-                final IOSession session = it.next();
-                if (!session.hasBufferedInput()) {
-                    it.remove();
-                    continue;
-                }
-                try {
-                    if ((session.getEventMask() & EventMask.READ) > 0) {
-                        final IOEventHandler eventHandler = ensureEventHandler(session);
-                        eventHandler.inputReady(session);
-                        if (!session.hasBufferedInput()) {
-                            it.remove();
-                        }
-                    }
-                } catch (final CancelledKeyException ex) {
-                    it.remove();
-                    session.shutdown();
-                } catch (final RuntimeException ex) {
-                    handleRuntimeException(ex);
-                }
-            }
-        }
     }
 
     /**

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSession.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSession.java?rev=1767344&r1=1767343&r2=1767344&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSession.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSession.java
Mon Oct 31 17:35:13 2016
@@ -181,76 +181,4 @@ public interface IOSession {
      */
     void setSocketTimeout(int timeout);
 
-    /**
-     * Quite often I/O sessions need to maintain internal I/O buffers in order
-     * to transform input / output data prior to returning it to the consumer or
-     * writing it to the underlying channel. Memory management in HttpCore NIO
-     * is based on the fundamental principle that the data consumer can read
-     * only as much input data as it can process without having to allocate more
-     * memory. That means, quite often some input data may remain unread in one
-     * of the internal or external session buffers. The I/O reactor can query
-     * the status of these session buffers, and make sure the consumer gets
-     * notified correctly as more data gets stored in one of the session
-     * buffers, thus allowing the consumer to read the remaining data once it
-     * is able to process it
-     * <p>
-     * I/O sessions can be made aware of the status of external session buffers
-     * using the {@link SessionBufferStatus} interface.
-     */
-    void setBufferStatus(SessionBufferStatus status);
-
-    /**
-     * Determines if the input buffer associated with the session contains data.
-     *
-     * @return {@code true} if the session input buffer contains data,
-     *   {@code false} otherwise.
-     */
-    boolean hasBufferedInput();
-
-    /**
-     * Determines if the output buffer associated with the session contains
-     * data.
-     *
-     * @return {@code true} if the session output buffer contains data,
-     *   {@code false} otherwise.
-     */
-    boolean hasBufferedOutput();
-
-    /**
-     * This method can be used to associate a particular object with the
-     * session by the given attribute name.
-     * <p>
-     * I/O sessions are not bound to an execution thread, therefore one cannot
-     * use the context of the thread to store a session's state. All details
-     * about a particular session must be stored within the session itself.
-     *
-     * @param name name of the attribute.
-     * @param obj value of the attribute.
-     */
-    void setAttribute(String name, Object obj);
-
-    /**
-     * Returns the value of the attribute with the given name. The value can be
-     * {@code null} if not set.
-     * <p>
-     * The value of the session attachment object can be obtained using
-     * {@link #ATTACHMENT_KEY} name.
-     *
-     * @see #setAttribute(String, Object)
-     *
-     * @param name name of the attribute.
-     * @return value of the attribute.
-     */
-    Object getAttribute(String name);
-
-    /**
-     * Removes attribute with the given name.
-     *
-     * @see #setAttribute(String, Object)
-     *
-     * @param name name of the attribute to be removed.
-     * @return value of the removed attribute.
-     */
-    Object removeAttribute(String name);
-
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java?rev=1767344&r1=1767343&r2=1767344&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOSessionImpl.java
Mon Oct 31 17:35:13 2016
@@ -29,7 +29,6 @@ package org.apache.hc.core5.reactor;
 
 import java.io.IOException;
 import java.net.InetSocketAddress;
-import java.net.Socket;
 import java.net.SocketAddress;
 import java.nio.channels.ByteChannel;
 import java.nio.channels.SelectionKey;
@@ -51,7 +50,7 @@ import org.apache.hc.core5.util.Args;
  * @since 4.0
  */
 @Contract(threading = ThreadingBehavior.SAFE)
-class IOSessionImpl implements IOSession, SocketAccessor {
+class IOSessionImpl implements IOSession {
 
     private final SelectionKey key;
     private final SocketChannel channel;
@@ -64,7 +63,6 @@ class IOSessionImpl implements IOSession
     private final Deque<Command> commandQueue;
 
     private volatile IOEventHandler eventHandler;
-    private volatile SessionBufferStatus bufferStatus;
     private volatile int socketTimeout;
 
     private volatile long lastReadTime;
@@ -228,42 +226,6 @@ class IOSessionImpl implements IOSession
         close();
     }
 
-    @Override
-    public boolean hasBufferedInput() {
-        final SessionBufferStatus buffStatus = this.bufferStatus;
-        return buffStatus != null && buffStatus.hasBufferedInput();
-    }
-
-    @Override
-    public boolean hasBufferedOutput() {
-        final SessionBufferStatus buffStatus = this.bufferStatus;
-        return buffStatus != null && buffStatus.hasBufferedOutput();
-    }
-
-    @Override
-    public void setBufferStatus(final SessionBufferStatus bufferStatus) {
-        this.bufferStatus = bufferStatus;
-    }
-
-    @Override
-    public Object getAttribute(final String name) {
-        return this.attributes.get(name);
-    }
-
-    @Override
-    public Object removeAttribute(final String name) {
-        return this.attributes.remove(name);
-    }
-
-    @Override
-    public void setAttribute(final String name, final Object obj) {
-        if (obj == null) {
-            this.attributes.remove(name);
-        } else {
-            this.attributes.put(name, obj);
-        }
-    }
-
     public long getStartedTime() {
         return this.startedTime;
     }
@@ -320,11 +282,6 @@ class IOSessionImpl implements IOSession
     }
 
     @Override
-    public Socket getSocket() {
-        return this.channel.socket();
-    }
-
-    @Override
     public String toString() {
         final StringBuilder buffer = new StringBuilder();
         final SocketAddress remoteAddress = getRemoteAddress();

Modified: httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java?rev=1767344&r1=1767343&r2=1767344&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLIOSession.java
Mon Oct 31 17:35:13 2016
@@ -28,7 +28,6 @@
 package org.apache.hc.core5.reactor.ssl;
 
 import java.io.IOException;
-import java.net.Socket;
 import java.net.SocketAddress;
 import java.nio.ByteBuffer;
 import java.nio.channels.ByteChannel;
@@ -52,8 +51,6 @@ import org.apache.hc.core5.reactor.Comma
 import org.apache.hc.core5.reactor.EventMask;
 import org.apache.hc.core5.reactor.IOEventHandler;
 import org.apache.hc.core5.reactor.IOSession;
-import org.apache.hc.core5.reactor.SessionBufferStatus;
-import org.apache.hc.core5.reactor.SocketAccessor;
 import org.apache.hc.core5.util.Args;
 import org.apache.hc.core5.util.Asserts;
 
@@ -75,7 +72,7 @@ import org.apache.hc.core5.util.Asserts;
  * @since 4.2
  */
 @Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL)
-public class SSLIOSession implements IOSession, SessionBufferStatus, SocketAccessor {
+public class SSLIOSession implements IOSession {
 
     /**
      * Name of the context attribute key, which can be used to obtain the
@@ -95,7 +92,6 @@ public class SSLIOSession implements IOS
     private final SSLSetupHandler handler;
 
     private int appEventMask;
-    private SessionBufferStatus appBufferStatus;
 
     private boolean endOfStream;
     private volatile SSLMode sslMode;
@@ -150,9 +146,6 @@ public class SSLIOSession implements IOS
         this.channel = new InternalByteChannel();
         this.handler = handler;
 
-        // Override the status buffer interface
-        this.session.setBufferStatus(this);
-
         if (this.sslMode == SSLMode.CLIENT && host != null) {
             this.sslEngine = sslContext.createSSLEngine(host.getHostName(), host.getPort());
         } else {
@@ -502,9 +495,7 @@ public class SSLIOSession implements IOS
         } while (this.sslEngine.getHandshakeStatus() == HandshakeStatus.NEED_TASK);
         // Some decrypted data is available or at the end of stream
         return (this.appEventMask & SelectionKey.OP_READ) > 0
-            && (this.inPlain.hasData()
-                    || (this.appBufferStatus != null && this.appBufferStatus.hasBufferedInput())
-                    || (this.endOfStream && this.status == ACTIVE));
+            && (this.inPlain.hasData() || (this.endOfStream && this.status
== ACTIVE));
     }
 
     /**
@@ -706,40 +697,6 @@ public class SSLIOSession implements IOS
     }
 
     @Override
-    public synchronized boolean hasBufferedInput() {
-        return (this.appBufferStatus != null && this.appBufferStatus.hasBufferedInput())
-            || this.inEncrypted.hasData()
-            || this.inPlain.hasData();
-    }
-
-    @Override
-    public synchronized boolean hasBufferedOutput() {
-        return (this.appBufferStatus != null && this.appBufferStatus.hasBufferedOutput())
-            || this.outEncrypted.hasData()
-            || this.outPlain.hasData();
-    }
-
-    @Override
-    public synchronized void setBufferStatus(final SessionBufferStatus status) {
-        this.appBufferStatus = status;
-    }
-
-    @Override
-    public Object getAttribute(final String name) {
-        return this.session.getAttribute(name);
-    }
-
-    @Override
-    public Object removeAttribute(final String name) {
-        return this.session.removeAttribute(name);
-    }
-
-    @Override
-    public void setAttribute(final String name, final Object obj) {
-        this.session.setAttribute(name, obj);
-    }
-
-    @Override
     public IOEventHandler getHandler() {
         return this.session.getHandler();
     }
@@ -799,14 +756,6 @@ public class SSLIOSession implements IOS
         return buffer.toString();
     }
 
-    @Override
-    public Socket getSocket(){
-        if (this.session instanceof SocketAccessor){
-            return ((SocketAccessor) this.session).getSocket();
-        }
-        return null;
-    }
-
     private class InternalByteChannel implements ByteChannel {
 
         @Override



Mime
View raw message