View Javadoc

    1   /*
    2    *  Licensed to the Apache Software Foundation (ASF) under one
    3    *  or more contributor license agreements.  See the NOTICE file
    4    *  distributed with this work for additional information
    5    *  regarding copyright ownership.  The ASF licenses this file
    6    *  to you under the Apache License, Version 2.0 (the
    7    *  "License"); you may not use this file except in compliance
    8    *  with the License.  You may obtain a copy of the License at
    9    *
    10   *    http://www.apache.org/licenses/LICENSE-2.0
    11   *
    12   *  Unless required by applicable law or agreed to in writing,
    13   *  software distributed under the License is distributed on an
    14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    15   *  KIND, either express or implied.  See the License for the
    16   *  specific language governing permissions and limitations
    17   *  under the License.
    18   *
    19   */
    20  package org.apache.mina.core.session;
    21
    22  import java.util.concurrent.BlockingQueue;
    23
    24  /**
    25   * The configuration of {@link IoSession}.
    26   *
    27   * @author <a href="http://mina.apache.org">Apache MINA Project</a>
    28   */
    29  public interface IoSessionConfig {
    30
    31      /**
    32       * Returns the size of the read buffer that I/O processor allocates
    33       * per each read.  It's unusual to adjust this property because
    34       * it's often adjusted automatically by the I/O processor.
    35       */
    36      int getReadBufferSize();
    37
    38      /**
    39       * Sets the size of the read buffer that I/O processor allocates
    40       * per each read.  It's unusual to adjust this property because
    41       * it's often adjusted automatically by the I/O processor.
    42       */
    43      void setReadBufferSize(int readBufferSize);
    44
    45      /**
    46       * Returns the minimum size of the read buffer that I/O processor
    47       * allocates per each read.  I/O processor will not decrease the
    48       * read buffer size to the smaller value than this property value.
    49       */
    50      int getMinReadBufferSize();
    51
    52      /**
    53       * Sets the minimum size of the read buffer that I/O processor
    54       * allocates per each read.  I/O processor will not decrease the
    55       * read buffer size to the smaller value than this property value.
    56       */
    57      void setMinReadBufferSize(int minReadBufferSize);
    58
    59      /**
    60       * Returns the maximum size of the read buffer that I/O processor
    61       * allocates per each read.  I/O processor will not increase the
    62       * read buffer size to the greater value than this property value.
    63       */
    64      int getMaxReadBufferSize();
    65
    66      /**
    67       * Sets the maximum size of the read buffer that I/O processor
    68       * allocates per each read.  I/O processor will not increase the
    69       * read buffer size to the greater value than this property value.
    70       */
    71      void setMaxReadBufferSize(int maxReadBufferSize);
    72
    73      /**
    74       * Returns the interval (seconds) between each throughput calculation.
    75       * The default value is <tt>3</tt> seconds.
    76       */
    77      int getThroughputCalculationInterval();
    78
    79      /**
    80       * Returns the interval (milliseconds) between each throughput calculation.
    81       * The default value is <tt>3</tt> seconds.
    82       */
    83      long getThroughputCalculationIntervalInMillis();
    84
    85      /**
    86       * Sets the interval (seconds) between each throughput calculation.  The
    87       * default value is <tt>3</tt> seconds.
    88       */
    89      void setThroughputCalculationInterval(int throughputCalculationInterval);
    90
    91      /**
    92       * Returns idle time for the specified type of idleness in seconds.
    93       */
    94      int getIdleTime(IdleStatus status);
    95
    96      /**
    97       * Returns idle time for the specified type of idleness in milliseconds.
    98       */
    99      long getIdleTimeInMillis(IdleStatus status);
    100
    101     /**
    102      * Sets idle time for the specified type of idleness in seconds.
    103      */
    104     void setIdleTime(IdleStatus status, int idleTime);
    105
    106     /**
    107      * Returns idle time for {@link IdleStatus#READER_IDLE} in seconds.
    108      */
    109     int getReaderIdleTime();
    110
    111     /**
    112      * Returns idle time for {@link IdleStatus#READER_IDLE} in milliseconds.
    113      */
    114     long getReaderIdleTimeInMillis();
    115
    116     /**
    117      * Sets idle time for {@link IdleStatus#READER_IDLE} in seconds.
    118      */
    119     void setReaderIdleTime(int idleTime);
    120
    121     /**
    122      * Returns idle time for {@link IdleStatus#WRITER_IDLE} in seconds.
    123      */
    124     int getWriterIdleTime();
    125
    126     /**
    127      * Returns idle time for {@link IdleStatus#WRITER_IDLE} in milliseconds.
    128      */
    129     long getWriterIdleTimeInMillis();
    130
    131     /**
    132      * Sets idle time for {@link IdleStatus#WRITER_IDLE} in seconds.
    133      */
    134     void setWriterIdleTime(int idleTime);
    135
    136     /**
    137      * Returns idle time for {@link IdleStatus#BOTH_IDLE} in seconds.
    138      */
    139     int getBothIdleTime();
    140
    141     /**
    142      * Returns idle time for {@link IdleStatus#BOTH_IDLE} in milliseconds.
    143      */
    144     long getBothIdleTimeInMillis();
    145
    146     /**
    147      * Sets idle time for {@link IdleStatus#WRITER_IDLE} in seconds.
    148      */
    149     void setBothIdleTime(int idleTime);
    150
    151     /**
    152      * Returns write timeout in seconds.
    153      */
    154     int getWriteTimeout();
    155
    156     /**
    157      * Returns write timeout in milliseconds.
    158      */
    159     long getWriteTimeoutInMillis();
    160
    161     /**
    162      * Sets write timeout in seconds.
    163      */
    164     void setWriteTimeout(int writeTimeout);
    165
    166     /**
    167      * Returns <tt>true</tt> if and only if {@link IoSession#read()} operation
    168      * is enabled.  If enabled, all received messages are stored in an internal
    169      * {@link BlockingQueue} so you can read received messages in more
    170      * convenient way for client applications.  Enabling this option is not
    171      * useful to server applications and can cause unintended memory leak, and
    172      * therefore it's disabled by default.
    173      */
    174     boolean isUseReadOperation();
    175
    176     /**
    177      * Enables or disabled {@link IoSession#read()} operation.  If enabled, all
    178      * received messages are stored in an internal {@link BlockingQueue} so you
    179      * can read received messages in more convenient way for client
    180      * applications.  Enabling this option is not useful to server applications
    181      * and can cause unintended memory leak, and therefore it's disabled by
    182      * default.
    183      */
    184     void setUseReadOperation(boolean useReadOperation);
    185
    186     /**
    187      * Sets all configuration properties retrieved from the specified
    188      * <tt>config</tt>.
    189      */
    190     void setAll(IoSessionConfig config);
    191 }