Search in sources :

Example 1 with ByteBufferChannel

use of org.apache.kafka.common.requests.ByteBufferChannel in project kafka by apache.

the class MockSelector method completeSend.

private void completeSend(NetworkSend send) throws IOException {
    // Consume the send so that we will be able to send more requests to the destination
    try (ByteBufferChannel discardChannel = new ByteBufferChannel(send.size())) {
        while (!send.completed()) {
            send.writeTo(discardChannel);
        }
        completedSends.add(send);
        completedSendBuffers.add(discardChannel);
    }
}
Also used : ByteBufferChannel(org.apache.kafka.common.requests.ByteBufferChannel)

Example 2 with ByteBufferChannel

use of org.apache.kafka.common.requests.ByteBufferChannel in project kafka by apache.

the class FetchResponseBenchmark method testSerializeFetchResponse.

@Benchmark
public int testSerializeFetchResponse() throws IOException {
    Send send = fetchResponse.toSend(header, ApiKeys.FETCH.latestVersion());
    ByteBufferChannel channel = new ByteBufferChannel(send.size());
    send.writeTo(channel);
    return channel.buffer().limit();
}
Also used : ByteBufferChannel(org.apache.kafka.common.requests.ByteBufferChannel) Send(org.apache.kafka.common.network.Send) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 3 with ByteBufferChannel

use of org.apache.kafka.common.requests.ByteBufferChannel in project kafka by apache.

the class FetchRequestBenchmark method testSerializeFetchRequestForReplica.

@Benchmark
public int testSerializeFetchRequestForReplica() throws IOException {
    Send send = replicaRequest.toSend(header);
    ByteBufferChannel channel = new ByteBufferChannel(send.size());
    send.writeTo(channel);
    return channel.buffer().limit();
}
Also used : ByteBufferChannel(org.apache.kafka.common.requests.ByteBufferChannel) Send(org.apache.kafka.common.network.Send) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 4 with ByteBufferChannel

use of org.apache.kafka.common.requests.ByteBufferChannel in project apache-kafka-on-k8s by banzaicloud.

the class MockSelector method completeSend.

private void completeSend(Send send) throws IOException {
    // Consume the send so that we will be able to send more requests to the destination
    ByteBufferChannel discardChannel = new ByteBufferChannel(send.size());
    while (!send.completed()) {
        send.writeTo(discardChannel);
    }
    completedSends.add(send);
}
Also used : ByteBufferChannel(org.apache.kafka.common.requests.ByteBufferChannel)

Example 5 with ByteBufferChannel

use of org.apache.kafka.common.requests.ByteBufferChannel in project kafka by apache.

the class FetchRequestBenchmark method testSerializeFetchRequestForConsumer.

@Benchmark
public int testSerializeFetchRequestForConsumer() throws IOException {
    Send send = consumerRequest.toSend(header);
    ByteBufferChannel channel = new ByteBufferChannel(send.size());
    send.writeTo(channel);
    return channel.buffer().limit();
}
Also used : ByteBufferChannel(org.apache.kafka.common.requests.ByteBufferChannel) Send(org.apache.kafka.common.network.Send) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Aggregations

ByteBufferChannel (org.apache.kafka.common.requests.ByteBufferChannel)6 Send (org.apache.kafka.common.network.Send)3 Benchmark (org.openjdk.jmh.annotations.Benchmark)3 IOException (java.io.IOException)1