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  /**
26   * The configuration of {@link IoSession}.
27   *
28   * @author The Apache MINA Project (dev@mina.apache.org)
29   * @version $Rev: 597940 $, $Date: 2007-11-25 02:00:09 +0100 (Sun, 25 Nov 2007) $
30   */
31  public interface IoSessionConfig {
32  
33      /**
34       * Returns the size of the read buffer that I/O processor allocates
35       * per each read.  It's unusual to adjust this property because
36       * it's often adjusted automatically by the I/O processor.
37       */
38      int getReadBufferSize();
39  
40      /**
41       * Sets the size of the read buffer that I/O processor allocates
42       * per each read.  It's unusual to adjust this property because
43       * it's often adjusted automatically by the I/O processor.
44       */
45      void setReadBufferSize(int readBufferSize);
46  
47      /**
48       * Returns 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      void setMinReadBufferSize(int minReadBufferSize);
60  
61      /**
62       * Returns the maximum size of the read buffer that I/O processor
63       * allocates per each read.  I/O processor will not increase the
64       * read buffer size to the greater value than this property value.
65       */
66      int getMaxReadBufferSize();
67  
68      /**
69       * Sets the maximum size of the read buffer that I/O processor
70       * allocates per each read.  I/O processor will not increase the
71       * read buffer size to the greater value than this property value.
72       */
73      void setMaxReadBufferSize(int maxReadBufferSize);
74      
75      /**
76       * Returns the interval (seconds) between each throughput calculation.
77       * The default value is <tt>3</tt> seconds.
78       */
79      int getThroughputCalculationInterval();
80      
81      /**
82       * Returns the interval (milliseconds) between each throughput calculation.
83       * The default value is <tt>3</tt> seconds.
84       */
85      long getThroughputCalculationIntervalInMillis();
86      
87      /**
88       * Sets the interval (seconds) between each throughput calculation.  The
89       * default value is <tt>3</tt> seconds.
90       */
91      void setThroughputCalculationInterval(int throughputCalculationInterval);
92  
93      /**
94       * Returns idle time for the specified type of idleness in seconds.
95       */
96      int getIdleTime(IdleStatus status);
97  
98      /**
99       * Returns idle time for the specified type of idleness in milliseconds.
100      */
101     long getIdleTimeInMillis(IdleStatus status);
102 
103     /**
104      * Sets idle time for the specified type of idleness in seconds.
105      */
106     void setIdleTime(IdleStatus status, int idleTime);
107 
108     /**
109      * Returns idle time for {@link IdleStatus#READER_IDLE} in seconds.
110      */
111     int getReaderIdleTime();
112     
113     /**
114      * Returns idle time for {@link IdleStatus#READER_IDLE} in milliseconds.
115      */
116     long getReaderIdleTimeInMillis();
117     
118     /**
119      * Sets idle time for {@link IdleStatus#READER_IDLE} in seconds.
120      */
121     void setReaderIdleTime(int idleTime);
122     
123     /**
124      * Returns idle time for {@link IdleStatus#WRITER_IDLE} in seconds.
125      */
126     int getWriterIdleTime();
127     
128     /**
129      * Returns idle time for {@link IdleStatus#WRITER_IDLE} in milliseconds.
130      */
131     long getWriterIdleTimeInMillis();
132     
133     /**
134      * Sets idle time for {@link IdleStatus#WRITER_IDLE} in seconds.
135      */
136     void setWriterIdleTime(int idleTime);
137     
138     /**
139      * Returns idle time for {@link IdleStatus#BOTH_IDLE} in seconds.
140      */
141     int getBothIdleTime();
142     
143     /**
144      * Returns idle time for {@link IdleStatus#BOTH_IDLE} in milliseconds.
145      */
146     long getBothIdleTimeInMillis();
147     
148     /**
149      * Sets idle time for {@link IdleStatus#WRITER_IDLE} in seconds.
150      */
151     void setBothIdleTime(int idleTime);
152     
153     /**
154      * Returns write timeout in seconds.
155      */
156     int getWriteTimeout();
157 
158     /**
159      * Returns write timeout in milliseconds.
160      */
161     long getWriteTimeoutInMillis();
162 
163     /**
164      * Sets write timeout in seconds.
165      */
166     void setWriteTimeout(int writeTimeout);
167     
168     /**
169      * Returns <tt>true</tt> if and only if {@link IoSession#read()} operation
170      * is enabled.  If enabled, all received messages are stored in an internal
171      * {@link BlockingQueue} so you can read received messages in more
172      * convenient way for client applications.  Enabling this option is not
173      * useful to server applications and can cause unintended memory leak, and
174      * therefore it's disabled by default.
175      */
176     boolean isUseReadOperation();
177     
178     /**
179      * Enables or disabled {@link IoSession#read()} operation.  If enabled, all
180      * received messages are stored in an internal {@link BlockingQueue} so you
181      * can read received messages in more convenient way for client
182      * applications.  Enabling this option is not useful to server applications
183      * and can cause unintended memory leak, and therefore it's disabled by
184      * default.
185      */
186     void setUseReadOperation(boolean useReadOperation);
187 
188     /**
189      * Sets all configuration properties retrieved from the specified
190      * <tt>config</tt>.
191      */
192     void setAll(IoSessionConfig config);
193 }