Skip to main content

One post tagged with "redission"

View All Tags

redission 调用流程

· 8 min read

背景

java的redis操作使用redission封装

一个简单的堆栈堆栈

使用

比较核心的堆栈

encode:132, CommandEncoder (org.redisson.client.handler)
encode:99, CommandEncoder (org.redisson.client.handler)
encode:55, CommandEncoder (org.redisson.client.handler)
write:107, MessageToByteEncoder (io.netty.handler.codec)
write:75, CommandEncoder (org.redisson.client.handler)
invokeWrite0:881, AbstractChannelHandlerContext (io.netty.channel)
invokeWrite:863, AbstractChannelHandlerContext (io.netty.channel)
write:968, AbstractChannelHandlerContext (io.netty.channel)
write:856, AbstractChannelHandlerContext (io.netty.channel)
write:120, MessageToByteEncoder (io.netty.handler.codec)
write:45, CommandBatchEncoder (org.redisson.client.handler)
invokeWrite0:881, AbstractChannelHandlerContext (io.netty.channel)
invokeWriteAndFlush:940, AbstractChannelHandlerContext (io.netty.channel)
write:966, AbstractChannelHandlerContext (io.netty.channel)
writeAndFlush:934, AbstractChannelHandlerContext (io.netty.channel)
write:83, CommandsQueue (org.redisson.client.handler)
invokeWrite0:879, AbstractChannelHandlerContext (io.netty.channel)
invokeWriteAndFlush:940, AbstractChannelHandlerContext (io.netty.channel)
run:1247, AbstractChannelHandlerContext$WriteTask (io.netty.channel)
runTask$$$capture:174, AbstractEventExecutor (io.netty.util.concurrent)
runTask:-1, AbstractEventExecutor (io.netty.util.concurrent)
- Async stack trace
addTask:-1, SingleThreadEventExecutor (io.netty.util.concurrent)
execute:836, SingleThreadEventExecutor (io.netty.util.concurrent)
execute0:827, SingleThreadEventExecutor (io.netty.util.concurrent)
execute:817, SingleThreadEventExecutor (io.netty.util.concurrent)
safeExecute:1165, AbstractChannelHandlerContext (io.netty.channel)
write:972, AbstractChannelHandlerContext (io.netty.channel)
writeAndFlush:934, AbstractChannelHandlerContext (io.netty.channel)
writeAndFlush:984, AbstractChannelHandlerContext (io.netty.channel)
writeAndFlush:1025, DefaultChannelPipeline (io.netty.channel)
writeAndFlush:306, AbstractChannel (io.netty.channel)
send:206, RedisConnection (org.redisson.client)
sendCommand:590, RedisExecutor (org.redisson.command)
lambda$execute$3:164, RedisExecutor (org.redisson.command)
uniWhenComplete:859, CompletableFuture (java.util.concurrent)
uniWhenCompleteStage:883, CompletableFuture (java.util.concurrent)
whenComplete:2251, CompletableFuture (java.util.concurrent)
execute:149, RedisExecutor (org.redisson.command)
async:526, CommandAsyncService (org.redisson.command)
writeAsync:490, CommandAsyncService (org.redisson.command)
setAsync:192, RedissonBucket (org.redisson)
set:183, RedissonBucket (org.redisson)
main:25, App (com.demo.redission)

分配内存

allocateMemory:608, Unsafe (jdk.internal.misc)
<init>:122, DirectByteBuffer (java.nio)
allocateDirect:317, ByteBuffer (java.nio)
<clinit>:93, PlatformDependent0 (io.netty.util.internal)
isAndroid:333, PlatformDependent (io.netty.util.internal)
<clinit>:88, PlatformDependent (io.netty.util.internal)
<clinit>:84, NioEventLoop (io.netty.channel.nio)
newChild:182, NioEventLoopGroup (io.netty.channel.nio)
newChild:38, NioEventLoopGroup (io.netty.channel.nio)
<init>:84, MultithreadEventExecutorGroup (io.netty.util.concurrent)
<init>:60, MultithreadEventExecutorGroup (io.netty.util.concurrent)
<init>:49, MultithreadEventExecutorGroup (io.netty.util.concurrent)
<init>:59, MultithreadEventLoopGroup (io.netty.channel)
<init>:87, NioEventLoopGroup (io.netty.channel.nio)
<init>:82, NioEventLoopGroup (io.netty.channel.nio)
<init>:69, NioEventLoopGroup (io.netty.channel.nio)
<init>:181, MasterSlaveConnectionManager (org.redisson.connection)
<init>:73, ClusterConnectionManager (org.redisson.cluster)
createConnectionManager:196, ConfigSupport (org.redisson.config)
<init>:68, Redisson (org.redisson)
create:109, Redisson (org.redisson)
main:24, App (com.demo.redission)

