use of org.apache.kafka.common.protocol.types.Struct in project kafka by apache.
the class FetchResponse method addPartitionData.
private static void addPartitionData(String dest, List<Send> sends, Struct partitionData) {
Struct header = partitionData.getStruct(PARTITION_HEADER_KEY_NAME);
Records records = partitionData.getRecords(RECORD_SET_KEY_NAME);
// include the partition header and the size of the record set
ByteBuffer buffer = ByteBuffer.allocate(header.sizeOf() + 4);
header.writeTo(buffer);
buffer.putInt(records.sizeInBytes());
buffer.rewind();
sends.add(new ByteBufferSend(dest, buffer));
// finally the send for the record set itself
sends.add(new RecordsSend(dest, records));
}
use of org.apache.kafka.common.protocol.types.Struct in project kafka by apache.
the class GroupCoordinatorRequest method toStruct.
@Override
protected Struct toStruct() {
Struct struct = new Struct(ApiKeys.GROUP_COORDINATOR.requestSchema(version()));
struct.set(GROUP_ID_KEY_NAME, groupId);
return struct;
}
use of org.apache.kafka.common.protocol.types.Struct in project kafka by apache.
the class ApiVersionsResponse method toStruct.
@Override
protected Struct toStruct(short version) {
Struct struct = new Struct(ApiKeys.API_VERSIONS.responseSchema(version));
struct.set(ERROR_CODE_KEY_NAME, error.code());
List<Struct> apiVersionList = new ArrayList<>();
for (ApiVersion apiVersion : apiKeyToApiVersion.values()) {
Struct apiVersionStruct = struct.instance(API_VERSIONS_KEY_NAME);
apiVersionStruct.set(API_KEY_NAME, apiVersion.apiKey);
apiVersionStruct.set(MIN_VERSION_KEY_NAME, apiVersion.minVersion);
apiVersionStruct.set(MAX_VERSION_KEY_NAME, apiVersion.maxVersion);
apiVersionList.add(apiVersionStruct);
}
struct.set(API_VERSIONS_KEY_NAME, apiVersionList.toArray());
return struct;
}
use of org.apache.kafka.common.protocol.types.Struct in project kafka by apache.
the class ControlledShutdownRequest method toStruct.
@Override
protected Struct toStruct() {
Struct struct = new Struct(ApiKeys.CONTROLLED_SHUTDOWN_KEY.requestSchema(version()));
struct.set(BROKER_ID_KEY_NAME, brokerId);
return struct;
}
use of org.apache.kafka.common.protocol.types.Struct in project kafka by apache.
the class ControlledShutdownResponse method toStruct.
@Override
protected Struct toStruct(short version) {
Struct struct = new Struct(ApiKeys.CONTROLLED_SHUTDOWN_KEY.responseSchema(version));
struct.set(ERROR_CODE_KEY_NAME, error.code());
List<Struct> partitionsRemainingList = new ArrayList<>(partitionsRemaining.size());
for (TopicPartition topicPartition : partitionsRemaining) {
Struct topicPartitionStruct = struct.instance(PARTITIONS_REMAINING_KEY_NAME);
topicPartitionStruct.set(TOPIC_KEY_NAME, topicPartition.topic());
topicPartitionStruct.set(PARTITION_KEY_NAME, topicPartition.partition());
partitionsRemainingList.add(topicPartitionStruct);
}
struct.set(PARTITIONS_REMAINING_KEY_NAME, partitionsRemainingList.toArray());
return struct;
}
Aggregations