Make Epoll ChannelMetadata more consistent with NIO
Motivation: In 4.0 AbstractNioByteChannel has a default of 16 max messages per read. However in 4.1 that constraint was applied at the NioSocketChannel which is not equivalent. In 4.1 AbstractEpollStreamChannel also did not have the default of 16 max messages per read applied. Modifications: - Make Nio consistent with 4.0 - Make Epoll consistent with Nio Result: Nio and Epoll both have consistent ChannelMetadata and are consistent with 4.0.
This commit is contained in:
parent
328510468c
commit
3d7ae97359
@ -22,6 +22,7 @@ import io.netty.channel.Channel;
|
|||||||
import io.netty.channel.ChannelConfig;
|
import io.netty.channel.ChannelConfig;
|
||||||
import io.netty.channel.ChannelFuture;
|
import io.netty.channel.ChannelFuture;
|
||||||
import io.netty.channel.ChannelFutureListener;
|
import io.netty.channel.ChannelFutureListener;
|
||||||
|
import io.netty.channel.ChannelMetadata;
|
||||||
import io.netty.channel.ChannelOutboundBuffer;
|
import io.netty.channel.ChannelOutboundBuffer;
|
||||||
import io.netty.channel.ChannelPipeline;
|
import io.netty.channel.ChannelPipeline;
|
||||||
import io.netty.channel.ChannelPromise;
|
import io.netty.channel.ChannelPromise;
|
||||||
@ -51,7 +52,7 @@ import static io.netty.channel.unix.FileDescriptor.pipe;
|
|||||||
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
||||||
|
|
||||||
public abstract class AbstractEpollStreamChannel extends AbstractEpollChannel implements DuplexChannel {
|
public abstract class AbstractEpollStreamChannel extends AbstractEpollChannel implements DuplexChannel {
|
||||||
|
private static final ChannelMetadata METADATA = new ChannelMetadata(false, 16);
|
||||||
private static final String EXPECTED_TYPES =
|
private static final String EXPECTED_TYPES =
|
||||||
" (expected: " + StringUtil.simpleClassName(ByteBuf.class) + ", " +
|
" (expected: " + StringUtil.simpleClassName(ByteBuf.class) + ", " +
|
||||||
StringUtil.simpleClassName(DefaultFileRegion.class) + ')';
|
StringUtil.simpleClassName(DefaultFileRegion.class) + ')';
|
||||||
@ -130,6 +131,11 @@ public abstract class AbstractEpollStreamChannel extends AbstractEpollChannel im
|
|||||||
return new EpollStreamUnsafe();
|
return new EpollStreamUnsafe();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChannelMetadata metadata() {
|
||||||
|
return METADATA;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Splice from this {@link AbstractEpollStreamChannel} to another {@link AbstractEpollStreamChannel}.
|
* Splice from this {@link AbstractEpollStreamChannel} to another {@link AbstractEpollStreamChannel}.
|
||||||
* The {@code len} is the number of bytes to splice. If using {@link Integer#MAX_VALUE} it will
|
* The {@code len} is the number of bytes to splice. If using {@link Integer#MAX_VALUE} it will
|
||||||
|
@ -44,8 +44,6 @@ public class NioUdtByteConnectorChannel extends AbstractNioByteChannel implement
|
|||||||
private static final InternalLogger logger =
|
private static final InternalLogger logger =
|
||||||
InternalLoggerFactory.getInstance(NioUdtByteConnectorChannel.class);
|
InternalLoggerFactory.getInstance(NioUdtByteConnectorChannel.class);
|
||||||
|
|
||||||
private static final ChannelMetadata METADATA = new ChannelMetadata(false, 16);
|
|
||||||
|
|
||||||
private final UdtChannelConfig config;
|
private final UdtChannelConfig config;
|
||||||
|
|
||||||
public NioUdtByteConnectorChannel() {
|
public NioUdtByteConnectorChannel() {
|
||||||
@ -175,11 +173,6 @@ public class NioUdtByteConnectorChannel extends AbstractNioByteChannel implement
|
|||||||
return javaChannel().socket().getLocalSocketAddress();
|
return javaChannel().socket().getLocalSocketAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ChannelMetadata metadata() {
|
|
||||||
return METADATA;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SocketAddress remoteAddress0() {
|
protected SocketAddress remoteAddress0() {
|
||||||
return javaChannel().socket().getRemoteSocketAddress();
|
return javaChannel().socket().getRemoteSocketAddress();
|
||||||
|
@ -20,6 +20,7 @@ import io.netty.buffer.ByteBufAllocator;
|
|||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelConfig;
|
import io.netty.channel.ChannelConfig;
|
||||||
import io.netty.channel.ChannelFuture;
|
import io.netty.channel.ChannelFuture;
|
||||||
|
import io.netty.channel.ChannelMetadata;
|
||||||
import io.netty.channel.ChannelOption;
|
import io.netty.channel.ChannelOption;
|
||||||
import io.netty.channel.ChannelOutboundBuffer;
|
import io.netty.channel.ChannelOutboundBuffer;
|
||||||
import io.netty.channel.ChannelPipeline;
|
import io.netty.channel.ChannelPipeline;
|
||||||
@ -36,7 +37,7 @@ import java.nio.channels.SelectionKey;
|
|||||||
* {@link AbstractNioChannel} base class for {@link Channel}s that operate on bytes.
|
* {@link AbstractNioChannel} base class for {@link Channel}s that operate on bytes.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractNioByteChannel extends AbstractNioChannel {
|
public abstract class AbstractNioByteChannel extends AbstractNioChannel {
|
||||||
|
private static final ChannelMetadata METADATA = new ChannelMetadata(false, 16);
|
||||||
private static final String EXPECTED_TYPES =
|
private static final String EXPECTED_TYPES =
|
||||||
" (expected: " + StringUtil.simpleClassName(ByteBuf.class) + ", " +
|
" (expected: " + StringUtil.simpleClassName(ByteBuf.class) + ", " +
|
||||||
StringUtil.simpleClassName(FileRegion.class) + ')';
|
StringUtil.simpleClassName(FileRegion.class) + ')';
|
||||||
@ -63,6 +64,11 @@ public abstract class AbstractNioByteChannel extends AbstractNioChannel {
|
|||||||
return new NioByteUnsafe();
|
return new NioByteUnsafe();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChannelMetadata metadata() {
|
||||||
|
return METADATA;
|
||||||
|
}
|
||||||
|
|
||||||
protected class NioByteUnsafe extends AbstractNioUnsafe {
|
protected class NioByteUnsafe extends AbstractNioUnsafe {
|
||||||
|
|
||||||
private void closeOnRead(ChannelPipeline pipeline) {
|
private void closeOnRead(ChannelPipeline pipeline) {
|
||||||
|
@ -48,7 +48,6 @@ import java.util.concurrent.Executor;
|
|||||||
*/
|
*/
|
||||||
public class NioSocketChannel extends AbstractNioByteChannel implements io.netty.channel.socket.SocketChannel {
|
public class NioSocketChannel extends AbstractNioByteChannel implements io.netty.channel.socket.SocketChannel {
|
||||||
private static final InternalLogger logger = InternalLoggerFactory.getInstance(NioSocketChannel.class);
|
private static final InternalLogger logger = InternalLoggerFactory.getInstance(NioSocketChannel.class);
|
||||||
private static final ChannelMetadata METADATA = new ChannelMetadata(false, 16);
|
|
||||||
private static final SelectorProvider DEFAULT_SELECTOR_PROVIDER = SelectorProvider.provider();
|
private static final SelectorProvider DEFAULT_SELECTOR_PROVIDER = SelectorProvider.provider();
|
||||||
|
|
||||||
private static SocketChannel newSocket(SelectorProvider provider) {
|
private static SocketChannel newSocket(SelectorProvider provider) {
|
||||||
@ -104,11 +103,6 @@ public class NioSocketChannel extends AbstractNioByteChannel implements io.netty
|
|||||||
return (ServerSocketChannel) super.parent();
|
return (ServerSocketChannel) super.parent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ChannelMetadata metadata() {
|
|
||||||
return METADATA;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SocketChannelConfig config() {
|
public SocketChannelConfig config() {
|
||||||
return config;
|
return config;
|
||||||
|
Loading…
Reference in New Issue
Block a user