use of org.jboss.netty.buffer.ChannelBuffer in project pinpoint by naver.
the class StreamCreatePacket method toBuffer.
@Override
public ChannelBuffer toBuffer() {
ChannelBuffer header = ChannelBuffers.buffer(2 + 4 + 4);
header.writeShort(getPacketType());
header.writeInt(getStreamChannelId());
return PayloadPacket.appendPayload(header, payload);
}
use of org.jboss.netty.buffer.ChannelBuffer in project pinpoint by naver.
the class StreamCreateSuccessPacket method toBuffer.
@Override
public ChannelBuffer toBuffer() {
ChannelBuffer header = ChannelBuffers.buffer(2 + 4);
header.writeShort(getPacketType());
header.writeInt(getStreamChannelId());
return header;
}
use of org.jboss.netty.buffer.ChannelBuffer in project pinpoint by naver.
the class StreamPongPacket method toBuffer.
@Override
public ChannelBuffer toBuffer() {
ChannelBuffer header = ChannelBuffers.buffer(2 + 4 + 4);
header.writeShort(getPacketType());
header.writeInt(getStreamChannelId());
header.writeInt(requestId);
return header;
}
use of org.jboss.netty.buffer.ChannelBuffer in project neo4j by neo4j.
the class BufferReusingChunkingChannelBufferTest method triggerOperationCompleteCallback.
private static ChannelBuffer triggerOperationCompleteCallback(BufferReusingChunkingChannelBuffer buffer) throws Exception {
ChannelBuffer reusedBuffer = spy(ChannelBuffers.dynamicBuffer());
ChannelFuture channelFuture = mock(ChannelFuture.class);
when(channelFuture.isDone()).thenReturn(true);
when(channelFuture.isSuccess()).thenReturn(true);
buffer.newChannelFutureListener(reusedBuffer).operationComplete(channelFuture);
return reusedBuffer;
}
use of org.jboss.netty.buffer.ChannelBuffer in project neo4j by neo4j.
the class BufferReusingChunkingChannelBufferTest method freeBuffersAreReused.
@Test
@SuppressWarnings("unchecked")
public void freeBuffersAreReused() throws Exception {
CountingChannelBufferFactory bufferFactory = new CountingChannelBufferFactory();
BufferReusingChunkingChannelBuffer buffer = newBufferReusingChunkingChannelBuffer(10, bufferFactory);
buffer.writeLong(1);
buffer.writeLong(2);
// return 2 buffers to the pool
ChannelBuffer reusedBuffer1 = triggerOperationCompleteCallback(buffer);
ChannelBuffer reusedBuffer2 = triggerOperationCompleteCallback(buffer);
buffer.writeLong(3);
buffer.writeLong(4);
// 2 buffers were created
assertEquals(2, bufferFactory.instancesCreated);
// and 2 buffers were reused
verify(reusedBuffer1).writeLong(3);
verify(reusedBuffer2).writeLong(4);
}
Aggregations