ByteBuf 写入

堆栈

putByte:704, PlatformDependent0 (io.netty.util.internal)
putByte:719, PlatformDependent (io.netty.util.internal)
unsafeWriteUtf8:1020, ByteBufUtil (io.netty.buffer)
writeUtf8:836, ByteBufUtil (io.netty.buffer)
writeUtf8:820, ByteBufUtil (io.netty.buffer)
setCharSequence0:707, AbstractByteBuf (io.netty.buffer)
writeCharSequence:1187, AbstractByteBuf (io.netty.buffer)
encode:45, StringCodec$1 (org.redisson.client.codec)
encode:622, CommandAsyncService (org.redisson.command)
encode:313, RedissonObject (org.redisson)
setAsync:192, RedissonBucket (org.redisson)
set:183, RedissonBucket (org.redisson)
testApp:57, AppTest (com.demo.redission)
invokeVirtual:-1, LambdaForm$DMH/0x0000000800c0c400 (java.lang.invoke)
invoke:-1, LambdaForm$MH/0x0000000800c0d000 (java.lang.invoke)
invokeExact_MT:-1, Invokers$Holder (java.lang.invoke)
invokeImpl:154, DirectMethodHandleAccessor (jdk.internal.reflect)
invoke:104, DirectMethodHandleAccessor (jdk.internal.reflect)
invoke:577, Method (java.lang.reflect)
runTest:154, TestCase (junit.framework)
runBare:127, TestCase (junit.framework)
protect:106, TestResult$1 (junit.framework)
runProtected:124, TestResult (junit.framework)
run:109, TestResult (junit.framework)
run:118, TestCase (junit.framework)
doRun:116, TestRunner (junit.textui)
doRun:117, JUnit3IdeaTestRunner (com.intellij.junit3)
doRun:109, TestRunner (junit.textui)
startRunnerWithArgs:38, JUnit3IdeaTestRunner (com.intellij.junit3)
execute:38, IdeaTestRunner$Repeater$1 (com.intellij.rt.junit)
repeat:11, TestsRepeater (com.intellij.rt.execution.junit)
startRunnerWithArgs:35, IdeaTestRunner$Repeater (com.intellij.rt.junit)
prepareStreamsAndStart:235, JUnitStarter (com.intellij.rt.junit)
main:54, JUnitStarter (com.intellij.rt.junit)

ByteBuf 最后会调用UNSAFE.putByte(data, offset, value); 写入

ByteBuf 写入socket

