[#917] Move transport depending ChannelOption to the specific transport to make it consistent
This commit is contained in:
parent
b7de868003
commit
895bce6cd5
@ -18,8 +18,8 @@ package io.netty.example.sctp;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.sctp.SctpChannel;
|
||||
import io.netty.channel.sctp.SctpChannelOption;
|
||||
import io.netty.channel.socket.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.sctp.nio.NioSctpChannel;
|
||||
import io.netty.handler.logging.LogLevel;
|
||||
@ -53,7 +53,7 @@ public class NioSctpEchoClient {
|
||||
try {
|
||||
b.group(new NioEventLoopGroup())
|
||||
.channel(NioSctpChannel.class)
|
||||
.option(ChannelOption.SCTP_NODELAY, true)
|
||||
.option(SctpChannelOption.SCTP_NODELAY, true)
|
||||
.remoteAddress(new InetSocketAddress(host, port))
|
||||
.handler(new ChannelInitializer<SctpChannel>() {
|
||||
@Override
|
||||
|
@ -20,6 +20,7 @@ import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.sctp.SctpChannel;
|
||||
import io.netty.channel.sctp.SctpChannelOption;
|
||||
import io.netty.channel.socket.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.sctp.nio.NioSctpServerChannel;
|
||||
import io.netty.handler.logging.LogLevel;
|
||||
@ -46,7 +47,7 @@ public class NioSctpEchoServer {
|
||||
.channel(NioSctpServerChannel.class)
|
||||
.option(ChannelOption.SO_BACKLOG, 100)
|
||||
.localAddress(new InetSocketAddress(port))
|
||||
.childOption(ChannelOption.SCTP_NODELAY, true)
|
||||
.childOption(SctpChannelOption.SCTP_NODELAY, true)
|
||||
.handler(new LoggingHandler(LogLevel.INFO))
|
||||
.childHandler(new ChannelInitializer<SctpChannel>() {
|
||||
@Override
|
||||
|
@ -18,8 +18,8 @@ package io.netty.example.sctp;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.sctp.SctpChannel;
|
||||
import io.netty.channel.sctp.SctpChannelOption;
|
||||
import io.netty.channel.socket.oio.OioEventLoopGroup;
|
||||
import io.netty.channel.sctp.oio.OioSctpChannel;
|
||||
import io.netty.handler.logging.LogLevel;
|
||||
@ -53,7 +53,7 @@ public class OioSctpEchoClient {
|
||||
try {
|
||||
b.group(new OioEventLoopGroup())
|
||||
.channel(OioSctpChannel.class)
|
||||
.option(ChannelOption.SCTP_NODELAY, true)
|
||||
.option(SctpChannelOption.SCTP_NODELAY, true)
|
||||
.remoteAddress(new InetSocketAddress(host, port))
|
||||
.handler(new ChannelInitializer<SctpChannel>() {
|
||||
@Override
|
||||
|
@ -20,6 +20,7 @@ import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.sctp.SctpChannel;
|
||||
import io.netty.channel.sctp.SctpChannelOption;
|
||||
import io.netty.channel.socket.oio.OioEventLoopGroup;
|
||||
import io.netty.channel.sctp.oio.OioSctpServerChannel;
|
||||
import io.netty.handler.logging.LogLevel;
|
||||
@ -46,7 +47,7 @@ public class OioSctpEchoServer {
|
||||
.channel(OioSctpServerChannel.class)
|
||||
.option(ChannelOption.SO_BACKLOG, 100)
|
||||
.localAddress(new InetSocketAddress(port))
|
||||
.childOption(ChannelOption.SCTP_NODELAY, true)
|
||||
.childOption(SctpChannelOption.SCTP_NODELAY, true)
|
||||
.handler(new LoggingHandler(LogLevel.INFO))
|
||||
.childHandler(new ChannelInitializer<SctpChannel>() {
|
||||
@Override
|
||||
|
@ -30,7 +30,7 @@ import java.net.SocketAddress;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.nio.channels.NotYetConnectedException;
|
||||
|
||||
import static io.netty.channel.rxtx.RxtxChannelOptions.*;
|
||||
import static io.netty.channel.rxtx.RxtxChannelOption.*;
|
||||
|
||||
/**
|
||||
* A channel to a serial device using the RXTX library.
|
||||
|
@ -21,7 +21,7 @@ import io.netty.channel.DefaultChannelConfig;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static io.netty.channel.rxtx.RxtxChannelOptions.*;
|
||||
import static io.netty.channel.rxtx.RxtxChannelOption.*;
|
||||
|
||||
/**
|
||||
* A configuration class for RXTX device connections.
|
||||
|
@ -21,9 +21,9 @@ import io.netty.channel.rxtx.RxtxChannelConfig.Paritybit;
|
||||
import io.netty.channel.rxtx.RxtxChannelConfig.Stopbits;
|
||||
|
||||
/**
|
||||
* Options for configuring a serial port connection
|
||||
* Option for configuring a serial port connection
|
||||
*/
|
||||
public final class RxtxChannelOptions {
|
||||
public final class RxtxChannelOption<T> extends ChannelOption<T> {
|
||||
public static final ChannelOption<Integer> BAUD_RATE =
|
||||
new ChannelOption<Integer>("BAUD_RATE");
|
||||
|
||||
@ -42,6 +42,7 @@ public final class RxtxChannelOptions {
|
||||
public static final ChannelOption<Paritybit> PARITY_BIT =
|
||||
new ChannelOption<Paritybit>("PARITY_BIT");
|
||||
|
||||
private RxtxChannelOptions() {
|
||||
public RxtxChannelOption(String name) {
|
||||
super(name);
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package io.netty.channel.sctp;
|
||||
|
||||
|
||||
import com.sun.nio.sctp.SctpChannel;
|
||||
import com.sun.nio.sctp.SctpStandardSocketOptions;
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
@ -25,7 +26,7 @@ import io.netty.channel.DefaultChannelConfig;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import static io.netty.channel.ChannelOption.*;
|
||||
import static io.netty.channel.sctp.SctpChannelOption.*;
|
||||
|
||||
/**
|
||||
* The default {@link SctpChannelConfig} implementation for SCTP.
|
||||
|
@ -51,7 +51,7 @@ public class DefaultSctpServerChannelConfig extends DefaultChannelConfig impleme
|
||||
public Map<ChannelOption<?>, Object> getOptions() {
|
||||
return getOptions(
|
||||
super.getOptions(),
|
||||
ChannelOption.SO_RCVBUF, ChannelOption.SO_SNDBUF, ChannelOption.SCTP_INIT_MAXSTREAMS);
|
||||
ChannelOption.SO_RCVBUF, ChannelOption.SO_SNDBUF, SctpChannelOption.SCTP_INIT_MAXSTREAMS);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -74,7 +74,7 @@ public class DefaultSctpServerChannelConfig extends DefaultChannelConfig impleme
|
||||
setReceiveBufferSize((Integer) value);
|
||||
} else if (option == ChannelOption.SO_SNDBUF) {
|
||||
setSendBufferSize((Integer) value);
|
||||
} else if (option == ChannelOption.SCTP_INIT_MAXSTREAMS) {
|
||||
} else if (option == SCTP_INIT_MAXSTREAMS) {
|
||||
setInitMaxStreams((InitMaxStreams) value);
|
||||
} else {
|
||||
return super.setOption(option, value);
|
||||
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2013 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.channel.sctp;
|
||||
|
||||
import io.netty.channel.ChannelOption;
|
||||
|
||||
import java.net.SocketAddress;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Option for configuring the SCTP transport
|
||||
*/
|
||||
public class SctpChannelOption<T> extends ChannelOption<T> {
|
||||
public static final ChannelOption<Boolean> SCTP_DISABLE_FRAGMENTS =
|
||||
new ChannelOption<Boolean>("SCTP_DISABLE_FRAGMENTS");
|
||||
public static final ChannelOption<Boolean> SCTP_EXPLICIT_COMPLETE =
|
||||
new ChannelOption<Boolean>("SCTP_EXPLICIT_COMPLETE");
|
||||
public static final ChannelOption<Integer> SCTP_FRAGMENT_INTERLEAVE =
|
||||
new ChannelOption<Integer>("SCTP_FRAGMENT_INTERLEAVE");
|
||||
public static final ChannelOption<List<Integer>> SCTP_INIT_MAXSTREAMS =
|
||||
new ChannelOption<List<Integer>>("SCTP_INIT_MAXSTREAMS") {
|
||||
@Override
|
||||
public void validate(List<Integer> value) {
|
||||
super.validate(value);
|
||||
if (value.size() != 2) {
|
||||
throw new IllegalArgumentException("value must be a List of 2 Integers: " + value);
|
||||
}
|
||||
if (value.get(0) == null) {
|
||||
throw new NullPointerException("value[0]");
|
||||
}
|
||||
if (value.get(1) == null) {
|
||||
throw new NullPointerException("value[1]");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static final ChannelOption<Boolean> SCTP_NODELAY =
|
||||
new ChannelOption<Boolean>("SCTP_NODELAY");
|
||||
public static final ChannelOption<SocketAddress> SCTP_PRIMARY_ADDR =
|
||||
new ChannelOption<SocketAddress>("SCTP_PRIMARY_ADDR");
|
||||
public static final ChannelOption<SocketAddress> SCTP_SET_PEER_PRIMARY_ADDR =
|
||||
new ChannelOption<SocketAddress>("SCTP_SET_PEER_PRIMARY_ADDR");
|
||||
|
||||
public SctpChannelOption(String name) {
|
||||
super(name);
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ import io.netty.channel.DefaultChannelConfig;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import static io.netty.channel.ChannelOption.*;
|
||||
import static io.netty.channel.udt.UdtChannelOption.*;
|
||||
|
||||
/**
|
||||
* The default {@link UdtChannelConfig} implementation.
|
||||
|
@ -53,11 +53,11 @@ import com.barchart.udt.nio.KindUDT;
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@code "protocolReceiveBuferSize"}</td>
|
||||
* <td>{@link #setProtocolBufferSize(int)}</td>
|
||||
* <td>{@link #setProtocolReceiveBufferSize(int)}</td>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td>{@code "systemReceiveBufferSize"}</td>
|
||||
* <td>{@link #setSystemBufferSize(int)}</td>
|
||||
* <td>{@link #setProtocolReceiveBufferSize(int)}</td>
|
||||
* <tr>
|
||||
* </table>
|
||||
* <p>
|
||||
@ -68,30 +68,6 @@ import com.barchart.udt.nio.KindUDT;
|
||||
*/
|
||||
public interface UdtChannelConfig extends ChannelConfig {
|
||||
|
||||
/**
|
||||
* See {@link OptionUDT#Protocol_Receive_Buffer_Size}.
|
||||
*/
|
||||
ChannelOption<Integer> PROTOCOL_RECEIVE_BUFFER_SIZE = new ChannelOption<Integer>(
|
||||
"PROTOCOL_RECEIVE_BUFFER_SIZE");
|
||||
|
||||
/**
|
||||
* See {@link OptionUDT#Protocol_Send_Buffer_Size}.
|
||||
*/
|
||||
ChannelOption<Integer> PROTOCOL_SEND_BUFFER_SIZE = new ChannelOption<Integer>(
|
||||
"PROTOCOL_SEND_BUFFER_SIZE");
|
||||
|
||||
/**
|
||||
* See {@link OptionUDT#System_Receive_Buffer_Size}.
|
||||
*/
|
||||
ChannelOption<Integer> SYSTEM_RECEIVE_BUFFER_SIZE = new ChannelOption<Integer>(
|
||||
"SYSTEM_RECEIVE_BUFFER_SIZE");
|
||||
|
||||
/**
|
||||
* See {@link OptionUDT#System_Send_Buffer_Size}.
|
||||
*/
|
||||
ChannelOption<Integer> SYSTEM_SEND_BUFFER_SIZE = new ChannelOption<Integer>(
|
||||
"SYSTEM_SEND_BUFFER_SIZE");
|
||||
|
||||
/**
|
||||
* Gets {@link KindUDT#ACCEPTOR} channel backlog.
|
||||
*/
|
||||
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2013 The Netty Project
|
||||
*
|
||||
* The Netty Project licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package io.netty.channel.udt;
|
||||
|
||||
import com.barchart.udt.OptionUDT;
|
||||
import io.netty.channel.ChannelOption;
|
||||
|
||||
/**
|
||||
* Options for the UDT transport
|
||||
*/
|
||||
public class UdtChannelOption<T> extends ChannelOption<T> {
|
||||
|
||||
/**
|
||||
* See {@link OptionUDT#Protocol_Receive_Buffer_Size}.
|
||||
*/
|
||||
public static final ChannelOption<Integer> PROTOCOL_RECEIVE_BUFFER_SIZE = new ChannelOption<Integer>(
|
||||
"PROTOCOL_RECEIVE_BUFFER_SIZE");
|
||||
|
||||
/**
|
||||
* See {@link OptionUDT#Protocol_Send_Buffer_Size}.
|
||||
*/
|
||||
public static final ChannelOption<Integer> PROTOCOL_SEND_BUFFER_SIZE = new ChannelOption<Integer>(
|
||||
"PROTOCOL_SEND_BUFFER_SIZE");
|
||||
|
||||
/**
|
||||
* See {@link OptionUDT#System_Receive_Buffer_Size}.
|
||||
*/
|
||||
public static final ChannelOption<Integer> SYSTEM_RECEIVE_BUFFER_SIZE = new ChannelOption<Integer>(
|
||||
"SYSTEM_RECEIVE_BUFFER_SIZE");
|
||||
|
||||
/**
|
||||
* See {@link OptionUDT#System_Send_Buffer_Size}.
|
||||
*/
|
||||
public static final ChannelOption<Integer> SYSTEM_SEND_BUFFER_SIZE = new ChannelOption<Integer>(
|
||||
"SYSTEM_SEND_BUFFER_SIZE");
|
||||
|
||||
public UdtChannelOption(String name) {
|
||||
super(name);
|
||||
}
|
||||
}
|
@ -20,8 +20,6 @@ import io.netty.util.UniqueName;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketAddress;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
@ -79,35 +77,6 @@ public class ChannelOption<T> extends UniqueName {
|
||||
public static final ChannelOption<Boolean> TCP_NODELAY =
|
||||
new ChannelOption<Boolean>("TCP_NODELAY");
|
||||
|
||||
public static final ChannelOption<Boolean> SCTP_DISABLE_FRAGMENTS =
|
||||
new ChannelOption<Boolean>("SCTP_DISABLE_FRAGMENTS");
|
||||
public static final ChannelOption<Boolean> SCTP_EXPLICIT_COMPLETE =
|
||||
new ChannelOption<Boolean>("SCTP_EXPLICIT_COMPLETE");
|
||||
public static final ChannelOption<Integer> SCTP_FRAGMENT_INTERLEAVE =
|
||||
new ChannelOption<Integer>("SCTP_FRAGMENT_INTERLEAVE");
|
||||
public static final ChannelOption<List<Integer>> SCTP_INIT_MAXSTREAMS =
|
||||
new ChannelOption<List<Integer>>("SCTP_INIT_MAXSTREAMS") {
|
||||
@Override
|
||||
public void validate(List<Integer> value) {
|
||||
super.validate(value);
|
||||
if (value.size() != 2) {
|
||||
throw new IllegalArgumentException("value must be a List of 2 Integers: " + value);
|
||||
}
|
||||
if (value.get(0) == null) {
|
||||
throw new NullPointerException("value[0]");
|
||||
}
|
||||
if (value.get(1) == null) {
|
||||
throw new NullPointerException("value[1]");
|
||||
}
|
||||
}
|
||||
};
|
||||
public static final ChannelOption<Boolean> SCTP_NODELAY =
|
||||
new ChannelOption<Boolean>("SCTP_NODELAY");
|
||||
public static final ChannelOption<SocketAddress> SCTP_PRIMARY_ADDR =
|
||||
new ChannelOption<SocketAddress>("SCTP_PRIMARY_ADDR");
|
||||
public static final ChannelOption<SocketAddress> SCTP_SET_PEER_PRIMARY_ADDR =
|
||||
new ChannelOption<SocketAddress>("SCTP_SET_PEER_PRIMARY_ADDR");
|
||||
|
||||
public static final ChannelOption<Long> AIO_READ_TIMEOUT =
|
||||
new ChannelOption<Long>("AIO_READ_TIMEOUT");
|
||||
public static final ChannelOption<Long> AIO_WRITE_TIMEOUT =
|
||||
|
Loading…
Reference in New Issue
Block a user