View Javadoc

    1   /*
    2    * Copyright 2012 The Netty Project
    3    *
    4    * The Netty Project licenses this file to you under the Apache License,
    5    * version 2.0 (the "License"); you may not use this file except in compliance
    6    * with the License. You may obtain a copy of the License at:
    7    *
    8    *   http://www.apache.org/licenses/LICENSE-2.0
    9    *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    13   * License for the specific language governing permissions and limitations
    14   * under the License.
    15   */
    16  package org.jboss.netty.channel.socket.nio;
    17
    18  import org.jboss.netty.channel.AdaptiveReceiveBufferSizePredictor;
    19  import org.jboss.netty.channel.AdaptiveReceiveBufferSizePredictorFactory;
    20  import org.jboss.netty.channel.ChannelConfig;
    21  import org.jboss.netty.channel.ReceiveBufferSizePredictor;
    22  import org.jboss.netty.channel.ReceiveBufferSizePredictorFactory;
    23  import org.jboss.netty.channel.socket.SocketChannel;
    24  import org.jboss.netty.channel.socket.SocketChannelConfig;
    25
    26  /**
    27   * A {@link SocketChannelConfig} for a NIO TCP/IP {@link SocketChannel}.
    28   *
    29   * <h3>Available options</h3>
    30   *
    31   * In addition to the options provided by {@link ChannelConfig} and
    32   * {@link SocketChannelConfig}, {@link NioSocketChannelConfig} allows the
    33   * following options in the option map:
    34   *
    35   * <table border="1" cellspacing="0" cellpadding="6">
    36   * <tr>
    37   * <th>Name</th><th>Associated setter method</th>
    38   * </tr><tr>
    39   * <td>{@code "writeBufferHighWaterMark"}</td><td>{@link #setWriteBufferHighWaterMark(int)}</td>
    40   * </tr><tr>
    41   * <td>{@code "writeBufferLowWaterMark"}</td><td>{@link #setWriteBufferLowWaterMark(int)}</td>
    42   * </tr><tr>
    43   * <td>{@code "writeSpinCount"}</td><td>{@link #setWriteSpinCount(int)}</td>
    44   * </tr><tr>
    45   * <td>{@code "receiveBufferSizePredictor"}</td>
    46   * <td>{@link #setReceiveBufferSizePredictor(ReceiveBufferSizePredictor)}</td>
    47   * </tr><tr>
    48   * <td>{@code "receiveBufferSizePredictorFactory"}</td>
    49   * <td>{@link #setReceiveBufferSizePredictorFactory(ReceiveBufferSizePredictorFactory)}</td>
    50   * </tr>
    51   * </table>
    52   */
    53  public interface NioSocketChannelConfig extends SocketChannelConfig, NioChannelConfig {
    54
    55      /**
    56       * Returns the {@link ReceiveBufferSizePredictor} which predicts the
    57       * number of readable bytes in the socket receive buffer.  The default
    58       * predictor is <tt>{@link AdaptiveReceiveBufferSizePredictor}(64, 1024, 65536)</tt>.
    59       */
    60      ReceiveBufferSizePredictor getReceiveBufferSizePredictor();
    61
    62      /**
    63       * Sets the {@link ReceiveBufferSizePredictor} which predicts the
    64       * number of readable bytes in the socket receive buffer.  The default
    65       * predictor is <tt>{@link AdaptiveReceiveBufferSizePredictor}(64, 1024, 65536)</tt>.
    66       */
    67      void setReceiveBufferSizePredictor(ReceiveBufferSizePredictor predictor);
    68
    69      /**
    70       * Returns the {@link ReceiveBufferSizePredictorFactory} which creates a new
    71       * {@link ReceiveBufferSizePredictor} when a new channel is created and
    72       * no {@link ReceiveBufferSizePredictor} was set.  If no predictor was set
    73       * for the channel, {@link #setReceiveBufferSizePredictor(ReceiveBufferSizePredictor)}
    74       * will be called with the new predictor.  The default factory is
    75       * <tt>{@link AdaptiveReceiveBufferSizePredictorFactory}(64, 1024, 65536)</tt>.
    76       */
    77      ReceiveBufferSizePredictorFactory getReceiveBufferSizePredictorFactory();
    78
    79      /**
    80       * Sets the {@link ReceiveBufferSizePredictor} which creates a new
    81       * {@link ReceiveBufferSizePredictor} when a new channel is created and
    82       * no {@link ReceiveBufferSizePredictor} was set.  If no predictor was set
    83       * for the channel, {@link #setReceiveBufferSizePredictor(ReceiveBufferSizePredictor)}
    84       * will be called with the new predictor.  The default factory is
    85       * <tt>{@link AdaptiveReceiveBufferSizePredictorFactory}(64, 1024, 65536)</tt>.
    86       */
    87      void setReceiveBufferSizePredictorFactory(ReceiveBufferSizePredictorFactory predictorFactory);
    88  }