查看本类的 API文档回源码主页即时通讯网 - 即时通讯开发者社区!
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       * @return 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       * @param readBufferSize The size of the read buffer
44       */
45      void setReadBufferSize(int readBufferSize);
46  
47      /**
48       * @return the minimum size of the read buffer that I/O processor
49       * allocates per each read.  I/O processor will not decrease the
50       * read buffer size to the smaller value than this property value.
51       */
52      int getMinReadBufferSize();
53  
54      /**
55       * Sets the minimum size of the read buffer that I/O processor
56       * allocates per each read.  I/O processor will not decrease the
57       * read buffer size to the smaller value than this property value.
58       * 
59       * @param minReadBufferSize The minimum size of the read buffer
60       */
61      void setMinReadBufferSize(int minReadBufferSize);
62  
63      /**
64       * @return the maximum size of the read buffer that I/O processor
65       * allocates per each read.  I/O processor will not increase the
66       * read buffer size to the greater value than this property value.
67       */
68      int getMaxReadBufferSize();
69  
70      /**
71       * Sets the maximum size of the read buffer that I/O processor
72       * allocates per each read.  I/O processor will not increase the
73       * read buffer size to the greater value than this property value.
74       * 
75       * @param maxReadBufferSize The maximum size of the read buffer
76       */
77      void setMaxReadBufferSize(int maxReadBufferSize);
78  
79      /**
80       * @return the interval (seconds) between each throughput calculation.
81       * The default value is <tt>3</tt> seconds.
82       */
83      int getThroughputCalculationInterval();
84  
85      /**
86       * @return the interval (milliseconds) between each throughput calculation.
87       * The default value is <tt>3</tt> seconds.
88       */
89      long getThroughputCalculationIntervalInMillis();
90  
91      /**
92       * Sets the interval (seconds) between each throughput calculation.  The
93       * default value is <tt>3</tt> seconds.
94       * 
95       * @param throughputCalculationInterval The interval
96       */
97      void setThroughputCalculationInterval(int throughputCalculationInterval);
98  
99      /**
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 }