View Javadoc
1   /*
2    * Copyright 2012 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package io.netty.channel.udt;
17  
18  import com.barchart.udt.OptionUDT;
19  import com.barchart.udt.TypeUDT;
20  import io.netty.buffer.ByteBufAllocator;
21  import io.netty.channel.ChannelConfig;
22  import io.netty.channel.ChannelException;
23  import io.netty.channel.ChannelOption;
24  import io.netty.channel.MessageSizeEstimator;
25  import io.netty.channel.RecvByteBufAllocator;
26  
27  /**
28   * A {@link ChannelConfig} for a {@link UdtChannel}.
29   * <p>
30   * <h3>Available options</h3>
31   * In addition to the options provided by {@link ChannelConfig},
32   * {@link UdtChannelConfig} allows the following options in the option map:
33   * <p>
34   * <table border="1" cellspacing="0" cellpadding="6">
35   * <tr>
36   * <th>Name</th>
37   * <th>Associated setter method</th>
38   * </tr><tr>
39   * <td>{@link ChannelOption#SO_REUSEADDR}</td><td>{@link #setReuseAddress(boolean)}</td>
40   * </tr><tr>
41   * <td>{@link ChannelOption#SO_RCVBUF}</td><td>{@link #setReceiveBufferSize(int)}</td>
42   * </tr><tr>
43   * <td>{@link ChannelOption#SO_SNDBUF}</td><td>{@link #setSendBufferSize(int)}</td>
44   * </tr><tr>
45   * <td>{@link ChannelOption#SO_REUSEADDR}</td><td>{@link #setReuseAddress(boolean)}</td>
46   * </tr><tr>
47   * <td>{@link ChannelOption#SO_LINGER}</td><td>{@link #setSoLinger(int)}</td>
48   * </tr><tr>
49   * <td>{@link ChannelOption#SO_RCVBUF}</td><td>{@link #setReceiveBufferSize(int)}</td>
50   * </tr><tr>
51   * <td>{@link ChannelOption#SO_SNDBUF}</td><td>{@link #setSendBufferSize(int)}</td>
52   * </tr><tr>
53   * <td>{@link UdtChannelOption#PROTOCOL_RECEIVE_BUFFER_SIZE}</td>
54   * <td>{@link #setProtocolReceiveBufferSize(int)}</td>
55   * </tr><tr>
56   * <td>{@link UdtChannelOption#PROTOCOL_SEND_BUFFER_SIZE}</td>
57   * <td>{@link #setProtocolSendBufferSize(int)}</td>
58   * </tr><tr>
59   * <td>{@link UdtChannelOption#SYSTEM_RECEIVE_BUFFER_SIZE}</td>
60   * <td>{@link #setSystemReceiveBufferSize(int)}</td>
61   * </tr><tr>
62   * <td>{@link UdtChannelOption#SYSTEM_SEND_BUFFER_SIZE}</td>
63   * <td>{@link #setSystemSendBufferSize(int)}</td>
64  
65   * </tr>
66   * </table>
67   * <p>
68   * Note that {@link TypeUDT#DATAGRAM} message oriented channels treat
69   * {@code "receiveBufferSize"} and {@code "sendBufferSize"} as maximum message
70   * size. If received or sent message does not fit specified sizes,
71   * {@link ChannelException} will be thrown.
72   */
73  public interface UdtChannelConfig extends ChannelConfig {
74  
75      /**
76       * Gets {@link OptionUDT#Protocol_Receive_Buffer_Size}
77       */
78      int getProtocolReceiveBufferSize();
79  
80      /**
81       * Gets {@link OptionUDT#Protocol_Send_Buffer_Size}
82       */
83      int getProtocolSendBufferSize();
84  
85      /**
86       * Gets the {@link ChannelOption#SO_RCVBUF} option.
87       */
88      int getReceiveBufferSize();
89  
90      /**
91       * Gets the {@link ChannelOption#SO_SNDBUF} option.
92       */
93      int getSendBufferSize();
94  
95      /**
96       * Gets the {@link ChannelOption#SO_LINGER} option.
97       */
98      int getSoLinger();
99  
100     /**
101      * Gets {@link OptionUDT#System_Receive_Buffer_Size}
102      */
103     int getSystemReceiveBufferSize();
104 
105     /**
106      * Gets {@link OptionUDT#System_Send_Buffer_Size}
107      */
108     int getSystemSendBufferSize();
109 
110     /**
111      * Gets the {@link ChannelOption#SO_REUSEADDR} option.
112      */
113     boolean isReuseAddress();
114 
115     @Override
116     UdtChannelConfig setConnectTimeoutMillis(int connectTimeoutMillis);
117 
118     @Override
119     UdtChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead);
120 
121     @Override
122     UdtChannelConfig setWriteSpinCount(int writeSpinCount);
123 
124     @Override
125     UdtChannelConfig setAllocator(ByteBufAllocator allocator);
126 
127     @Override
128     UdtChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator);
129 
130     @Override
131     UdtChannelConfig setAutoRead(boolean autoRead);
132 
133     @Override
134     UdtChannelConfig setWriteBufferHighWaterMark(int writeBufferHighWaterMark);
135 
136     @Override
137     UdtChannelConfig setWriteBufferLowWaterMark(int writeBufferLowWaterMark);
138 
139     @Override
140     UdtChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator);
141 
142     /**
143      * Sets {@link OptionUDT#Protocol_Receive_Buffer_Size}
144      */
145     UdtChannelConfig setProtocolReceiveBufferSize(int size);
146 
147     /**
148      * Sets {@link OptionUDT#Protocol_Send_Buffer_Size}
149      */
150     UdtChannelConfig setProtocolSendBufferSize(int size);
151 
152     /**
153      * Sets the {@link ChannelOption#SO_RCVBUF} option.
154      */
155     UdtChannelConfig setReceiveBufferSize(int receiveBufferSize);
156 
157     /**
158      * Sets the {@link ChannelOption#SO_REUSEADDR} option.
159      */
160     UdtChannelConfig setReuseAddress(boolean reuseAddress);
161 
162     /**
163      * Sets the {@link ChannelOption#SO_SNDBUF} option.
164      */
165     UdtChannelConfig setSendBufferSize(int sendBufferSize);
166 
167     /**
168      * Sets the {@link ChannelOption#SO_LINGER} option.
169      */
170     UdtChannelConfig setSoLinger(int soLinger);
171 
172     /**
173      * Sets {@link OptionUDT#System_Receive_Buffer_Size}
174      */
175     UdtChannelConfig setSystemReceiveBufferSize(int size);
176 
177     /**
178      * Sets {@link OptionUDT#System_Send_Buffer_Size}
179      */
180     UdtChannelConfig setSystemSendBufferSize(int size);
181 }