write:62, SocketDispatcher (sun.nio.ch)
writeFromNativeBuffer:137, IOUtil (sun.nio.ch)
write:81, IOUtil (sun.nio.ch)
write:58, IOUtil (sun.nio.ch)
write:532, SocketChannelImpl (sun.nio.ch)
doWrite:415, NioSocketChannel (io.netty.channel.socket.nio)
flush0:931, AbstractChannel$AbstractUnsafe (io.netty.channel)
flush0:354, AbstractNioChannel$AbstractNioUnsafe (io.netty.channel.nio)
flush:895, AbstractChannel$AbstractUnsafe (io.netty.channel)
flush:1372, DefaultChannelPipeline$HeadContext (io.netty.channel)
invokeFlush0:921, AbstractChannelHandlerContext (io.netty.channel)
invokeFlush:907, AbstractChannelHandlerContext (io.netty.channel)
flush:893, AbstractChannelHandlerContext (io.netty.channel)
flush:125, ChannelOutboundHandlerAdapter (io.netty.channel)
invokeFlush0:925, AbstractChannelHandlerContext (io.netty.channel)
invokeWriteAndFlush:941, AbstractChannelHandlerContext (io.netty.channel)
write:966, AbstractChannelHandlerContext (io.netty.channel)
writeAndFlush:934, AbstractChannelHandlerContext (io.netty.channel)
write:83, CommandsQueue (org.redisson.client.handler)
invokeWrite0:879, AbstractChannelHandlerContext (io.netty.channel)
invokeWriteAndFlush:940, AbstractChannelHandlerContext (io.netty.channel)
run:1247, AbstractChannelHandlerContext$WriteTask (io.netty.channel)
runTask$$$capture:174, AbstractEventExecutor (io.netty.util.concurrent)
runTask:-1, AbstractEventExecutor (io.netty.util.concurrent)
- Async stack trace
addTask:-1, SingleThreadEventExecutor (io.netty.util.concurrent)
execute:836, SingleThreadEventExecutor (io.netty.util.concurrent)
execute0:827, SingleThreadEventExecutor (io.netty.util.concurrent)
execute:817, SingleThreadEventExecutor (io.netty.util.concurrent)
safeExecute:1165, AbstractChannelHandlerContext (io.netty.channel)
write:972, AbstractChannelHandlerContext (io.netty.channel)
writeAndFlush:934, AbstractChannelHandlerContext (io.netty.channel)
writeAndFlush:984, AbstractChannelHandlerContext (io.netty.channel)
writeAndFlush:1025, DefaultChannelPipeline (io.netty.channel)
writeAndFlush:306, AbstractChannel (io.netty.channel)
send:206, RedisConnection (org.redisson.client)
sendCommand:590, RedisExecutor (org.redisson.command)
lambda$execute$3:164, RedisExecutor (org.redisson.command)
uniWhenComplete:863, CompletableFuture (java.util.concurrent)
uniWhenCompleteStage:887, CompletableFuture (java.util.concurrent)
whenComplete:2325, CompletableFuture (java.util.concurrent)
execute:149, RedisExecutor (org.redisson.command)
async:526, CommandAsyncService (org.redisson.command)
readAsync:292, CommandAsyncService (org.redisson.command)
getAsync:140, RedissonBucket (org.redisson)
get:135, RedissonBucket (org.redisson)
testApp:59, AppTest (com.demo.redission)
invoke:104, DirectMethodHandleAccessor (jdk.internal.reflect)
invoke:577, Method (java.lang.reflect)
runTest:154, TestCase (junit.framework)
runBare:127, TestCase (junit.framework)
protect:106, TestResult$1 (junit.framework)
runProtected:124, TestResult (junit.framework)
run:109, TestResult (junit.framework)
run:118, TestCase (junit.framework)
doRun:116, TestRunner (junit.textui)
doRun:117, JUnit3IdeaTestRunner (com.intellij.junit3)
doRun:109, TestRunner (junit.textui)
startRunnerWithArgs:38, JUnit3IdeaTestRunner (com.intellij.junit3)
execute:38, IdeaTestRunner$Repeater$1 (com.intellij.rt.junit)
repeat:11, TestsRepeater (com.intellij.rt.execution.junit)
startRunnerWithArgs:35, IdeaTestRunner$Repeater (com.intellij.rt.junit)
prepareStreamsAndStart:235, JUnitStarter (com.intellij.rt.junit)
main:54, JUnitStarter (com.intellij.rt.junit)

ByteBuf 到ByteBuffer 转换

    public ByteBuffer[] nioBuffers(int maxCount, long maxBytes) {
...
ByteBuffer[] nioBuffers = NIO_BUFFERS.get(threadLocalMap);
Entry entry = flushedEntry;
while (isFlushedEntry(entry) && entry.msg instanceof ByteBuf) {
if (!entry.cancelled) {
ByteBuf buf = (ByteBuf) entry.msg;
final int readerIndex = buf.readerIndex();
final int readableBytes = buf.writerIndex() - readerIndex;

if (readableBytes > 0) {
nioBufferSize += readableBytes;
int count = entry.count;
if (count == -1) {
//noinspection ConstantValueVariableUse
entry.count = count = buf.nioBufferCount();
}
int neededSpace = min(maxCount, nioBufferCount + count);
if (neededSpace > nioBuffers.length) {
nioBuffers = expandNioBufferArray(nioBuffers, neededSpace, nioBufferCount);
NIO_BUFFERS.set(threadLocalMap, nioBuffers);
}
if (count == 1) {
ByteBuffer nioBuf = entry.buf;
if (nioBuf == null) {
// cache ByteBuffer as it may need to create a new ByteBuffer instance if its a
// derived buffer
entry.buf = nioBuf = buf.internalNioBuffer(readerIndex, readableBytes); // 转换
}
nioBuffers[nioBufferCount++] = nioBuf;
} else {
// The code exists in an extra method to ensure the method is not too big to inline as this
// branch is not very likely to get hit very frequently.
nioBufferCount = nioBuffers(entry, buf, nioBuffers, nioBufferCount, maxCount); // 转换nioBuffers
}
if (nioBufferCount >= maxCount) {
break;
}
}
}
entry = entry.next;
}
this.nioBufferCount = nioBufferCount;
this.nioBufferSize = nioBufferSize;

return nioBuffers;
}

