org.apache.kafka.common.message.StopReplicaResponseData 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.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.ArrayOf;
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 StopReplicaResponseData implements ApiMessage {
short errorCode;
List partitionErrors;
private List _unknownTaggedFields;
public static final Schema SCHEMA_0 =
new Schema(
new Field("error_code", Type.INT16, "The top-level error code, or 0 if there was no top-level error."),
new Field("partition_errors", new ArrayOf(StopReplicaPartitionError.SCHEMA_0), "The responses for each partition.")
);
public static final Schema SCHEMA_1 = SCHEMA_0;
public static final Schema SCHEMA_2 =
new Schema(
new Field("error_code", Type.INT16, "The top-level error code, or 0 if there was no top-level error."),
new Field("partition_errors", new CompactArrayOf(StopReplicaPartitionError.SCHEMA_2), "The responses for each partition."),
TaggedFieldsSection.of(
)
);
public static final Schema SCHEMA_3 = SCHEMA_2;
public static final Schema SCHEMA_4 = SCHEMA_3;
public static final Schema[] SCHEMAS = new Schema[] {
SCHEMA_0,
SCHEMA_1,
SCHEMA_2,
SCHEMA_3,
SCHEMA_4
};
public static final short LOWEST_SUPPORTED_VERSION = 0;
public static final short HIGHEST_SUPPORTED_VERSION = 4;
public StopReplicaResponseData(Readable _readable, short _version) {
read(_readable, _version);
}
public StopReplicaResponseData() {
this.errorCode = (short) 0;
this.partitionErrors = new ArrayList(0);
}
@Override
public short apiKey() {
return 5;
}
@Override
public short lowestSupportedVersion() {
return 0;
}
@Override
public short highestSupportedVersion() {
return 4;
}
@Override
public void read(Readable _readable, short _version) {
this.errorCode = _readable.readShort();
{
if (_version >= 2) {
int arrayLength;
arrayLength = _readable.readUnsignedVarint() - 1;
if (arrayLength < 0) {
throw new RuntimeException("non-nullable field partitionErrors 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 StopReplicaPartitionError(_readable, _version));
}
this.partitionErrors = newCollection;
}
} else {
int arrayLength;
arrayLength = _readable.readInt();
if (arrayLength < 0) {
throw new RuntimeException("non-nullable field partitionErrors 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 StopReplicaPartitionError(_readable, _version));
}
this.partitionErrors = newCollection;
}
}
}
this._unknownTaggedFields = null;
if (_version >= 2) {
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.writeShort(errorCode);
if (_version >= 2) {
_writable.writeUnsignedVarint(partitionErrors.size() + 1);
for (StopReplicaPartitionError partitionErrorsElement : partitionErrors) {
partitionErrorsElement.write(_writable, _cache, _version);
}
} else {
_writable.writeInt(partitionErrors.size());
for (StopReplicaPartitionError partitionErrorsElement : partitionErrors) {
partitionErrorsElement.write(_writable, _cache, _version);
}
}
RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields);
_numTaggedFields += _rawWriter.numFields();
if (_version >= 2) {
_writable.writeUnsignedVarint(_numTaggedFields);
_rawWriter.writeRawTags(_writable, Integer.MAX_VALUE);
} else {
if (_numTaggedFields > 0) {
throw new UnsupportedVersionException("Tagged fields were set, but version " + _version + " of this message does not support them.");
}
}
}
@Override
public void addSize(MessageSizeAccumulator _size, ObjectSerializationCache _cache, short _version) {
int _numTaggedFields = 0;
_size.addBytes(2);
{
if (_version >= 2) {
_size.addBytes(ByteUtils.sizeOfUnsignedVarint(partitionErrors.size() + 1));
} else {
_size.addBytes(4);
}
for (StopReplicaPartitionError partitionErrorsElement : partitionErrors) {
partitionErrorsElement.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());
}
}
if (_version >= 2) {
_size.addBytes(ByteUtils.sizeOfUnsignedVarint(_numTaggedFields));
} else {
if (_numTaggedFields > 0) {
throw new UnsupportedVersionException("Tagged fields were set, but version " + _version + " of this message does not support them.");
}
}
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof StopReplicaResponseData)) return false;
StopReplicaResponseData other = (StopReplicaResponseData) obj;
if (errorCode != other.errorCode) return false;
if (this.partitionErrors == null) {
if (other.partitionErrors != null) return false;
} else {
if (!this.partitionErrors.equals(other.partitionErrors)) return false;
}
return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields);
}
@Override
public int hashCode() {
int hashCode = 0;
hashCode = 31 * hashCode + errorCode;
hashCode = 31 * hashCode + (partitionErrors == null ? 0 : partitionErrors.hashCode());
return hashCode;
}
@Override
public StopReplicaResponseData duplicate() {
StopReplicaResponseData _duplicate = new StopReplicaResponseData();
_duplicate.errorCode = errorCode;
ArrayList newPartitionErrors = new ArrayList(partitionErrors.size());
for (StopReplicaPartitionError _element : partitionErrors) {
newPartitionErrors.add(_element.duplicate());
}
_duplicate.partitionErrors = newPartitionErrors;
return _duplicate;
}
@Override
public String toString() {
return "StopReplicaResponseData("
+ "errorCode=" + errorCode
+ ", partitionErrors=" + MessageUtil.deepToString(partitionErrors.iterator())
+ ")";
}
public short errorCode() {
return this.errorCode;
}
public List partitionErrors() {
return this.partitionErrors;
}
@Override
public List unknownTaggedFields() {
if (_unknownTaggedFields == null) {
_unknownTaggedFields = new ArrayList<>(0);
}
return _unknownTaggedFields;
}
public StopReplicaResponseData setErrorCode(short v) {
this.errorCode = v;
return this;
}
public StopReplicaResponseData setPartitionErrors(List v) {
this.partitionErrors = v;
return this;
}
public static class StopReplicaPartitionError implements Message {
String topicName;
int partitionIndex;
short errorCode;
private List _unknownTaggedFields;
public static final Schema SCHEMA_0 =
new Schema(
new Field("topic_name", Type.STRING, "The topic name."),
new Field("partition_index", Type.INT32, "The partition index."),
new Field("error_code", Type.INT16, "The partition error code, or 0 if there was no partition error.")
);
public static final Schema SCHEMA_1 = SCHEMA_0;
public static final Schema SCHEMA_2 =
new Schema(
new Field("topic_name", Type.COMPACT_STRING, "The topic name."),
new Field("partition_index", Type.INT32, "The partition index."),
new Field("error_code", Type.INT16, "The partition error code, or 0 if there was no partition error."),
TaggedFieldsSection.of(
)
);
public static final Schema SCHEMA_3 = SCHEMA_2;
public static final Schema SCHEMA_4 = SCHEMA_3;
public static final Schema[] SCHEMAS = new Schema[] {
SCHEMA_0,
SCHEMA_1,
SCHEMA_2,
SCHEMA_3,
SCHEMA_4
};
public static final short LOWEST_SUPPORTED_VERSION = 0;
public static final short HIGHEST_SUPPORTED_VERSION = 4;
public StopReplicaPartitionError(Readable _readable, short _version) {
read(_readable, _version);
}
public StopReplicaPartitionError() {
this.topicName = "";
this.partitionIndex = 0;
this.errorCode = (short) 0;
}
@Override
public short lowestSupportedVersion() {
return 0;
}
@Override
public short highestSupportedVersion() {
return 4;
}
@Override
public void read(Readable _readable, short _version) {
if (_version > 4) {
throw new UnsupportedVersionException("Can't read version " + _version + " of StopReplicaPartitionError");
}
{
int length;
if (_version >= 2) {
length = _readable.readUnsignedVarint() - 1;
} else {
length = _readable.readShort();
}
if (length < 0) {
throw new RuntimeException("non-nullable field topicName was serialized as null");
} else if (length > 0x7fff) {
throw new RuntimeException("string field topicName had invalid length " + length);
} else {
this.topicName = _readable.readString(length);
}
}
this.partitionIndex = _readable.readInt();
this.errorCode = _readable.readShort();
this._unknownTaggedFields = null;
if (_version >= 2) {
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;
{
byte[] _stringBytes = _cache.getSerializedValue(topicName);
if (_version >= 2) {
_writable.writeUnsignedVarint(_stringBytes.length + 1);
} else {
_writable.writeShort((short) _stringBytes.length);
}
_writable.writeByteArray(_stringBytes);
}
_writable.writeInt(partitionIndex);
_writable.writeShort(errorCode);
RawTaggedFieldWriter _rawWriter = RawTaggedFieldWriter.forFields(_unknownTaggedFields);
_numTaggedFields += _rawWriter.numFields();
if (_version >= 2) {
_writable.writeUnsignedVarint(_numTaggedFields);
_rawWriter.writeRawTags(_writable, Integer.MAX_VALUE);
} else {
if (_numTaggedFields > 0) {
throw new UnsupportedVersionException("Tagged fields were set, but version " + _version + " of this message does not support them.");
}
}
}
@Override
public void addSize(MessageSizeAccumulator _size, ObjectSerializationCache _cache, short _version) {
int _numTaggedFields = 0;
if (_version > 4) {
throw new UnsupportedVersionException("Can't size version " + _version + " of StopReplicaPartitionError");
}
{
byte[] _stringBytes = topicName.getBytes(StandardCharsets.UTF_8);
if (_stringBytes.length > 0x7fff) {
throw new RuntimeException("'topicName' field is too long to be serialized");
}
_cache.cacheSerializedValue(topicName, _stringBytes);
if (_version >= 2) {
_size.addBytes(_stringBytes.length + ByteUtils.sizeOfUnsignedVarint(_stringBytes.length + 1));
} else {
_size.addBytes(_stringBytes.length + 2);
}
}
_size.addBytes(4);
_size.addBytes(2);
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());
}
}
if (_version >= 2) {
_size.addBytes(ByteUtils.sizeOfUnsignedVarint(_numTaggedFields));
} else {
if (_numTaggedFields > 0) {
throw new UnsupportedVersionException("Tagged fields were set, but version " + _version + " of this message does not support them.");
}
}
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof StopReplicaPartitionError)) return false;
StopReplicaPartitionError other = (StopReplicaPartitionError) obj;
if (this.topicName == null) {
if (other.topicName != null) return false;
} else {
if (!this.topicName.equals(other.topicName)) return false;
}
if (partitionIndex != other.partitionIndex) return false;
if (errorCode != other.errorCode) return false;
return MessageUtil.compareRawTaggedFields(_unknownTaggedFields, other._unknownTaggedFields);
}
@Override
public int hashCode() {
int hashCode = 0;
hashCode = 31 * hashCode + (topicName == null ? 0 : topicName.hashCode());
hashCode = 31 * hashCode + partitionIndex;
hashCode = 31 * hashCode + errorCode;
return hashCode;
}
@Override
public StopReplicaPartitionError duplicate() {
StopReplicaPartitionError _duplicate = new StopReplicaPartitionError();
_duplicate.topicName = topicName;
_duplicate.partitionIndex = partitionIndex;
_duplicate.errorCode = errorCode;
return _duplicate;
}
@Override
public String toString() {
return "StopReplicaPartitionError("
+ "topicName=" + ((topicName == null) ? "null" : "'" + topicName.toString() + "'")
+ ", partitionIndex=" + partitionIndex
+ ", errorCode=" + errorCode
+ ")";
}
public String topicName() {
return this.topicName;
}
public int partitionIndex() {
return this.partitionIndex;
}
public short errorCode() {
return this.errorCode;
}
@Override
public List unknownTaggedFields() {
if (_unknownTaggedFields == null) {
_unknownTaggedFields = new ArrayList<>(0);
}
return _unknownTaggedFields;
}
public StopReplicaPartitionError setTopicName(String v) {
this.topicName = v;
return this;
}
public StopReplicaPartitionError setPartitionIndex(int v) {
this.partitionIndex = v;
return this;
}
public StopReplicaPartitionError setErrorCode(short v) {
this.errorCode = v;
return this;
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy