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