写入ByteBuf 转换到ByteBuffer 的过程, 最后调用的是PooledByteBuf.internalNioBuffer 这个方法

internalNioBuffer:158, PooledByteBuf (io.netty.buffer)
_internalNioBuffer:194, PooledByteBuf (io.netty.buffer)
internalNioBuffer:207, PooledByteBuf (io.netty.buffer)
nioBuffers:447, ChannelOutboundBuffer (io.netty.channel)
doWrite:399, NioSocketChannel (io.netty.channel.socket.nio)
flush0:931, AbstractChannel$AbstractUnsafe (io.netty.channel)
flush0:354, AbstractNioChannel$AbstractNioUnsafe (io.netty.channel.nio)
flush:895, AbstractChannel$AbstractUnsafe (io.netty.channel)
flush:1372, DefaultChannelPipeline$HeadContext (io.netty.channel)
invokeFlush0:921, AbstractChannelHandlerContext (io.netty.channel)
invokeFlush:907, AbstractChannelHandlerContext (io.netty.channel)
flush:893, AbstractChannelHandlerContext (io.netty.channel)
flush:125, ChannelOutboundHandlerAdapter (io.netty.channel)
invokeFlush0:925, AbstractChannelHandlerContext (io.netty.channel)
invokeWriteAndFlush:941, AbstractChannelHandlerContext (io.netty.channel)
write:966, AbstractChannelHandlerContext (io.netty.channel)
writeAndFlush:934, AbstractChannelHandlerContext (io.netty.channel)
write:83, CommandsQueue (org.redisson.client.handler)
invokeWrite0:879, AbstractChannelHandlerContext (io.netty.channel)
invokeWriteAndFlush:940, AbstractChannelHandlerContext (io.netty.channel)
run:1247, AbstractChannelHandlerContext$WriteTask (io.netty.channel)
runTask$$$capture:174, AbstractEventExecutor (io.netty.util.concurrent)
runTask:-1, AbstractEventExecutor (io.netty.util.concurrent)
- Async stack trace
addTask:-1, SingleThreadEventExecutor (io.netty.util.concurrent)
execute:836, SingleThreadEventExecutor (io.netty.util.concurrent)
execute0:827, SingleThreadEventExecutor (io.netty.util.concurrent)
execute:817, SingleThreadEventExecutor (io.netty.util.concurrent)
safeExecute:1165, AbstractChannelHandlerContext (io.netty.channel)
write:972, AbstractChannelHandlerContext (io.netty.channel)
writeAndFlush:934, AbstractChannelHandlerContext (io.netty.channel)
writeAndFlush:984, AbstractChannelHandlerContext (io.netty.channel)
writeAndFlush:1025, DefaultChannelPipeline (io.netty.channel)
writeAndFlush:306, AbstractChannel (io.netty.channel)
send:206, RedisConnection (org.redisson.client)
sync:215, RedisConnection (org.redisson.client)
sync:202, RedisConnection (org.redisson.client)
<init>:100, ClusterConnectionManager (org.redisson.cluster)
createConnectionManager:196, ConfigSupport (org.redisson.config)
<init>:68, Redisson (org.redisson)
create:109, Redisson (org.redisson)
main:24, App (com.demo.redission)

创建链接的过程:

