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: */
020: package org.apache.mina.common;
021:
022: import java.util.concurrent.BlockingQueue;
023:
024: /**
025: * The configuration of {@link IoSession}.
026: *
027: * @author The Apache MINA Project (dev@mina.apache.org)
028: * @version $Rev: 597940 $, $Date: 2007-11-24 18:00:09 -0700 (Sat, 24 Nov 2007) $
029: */
030: public interface IoSessionConfig {
031:
032: /**
033: * Returns the size of the read buffer that I/O processor allocates
034: * per each read. It's unusual to adjust this property because
035: * it's often adjusted automatically by the I/O processor.
036: */
037: int getReadBufferSize();
038:
039: /**
040: * Sets the size of the read buffer that I/O processor allocates
041: * per each read. It's unusual to adjust this property because
042: * it's often adjusted automatically by the I/O processor.
043: */
044: void setReadBufferSize(int readBufferSize);
045:
046: /**
047: * Returns the minimum size of the read buffer that I/O processor
048: * allocates per each read. I/O processor will not decrease the
049: * read buffer size to the smaller value than this property value.
050: */
051: int getMinReadBufferSize();
052:
053: /**
054: * Sets the minimum size of the read buffer that I/O processor
055: * allocates per each read. I/O processor will not decrease the
056: * read buffer size to the smaller value than this property value.
057: */
058: void setMinReadBufferSize(int minReadBufferSize);
059:
060: /**
061: * Returns the maximum size of the read buffer that I/O processor
062: * allocates per each read. I/O processor will not increase the
063: * read buffer size to the greater value than this property value.
064: */
065: int getMaxReadBufferSize();
066:
067: /**
068: * Sets the maximum size of the read buffer that I/O processor
069: * allocates per each read. I/O processor will not increase the
070: * read buffer size to the greater value than this property value.
071: */
072: void setMaxReadBufferSize(int maxReadBufferSize);
073:
074: /**
075: * Returns the interval (seconds) between each throughput calculation.
076: * The default value is <tt>3</tt> seconds.
077: */
078: int getThroughputCalculationInterval();
079:
080: /**
081: * Returns the interval (milliseconds) between each throughput calculation.
082: * The default value is <tt>3</tt> seconds.
083: */
084: long getThroughputCalculationIntervalInMillis();
085:
086: /**
087: * Sets the interval (seconds) between each throughput calculation. The
088: * default value is <tt>3</tt> seconds.
089: */
090: void setThroughputCalculationInterval(
091: int throughputCalculationInterval);
092:
093: /**
094: * Returns idle time for the specified type of idleness in seconds.
095: */
096: int getIdleTime(IdleStatus status);
097:
098: /**
099: * 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: }
|