MemcacheClient Class — netty Architecture
Architecture documentation for the MemcacheClient class in MemcacheClient.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 61326ce9_5314_3055_2e7e_9eb8e7595bfc["MemcacheClient"] 24922ae3_267d_735a_9a2d_fcaba25b6881["MemcacheClient.java"] 61326ce9_5314_3055_2e7e_9eb8e7595bfc -->|defined in| 24922ae3_267d_735a_9a2d_fcaba25b6881 eb86b1d6_63ff_0351_a7f1_c5e8a8738ea5["main()"] 61326ce9_5314_3055_2e7e_9eb8e7595bfc -->|method| eb86b1d6_63ff_0351_a7f1_c5e8a8738ea5
Relationship Graph
Source Code
example/src/main/java/io/netty/example/memcache/binary/MemcacheClient.java lines 40–104
public final class MemcacheClient {
static final boolean SSL = System.getProperty("ssl") != null;
static final String HOST = System.getProperty("host", "127.0.0.1");
static final int PORT = Integer.parseInt(System.getProperty("port", "11211"));
public static void main(String[] args) throws Exception {
// Configure SSL.
final SslContext sslCtx;
if (SSL) {
sslCtx = SslContextBuilder.forClient()
.trustManager(InsecureTrustManagerFactory.INSTANCE).build();
} else {
sslCtx = null;
}
EventLoopGroup group = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());
try {
Bootstrap b = new Bootstrap();
b.group(group)
.channel(NioSocketChannel.class)
.handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline p = ch.pipeline();
if (sslCtx != null) {
p.addLast(sslCtx.newHandler(ch.alloc(), HOST, PORT));
}
p.addLast(new BinaryMemcacheClientCodec());
p.addLast(new BinaryMemcacheObjectAggregator(Integer.MAX_VALUE));
p.addLast(new MemcacheClientHandler());
}
});
// Start the connection attempt.
Channel ch = b.connect(HOST, PORT).sync().channel();
// Read commands from the stdin.
System.out.println("Enter commands (quit to end)");
System.out.println("get <key>");
System.out.println("set <key> <value>");
ChannelFuture lastWriteFuture = null;
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
for (;;) {
String line = in.readLine();
if (line == null) {
break;
}
if ("quit".equals(line.toLowerCase())) {
ch.close().sync();
break;
}
// Sends the received line to the server.
lastWriteFuture = ch.writeAndFlush(line);
}
// Wait until all messages are flushed before closing the channel.
if (lastWriteFuture != null) {
lastWriteFuture.sync();
}
} finally {
group.shutdownGracefully();
}
}
}
Source
Frequently Asked Questions
What is the MemcacheClient class?
MemcacheClient is a class in the netty codebase, defined in example/src/main/java/io/netty/example/memcache/binary/MemcacheClient.java.
Where is MemcacheClient defined?
MemcacheClient is defined in example/src/main/java/io/netty/example/memcache/binary/MemcacheClient.java at line 40.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free