createConnection:36, RedisConnectionHandler (org.redisson.client.handler)
channelRegistered:53, BaseConnectionHandler (org.redisson.client.handler)
invokeChannelRegistered:176, AbstractChannelHandlerContext (io.netty.channel)
invokeChannelRegistered:152, AbstractChannelHandlerContext (io.netty.channel) [2]
fireChannelRegistered:145, AbstractChannelHandlerContext (io.netty.channel)
channelRegistered:1383, DefaultChannelPipeline$HeadContext (io.netty.channel)
invokeChannelRegistered:172, AbstractChannelHandlerContext (io.netty.channel)
invokeChannelRegistered:152, AbstractChannelHandlerContext (io.netty.channel) [1]
fireChannelRegistered:815, DefaultChannelPipeline (io.netty.channel)
register0:517, AbstractChannel$AbstractUnsafe (io.netty.channel)
access$200:429, AbstractChannel$AbstractUnsafe (io.netty.channel)
run:486, AbstractChannel$AbstractUnsafe$1 (io.netty.channel)
runTask$$$capture:174, AbstractEventExecutor (io.netty.util.concurrent)
runTask:-1, AbstractEventExecutor (io.netty.util.concurrent)
- Async stack trace
addTask:-1, SingleThreadEventExecutor (io.netty.util.concurrent)
execute:836, SingleThreadEventExecutor (io.netty.util.concurrent)
execute0:827, SingleThreadEventExecutor (io.netty.util.concurrent)
execute:817, SingleThreadEventExecutor (io.netty.util.concurrent)
register:483, AbstractChannel$AbstractUnsafe (io.netty.channel)
register:89, SingleThreadEventLoop (io.netty.channel)
register:83, SingleThreadEventLoop (io.netty.channel)
register:86, MultithreadEventLoopGroup (io.netty.channel)
initAndRegister:323, AbstractBootstrap (io.netty.bootstrap)
doResolveAndConnect:155, Bootstrap (io.netty.bootstrap)
connect:139, Bootstrap (io.netty.bootstrap)
lambda$connectAsync$1:220, RedisClient (org.redisson.client)
uniComposeStage:1187, CompletableFuture (java.util.concurrent)
thenCompose:2309, CompletableFuture (java.util.concurrent)
connectAsync:218, RedisClient (org.redisson.client)
connect:189, ClientConnectionsEntry (org.redisson.connection)
connect:249, ConnectionPool (org.redisson.connection.pool)
createConnection:274, ConnectionPool (org.redisson.connection.pool)
lambda$createConnection$1:112, ConnectionPool (org.redisson.connection.pool)
uniAcceptNow:757, CompletableFuture (java.util.concurrent)
uniAcceptStage:735, CompletableFuture (java.util.concurrent)
thenAccept:2182, CompletableFuture (java.util.concurrent)
createConnection:110, ConnectionPool (org.redisson.connection.pool)
initConnections:92, ConnectionPool (org.redisson.connection.pool)
add:69, ConnectionPool (org.redisson.connection.pool)
add:34, MasterConnectionPool (org.redisson.connection.pool)
lambda$setupMasterEntry$1:139, MasterSlaveEntry (org.redisson.connection)
uniComposeStage:1187, CompletableFuture (java.util.concurrent)
thenCompose:2309, CompletableFuture (java.util.concurrent)
setupMasterEntry:122, MasterSlaveEntry (org.redisson.connection)
setupMasterEntry:117, MasterSlaveEntry (org.redisson.connection)
setupMasterEntry:112, MasterSlaveEntry (org.redisson.connection)
initSingleEntry:330, MasterSlaveConnectionManager (org.redisson.connection)
<init>:146, MasterSlaveConnectionManager (org.redisson.connection)
<init>:30, SingleConnectionManager (org.redisson.connection)
createConnectionManager:190, ConfigSupport (org.redisson.config)
<init>:68, Redisson (org.redisson)
create:109, Redisson (org.redisson)
testApp:58, AppTest (com.demo.redission)
invoke:104, DirectMethodHandleAccessor (jdk.internal.reflect)
invoke:577, Method (java.lang.reflect)
runTest:154, TestCase (junit.framework)
runBare:127, TestCase (junit.framework)
protect:106, TestResult$1 (junit.framework)
runProtected:124, TestResult (junit.framework)
run:109, TestResult (junit.framework)
run:118, TestCase (junit.framework)
doRun:116, TestRunner (junit.textui)
doRun:117, JUnit3IdeaTestRunner (com.intellij.junit3)
doRun:109, TestRunner (junit.textui)
startRunnerWithArgs:38, JUnit3IdeaTestRunner (com.intellij.junit3)
execute:38, IdeaTestRunner$Repeater$1 (com.intellij.rt.junit)
repeat:11, TestsRepeater (com.intellij.rt.execution.junit)
startRunnerWithArgs:35, IdeaTestRunner$Repeater (com.intellij.rt.junit)
prepareStreamsAndStart:235, JUnitStarter (com.intellij.rt.junit)
main:54, JUnitStarter (com.intellij.rt.junit)

Bootstrap使用:

