use of org.apache.kafka.common.protocol.types.Struct in project kafka by apache.
the class GroupCoordinatorResponse method toStruct.
@Override
protected Struct toStruct(short version) {
Struct struct = new Struct(ApiKeys.GROUP_COORDINATOR.responseSchema(version));
struct.set(ERROR_CODE_KEY_NAME, error.code());
Struct coordinator = struct.instance(COORDINATOR_KEY_NAME);
coordinator.set(NODE_ID_KEY_NAME, node.id());
coordinator.set(HOST_KEY_NAME, node.host());
coordinator.set(PORT_KEY_NAME, node.port());
struct.set(COORDINATOR_KEY_NAME, coordinator);
return struct;
}
use of org.apache.kafka.common.protocol.types.Struct in project kafka by apache.
the class HeartbeatRequest method toStruct.
@Override
protected Struct toStruct() {
Struct struct = new Struct(ApiKeys.HEARTBEAT.requestSchema(version()));
struct.set(GROUP_ID_KEY_NAME, groupId);
struct.set(GROUP_GENERATION_ID_KEY_NAME, groupGenerationId);
struct.set(MEMBER_ID_KEY_NAME, memberId);
return struct;
}
use of org.apache.kafka.common.protocol.types.Struct in project kafka by apache.
the class HeartbeatResponse method toStruct.
@Override
protected Struct toStruct(short version) {
Struct struct = new Struct(ApiKeys.HEARTBEAT.responseSchema(version));
struct.set(ERROR_CODE_KEY_NAME, error.code());
return struct;
}
use of org.apache.kafka.common.protocol.types.Struct in project kafka by apache.
the class JoinGroupRequest method toStruct.
@Override
protected Struct toStruct() {
short version = version();
Struct struct = new Struct(ApiKeys.JOIN_GROUP.requestSchema(version));
struct.set(GROUP_ID_KEY_NAME, groupId);
struct.set(SESSION_TIMEOUT_KEY_NAME, sessionTimeout);
if (version >= 1) {
struct.set(REBALANCE_TIMEOUT_KEY_NAME, rebalanceTimeout);
}
struct.set(MEMBER_ID_KEY_NAME, memberId);
struct.set(PROTOCOL_TYPE_KEY_NAME, protocolType);
List<Struct> groupProtocolsList = new ArrayList<>(groupProtocols.size());
for (ProtocolMetadata protocol : groupProtocols) {
Struct protocolStruct = struct.instance(GROUP_PROTOCOLS_KEY_NAME);
protocolStruct.set(PROTOCOL_NAME_KEY_NAME, protocol.name);
protocolStruct.set(PROTOCOL_METADATA_KEY_NAME, protocol.metadata);
groupProtocolsList.add(protocolStruct);
}
struct.set(GROUP_PROTOCOLS_KEY_NAME, groupProtocolsList.toArray());
return struct;
}
use of org.apache.kafka.common.protocol.types.Struct in project kafka by apache.
the class JoinGroupResponse method toStruct.
@Override
protected Struct toStruct(short version) {
Struct struct = new Struct(ApiKeys.JOIN_GROUP.responseSchema(version));
struct.set(ERROR_CODE_KEY_NAME, error.code());
struct.set(GENERATION_ID_KEY_NAME, generationId);
struct.set(GROUP_PROTOCOL_KEY_NAME, groupProtocol);
struct.set(MEMBER_ID_KEY_NAME, memberId);
struct.set(LEADER_ID_KEY_NAME, leaderId);
List<Struct> memberArray = new ArrayList<>();
for (Map.Entry<String, ByteBuffer> entries : members.entrySet()) {
Struct memberData = struct.instance(MEMBERS_KEY_NAME);
memberData.set(MEMBER_ID_KEY_NAME, entries.getKey());
memberData.set(MEMBER_METADATA_KEY_NAME, entries.getValue());
memberArray.add(memberData);
}
struct.set(MEMBERS_KEY_NAME, memberArray.toArray());
return struct;
}
Aggregations