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