EpollReuseAddrTest Class — netty Architecture
Architecture documentation for the EpollReuseAddrTest class in EpollReuseAddrTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 872e58d8_72a4_04f4_f4a3_a86fb110f538["EpollReuseAddrTest"] 795118a9_6cf3_0704_be60_fdabf6668344["EpollReuseAddrTest.java"] 872e58d8_72a4_04f4_f4a3_a86fb110f538 -->|defined in| 795118a9_6cf3_0704_be60_fdabf6668344 db502e8a_8e69_34b7_3054_d4725ec9080e["testMultipleBindSocketChannelWithoutReusePortFails()"] 872e58d8_72a4_04f4_f4a3_a86fb110f538 -->|method| db502e8a_8e69_34b7_3054_d4725ec9080e 09ae229f_6cc2_3ad2_8aa5_2c734d8add37["testMultipleBindDatagramChannelWithoutReusePortFails()"] 872e58d8_72a4_04f4_f4a3_a86fb110f538 -->|method| 09ae229f_6cc2_3ad2_8aa5_2c734d8add37 1e25e9c6_d332_8512_88bf_c33b21ddefa0["testMultipleBindDatagramChannelWithoutReusePortFails0()"] 872e58d8_72a4_04f4_f4a3_a86fb110f538 -->|method| 1e25e9c6_d332_8512_88bf_c33b21ddefa0 a01a7156_56b9_340b_9199_4950aa101ca9["testMultipleBindSocketChannel()"] 872e58d8_72a4_04f4_f4a3_a86fb110f538 -->|method| a01a7156_56b9_340b_9199_4950aa101ca9 f3e2e7fd_7460_739d_9cb6_36351cbde902["testMultipleBindDatagramChannel()"] 872e58d8_72a4_04f4_f4a3_a86fb110f538 -->|method| f3e2e7fd_7460_739d_9cb6_36351cbde902 b724e2c2_2a74_bebd_ca63_deec8ecd4855["ServerBootstrap()"] 872e58d8_72a4_04f4_f4a3_a86fb110f538 -->|method| b724e2c2_2a74_bebd_ca63_deec8ecd4855 15a4de0f_1f4a_2f2e_d540_d377c130038b["Bootstrap()"] 872e58d8_72a4_04f4_f4a3_a86fb110f538 -->|method| 15a4de0f_1f4a_2f2e_d540_d377c130038b 2cb5d0a8_8e51_b815_9f07_7fbf35f11bf5["versionEqOrGt()"] 872e58d8_72a4_04f4_f4a3_a86fb110f538 -->|method| 2cb5d0a8_8e51_b815_9f07_7fbf35f11bf5
Relationship Graph
Source Code
transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollReuseAddrTest.java lines 54–263
public class EpollReuseAddrTest {
private static final InternalLogger LOGGER = InternalLoggerFactory.getInstance(EpollReuseAddrTest.class);
private static final int MAJOR;
private static final int MINOR;
private static final int BUGFIX;
static {
String kernelVersion = Native.KERNEL_VERSION;
int index = kernelVersion.indexOf('-');
if (index > -1) {
kernelVersion = kernelVersion.substring(0, index);
}
String[] versionParts = kernelVersion.split("\\.");
if (versionParts.length <= 3) {
MAJOR = Integer.parseInt(versionParts[0]);
MINOR = Integer.parseInt(versionParts[1]);
if (versionParts.length == 3) {
int bugFix;
try {
bugFix = Integer.parseInt(versionParts[2]);
} catch (NumberFormatException ignore) {
// the last part of the version may include all kind of different things. Especially when
// someone compiles his / her own kernel.
// Just ignore a parse error here and use 0.
bugFix = 0;
}
BUGFIX = bugFix;
} else {
BUGFIX = 0;
}
} else {
LOGGER.log(InternalLogLevel.INFO, "Unable to parse kernel version: " + kernelVersion);
MAJOR = 0;
MINOR = 0;
BUGFIX = 0;
}
}
@Test
public void testMultipleBindSocketChannelWithoutReusePortFails() {
assumeTrue(versionEqOrGt(3, 9, 0));
testMultipleBindDatagramChannelWithoutReusePortFails0(createServerBootstrap());
}
@Test
public void testMultipleBindDatagramChannelWithoutReusePortFails() {
assumeTrue(versionEqOrGt(3, 9, 0));
testMultipleBindDatagramChannelWithoutReusePortFails0(createBootstrap());
}
private static void testMultipleBindDatagramChannelWithoutReusePortFails0(AbstractBootstrap<?, ?> bootstrap) {
bootstrap.handler(new LoggingHandler(LogLevel.ERROR));
ChannelFuture future = bootstrap.bind().syncUninterruptibly();
try {
bootstrap.bind(future.channel().localAddress()).syncUninterruptibly();
fail();
} catch (Exception e) {
assertTrue(e instanceof IOException);
}
future.channel().close().syncUninterruptibly();
}
@Test
@Timeout(value = 10000, unit = TimeUnit.MILLISECONDS)
public void testMultipleBindSocketChannel() throws Exception {
assumeTrue(versionEqOrGt(3, 9, 0));
ServerBootstrap bootstrap = createServerBootstrap();
bootstrap.option(EpollChannelOption.SO_REUSEPORT, true);
final AtomicBoolean accepted1 = new AtomicBoolean();
bootstrap.childHandler(new ServerSocketTestHandler(accepted1));
ChannelFuture future = bootstrap.bind().syncUninterruptibly();
InetSocketAddress address1 = (InetSocketAddress) future.channel().localAddress();
final AtomicBoolean accepted2 = new AtomicBoolean();
bootstrap.childHandler(new ServerSocketTestHandler(accepted2));
ChannelFuture future2 = bootstrap.bind(address1).syncUninterruptibly();
InetSocketAddress address2 = (InetSocketAddress) future2.channel().localAddress();
assertEquals(address1, address2);
while (!accepted1.get() || !accepted2.get()) {
Socket socket = new Socket(address1.getAddress(), address1.getPort());
Source
Frequently Asked Questions
What is the EpollReuseAddrTest class?
EpollReuseAddrTest is a class in the netty codebase, defined in transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollReuseAddrTest.java.
Where is EpollReuseAddrTest defined?
EpollReuseAddrTest is defined in transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollReuseAddrTest.java at line 54.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free