createBootstrap:122, RedisClient (org.redisson.client)
<init>:115, RedisClient (org.redisson.client)
create:77, RedisClient (org.redisson.client)
createClient:425, MasterSlaveConnectionManager (org.redisson.connection)
createClient:412, MasterSlaveConnectionManager (org.redisson.connection)
setupMasterEntry:116, MasterSlaveEntry (org.redisson.connection)
setupMasterEntry:112, MasterSlaveEntry (org.redisson.connection)
initSingleEntry:330, MasterSlaveConnectionManager (org.redisson.connection)
<init>:146, MasterSlaveConnectionManager (org.redisson.connection)
<init>:30, SingleConnectionManager (org.redisson.connection)
createConnectionManager:190, ConfigSupport (org.redisson.config)
<init>:68, Redisson (org.redisson)
create:109, Redisson (org.redisson)
testApp:58, AppTest (com.demo.redission)
invokeVirtual:-1, LambdaForm$DMH/0x0000000800c0c400 (java.lang.invoke)
invoke:-1, LambdaForm$MH/0x0000000800c0d800 (java.lang.invoke)
invokeExact_MT:-1, Invokers$Holder (java.lang.invoke)
invokeImpl:154, DirectMethodHandleAccessor (jdk.internal.reflect)
invoke:104, DirectMethodHandleAccessor (jdk.internal.reflect)
invoke:577, Method (java.lang.reflect)
runTest:154, TestCase (junit.framework)
runBare:127, TestCase (junit.framework)
protect:106, TestResult$1 (junit.framework)
runProtected:124, TestResult (junit.framework)
run:109, TestResult (junit.framework)
run:118, TestCase (junit.framework)
runTest:208, TestSuite (junit.framework)
run:203, TestSuite (junit.framework)
doRun:116, TestRunner (junit.textui)
doRun:117, JUnit3IdeaTestRunner (com.intellij.junit3)
doRun:109, TestRunner (junit.textui)
startRunnerWithArgs:38, JUnit3IdeaTestRunner (com.intellij.junit3)
execute:38, IdeaTestRunner$Repeater$1 (com.intellij.rt.junit)
repeat:11, TestsRepeater (com.intellij.rt.execution.junit)
startRunnerWithArgs:35, IdeaTestRunner$Repeater (com.intellij.rt.junit)
prepareStreamsAndStart:235, JUnitStarter (com.intellij.rt.junit)
main:54, JUnitStarter (com.intellij.rt.junit)

future 使用:

handleResult:547, RedisExecutor (org.redisson.command)
checkAttemptPromise:524, RedisExecutor (org.redisson.command)
lambda$execute$4:176, RedisExecutor (org.redisson.command)
accept:-1, RedisExecutor$$Lambda$85/0x0000000800d64c28 (org.redisson.command)
uniWhenComplete:863, CompletableFuture (java.util.concurrent)
tryFire:841, CompletableFuture$UniWhenComplete (java.util.concurrent)
postComplete:510, CompletableFuture (java.util.concurrent)
complete:2147, CompletableFuture (java.util.concurrent)
completeResponse:467, CommandDecoder (org.redisson.client.handler)
handleResult:461, CommandDecoder (org.redisson.client.handler)
decode:340, CommandDecoder (org.redisson.client.handler)
decodeCommand:205, CommandDecoder (org.redisson.client.handler)
decode:144, CommandDecoder (org.redisson.client.handler)
decode:120, CommandDecoder (org.redisson.client.handler)
decodeRemovalReentryProtection:529, ByteToMessageDecoder (io.netty.handler.codec)
callDecode:366, ReplayingDecoder (io.netty.handler.codec)
channelRead:290, ByteToMessageDecoder (io.netty.handler.codec)
invokeChannelRead:444, AbstractChannelHandlerContext (io.netty.channel)
invokeChannelRead:420, AbstractChannelHandlerContext (io.netty.channel)
fireChannelRead:412, AbstractChannelHandlerContext (io.netty.channel)
channelRead:1410, DefaultChannelPipeline$HeadContext (io.netty.channel)
invokeChannelRead:440, AbstractChannelHandlerContext (io.netty.channel)
invokeChannelRead:420, AbstractChannelHandlerContext (io.netty.channel)
fireChannelRead:919, DefaultChannelPipeline (io.netty.channel)
read:166, AbstractNioByteChannel$NioByteUnsafe (io.netty.channel.nio)
processSelectedKey:788, NioEventLoop (io.netty.channel.nio)
processSelectedKeysOptimized:724, NioEventLoop (io.netty.channel.nio)
processSelectedKeys:650, NioEventLoop (io.netty.channel.nio)
run:562, NioEventLoop (io.netty.channel.nio)
run:997, SingleThreadEventExecutor$4 (io.netty.util.concurrent)
run:74, ThreadExecutorMap$2 (io.netty.util.internal)
run:30, FastThreadLocalRunnable (io.netty.util.concurrent)
run:833, Thread (java.lang)

