View Javadoc
1   /*
2    * Copyright 2013 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.nio.ChannelUDT;
19  import io.netty.buffer.ByteBufAllocator;
20  import io.netty.channel.ChannelOption;
21  import io.netty.channel.MessageSizeEstimator;
22  import io.netty.channel.RecvByteBufAllocator;
23  import io.netty.channel.WriteBufferWaterMark;
24  
25  import java.io.IOException;
26  import java.util.Map;
27  
28  import static io.netty.channel.ChannelOption.SO_BACKLOG;
29  
30  /**
31   * The default {@link UdtServerChannelConfig} implementation.
32   *
33   * @deprecated The UDT transport is no longer maintained and will be removed.
34   */
35  @Deprecated
36  public class DefaultUdtServerChannelConfig extends DefaultUdtChannelConfig
37          implements UdtServerChannelConfig {
38  
39      private volatile int backlog = 64;
40  
41      public DefaultUdtServerChannelConfig(
42              final UdtChannel channel, final ChannelUDT channelUDT, final boolean apply) throws IOException {
43          super(channel, channelUDT, apply);
44          if (apply) {
45              apply(channelUDT);
46          }
47      }
48  
49      @Override
50      protected void apply(final ChannelUDT channelUDT) throws IOException {
51          // nothing to apply for now.
52      }
53  
54      @Override
55      public int getBacklog() {
56          return backlog;
57      }
58  
59      @SuppressWarnings("unchecked")
60      @Override
61      public <T> T getOption(final ChannelOption<T> option) {
62          if (option == SO_BACKLOG) {
63              return (T) Integer.valueOf(getBacklog());
64          }
65          return super.getOption(option);
66      }
67  
68      @Override
69      public Map<ChannelOption<?>, Object> getOptions() {
70          return getOptions(super.getOptions(), SO_BACKLOG);
71      }
72  
73      @Override
74      public UdtServerChannelConfig setBacklog(final int backlog) {
75          this.backlog = backlog;
76          return this;
77      }
78  
79      @Override
80      public <T> boolean setOption(final ChannelOption<T> option, final T value) {
81          validate(option, value);
82          if (option == SO_BACKLOG) {
83              setBacklog((Integer) value);
84          } else {
85              return super.setOption(option, value);
86          }
87          return true;
88      }
89  
90      @Override
91      public UdtServerChannelConfig setProtocolReceiveBufferSize(
92              final int protocolReceiveBufferSize) {
93          super.setProtocolReceiveBufferSize(protocolReceiveBufferSize);
94          return this;
95      }
96  
97      @Override
98      public UdtServerChannelConfig setProtocolSendBufferSize(
99              final int protocolSendBufferSize) {
100         super.setProtocolSendBufferSize(protocolSendBufferSize);
101         return this;
102     }
103 
104     @Override
105     public UdtServerChannelConfig setReceiveBufferSize(
106             final int receiveBufferSize) {
107         super.setReceiveBufferSize(receiveBufferSize);
108         return this;
109     }
110 
111     @Override
112     public UdtServerChannelConfig setReuseAddress(final boolean reuseAddress) {
113         super.setReuseAddress(reuseAddress);
114         return this;
115     }
116 
117     @Override
118     public UdtServerChannelConfig setSendBufferSize(final int sendBufferSize) {
119         super.setSendBufferSize(sendBufferSize);
120         return this;
121     }
122 
123     @Override
124     public UdtServerChannelConfig setSoLinger(final int soLinger) {
125         super.setSoLinger(soLinger);
126         return this;
127     }
128 
129     @Override
130     public UdtServerChannelConfig setSystemReceiveBufferSize(
131             final int systemSendBufferSize) {
132         super.setSystemReceiveBufferSize(systemSendBufferSize);
133         return this;
134     }
135 
136     @Override
137     public UdtServerChannelConfig setSystemSendBufferSize(
138             final int systemReceiveBufferSize) {
139         super.setSystemSendBufferSize(systemReceiveBufferSize);
140         return this;
141     }
142 
143     @Override
144     public UdtServerChannelConfig setConnectTimeoutMillis(int connectTimeoutMillis) {
145         super.setConnectTimeoutMillis(connectTimeoutMillis);
146         return this;
147     }
148 
149     @Override
150     @Deprecated
151     public UdtServerChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead) {
152         super.setMaxMessagesPerRead(maxMessagesPerRead);
153         return this;
154     }
155 
156     @Override
157     public UdtServerChannelConfig setWriteSpinCount(int writeSpinCount) {
158         super.setWriteSpinCount(writeSpinCount);
159         return this;
160     }
161 
162     @Override
163     public UdtServerChannelConfig setAllocator(ByteBufAllocator allocator) {
164         super.setAllocator(allocator);
165         return this;
166     }
167 
168     @Override
169     public UdtServerChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator) {
170         super.setRecvByteBufAllocator(allocator);
171         return this;
172     }
173 
174     @Override
175     public UdtServerChannelConfig setAutoRead(boolean autoRead) {
176         super.setAutoRead(autoRead);
177         return this;
178     }
179 
180     @Override
181     public UdtServerChannelConfig setAutoClose(boolean autoClose) {
182         super.setAutoClose(autoClose);
183         return this;
184     }
185 
186     @Override
187     public UdtServerChannelConfig setWriteBufferLowWaterMark(int writeBufferLowWaterMark) {
188         super.setWriteBufferLowWaterMark(writeBufferLowWaterMark);
189         return this;
190     }
191 
192     @Override
193     public UdtServerChannelConfig setWriteBufferHighWaterMark(int writeBufferHighWaterMark) {
194         super.setWriteBufferHighWaterMark(writeBufferHighWaterMark);
195         return this;
196     }
197 
198     @Override
199     public UdtServerChannelConfig setWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark) {
200         super.setWriteBufferWaterMark(writeBufferWaterMark);
201         return this;
202     }
203 
204     @Override
205     public UdtServerChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator) {
206         super.setMessageSizeEstimator(estimator);
207         return this;
208     }
209 }