001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License.
018 *
019 */
020package org.apache.mina.core.session;
021
022import java.util.concurrent.BlockingQueue;
023
024/**
025 * The configuration of {@link IoSession}.
026 *
027 * @author <a href="http://mina.apache.org">Apache MINA Project</a>
028 */
029public interface IoSessionConfig {
030
031    /**
032     * Returns the size of the read buffer that I/O processor allocates
033     * per each read.  It's unusual to adjust this property because
034     * it's often adjusted automatically by the I/O processor.
035     */
036    int getReadBufferSize();
037
038    /**
039     * Sets the size of the read buffer that I/O processor allocates
040     * per each read.  It's unusual to adjust this property because
041     * it's often adjusted automatically by the I/O processor.
042     */
043    void setReadBufferSize(int readBufferSize);
044
045    /**
046     * Returns the minimum size of the read buffer that I/O processor
047     * allocates per each read.  I/O processor will not decrease the
048     * read buffer size to the smaller value than this property value.
049     */
050    int getMinReadBufferSize();
051
052    /**
053     * Sets the minimum size of the read buffer that I/O processor
054     * allocates per each read.  I/O processor will not decrease the
055     * read buffer size to the smaller value than this property value.
056     */
057    void setMinReadBufferSize(int minReadBufferSize);
058
059    /**
060     * Returns the maximum size of the read buffer that I/O processor
061     * allocates per each read.  I/O processor will not increase the
062     * read buffer size to the greater value than this property value.
063     */
064    int getMaxReadBufferSize();
065
066    /**
067     * Sets the maximum size of the read buffer that I/O processor
068     * allocates per each read.  I/O processor will not increase the
069     * read buffer size to the greater value than this property value.
070     */
071    void setMaxReadBufferSize(int maxReadBufferSize);
072
073    /**
074     * Returns the interval (seconds) between each throughput calculation.
075     * The default value is <tt>3</tt> seconds.
076     */
077    int getThroughputCalculationInterval();
078
079    /**
080     * Returns the interval (milliseconds) between each throughput calculation.
081     * The default value is <tt>3</tt> seconds.
082     */
083    long getThroughputCalculationIntervalInMillis();
084
085    /**
086     * Sets the interval (seconds) between each throughput calculation.  The
087     * default value is <tt>3</tt> seconds.
088     */
089    void setThroughputCalculationInterval(int throughputCalculationInterval);
090
091    /**
092     * Returns idle time for the specified type of idleness in seconds.
093     */
094    int getIdleTime(IdleStatus status);
095
096    /**
097     * Returns idle time for the specified type of idleness in milliseconds.
098     */
099    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}