netty中的一些配置相关

在netty中,可能会需要用到一些配置,比如说:

ServerBootstrap b = new ServerBootstrap();
b.option(ChannelOption.SO_BACKLOG, 1024);//这里我们需要关注ChannelOption类
//用于指定是否使用对象池,一般使用默认,即不用配置。详情见:ByteBufAllocator
ChannelOption<ByteBufAllocator> ALLOCATOR = valueOf("ALLOCATOR");
//Channel接受Buffer的分配器,默认值为AdaptiveRecvByteBufAllocator.DEFAULT。可选值为FixedRecvByteBufAllocator,固定大小的接受缓冲区分配器。
ChannelOption<RecvByteBufAllocator> RCVBUF_ALLOCATOR = valueOf("RCVBUF_ALLOCATOR");
//消息大小估算器
ChannelOption<MessageSizeEstimator> MESSAGE_SIZE_ESTIMATOR = valueOf("MESSAGE_SIZE_ESTIMATOR");
//netty的client链接server的超时时间。
ChannelOption<Integer> CONNECT_TIMEOUT_MILLIS = valueOf("CONNECT_TIMEOUT_MILLIS");
//一次Loop读取的最大消息数
ChannelOption<Integer> MAX_MESSAGES_PER_READ = valueOf("MAX_MESSAGES_PER_READ");
//一个Loop写操作执行的最大次数,默认值为16。也就是说,对于大数据量的写操作至多进行16次,如果16次仍没有全部写完数据,
//此时会提交一个新的写任务给EventLoop,任务将在下次调度继续执行。
//这样,其他的写请求才能被响应不会因为单个大数据量写请求而耽误。
ChannelOption<Integer> WRITE_SPIN_COUNT = valueOf("WRITE_SPIN_COUNT");
ChannelOption<Integer> WRITE_BUFFER_HIGH_WATER_MARK = valueOf("WRITE_BUFFER_HIGH_WATER_MARK");
ChannelOption<Integer> WRITE_BUFFER_LOW_WATER_MARK = valueOf("WRITE_BUFFER_LOW_WATER_MARK");
//一个连接的远端关闭时本地端是否关闭,默认值为False。值为False时,连接自动关闭;为True时,触发ChannelInboundHandler的userEventTriggered()方法,事件为ChannelInputShutdownEvent。
ChannelOption<Boolean> ALLOW_HALF_CLOSURE = valueOf("ALLOW_HALF_CLOSURE");
ChannelOption<Boolean> AUTO_READ = valueOf("AUTO_READ");
ChannelOption<Boolean> AUTO_CLOSE = valueOf("AUTO_CLOSE");
ChannelOption<Boolean> SO_BROADCAST = valueOf("SO_BROADCAST");
ChannelOption<Boolean> SO_KEEPALIVE = valueOf("SO_KEEPALIVE");
ChannelOption<Integer> SO_SNDBUF = valueOf("SO_SNDBUF");
ChannelOption<Integer> SO_RCVBUF = valueOf("SO_RCVBUF");
ChannelOption<Boolean> SO_REUSEADDR = valueOf("SO_REUSEADDR");
ChannelOption<Integer> SO_LINGER = valueOf("SO_LINGER");
ChannelOption<Integer> SO_BACKLOG = valueOf("SO_BACKLOG");
ChannelOption<Integer> SO_TIMEOUT = valueOf("SO_TIMEOUT");
ChannelOption<Integer> IP_TOS = valueOf("IP_TOS");
ChannelOption<InetAddress> IP_MULTICAST_ADDR = valueOf("IP_MULTICAST_ADDR");
ChannelOption<NetworkInterface> IP_MULTICAST_IF = valueOf("IP_MULTICAST_IF");
ChannelOption<Integer> IP_MULTICAST_TTL = valueOf("IP_MULTICAST_TTL");
ChannelOption<Boolean> IP_MULTICAST_LOOP_DISABLED = valueOf("IP_MULTICAST_LOOP_DISABLED");
ChannelOption<Boolean> TCP_NODELAY = valueOf("TCP_NODELAY");
@Deprecated
ChannelOption<Long> AIO_READ_TIMEOUT = valueOf("AIO_READ_TIMEOUT");
@Deprecated
ChannelOption<Long> AIO_WRITE_TIMEOUT = valueOf("AIO_WRITE_TIMEOUT");
@Deprecated
ChannelOption<Boolean> DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION = valueOf("DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION");
ChannelOption<Boolean> SINGLE_EVENTEXECUTOR_PER_GROUP = valueOf("SINGLE_EVENTEXECUTOR_PER_GROUP");

你可能感兴趣的:(netty中的一些配置相关)