redis 解码

/home/dai/.m2/repository/org/redisson/redisson/3.19.0/redisson-3.19.0-sources.jar!/org/redisson/client/handler/RedisChannelInitializer.java
@Override
protected void initChannel(Channel ch) throws Exception {
initSsl(config, ch);

if (type == Type.PLAIN) {
ch.pipeline().addLast(new RedisConnectionHandler(redisClient));
} else {
ch.pipeline().addLast(new RedisPubSubConnectionHandler(redisClient));
}

ch.pipeline().addLast(
connectionWatchdog,
CommandEncoder.INSTANCE,
CommandBatchEncoder.INSTANCE);

if (type == Type.PLAIN) {
ch.pipeline().addLast(new CommandsQueue());
} else {
ch.pipeline().addLast(new CommandsQueuePubSub());
}

if (pingConnectionHandler != null) {
ch.pipeline().addLast(pingConnectionHandler);
}

if (type == Type.PLAIN) {
ch.pipeline().addLast(new CommandDecoder(config.getAddress().getScheme())); // 解码
} else {
ch.pipeline().addLast(new CommandPubSubDecoder(config));
}

ch.pipeline().addLast(new ErrorsLoggingHandler());

config.getNettyHook().afterChannelInitialization(ch);
}

redission future 回调:

handleResult:547, RedisExecutor (org.redisson.command)
checkAttemptPromise:524, RedisExecutor (org.redisson.command)
lambda$execute$4:176, RedisExecutor (org.redisson.command)
accept:-1, RedisExecutor$$Lambda$86/0x0000000800d64c18 (org.redisson.command)
uniWhenComplete:863, CompletableFuture (java.util.concurrent)
tryFire:841, CompletableFuture$UniWhenComplete (java.util.concurrent)
postComplete:510, CompletableFuture (java.util.concurrent)
complete:2147, CompletableFuture (java.util.concurrent)
completeResponse:467, CommandDecoder (org.redisson.client.handler)
handleResult:461, CommandDecoder (org.redisson.client.handler)
decode:392, CommandDecoder (org.redisson.client.handler)
decodeCommand:205, CommandDecoder (org.redisson.client.handler)
decode:144, CommandDecoder (org.redisson.client.handler)
decode:120, CommandDecoder (org.redisson.client.handler)
decodeRemovalReentryProtection:529, ByteToMessageDecoder (io.netty.handler.codec)
callDecode:366, ReplayingDecoder (io.netty.handler.codec)
channelRead:290, ByteToMessageDecoder (io.netty.handler.codec)
invokeChannelRead:444, AbstractChannelHandlerContext (io.netty.channel)
invokeChannelRead:420, AbstractChannelHandlerContext (io.netty.channel)
fireChannelRead:412, AbstractChannelHandlerContext (io.netty.channel)
channelRead:1410, DefaultChannelPipeline$HeadContext (io.netty.channel)
invokeChannelRead:440, AbstractChannelHandlerContext (io.netty.channel)
invokeChannelRead:420, AbstractChannelHandlerContext (io.netty.channel)
fireChannelRead:919, DefaultChannelPipeline (io.netty.channel)
read:166, AbstractNioByteChannel$NioByteUnsafe (io.netty.channel.nio)
processSelectedKey:788, NioEventLoop (io.netty.channel.nio)
processSelectedKeysOptimized:724, NioEventLoop (io.netty.channel.nio)
processSelectedKeys:650, NioEventLoop (io.netty.channel.nio)
run:562, NioEventLoop (io.netty.channel.nio)
run:997, SingleThreadEventExecutor$4 (io.netty.util.concurrent)
run:74, ThreadExecutorMap$2 (io.netty.util.internal)
run:30, FastThreadLocalRunnable (io.netty.util.concurrent)
run:833, Thread (java.lang)

相关阅读