org.apache.kafka.common.message.ConsumerGroupHeartbeatResponseData Maven / Gradle / Ivy
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// THIS CODE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
package org.apache.kafka.common.message;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import org.apache.kafka.common.Uuid;
import org.apache.kafka.common.errors.UnsupportedVersionException;
import org.apache.kafka.common.protocol.ApiMessage;
import org.apache.kafka.common.protocol.Message;
import org.apache.kafka.common.protocol.MessageSizeAccumulator;
import org.apache.kafka.common.protocol.MessageUtil;
import org.apache.kafka.common.protocol.ObjectSerializationCache;
import org.apache.kafka.common.protocol.Readable;
import org.apache.kafka.common.protocol.Writable;
import org.apache.kafka.common.protocol.types.CompactArrayOf;
import org.apache.kafka.common.protocol.types.Field;
import org.apache.kafka.common.protocol.types.RawTaggedField;
import org.apache.kafka.common.protocol.types.RawTaggedFieldWriter;
import org.apache.kafka.common.protocol.types.Schema;
import org.apache.kafka.common.protocol.types.Type;
import org.apache.kafka.common.utils.ByteUtils;
import static org.apache.kafka.common.protocol.types.Field.TaggedFieldsSection;
public class ConsumerGroupHeartbeatResponseData implements ApiMessage {
int throttleTimeMs;
short errorCode;
String errorMessage;
String memberId;
int memberEpoch;
int heartbeatIntervalMs;
Assignment assignment;
private List _unknownTaggedFields;
public static final Schema SCHEMA_0 =
new Schema(
new Field("throttle_time_ms", Type.INT32, "The duration in milliseconds for which the request was throttled due to a quota violation, or zero if the request did not violate any quota."),
new Field("error_code", Type.INT16, "The top-level error code, or 0 if there was no error"),
new Field("error_message", Type.COMPACT_NULLABLE_STRING, "The top-level error message, or null if there was no error."),
new Field("member_id", Type.COMPACT_NULLABLE_STRING, "The member id generated by the coordinator. Only provided when the member joins with MemberEpoch == 0."),
new Field("member_epoch", Type.INT32, "The member epoch."),
new Field("heartbeat_interval_ms", Type.INT32, "The heartbeat interval in milliseconds."),
new Field("assignment", Assignment.SCHEMA_0, "null if not provided; the assignment otherwise."),
TaggedFieldsSection.of(
)
);
public static final Schema[] SCHEMAS = new Schema[] {
SCHEMA_0
};
public static final short LOWEST_SUPPORTED_VERSION = 0;
public static final short HIGHEST_SUPPORTED_VERSION = 0;
public ConsumerGroupHeartbeatResponseData(Readable _readable, short _version) {
read(_readable, _version);
}
public ConsumerGroupHeartbeatResponseData() {
this.throttleTimeMs = 0;
this.errorCode = (short) 0;
this.errorMessage = null;
this.memberId = null;
this.memberEpoch = 0;
this.heartbeatIntervalMs = 0;
this.assignment = null;
}
@Override
public short apiKey() {
return 68;
}
@Override
public short lowestSupportedVersion() {
return 0;
}
@Override
public short highestSupportedVersion() {
return 0;
}
@Override
public final void read(Readable _readable, short _version) {
this.throttleTimeMs = _readable.readInt();
this.errorCode = _readable.readShort();
{
int length;
length = _readable.readUnsignedVarint() - 1;
if (length < 0) {
this.errorMessage = null;
} else if (length > 0x7fff) {
throw new RuntimeException("string field errorMessage had invalid length " + length);
} else {
this.errorMessage = _readable.readString(length);
}
}
{
int length;
length = _readable.readUnsignedVarint() - 1;
if (length < 0) {
this.memberId = null;
} else if (length > 0x7fff) {
throw new RuntimeException("string field memberId had invalid length " + length);
} else {
this.memberId = _readable.readString(length);
}
}
this.memberEpoch = _readable.readInt();
this.heartbeatIntervalMs = _readable.readInt();
{
if (_readable.readByte() < 0) {
this.assignment = null;
} else {
this.assignment = new Assignment(_readable, _version);
}
}
this._unknownTaggedFields = null;
int _numTaggedFields = _readable.readUnsignedVarint();
for (int _i = 0; _i < _numTaggedFields; _i++) {
int _tag = _readable.readUnsignedVarint();
int _size = _readable.readUnsignedVarint();
switch (_tag) {
default:
this._unknownTaggedFields = _readable.readUnknownTaggedField(this._unknownTaggedFields, _tag, _size);
break;
}
}
}
@Override
public void write(Writable _writable, ObjectSerializationCache _cache, short _version) {
int _numTaggedFields = 0;
_writable.writeInt(throttleTimeMs);
_writable.writeShort(errorCode);
if (errorMessage == null) {
_writable.writeUnsignedVarint(0);
} else {
byte[] _stringBytes = _cache.getSerializedValue(errorMessage);
_writable.writeUnsignedVarint(_stringBytes.length + 1);
_writable.writeByteArray(_stringBytes);
}
if (memberId == null) {
_writable.writeUnsignedVarint(0);
} else {
byte[] _stringBytes = _cache.getSerializedValue(memberId);
_writable.writeUnsignedVarint(_stringBytes.length + 1);
_writable.writeByteArray(_stringBytes);
}
_writable.writeInt(memberEpoch);
_writable.writeInt(heartbeatIntervalMs);
if (assignment == null) {
_writable.writeByte((byte) -1);
} else {
_writable.writeByte((byte) 1);
assignment.write(_writable, _cache, _version);
}
RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields);
_numTaggedFields += _rawWriter.numFields();
_writable.writeUnsignedVarint(_numTaggedFields);
_rawWriter.writeRawTags(_writable, Integer.MAX_VALUE);
}
@Override
public void addSize(MessageSizeAccumulator _size, ObjectSerializationCache _cache, short _version) {
int _numTaggedFields = 0;
_size.addBytes(4);
_size.addBytes(2);
if (errorMessage == null) {
_size.addBytes(1);
} else {
byte[] _stringBytes = errorMessage.getBytes(StandardCharsets.UTF_8);
if (_stringBytes.length > 0x7fff) {
throw new RuntimeException("'errorMessage' field is too long to be serialized");
}
_cache.cacheSerializedValue(errorMessage, _stringBytes);
_size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1));
}
if (memberId == null) {
_size.addBytes(1);
} else {
byte[] _stringBytes = memberId.getBytes(StandardCharsets.UTF_8);
if (_stringBytes.length > 0x7fff) {
throw new RuntimeException("'memberId' field is too long to be serialized");
}
_cache.cacheSerializedValue(memberId, _stringBytes);
_size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1));
}
_size.addBytes(4);
_size.addBytes(4);
if (assignment == null) {
_size.addBytes(1);
} else {
_size.addBytes(1);
this.assignment.addSize(_size, _cache, _version);
}
if (_unknownTaggedFields != null) {
_numTaggedFields += _unknownTaggedFields.size();
for (RawTaggedField _field : _unknownTaggedFields) {
_size.addBytes(ByteUtils.sizeOfUnsignedVarint(_field.tag()));
_size.addBytes(ByteUtils.sizeOfUnsignedVarint(_field.size()));
_size.addBytes(_field.size());
}
}
_size.addBytes(ByteUtils.sizeOfUnsignedVarint(_numTaggedFields));
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ConsumerGroupHeartbeatResponseData)) return false;
ConsumerGroupHeartbeatResponseData other = (ConsumerGroupHeartbeatResponseData) obj;
if (throttleTimeMs != other.throttleTimeMs) return false;
if (errorCode != other.errorCode) return false;
if (this.errorMessage == null) {
if (other.errorMessage != null) return false;
} else {
if (!this.errorMessage.equals(other.errorMessage)) return false;
}
if (this.memberId == null) {
if (other.memberId != null) return false;
} else {
if (!this.memberId.equals(other.memberId)) return false;
}
if (memberEpoch != other.memberEpoch) return false;
if (heartbeatIntervalMs != other.heartbeatIntervalMs) return false;
if (this.assignment == null) {
if (other.assignment != null) return false;
} else {
if (!this.assignment.equals(other.assignment)) return false;
}
return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields);
}
@Override
public int hashCode() {
int hashCode = 0;
hashCode = 31 * hashCode + throttleTimeMs;
hashCode = 31 * hashCode + errorCode;
hashCode = 31 * hashCode + (errorMessage == null ? 0 : errorMessage.hashCode());
hashCode = 31 * hashCode + (memberId == null ? 0 : memberId.hashCode());
hashCode = 31 * hashCode + memberEpoch;
hashCode = 31 * hashCode + heartbeatIntervalMs;
hashCode = 31 * hashCode + (assignment == null ? 0 : assignment.hashCode());
return hashCode;
}
@Override
public ConsumerGroupHeartbeatResponseData duplicate() {
ConsumerGroupHeartbeatResponseData _duplicate = new ConsumerGroupHeartbeatResponseData();
_duplicate.throttleTimeMs = throttleTimeMs;
_duplicate.errorCode = errorCode;
if (errorMessage == null) {
_duplicate.errorMessage = null;
} else {
_duplicate.errorMessage = errorMessage;
}
if (memberId == null) {
_duplicate.memberId = null;
} else {
_duplicate.memberId = memberId;
}
_duplicate.memberEpoch = memberEpoch;
_duplicate.heartbeatIntervalMs = heartbeatIntervalMs;
if (assignment == null) {
_duplicate.assignment = null;
} else {
_duplicate.assignment = assignment.duplicate();
}
return _duplicate;
}
@Override
public String toString() {
return "ConsumerGroupHeartbeatResponseData("
+ "throttleTimeMs=" + throttleTimeMs
+ ", errorCode=" + errorCode
+ ", errorMessage=" + ((errorMessage == null) ? "null" : "'" + errorMessage.toString() + "'")
+ ", memberId=" + ((memberId == null) ? "null" : "'" + memberId.toString() + "'")
+ ", memberEpoch=" + memberEpoch
+ ", heartbeatIntervalMs=" + heartbeatIntervalMs
+ ", assignment=" + ((assignment == null) ? "null" : assignment.toString())
+ ")";
}
public int throttleTimeMs() {
return this.throttleTimeMs;
}
public short errorCode() {
return this.errorCode;
}
public String errorMessage() {
return this.errorMessage;
}
public String memberId() {
return this.memberId;
}
public int memberEpoch() {
return this.memberEpoch;
}
public int heartbeatIntervalMs() {
return this.heartbeatIntervalMs;
}
public Assignment assignment() {
return this.assignment;
}
@Override
public List unknownTaggedFields() {
if (_unknownTaggedFields == null) {
_unknownTaggedFields = new ArrayList<>(0);
}
return _unknownTaggedFields;
}
public ConsumerGroupHeartbeatResponseData setThrottleTimeMs(int v) {
this.throttleTimeMs = v;
return this;
}
public ConsumerGroupHeartbeatResponseData setErrorCode(short v) {
this.errorCode = v;
return this;
}
public ConsumerGroupHeartbeatResponseData setErrorMessage(String v) {
this.errorMessage = v;
return this;
}
public ConsumerGroupHeartbeatResponseData setMemberId(String v) {
this.memberId = v;
return this;
}
public ConsumerGroupHeartbeatResponseData setMemberEpoch(int v) {
this.memberEpoch = v;
return this;
}
public ConsumerGroupHeartbeatResponseData setHeartbeatIntervalMs(int v) {
this.heartbeatIntervalMs = v;
return this;
}
public ConsumerGroupHeartbeatResponseData setAssignment(Assignment v) {
this.assignment = v;
return this;
}
public static class Assignment implements Message {
List topicPartitions;
private List _unknownTaggedFields;
public static final Schema SCHEMA_0 =
new Schema(
new Field("topic_partitions", new CompactArrayOf(TopicPartitions.SCHEMA_0), "The partitions assigned to the member that can be used immediately."),
TaggedFieldsSection.of(
)
);
public static final Schema[] SCHEMAS = new Schema[] {
SCHEMA_0
};
public static final short LOWEST_SUPPORTED_VERSION = 0;
public static final short HIGHEST_SUPPORTED_VERSION = 0;
public Assignment(Readable _readable, short _version) {
read(_readable, _version);
}
public Assignment() {
this.topicPartitions = new ArrayList(0);
}
@Override
public short lowestSupportedVersion() {
return 0;
}
@Override
public short highestSupportedVersion() {
return 0;
}
@Override
public final void read(Readable _readable, short _version) {
if (_version > 0) {
throw new UnsupportedVersionException("Can't read version " + _version + " of Assignment");
}
{
int arrayLength;
arrayLength = _readable.readUnsignedVarint() - 1;
if (arrayLength < 0) {
throw new RuntimeException("non-nullable field topicPartitions was serialized as null");
} else {
if (arrayLength > _readable.remaining()) {
throw new RuntimeException("Tried to allocate a collection of size " + arrayLength + ", but there are only " + _readable.remaining() + " bytes remaining.");
}
ArrayList newCollection = new ArrayList<>(arrayLength);
for (int i = 0; i < arrayLength; i++) {
newCollection.add(new TopicPartitions(_readable, _version));
}
this.topicPartitions = newCollection;
}
}
this._unknownTaggedFields = null;
int _numTaggedFields = _readable.readUnsignedVarint();
for (int _i = 0; _i < _numTaggedFields; _i++) {
int _tag = _readable.readUnsignedVarint();
int _size = _readable.readUnsignedVarint();
switch (_tag) {
default:
this._unknownTaggedFields = _readable.readUnknownTaggedField(this._unknownTaggedFields, _tag, _size);
break;
}
}
}
@Override
public void write(Writable _writable, ObjectSerializationCache _cache, short _version) {
int _numTaggedFields = 0;
_writable.writeUnsignedVarint(topicPartitions.size() + 1);
for (TopicPartitions topicPartitionsElement : topicPartitions) {
topicPartitionsElement.write(_writable, _cache, _version);
}
RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields);
_numTaggedFields += _rawWriter.numFields();
_writable.writeUnsignedVarint(_numTaggedFields);
_rawWriter.writeRawTags(_writable, Integer.MAX_VALUE);
}
@Override
public void addSize(MessageSizeAccumulator _size, ObjectSerializationCache _cache, short _version) {
int _numTaggedFields = 0;
if (_version > 0) {
throw new UnsupportedVersionException("Can't size version " + _version + " of Assignment");
}
{
_size.addBytes(ByteUtils.sizeOfUnsignedVarint(topicPartitions.size() + 1));
for (TopicPartitions topicPartitionsElement : topicPartitions) {
topicPartitionsElement.addSize(_size, _cache, _version);
}
}
if (_unknownTaggedFields != null) {
_numTaggedFields += _unknownTaggedFields.size();
for (RawTaggedField _field : _unknownTaggedFields) {
_size.addBytes(ByteUtils.sizeOfUnsignedVarint(_field.tag()));
_size.addBytes(ByteUtils.sizeOfUnsignedVarint(_field.size()));
_size.addBytes(_field.size());
}
}
_size.addBytes(ByteUtils.sizeOfUnsignedVarint(_numTaggedFields));
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Assignment)) return false;
Assignment other = (Assignment) obj;
if (this.topicPartitions == null) {
if (other.topicPartitions != null) return false;
} else {
if (!this.topicPartitions.equals(other.topicPartitions)) return false;
}
return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields);
}
@Override
public int hashCode() {
int hashCode = 0;
hashCode = 31 * hashCode + (topicPartitions == null ? 0 : topicPartitions.hashCode());
return hashCode;
}
@Override
public Assignment duplicate() {
Assignment _duplicate = new Assignment();
ArrayList newTopicPartitions = new ArrayList(topicPartitions.size());
for (TopicPartitions _element : topicPartitions) {
newTopicPartitions.add(_element.duplicate());
}
_duplicate.topicPartitions = newTopicPartitions;
return _duplicate;
}
@Override
public String toString() {
return "Assignment("
+ "topicPartitions=" + MessageUtil.deepToString(topicPartitions.iterator())
+ ")";
}
public List topicPartitions() {
return this.topicPartitions;
}
@Override
public List unknownTaggedFields() {
if (_unknownTaggedFields == null) {
_unknownTaggedFields = new ArrayList<>(0);
}
return _unknownTaggedFields;
}
public Assignment setTopicPartitions(List v) {
this.topicPartitions = v;
return this;
}
}
public static class TopicPartitions implements Message {
Uuid topicId;
List partitions;
private List _unknownTaggedFields;
public static final Schema SCHEMA_0 =
new Schema(
new Field("topic_id", Type.UUID, "The topic ID."),
new Field("partitions", new CompactArrayOf(Type.INT32), "The partitions."),
TaggedFieldsSection.of(
)
);
public static final Schema[] SCHEMAS = new Schema[] {
SCHEMA_0
};
public static final short LOWEST_SUPPORTED_VERSION = 0;
public static final short HIGHEST_SUPPORTED_VERSION = 0;
public TopicPartitions(Readable _readable, short _version) {
read(_readable, _version);
}
public TopicPartitions() {
this.topicId = Uuid.ZERO_UUID;
this.partitions = new ArrayList(0);
}
@Override
public short lowestSupportedVersion() {
return 0;
}
@Override
public short highestSupportedVersion() {
return 32767;
}
@Override
public final void read(Readable _readable, short _version) {
this.topicId = _readable.readUuid();
{
int arrayLength;
arrayLength = _readable.readUnsignedVarint() - 1;
if (arrayLength < 0) {
throw new RuntimeException("non-nullable field partitions was serialized as null");
} else {
if (arrayLength > _readable.remaining()) {
throw new RuntimeException("Tried to allocate a collection of size " + arrayLength + ", but there are only " + _readable.remaining() + " bytes remaining.");
}
ArrayList newCollection = new ArrayList<>(arrayLength);
for (int i = 0; i < arrayLength; i++) {
newCollection.add(_readable.readInt());
}
this.partitions = newCollection;
}
}
this._unknownTaggedFields = null;
int _numTaggedFields = _readable.readUnsignedVarint();
for (int _i = 0; _i < _numTaggedFields; _i++) {
int _tag = _readable.readUnsignedVarint();
int _size = _readable.readUnsignedVarint();
switch (_tag) {
default:
this._unknownTaggedFields = _readable.readUnknownTaggedField(this._unknownTaggedFields, _tag, _size);
break;
}
}
}
@Override
public void write(Writable _writable, ObjectSerializationCache _cache, short _version) {
int _numTaggedFields = 0;
_writable.writeUuid(topicId);
_writable.writeUnsignedVarint(partitions.size() + 1);
for (Integer partitionsElement : partitions) {
_writable.writeInt(partitionsElement);
}
RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields);
_numTaggedFields += _rawWriter.numFields();
_writable.writeUnsignedVarint(_numTaggedFields);
_rawWriter.writeRawTags(_writable, Integer.MAX_VALUE);
}
@Override
public void addSize(MessageSizeAccumulator _size, ObjectSerializationCache _cache, short _version) {
int _numTaggedFields = 0;
_size.addBytes(16);
{
_size.addBytes(ByteUtils.sizeOfUnsignedVarint(partitions.size() + 1));
_size.addBytes(partitions.size() * 4);
}
if (_unknownTaggedFields != null) {
_numTaggedFields += _unknownTaggedFields.size();
for (RawTaggedField _field : _unknownTaggedFields) {
_size.addBytes(ByteUtils.sizeOfUnsignedVarint(_field.tag()));
_size.addBytes(ByteUtils.sizeOfUnsignedVarint(_field.size()));
_size.addBytes(_field.size());
}
}
_size.addBytes(ByteUtils.sizeOfUnsignedVarint(_numTaggedFields));
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof TopicPartitions)) return false;
TopicPartitions other = (TopicPartitions) obj;
if (!this.topicId.equals(other.topicId)) return false;
if (this.partitions == null) {
if (other.partitions != null) return false;
} else {
if (!this.partitions.equals(other.partitions)) return false;
}
return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields);
}
@Override
public int hashCode() {
int hashCode = 0;
hashCode = 31 * hashCode + topicId.hashCode();
hashCode = 31 * hashCode + (partitions == null ? 0 : partitions.hashCode());
return hashCode;
}
@Override
public TopicPartitions duplicate() {
TopicPartitions _duplicate = new TopicPartitions();
_duplicate.topicId = topicId;
ArrayList newPartitions = new ArrayList(partitions.size());
for (Integer _element : partitions) {
newPartitions.add(_element);
}
_duplicate.partitions = newPartitions;
return _duplicate;
}
@Override
public String toString() {
return "TopicPartitions("
+ "topicId=" + topicId.toString()
+ ", partitions=" + MessageUtil.deepToString(partitions.iterator())
+ ")";
}
public Uuid topicId() {
return this.topicId;
}
public List partitions() {
return this.partitions;
}
@Override
public List unknownTaggedFields() {
if (_unknownTaggedFields == null) {
_unknownTaggedFields = new ArrayList<>(0);
}
return _unknownTaggedFields;
}
public TopicPartitions setTopicId(Uuid v) {
this.topicId = v;
return this;
}
public TopicPartitions setPartitions(List v) {
this.partitions = v;
return this;
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy