use of org.apache.kafka.common.network.MultiSend in project kafka by apache.
the class FetchResponse method toSend.
public Send toSend(Struct responseStruct, int throttleTimeMs, String dest, RequestHeader requestHeader) {
Struct responseHeader = new ResponseHeader(requestHeader.correlationId()).toStruct();
// write the total size and the response header
ByteBuffer buffer = ByteBuffer.allocate(responseHeader.sizeOf() + 4);
buffer.putInt(responseHeader.sizeOf() + responseStruct.sizeOf());
responseHeader.writeTo(buffer);
buffer.rewind();
List<Send> sends = new ArrayList<>();
sends.add(new ByteBufferSend(dest, buffer));
addResponseData(responseStruct, throttleTimeMs, dest, sends);
return new MultiSend(dest, sends);
}
use of org.apache.kafka.common.network.MultiSend in project apache-kafka-on-k8s by banzaicloud.
the class FetchResponse method toSend.
@Override
protected Send toSend(String dest, ResponseHeader responseHeader, short apiVersion) {
Struct responseHeaderStruct = responseHeader.toStruct();
Struct responseBodyStruct = toStruct(apiVersion);
// write the total size and the response header
ByteBuffer buffer = ByteBuffer.allocate(responseHeaderStruct.sizeOf() + 4);
buffer.putInt(responseHeaderStruct.sizeOf() + responseBodyStruct.sizeOf());
responseHeaderStruct.writeTo(buffer);
buffer.rewind();
Queue<Send> sends = new ArrayDeque<>();
sends.add(new ByteBufferSend(dest, buffer));
addResponseData(responseBodyStruct, throttleTimeMs, dest, sends);
return new MultiSend(dest, sends);
}
Aggregations