eb1c8e4991
Motivation: fix checkstyle errors and many classes are unnecessarily public Modification: -fixed maven checkstyle errors -using package-private and final classes Result: better code quality
159 lines
4.8 KiB
Java
159 lines
4.8 KiB
Java
/*
|
|
* Copyright 2020 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.uring;
|
|
|
|
import io.netty.buffer.ByteBufAllocator;
|
|
import io.netty.channel.Channel;
|
|
import io.netty.channel.ChannelException;
|
|
import io.netty.channel.ChannelOption;
|
|
import io.netty.channel.MessageSizeEstimator;
|
|
import io.netty.channel.RecvByteBufAllocator;
|
|
import io.netty.channel.WriteBufferWaterMark;
|
|
import io.netty.channel.socket.ServerSocketChannelConfig;
|
|
import io.netty.util.NetUtil;
|
|
|
|
import java.io.IOException;
|
|
import java.util.Map;
|
|
|
|
import static io.netty.channel.ChannelOption.*;
|
|
import static io.netty.util.internal.ObjectUtil.*;
|
|
|
|
public class IOUringServerChannelConfig extends IOUringChannelConfig implements ServerSocketChannelConfig {
|
|
private volatile int backlog = NetUtil.SOMAXCONN;
|
|
|
|
IOUringServerChannelConfig(AbstractIOUringServerChannel channel) {
|
|
super(channel);
|
|
}
|
|
|
|
@Override
|
|
public boolean isReuseAddress() {
|
|
try {
|
|
return ((IOUringSocketChannel) channel).socket.isReuseAddress();
|
|
} catch (IOException e) {
|
|
throw new ChannelException(e);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public IOUringServerChannelConfig setReuseAddress(boolean reuseAddress) {
|
|
try {
|
|
((IOUringSocketChannel) channel).socket.setReuseAddress(reuseAddress);
|
|
return this;
|
|
} catch (IOException e) {
|
|
throw new ChannelException(e);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public int getReceiveBufferSize() {
|
|
try {
|
|
return ((IOUringSocketChannel) channel).socket.getReceiveBufferSize();
|
|
} catch (IOException e) {
|
|
throw new ChannelException(e);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public IOUringServerChannelConfig setReceiveBufferSize(int receiveBufferSize) {
|
|
try {
|
|
((IOUringSocketChannel) channel).socket.setReceiveBufferSize(receiveBufferSize);
|
|
return this;
|
|
} catch (IOException e) {
|
|
throw new ChannelException(e);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public int getBacklog() {
|
|
return backlog;
|
|
}
|
|
|
|
@Override
|
|
public IOUringServerChannelConfig setBacklog(int backlog) {
|
|
checkPositiveOrZero(backlog, "backlog");
|
|
this.backlog = backlog;
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public IOUringServerChannelConfig setPerformancePreferences(int connectionTime, int latency, int bandwidth) {
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public IOUringServerChannelConfig setConnectTimeoutMillis(int connectTimeoutMillis) {
|
|
super.setConnectTimeoutMillis(connectTimeoutMillis);
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
@Deprecated
|
|
public IOUringServerChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead) {
|
|
super.setMaxMessagesPerRead(maxMessagesPerRead);
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public IOUringServerChannelConfig setWriteSpinCount(int writeSpinCount) {
|
|
super.setWriteSpinCount(writeSpinCount);
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public IOUringServerChannelConfig setAllocator(ByteBufAllocator allocator) {
|
|
super.setAllocator(allocator);
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public IOUringServerChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator) {
|
|
super.setRecvByteBufAllocator(allocator);
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public IOUringServerChannelConfig setAutoRead(boolean autoRead) {
|
|
super.setAutoRead(autoRead);
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
@Deprecated
|
|
public IOUringServerChannelConfig setWriteBufferHighWaterMark(int writeBufferHighWaterMark) {
|
|
super.setWriteBufferHighWaterMark(writeBufferHighWaterMark);
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
@Deprecated
|
|
public IOUringServerChannelConfig setWriteBufferLowWaterMark(int writeBufferLowWaterMark) {
|
|
super.setWriteBufferLowWaterMark(writeBufferLowWaterMark);
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public IOUringServerChannelConfig setWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark) {
|
|
super.setWriteBufferWaterMark(writeBufferWaterMark);
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public IOUringServerChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator) {
|
|
super.setMessageSizeEstimator(estimator);
|
|
return this;
|
|
}
|
|
}
|