hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r1444386 - in /httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor: AbstractMultiworkerIOReactor.java DefaultListeningIOReactor.java IOReactorConfig.java
Date Sun, 10 Feb 2013 00:32:43 GMT
On 9 February 2013 16:08,  <olegk@apache.org> wrote:
> Author: olegk
> Date: Sat Feb  9 16:08:28 2013
> New Revision: 1444386
>
> URL: http://svn.apache.org/r1444386
> Log:
> Added sndBufSize / rcvBufSize parameters to IOReactorConfig
>
> Modified:
>     httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
>     httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java
>     httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOReactorConfig.java
>
> Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
> URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java?rev=1444386&r1=1444385&r2=1444386&view=diff
> ==============================================================================
> --- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
(original)
> +++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
Sat Feb  9 16:08:28 2013
> @@ -498,8 +498,17 @@ public abstract class AbstractMultiworke
>       */
>      protected void prepareSocket(final Socket socket) throws IOException {
>          socket.setTcpNoDelay(this.config.isTcpNoDelay());
> -        socket.setSoTimeout(this.config.getSoTimeout());
>          socket.setKeepAlive(this.config.isSoKeepalive());
> +        socket.setReuseAddress(this.config.isSoReuseAddress());
> +        if (this.config.getSoTimeout() > 0) {
> +            socket.setSoTimeout(this.config.getSoTimeout());
> +        }
> +        if (this.config.getSndBufSize() > 0) {
> +            socket.setSendBufferSize(this.config.getSndBufSize());
> +        }
> +        if (this.config.getRcvBufSize() > 0) {
> +            socket.setReceiveBufferSize(this.config.getRcvBufSize());
> +        }
>          final int linger = this.config.getSoLinger();
>          if (linger >= 0) {
>              socket.setSoLinger(linger > 0, linger);
>
> Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java
> URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java?rev=1444386&r1=1444385&r2=1444386&view=diff
> ==============================================================================
> --- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java
(original)
> +++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/DefaultListeningIOReactor.java
Sat Feb  9 16:08:28 2013
> @@ -28,6 +28,7 @@
>  package org.apache.http.impl.nio.reactor;
>
>  import java.io.IOException;
> +import java.net.ServerSocket;
>  import java.net.SocketAddress;
>  import java.nio.channels.CancelledKeyException;
>  import java.nio.channels.SelectionKey;
> @@ -231,8 +232,10 @@ public class DefaultListeningIOReactor e
>                  throw new IOReactorException("Failure opening server socket", ex);
>              }
>              try {
> +                final ServerSocket socket = serverChannel.socket();
> +                socket.setReuseAddress(this.config.isSoReuseAddress());
>                  serverChannel.configureBlocking(false);
> -                serverChannel.socket().bind(address);
> +                socket.bind(address);
>              } catch (final IOException ex) {
>                  closeChannel(serverChannel);
>                  request.failed(ex);
>
> Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOReactorConfig.java
> URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOReactorConfig.java?rev=1444386&r1=1444385&r2=1444386&view=diff
> ==============================================================================
> --- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOReactorConfig.java
(original)
> +++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/IOReactorConfig.java
Sat Feb  9 16:08:28 2013
> @@ -56,6 +56,8 @@ public final class IOReactorConfig imple
>      private boolean soKeepAlive;
>      private boolean tcpNoDelay;
>      private int connectTimeout;
> +    private int sndBufSize;
> +    private int rcvBufSize;
>
>      @Deprecated
>      public IOReactorConfig() {
> @@ -70,6 +72,8 @@ public final class IOReactorConfig imple
>          this.soKeepAlive = false;
>          this.tcpNoDelay = true;
>          this.connectTimeout = 0;
> +        this.sndBufSize = 0;
> +        this.rcvBufSize = 0;
>      }
>
>      IOReactorConfig(
> @@ -82,7 +86,9 @@ public final class IOReactorConfig imple
>              final int soLinger,
>              final boolean soKeepAlive,
>              final boolean tcpNoDelay,
> -            final int connectTimeout) {
> +            final int connectTimeout,
> +            final int sndBufSize,
> +            final int rcvBufSize) {
>          super();
>          this.selectInterval = selectInterval;
>          this.shutdownGracePeriod = shutdownGracePeriod;
> @@ -94,6 +100,8 @@ public final class IOReactorConfig imple
>          this.soKeepAlive = soKeepAlive;
>          this.tcpNoDelay = tcpNoDelay;
>          this.connectTimeout = connectTimeout;
> +        this.sndBufSize = sndBufSize;
> +        this.rcvBufSize = rcvBufSize;
>      }
>
>      /**
> @@ -261,6 +269,52 @@ public final class IOReactorConfig imple
>          this.connectTimeout = connectTimeout;
>      }
>
> +    /**
> +     * Determines the default value of the {@link SocketOptions#SO_SNDBUF} parameter
> +     * for newly created sockets.
> +     * <p/>
> +     * Default: <code>0</code> (system default)
> +     *
> +     * @see SocketOptions#SO_SNDBUF
> +     */
> +    public int getSndBufSize() {
> +        return sndBufSize;
> +    }
> +
> +    /**
> +     * Defines the default value of the {@link SocketOptions#SO_SNDBUF} parameter
> +     * for newly created sockets.
> +     *

The Javadoc should mention that the param is ignored unless > 0.
> +     * @see SocketOptions#SO_SNDBUF
> +     */
> +    @Deprecated

Huh? Why add a deprecated method?
If it is really deprecated from birth, should include @deprecated
Javadoc tag with details of replacement.

> +    public void setSndBufSize(final int sndBufSize) {
> +        this.sndBufSize = sndBufSize;
> +    }
> +
> +    /**
> +     * Determines the default value of the {@link SocketOptions#SO_RCVBUF} parameter
> +     * for newly created sockets.
> +     * <p/>
> +     * Default: <code>0</code> (system default)
> +     *
> +     * @see SocketOptions#SO_RCVBUF
> +     */
> +    public int getRcvBufSize() {
> +        return rcvBufSize;
> +    }
> +
> +    /**
> +     * Defines the default value of the {@link SocketOptions#SO_RCVBUF} parameter
> +     * for newly created sockets.
> +     *
> +     * @see SocketOptions#SO_RCVBUF
> +     */
> +    @Deprecated

Same comments apply here.

> +    public void setRcvBufSize(final int rcvBufSize) {
> +        this.rcvBufSize = rcvBufSize;
> +    }
> +
>      @Override
>      protected IOReactorConfig clone() throws CloneNotSupportedException {
>          return (IOReactorConfig) super.clone();
> @@ -297,6 +351,8 @@ public final class IOReactorConfig imple
>          private boolean soKeepAlive;
>          private boolean tcpNoDelay;
>          private int connectTimeout;
> +        private int sndBufSize;
> +        private int rcvBufSize;
>
>          Builder() {
>              this.selectInterval = 1000;
> @@ -309,6 +365,8 @@ public final class IOReactorConfig imple
>              this.soKeepAlive = false;
>              this.tcpNoDelay = true;
>              this.connectTimeout = 0;
> +            this.sndBufSize = 0;
> +            this.rcvBufSize = 0;
>          }
>
>          public Builder setSelectInterval(final long selectInterval) {
> @@ -361,10 +419,21 @@ public final class IOReactorConfig imple
>              return this;
>          }
>
> +        public Builder setSndBufSize(final int sndBufSize) {
> +            this.sndBufSize = sndBufSize;
> +            return this;
> +        }
> +
> +        public Builder setRcvBufSize(final int rcvBufSize) {
> +            this.rcvBufSize = rcvBufSize;
> +            return this;
> +        }
> +
>          public IOReactorConfig build() {
>              return new IOReactorConfig(
>                      selectInterval, shutdownGracePeriod, interestOpQueued, ioThreadCount,
> -                    soTimeout, soReuseAddress, soLinger, soKeepAlive, tcpNoDelay, connectTimeout);
> +                    soTimeout, soReuseAddress, soLinger, soKeepAlive, tcpNoDelay,
> +                    connectTimeout, sndBufSize, rcvBufSize);
>          }
>
>      }
> @@ -381,7 +450,10 @@ public final class IOReactorConfig imple
>                  .append(", soLinger=").append(this.soLinger)
>                  .append(", soKeepAlive=").append(this.soKeepAlive)
>                  .append(", tcpNoDelay=").append(this.tcpNoDelay)
> -                .append(", connectTimeout=").append(this.connectTimeout).append("]");
> +                .append(", connectTimeout=").append(this.connectTimeout)
> +                .append(", sndBufSize=").append(this.sndBufSize)
> +                .append(", rcvBufSize=").append(this.rcvBufSize)
> +                .append("]");
>          return builder.toString();
>      }
>
>
>

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


Mime
View raw message