Client Class — netty Architecture
Architecture documentation for the Client class in UDTClientServerConnectionTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 04943c9a_8ea1_0974_cf09_4ca1510eeef0["Client"] f3540ce4_30eb_36e3_f952_e84f7d4af406["UDTClientServerConnectionTest.java"] 04943c9a_8ea1_0974_cf09_4ca1510eeef0 -->|defined in| f3540ce4_30eb_36e3_f952_e84f7d4af406 202b92d3_2598_75c5_0717_6264769764e5["Client()"] 04943c9a_8ea1_0974_cf09_4ca1510eeef0 -->|method| 202b92d3_2598_75c5_0717_6264769764e5 96b8c4e6_d3c3_17d6_a8c3_a91250f3642c["run()"] 04943c9a_8ea1_0974_cf09_4ca1510eeef0 -->|method| 96b8c4e6_d3c3_17d6_a8c3_a91250f3642c 5c35f461_b71d_ba22_0b55_daea6659d38f["shutdown()"] 04943c9a_8ea1_0974_cf09_4ca1510eeef0 -->|method| 5c35f461_b71d_ba22_0b55_daea6659d38f 94101f11_b478_17c6_e827_424e905af992["waitForActive()"] 04943c9a_8ea1_0974_cf09_4ca1510eeef0 -->|method| 94101f11_b478_17c6_e827_424e905af992 632a767d_e337_a2b4_e179_e0d936c7c46f["waitForRunning()"] 04943c9a_8ea1_0974_cf09_4ca1510eeef0 -->|method| 632a767d_e337_a2b4_e179_e0d936c7c46f 7fa79a1b_ae98_238d_3bad_3ee06c5941a6["waitForShutdown()"] 04943c9a_8ea1_0974_cf09_4ca1510eeef0 -->|method| 7fa79a1b_ae98_238d_3bad_3ee06c5941a6
Relationship Graph
Source Code
testsuite/src/main/java/io/netty/testsuite/transport/udt/UDTClientServerConnectionTest.java lines 59–145
static class Client implements Runnable {
static final Logger log = LoggerFactory.getLogger(Client.class);
private final InetSocketAddress address;
volatile Channel channel;
volatile boolean isRunning;
volatile boolean isShutdown;
Client(InetSocketAddress address) {
this.address = address;
}
@Override
public void run() {
final Bootstrap boot = new Bootstrap();
final ThreadFactory clientFactory = new DefaultThreadFactory("client");
final EventLoopGroup connectGroup = new MultiThreadIoEventLoopGroup(1,
clientFactory, NioIoHandler.newFactory(NioUdtProvider.BYTE_PROVIDER));
try {
boot.group(connectGroup)
.channelFactory(NioUdtProvider.BYTE_CONNECTOR)
.handler(new ChannelInitializer<UdtChannel>() {
@Override
protected void initChannel(final UdtChannel ch)
throws Exception {
final ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast("framer",
new DelimiterBasedFrameDecoder(8192,
Delimiters.lineDelimiter()));
pipeline.addLast("decoder", new StringDecoder(
CharsetUtil.UTF_8));
pipeline.addLast("encoder", new StringEncoder(
CharsetUtil.UTF_8));
pipeline.addLast("handler", new ClientHandler());
}
});
channel = boot.connect(address).sync().channel();
isRunning = true;
log.info("Client ready.");
waitForRunning(false);
log.info("Client closing...");
channel.close().sync();
isShutdown = true;
log.info("Client is done.");
} catch (final Throwable e) {
log.error("Client failed.", e);
} finally {
connectGroup.shutdownGracefully().syncUninterruptibly();
}
}
void shutdown() {
isRunning = false;
}
void waitForActive(final boolean isActive) throws Exception {
for (int k = 0; k < WAIT_COUNT; k++) {
Thread.sleep(WAIT_SLEEP);
final ClientHandler handler = channel.pipeline().get(
ClientHandler.class);
if (handler != null && isActive == handler.isActive) {
return;
}
}
}
void waitForRunning(final boolean isRunning) throws Exception {
for (int k = 0; k < WAIT_COUNT; k++) {
if (isRunning == this.isRunning) {
return;
}
Thread.sleep(WAIT_SLEEP);
}
}
private void waitForShutdown() throws Exception {
for (int k = 0; k < WAIT_COUNT; k++) {
if (isShutdown) {
Defined In
Source
Frequently Asked Questions
What is the Client class?
Client is a class in the netty codebase, defined in testsuite/src/main/java/io/netty/testsuite/transport/udt/UDTClientServerConnectionTest.java.
Where is Client defined?
Client is defined in testsuite/src/main/java/io/netty/testsuite/transport/udt/UDTClientServerConnectionTest.java at line 59.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free