Search in sources :

Example 81 with ChannelBuffer

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);
}
Also used : ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer)

Example 82 with ChannelBuffer

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;
}
Also used : ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer)

Example 83 with ChannelBuffer

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;
}
Also used : ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer)

Example 84 with ChannelBuffer

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;
}
Also used : ChannelFuture(org.jboss.netty.channel.ChannelFuture) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer)

Example 85 with ChannelBuffer

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);
}
Also used : ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer) Test(org.junit.Test)

Aggregations

ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)494 DefaultHttpResponse (org.jboss.netty.handler.codec.http.DefaultHttpResponse)70 Test (org.junit.Test)67 DeviceSession (org.traccar.DeviceSession)64 Position (org.traccar.model.Position)62 HttpResponse (org.jboss.netty.handler.codec.http.HttpResponse)61 Test (org.testng.annotations.Test)49 HttpChunk (org.jboss.netty.handler.codec.http.HttpChunk)48 DefaultHttpChunk (org.jboss.netty.handler.codec.http.DefaultHttpChunk)44 HttpChunkTrailer (org.jboss.netty.handler.codec.http.HttpChunkTrailer)37 DefaultHttpChunkTrailer (org.jboss.netty.handler.codec.http.DefaultHttpChunkTrailer)34 ChannelFuture (org.jboss.netty.channel.ChannelFuture)28 Checkpoint (com.linkedin.databus.core.Checkpoint)27 ByteBuffer (java.nio.ByteBuffer)27 RecoverablePduException (com.cloudhopper.smpp.type.RecoverablePduException)26 UnrecoverablePduException (com.cloudhopper.smpp.type.UnrecoverablePduException)26 DateBuilder (org.traccar.helper.DateBuilder)26 BootstrapDatabaseTooOldException (com.linkedin.databus2.core.container.request.BootstrapDatabaseTooOldException)25 IOException (java.io.IOException)23 ArrayList (java.util.ArrayList)23