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     * @return 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     * @param readBufferSize The size of the read buffer
044     */
045    void setReadBufferSize(int readBufferSize);
046
047    /**
048     * @return the minimum size of the read buffer that I/O processor
049     * allocates per each read.  I/O processor will not decrease the
050     * read buffer size to the smaller value than this property value.
051     */
052    int getMinReadBufferSize();
053
054    /**
055     * Sets the minimum size of the read buffer that I/O processor
056     * allocates per each read.  I/O processor will not decrease the
057     * read buffer size to the smaller value than this property value.
058     * 
059     * @param minReadBufferSize The minimum size of the read buffer
060     */
061    void setMinReadBufferSize(int minReadBufferSize);
062
063    /**
064     * @return the maximum size of the read buffer that I/O processor
065     * allocates per each read.  I/O processor will not increase the
066     * read buffer size to the greater value than this property value.
067     */
068    int getMaxReadBufferSize();
069
070    /**
071     * Sets the maximum size of the read buffer that I/O processor
072     * allocates per each read.  I/O processor will not increase the
073     * read buffer size to the greater value than this property value.
074     * 
075     * @param maxReadBufferSize The maximum size of the read buffer
076     */
077    void setMaxReadBufferSize(int maxReadBufferSize);
078
079    /**
080     * @return the interval (seconds) between each throughput calculation.
081     * The default value is <tt>3</tt> seconds.
082     */
083    int getThroughputCalculationInterval();
084
085    /**
086     * @return the interval (milliseconds) between each throughput calculation.
087     * The default value is <tt>3</tt> seconds.
088     */
089    long getThroughputCalculationIntervalInMillis();
090
091    /**
092     * Sets the interval (seconds) between each throughput calculation.  The
093     * default value is <tt>3</tt> seconds.
094     * 
095     * @param throughputCalculationInterval The interval
096     */
097    void setThroughputCalculationInterval(int throughputCalculationInterval);
098
099    /**
100     * @return idle time for the specified type of idleness in seconds.
101     * 
102     * @param status The status for which we want the idle time (One of READER_IDLE,
103     * WRITER_IDLE or BOTH_IDLE)
104     */
105    int getIdleTime(IdleStatus status);
106
107    /**
108     * @return idle time for the specified type of idleness in milliseconds.
109     * 
110     * @param status The status for which we want the idle time (One of READER_IDLE,
111     * WRITER_IDLE or BOTH_IDLE)
112     */
113    long getIdleTimeInMillis(IdleStatus status);
114
115    /**
116     * Sets idle time for the specified type of idleness in seconds.
117     * @param status The status for which we want to set the idle time (One of READER_IDLE,
118     * WRITER_IDLE or BOTH_IDLE)
119     * @param idleTime The time in second to set
120     */
121    void setIdleTime(IdleStatus status, int idleTime);
122
123    /**
124     * @return idle time for {@link IdleStatus#READER_IDLE} in seconds.
125     */
126    int getReaderIdleTime();
127
128    /**
129     * @return idle time for {@link IdleStatus#READER_IDLE} in milliseconds.
130     */
131    long getReaderIdleTimeInMillis();
132
133    /**
134     * Sets idle time for {@link IdleStatus#READER_IDLE} in seconds.
135     * 
136     * @param idleTime The time to set
137     */
138    void setReaderIdleTime(int idleTime);
139
140    /**
141     * @return idle time for {@link IdleStatus#WRITER_IDLE} in seconds.
142     */
143    int getWriterIdleTime();
144
145    /**
146     * @return idle time for {@link IdleStatus#WRITER_IDLE} in milliseconds.
147     */
148    long getWriterIdleTimeInMillis();
149
150    /**
151     * Sets idle time for {@link IdleStatus#WRITER_IDLE} in seconds.
152     * 
153     * @param idleTime The time to set
154     */
155    void setWriterIdleTime(int idleTime);
156
157    /**
158     * @return idle time for {@link IdleStatus#BOTH_IDLE} in seconds.
159     */
160    int getBothIdleTime();
161
162    /**
163     * @return idle time for {@link IdleStatus#BOTH_IDLE} in milliseconds.
164     */
165    long getBothIdleTimeInMillis();
166
167    /**
168     * Sets idle time for {@link IdleStatus#WRITER_IDLE} in seconds.
169     * 
170     * @param idleTime The time to set
171     */
172    void setBothIdleTime(int idleTime);
173
174    /**
175     * @return write timeout in seconds.
176     */
177    int getWriteTimeout();
178
179    /**
180     * @return write timeout in milliseconds.
181     */
182    long getWriteTimeoutInMillis();
183
184    /**
185     * Sets write timeout in seconds.
186     * 
187     * @param writeTimeout The timeout to set
188     */
189    void setWriteTimeout(int writeTimeout);
190
191    /**
192     * @return <tt>true</tt> if and only if {@link IoSession#read()} operation
193     * is enabled.  If enabled, all received messages are stored in an internal
194     * {@link BlockingQueue} so you can read received messages in more
195     * convenient way for client applications.  Enabling this option is not
196     * useful to server applications and can cause unintended memory leak, and
197     * therefore it's disabled by default.
198     */
199    boolean isUseReadOperation();
200
201    /**
202     * Enables or disabled {@link IoSession#read()} operation.  If enabled, all
203     * received messages are stored in an internal {@link BlockingQueue} so you
204     * can read received messages in more convenient way for client
205     * applications.  Enabling this option is not useful to server applications
206     * and can cause unintended memory leak, and therefore it's disabled by
207     * default.
208     * 
209     * @param useReadOperation <tt>true</tt> if the read operation is enabled, <tt>false</tt> otherwise
210     */
211    void setUseReadOperation(boolean useReadOperation);
212
213    /**
214     * Sets all configuration properties retrieved from the specified
215     * <tt>config</tt>.
216     * 
217     * @param config The configuration to use
218     */
219    void setAll(IoSessionConfig config);
220}