-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-26674][CORE]Consolidate CompositeByteBuf when reading large frame #23602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
0072d06
a2536da
9fd8ecd
9515621
1e3e9cf
96a71ed
f872e24
3fb7484
bc44188
ef63cdb
449efed
5f8c4eb
3aad18a
6ca6f71
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| import java.util.Random; | ||
| import java.util.concurrent.atomic.AtomicInteger; | ||
|
|
||
| import com.google.common.collect.Lists; | ||
| import io.netty.buffer.ByteBuf; | ||
| import io.netty.buffer.Unpooled; | ||
| import io.netty.channel.ChannelHandlerContext; | ||
|
|
@@ -47,6 +48,35 @@ public void testFrameDecoding() throws Exception { | |
| verifyAndCloseDecoder(decoder, ctx, data); | ||
| } | ||
|
|
||
| @Test | ||
| public void testConsolidationForDecodingNonFullyWrittenByteBuf() { | ||
|
||
| TransportFrameDecoder decoder = new TransportFrameDecoder(); | ||
| ChannelHandlerContext ctx = mock(ChannelHandlerContext.class); | ||
| ArrayList<ByteBuf> retained = Lists.newArrayList(); | ||
| when(ctx.fireChannelRead(any())).thenAnswer(in -> { | ||
| ByteBuf buf = (ByteBuf) in.getArguments()[0]; | ||
| retained.add(buf); | ||
| return null; | ||
| }); | ||
| ByteBuf data1 = Unpooled.buffer(1024 * 1024); | ||
| data1.writeLong(1024 * 1024 + 8); | ||
| data1.writeByte(127); | ||
| ByteBuf data2 = Unpooled.buffer(1024 * 1024); | ||
| for (int i = 0; i < 1024 * 1024 - 1; i++) { | ||
| data2.writeByte(128); | ||
| } | ||
| int orignalCapacity = data1.capacity() + data2.capacity(); | ||
| try { | ||
| decoder.channelRead(ctx, data1); | ||
| decoder.channelRead(ctx, data2); | ||
| assertEquals(1, retained.size()); | ||
| assert(retained.get(0).capacity() < orignalCapacity); | ||
| } catch (Exception e) { | ||
liupc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| release(data1); | ||
| release(data2); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testInterception() throws Exception { | ||
| int interceptedReads = 3; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.